:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1b2028;
  --panel-2: #202733;
  --line: #343d4d;
  --text: #eef3f8;
  --muted: #9da9b8;
  --accent: #4cc9a6;
  --accent-2: #5da9ff;
  --warn: #ffce5c;
  --bad: #ff5f73;
  --code: #0d1117;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(76, 201, 166, 0.14), transparent 28rem),
    linear-gradient(135deg, #111318 0%, #151a22 48%, #111318 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #061713;
  cursor: pointer;
  font-weight: 800;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  filter: brightness(1.08);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 24, 0.88);
  backdrop-filter: blur(12px);
}

.brand,
.account-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  width: 52px;
  height: 52px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 950;
  letter-spacing: 0;
  background: #101d1a;
  box-shadow: 0 0 0 4px rgba(76, 201, 166, 0.12);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.6rem;
  letter-spacing: 0;
}

.brand p,
.editor-toolbar span,
.preview-header span,
.account-box span,
.mini-card p,
.progress-panel p {
  color: var(--muted);
  font-size: 0.88rem;
}

.account-box {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 10px;
  min-width: 320px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 16px rgba(255, 206, 92, 0.7);
}

.ghost-button {
  margin-left: auto;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(360px, 1fr);
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.sidebar,
.editor-area,
.preview-area {
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel,
.editor-area,
.preview-area {
  border: 1px solid var(--line);
  background: rgba(27, 32, 40, 0.92);
  border-radius: 8px;
}

.panel {
  padding: 14px;
}

.panel-title,
.editor-toolbar,
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin-bottom: 14px;
  font-weight: 900;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 1.35rem;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.text-input {
  width: 100%;
  border: 1px solid var(--line);
  background: #111820;
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 10px;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 14px;
}

.danger-button {
  background: #372027;
  color: #ffd7de;
  border: 1px solid #703040;
}

.project-list {
  display: grid;
  gap: 8px;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--text);
}

.project-item.active {
  border-color: var(--accent);
}

.badge {
  border-radius: 999px;
  border: 1px solid rgba(76, 201, 166, 0.4);
  background: rgba(76, 201, 166, 0.12);
  color: var(--accent);
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge.quiet {
  color: var(--muted);
  border-color: var(--line);
  background: #151a22;
}

.badge.bad {
  color: #ffd7de;
  border-color: rgba(255, 95, 115, 0.5);
  background: rgba(255, 95, 115, 0.14);
}

.level-track {
  height: 10px;
  border-radius: 999px;
  background: #111820;
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 10px;
}

#levelFill {
  width: 22%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.editor-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 10px 0;
}

.tab {
  background: #151a22;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active {
  color: var(--text);
  border-color: var(--accent);
}

.editor-toolbar {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.code-frame {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: 54px 1fr;
  min-height: 420px;
  background: var(--code);
}

.preview-code-frame {
  display: grid;
  grid-template-columns: 54px 1fr;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid #263041;
  border-radius: 8px;
  background: var(--code);
}

.preview-code-frame pre {
  min-height: 0;
  margin: 0;
  padding: 16px;
  color: #dce7f3;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.94rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.code-frame.has-errors {
  box-shadow: inset 0 0 0 2px rgba(255, 95, 115, 0.55);
}

.line-numbers {
  padding: 16px 8px;
  border-right: 1px solid #263041;
  color: #687487;
  text-align: right;
  line-height: 1.45;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.94rem;
  user-select: none;
  white-space: pre;
}

textarea {
  resize: none;
  border: 0;
  outline: none;
  width: 100%;
  min-height: 100%;
  padding: 16px;
  background: transparent;
  color: #dce7f3;
  line-height: 1.45;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.94rem;
  tab-size: 2;
}

.preview-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow: auto;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preview-actions .tab {
  min-height: 34px;
}

.workspace:not(.preview-mode) .preview-area {
  display: none;
}

.workspace.preview-mode .editor-area {
  display: none;
}

.output-box,
.error-box,
.mini-card,
.explain-card,
.code-snapshot {
  border: 1px solid var(--line);
  background: #151a22;
  border-radius: 8px;
  padding: 14px;
}

.output-box.flash {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 201, 166, 0.14);
}

.task-panel p,
.explain-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.help-button {
  background: var(--accent-2);
  color: #07111d;
}

.task-details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.task-details strong {
  display: block;
  margin-bottom: 8px;
}

.task-details pre {
  min-height: 0;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code);
  color: #dce7f3;
  font-size: 0.78rem;
  overflow: auto;
}

h2 {
  font-size: 0.95rem;
  margin-bottom: 10px;
}

pre {
  min-height: 140px;
  margin: 0;
  white-space: pre-wrap;
  color: #c9ffd8;
  font-family: "Cascadia Mono", Consolas, monospace;
}

ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

li + li {
  margin-top: 8px;
}

.error-line {
  color: #ffd7de;
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 260px 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .brand,
  .account-box {
    align-items: stretch;
  }

  .topbar,
  .workspace {
    display: flex;
    flex-direction: column;
  }

  .account-box {
    min-width: 0;
  }

  .code-frame {
    min-height: 360px;
  }

}
