/* ==========================================================================
   Workbench design layer — loaded after styles.css.

   Owns the colour tokens (graphite + cyan) and the problem-view layout:
   pane chrome, splitters, the header layout toggles and the results strip.
   Anything that used a hard-coded dark-only colour is re-pointed at tokens
   here so both themes stay legible. Behaviour (collapse classes, the
   --prompt-width / --results-height / --explorer-width vars) still comes
   from app.js.
   ========================================================================== */

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-2: #0f1115;
  --surface: #111419;
  --panel: #14171c;
  --panel-strong: #1a1e24;
  --panel-soft: rgba(255, 255, 255, 0.035);
  --ink: #e6e9ee;
  --muted: #9aa2af;
  --quiet: #7a8391;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #22c3e6;
  --accent-2: #3fd68f;
  --bad: #ff6b6b;
  --warn: #f5c451;
  --code: #0e1014;
  --code-top: #14171c;
  --shadow: none;
  --card-shadow: none;

  --on-accent: #04202a;
  --accent-ink: #5fd6f0;
  --accent-soft: rgba(34, 195, 230, 0.12);
  --accent-line: rgba(34, 195, 230, 0.45);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --ok-ink: #6fe3a8;
  --ok-soft: rgba(63, 214, 143, 0.1);
  --ok-line: rgba(63, 214, 143, 0.3);
  --bad-ink: #ff9d9d;
  --bad-soft: rgba(255, 107, 107, 0.1);
  --bad-line: rgba(255, 107, 107, 0.32);
  --warn-ink: #f7d27a;
  --warn-soft: rgba(245, 196, 81, 0.1);
  --prose: #c3c9d2;
  --code-ink: #f2b36d;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f3;
  --bg-2: #f5f6f8;
  --surface: #ffffff;
  --panel: #ffffff;
  --panel-strong: #f6f7f9;
  --panel-soft: rgba(15, 23, 42, 0.03);
  --ink: #16191f;
  --muted: #545d6b;
  --quiet: #636c79;
  --line: #d6dae1;
  --line-strong: #c3c9d2;
  --accent: #0e7490;
  --accent-2: #15803d;
  --bad: #c2312a;
  --warn: #a16207;
  --code: #ffffff;
  --code-top: #f6f7f9;
  --shadow: none;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);

  --on-accent: #ffffff;
  --accent-ink: #0e7490;
  --accent-soft: rgba(14, 116, 144, 0.08);
  --accent-line: rgba(14, 116, 144, 0.4);
  --chip-bg: rgba(15, 23, 42, 0.05);
  --ok-ink: #166534;
  --ok-soft: #ecf8f0;
  --ok-line: rgba(22, 101, 52, 0.25);
  --bad-ink: #9f1d17;
  --bad-soft: #fdf0ef;
  --bad-line: rgba(194, 49, 42, 0.28);
  --warn-ink: #854d0e;
  --warn-soft: #fdf6e3;
  --prose: #3f4752;
  --code-ink: #a1450b;
}

/* ---------- base ---------- */

body {
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

button {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

button:hover:not(:disabled) {
  border-color: var(--line-strong);
}

:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

/* Primary actions: one accent, with text colour chosen for contrast. */
#runButton,
.run-custom-button,
.cta-button,
.tutor-save,
.login-card button:not(.login-toggle) {
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: none;
  font-weight: 650;
}

#runButton:hover:not(:disabled),
.run-custom-button:hover,
.cta-button:hover,
.tutor-save:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

.tutor-dock button.active,
.stale-banner button,
.settings-field-row button,
.tutor-bubble.user,
.tutor-input button,
.topbar-tutor.active,
.conv-bit.on {
  color: var(--on-accent);
}

/* Subtle, theme-aware scrollbars everywhere. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

/* ---------- chips, tags, inline code ---------- */

.tag,
.mini-tag {
  border: 1px solid transparent;
  background: var(--chip-bg);
  color: var(--muted);
}

.prompt-markdown {
  color: var(--ink);
}

.prompt-markdown code,
.test-case code,
.result-test code {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

/* Native <select> option lists: styles.css hard-codes a dark option
   background, which left dark-on-black text in light theme. */
select option {
  background: var(--panel);
  color: var(--ink);
}

/* Code in problem statements / design notes: amber so it stands apart from
   prose (and from the cyan accent used for links and controls). */
.prompt-markdown code {
  color: var(--code-ink);
}

.prompt-markdown pre {
  border: 1px solid var(--line);
  background: var(--code);
}

.prompt-markdown pre code {
  border: 0;
  background: transparent;
  color: var(--code-ink);
}

.test-case code {
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--code);
  color: var(--muted);
}

.widget-hint {
  color: var(--muted);
}

/* ---------- status colours ---------- */

.result-summary {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--muted);
}

.result-summary.pass,
.result-test.pass {
  border-color: var(--ok-line);
  background: var(--ok-soft);
  color: var(--ok-ink);
}

.result-summary.fail,
.result-test.fail {
  border-color: var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad-ink);
}

.result-case {
  border-color: var(--line);
  background: var(--panel-soft);
}

.result-case.pass {
  border-color: var(--ok-line);
  background: var(--ok-soft);
}

.result-case.fail {
  border-color: var(--bad-line);
  background: var(--bad-soft);
}

.result-case.neutral {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.result-case span {
  color: var(--muted);
}

#timerDisplay,
#fontSizeLabel {
  color: var(--ink);
}

#timerDisplay.expired {
  color: var(--bad-ink);
}

.diagnostics-panel,
.diagnostics-panel.pending {
  border-top: 1px solid var(--line);
  background: var(--code);
  color: var(--muted);
}

.diagnostics-panel.clean { color: var(--ok-ink); background: var(--code); }
.diagnostics-panel.warn { color: var(--warn-ink); background: var(--warn-soft); }
.diagnostics-panel.fail { color: var(--bad-ink); background: var(--bad-soft); }

.case-run-button {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.hero-stats strong,
.entry-go,
.eyebrow {
  color: var(--accent-ink);
}

/* ==========================================================================
   Problem view
   ========================================================================== */

/* Flush layout: panes touch, separated only by 1px dividers that double as
   the resize handles. No cards, gaps, radii or shadows. */
.workspace[data-view="problem"] {
  gap: 0;
  padding: 0;
  grid-template-rows: auto minmax(0, 1fr) minmax(120px, var(--results-height, 30vh));
}

.workspace.results-collapsed[data-view="problem"] {
  grid-template-rows: auto minmax(0, 1fr) 36px;
}

/* ---------- header ---------- */

.workspace[data-view="problem"] .problem-header {
  display: flex; /* styles.css switches it to a grid below 1120px */
  gap: 8px 12px;
  min-height: 44px;
  padding: 6px 10px 6px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
  align-items: center;
}

/* The big title lives at the top of the prompt; the header shows it as a
   quiet breadcrumb, and only steps up when the prompt pane is hidden. */
.workspace[data-view="problem"] .problem-header h2,
.workspace.toolbar-collapsed[data-view="problem"] .problem-header h2 {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--muted);
}

.workspace.prompt-collapsed[data-view="problem"] .problem-header h2 {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}

.workspace[data-view="problem"] .eyebrow {
  min-height: 0;
  font-size: 10.5px;
  letter-spacing: 0.06em;
}

.workspace[data-view="problem"] .eyebrow:empty {
  display: none;
}

.workspace[data-view="problem"] .toolbar {
  gap: 6px;
}

.workspace[data-view="problem"] .toolbar > button,
.workspace[data-view="problem"] .toolbar select {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12.5px;
  border-radius: 7px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

.layout-toggles {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
}

.layout-toggles .layout-toggle {
  width: 30px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
}

.layout-toggles .layout-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.layout-toggles .layout-toggle svg .fill {
  fill: currentColor;
  stroke: none;
  opacity: 0;
}

.layout-toggles .layout-toggle:hover:not(:disabled) {
  color: var(--ink);
  background: var(--panel-strong);
}

.layout-toggles .layout-toggle.active {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.layout-toggles .layout-toggle.active svg .fill {
  opacity: 0.85;
}

.layout-toggles .layout-toggle:disabled {
  opacity: 0.35;
  cursor: default;
}

.workspace[data-view="problem"] .toolbar-collapse {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12.5px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.workspace[data-view="problem"] .toolbar-collapse::after {
  content: "Hide controls";
}

.workspace[data-view="problem"] .toolbar-collapse.is-collapsed::after {
  content: "Controls";
}

#runButton {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 14px 4px 11px;
  border-radius: 7px;
  font-size: 13px;
}

#runButton svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

#runButton:disabled {
  opacity: 0.7;
  cursor: progress;
}

/* ---------- split + panes ---------- */

.workspace[data-view="problem"] .split {
  gap: 0;
  grid-template-columns:
    minmax(260px, var(--prompt-width, 34%)) 1px
    minmax(0, 1fr) 0 minmax(220px, 0.2fr);
}

.workspace.notes-collapsed[data-view="problem"] .split {
  grid-template-columns: minmax(260px, var(--prompt-width, 34%)) 1px minmax(0, 1fr) 0 0;
}

.workspace.prompt-collapsed[data-view="problem"] .split {
  grid-template-columns: 0 0 minmax(0, 1fr) 0 minmax(220px, 0.2fr);
}

.workspace.prompt-collapsed.notes-collapsed[data-view="problem"] .split {
  grid-template-columns: 0 0 minmax(0, 1fr) 0 0;
}

.workspace[data-view="problem"] .prompt-pane,
.workspace[data-view="problem"] .editor-pane,
.workspace[data-view="problem"] .notes-pane,
.workspace[data-view="problem"] .results-pane {
  border: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
}

.workspace[data-view="problem"] .editor-pane {
  overflow: hidden;
  background: var(--code);
}

.workspace[data-view="problem"] .notes-pane {
  grid-column: 5;
  border-left: 1px solid var(--line);
}

.workspace[data-view="problem"] .notes-header {
  background: transparent;
}

/* Old floating chevron tabs are replaced by the header layout toggles and the
   results strip. */
.workspace[data-view] .edge-toggle {
  display: none;
}

/* ---------- prompt typography ---------- */

.workspace[data-view="problem"] .prompt-pane {
  padding: 26px 28px 32px;
}

.workspace[data-view="problem"] #promptText {
  color: var(--prose);
  font-size: 15px;
  line-height: 1.75;
}

.workspace[data-view="problem"] #promptText > h1:first-child {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.workspace[data-view="problem"] #promptText h2 {
  margin: 28px 0 8px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
}

.workspace[data-view="problem"] #promptText h3 {
  margin: 22px 0 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
}

.workspace[data-view="problem"] #promptText p,
.workspace[data-view="problem"] #promptText li {
  color: var(--prose);
  font-size: 15px;
  line-height: 1.75;
}

.workspace[data-view="problem"] #promptText strong {
  color: var(--ink);
}

.workspace[data-view="problem"] .prompt-pane > h3 {
  margin-top: 28px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- splitters ---------- */
/* Each divider is a visible 1px line with a 9px invisible grab area around
   it; hover or drag turns it into a 3px accent bar. */

.workspace[data-view="problem"] .split-resizer:not(.horizontal) {
  grid-column: 2;
  min-width: 0;
  width: 1px;
  position: relative;
  z-index: 5;
  border-radius: 0;
  background: var(--line);
  cursor: col-resize;
  touch-action: none;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.workspace[data-view="problem"] .split-resizer:not(.horizontal)::before {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

.workspace[data-view="problem"] .split-resizer:not(.horizontal):hover,
.workspace[data-view="problem"] .split-resizer:not(.horizontal):focus-visible,
body.resizing-split .workspace[data-view="problem"] .split-resizer:not(.horizontal) {
  outline: 0;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.workspace.prompt-collapsed[data-view="problem"] .split-resizer:not(.horizontal) {
  display: none;
}

/* Results: the pane's top border is the divider; the handle straddles it.
   The pane must not clip, or the half above the border is unclickable. */
.workspace[data-view="problem"] .results-pane {
  overflow: visible;
  border-top: 1px solid var(--line);
}

.workspace[data-view="problem"] .results-pane > .split-resizer.horizontal {
  top: -5px;
  height: 9px;
  z-index: 6;
  align-items: center;
  background: none;
}

.workspace[data-view="problem"] .results-pane > .split-resizer.horizontal::before {
  width: 100%;
  height: 3px;
  border-radius: 0;
  background: transparent;
  transition: background 120ms ease;
}

.workspace[data-view="problem"] .results-pane > .split-resizer.horizontal:hover::before,
.workspace[data-view="problem"] .results-pane > .split-resizer.horizontal:focus-visible::before,
body.resizing-results .workspace[data-view="problem"] .results-pane > .split-resizer.horizontal::before {
  height: 3px;
  background: var(--accent);
}

.workspace[data-view="problem"] .explorer-resizer::after {
  width: 3px;
  background: transparent;
}

.workspace[data-view="problem"] .explorer-resizer:hover::after,
body.resizing-explorer .workspace[data-view="problem"] .explorer-resizer::after {
  background: var(--accent);
}

.work-area[data-dock] > .tutor-resizer {
  flex-basis: 1px;
  width: 1px;
  background: var(--line);
  transition: background 120ms ease, box-shadow 120ms ease;
}

.work-area[data-dock="top"] > .tutor-resizer,
.work-area[data-dock="bottom"] > .tutor-resizer {
  width: auto;
  height: 1px;
}

.work-area[data-dock] > .tutor-resizer::before {
  inset: -4px;
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
}

.work-area[data-dock] > .tutor-resizer:hover,
body.resizing-tutor .work-area[data-dock] > .tutor-resizer {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.work-area[data-dock] > .tutor-panel {
  border-inline: 0;
  border-block: 0;
}

/* ---------- explorer + editor ---------- */

.workspace[data-view="problem"] .context-files {
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.workspace[data-view="problem"] .context-files-top {
  color: var(--quiet);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.file-tree-item {
  color: var(--muted);
}

.file-tree-item:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.workspace[data-view="problem"] .file-tree-item.active {
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--accent);
}

.workspace[data-view="problem"] .editor-top {
  display: none;
}

/* Light theme: tint the reading panes (statement, Explorer) a soft grey so the
   white editor reads as the work surface and the panes don't run together.
   Inline code sits on white so it still pops off the grey. */
html[data-theme="light"] .workspace[data-view="problem"] .prompt-pane {
  background: #f1f3f6;
}

html[data-theme="light"] .workspace[data-view="problem"] .context-files {
  background: #ebeef2;
}

html[data-theme="light"] .workspace[data-view="problem"] .prompt-markdown code {
  background: var(--surface);
}

html[data-theme="light"] .workspace[data-view="problem"] .prompt-markdown pre {
  background: var(--surface);
}

.workspace[data-view="problem"] .editor-group-head {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.editor-tab,
.editor-tab.tabbed {
  border-right: 1px solid var(--line);
  border-top: 2px solid transparent;
  background: transparent;
  color: var(--muted);
}

.editor-tab:not(.tabbed),
.editor-tab.tabbed.active {
  border-top-color: var(--accent);
  background: var(--code);
  color: var(--ink);
}

.editor-tab.tabbed:hover {
  color: var(--ink);
}

.workspace[data-view="problem"] .editor-body,
.workspace[data-view="problem"] .editor-main,
.workspace[data-view="problem"] #codeEditor,
.workspace[data-view="problem"] #mdPreview,
.workspace[data-view="problem"] #mdPreviewB,
.workspace[data-view="problem"] #diagramPreview,
.workspace[data-view="problem"] #diagramPreviewB {
  background: var(--code);
}

/* ---------- results ---------- */

/* styles.css caps the pane at ~24vh, which made dragging the splitter
   past that do nothing. The grid row height is the only limit now. */
.workspace[data-view="problem"] .results-pane,
.workspace[data-view="problem"] .results-pane:has(#outputPanel:not(:empty)),
.workspace[data-view="problem"] .results-pane:has(.result-tests:not(:empty)) {
  max-height: none;
  padding: 0;
}

.workspace[data-view="problem"] .results-header {
  min-height: 36px;
  padding: 0 8px 0 14px;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}

.workspace[data-view="problem"] .results-header h3 {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.workspace[data-view="problem"] #durationLabel {
  margin-left: auto;
  font-size: 12px;
  color: var(--quiet);
}

.results-collapse {
  width: 26px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--quiet);
}

.results-collapse:hover {
  background: var(--panel-strong);
  color: var(--ink);
}

.results-collapse svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 150ms ease;
}

.workspace.results-collapsed .results-collapse svg {
  transform: rotate(180deg);
}

#outputPanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code);
  color: var(--ink);
}

.workspace[data-view="problem"] .results-scroll {
  padding: 10px 14px 14px;
}

/* Collapsed results: keep the header visible as a one-line strip. */
.workspace.results-collapsed[data-view="problem"] .results-pane {
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.workspace.results-collapsed[data-view="problem"] .results-pane > .results-header {
  display: flex;
  border-bottom: 0;
}

.workspace.results-collapsed[data-view="problem"] .results-pane > .results-scroll {
  display: none;
}

/* ---------- narrow screens ---------- */

@media (max-width: 1100px) {
  .workspace[data-view="problem"] .split,
  .workspace.notes-collapsed[data-view="problem"] .split {
    grid-template-columns: minmax(240px, var(--prompt-width, 38%)) 1px minmax(0, 1fr) 0 0;
  }

  .workspace.prompt-collapsed[data-view="problem"] .split {
    grid-template-columns: 0 0 minmax(0, 1fr) 0 0;
  }

  .workspace[data-view="problem"] .notes-pane {
    display: none;
  }

  .layout-toggles .layout-toggle[data-toggle="notes"] {
    display: none;
  }
}

/* Phone / narrow-pane layout: styles.css shows one pane at a time behind
   Prompt / Code / Results tabs, which adds a row above the header. */
@media (max-width: 820px) {
  .workspace[data-view="problem"],
  .workspace[data-view="problem"]:not(.results-collapsed),
  .workspace.results-collapsed[data-view="problem"] {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .workspace[data-view="problem"] .workspace-tabs {
    padding: 0;
    background: var(--bg);
  }

  .workspace[data-view="problem"] .workspace-tabs button {
    min-height: 34px;
    padding: 6px 10px;
    border-color: var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
  }

  .workspace[data-view="problem"] .workspace-tabs button.active {
    border-color: var(--accent-line);
    background: var(--accent-soft);
    color: var(--accent-ink);
  }

  /* Tabs already choose the pane, so panel toggles and splitters go away. */
  .layout-toggles,
  .results-collapse,
  .workspace[data-view="problem"] .results-pane > .split-resizer.horizontal {
    display: none;
  }

  .workspace[data-view="problem"] .results-header {
    cursor: default;
  }

  .workspace.results-collapsed[data-view="problem"] .results-pane > .results-scroll {
    display: block;
  }

  .workspace[data-view="problem"] .problem-header h2 {
    font-size: 16px;
  }

  /* Keep the explorer from eating a narrow editor pane. */
  .workspace[data-view="problem"] .editor-pane.multi-file:not(.explorer-collapsed) .editor-body,
  .workspace[data-view="problem"] .editor-pane.multi-file:not(.explorer-collapsed) .editor-body[style*="--explorer-width"] {
    grid-template-columns: 0 min(var(--explorer-width, 200px), 36%) minmax(0, 1fr);
  }

  .workspace[data-view="problem"] .explorer-resizer {
    left: min(var(--explorer-width, 200px), 36%);
  }
}

/* The topbar has a fixed height; let it grow instead of overlapping the
   content when its buttons wrap. */
@media (max-width: 640px) {
  .topbar {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .topbar-brand span {
    display: none;
  }

  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .topbar-right .theme-select {
    width: auto;
    flex: 0 0 auto;
  }

  .custom-runner {
    grid-template-columns: minmax(0, 1fr);
  }

  .run-custom-button {
    justify-self: start;
  }
}

@media (max-width: 900px) {
  .workspace[data-view="problem"] .split,
  .workspace.notes-collapsed[data-view="problem"] .split,
  .workspace.prompt-collapsed[data-view="problem"] .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace[data-view="problem"] .split-resizer:not(.horizontal) {
    display: none;
  }
}

/* ==========================================================================
   Settings (#settings) and Admin (#admin) pages: one sidebar layout, one
   panel at a time, filling the workspace like the other views.
   ========================================================================== */

/* Only the account page shows in these views, and it shows nowhere else. */
.workspace[data-view="settings"] > :not(#accountPane),
.workspace[data-view="admin"] > :not(#accountPane) {
  display: none;
}

.workspace:not([data-view="settings"]):not([data-view="admin"]) > #accountPane {
  display: none;
}

.workspace[data-view="settings"],
.workspace[data-view="admin"] {
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
}

#accountPane {
  display: block;
  min-height: 0;
  overflow: hidden;
}

.account-page .settings-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: 100%;
}

/* ---------- sidebar ---------- */

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  padding: 20px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.settings-nav-head {
  display: grid;
  gap: 2px;
  padding: 0 10px;
}

.settings-nav-head strong {
  font-size: 15px;
  font-weight: 650;
}

/* The sidebar title already says "Admin"; the group label would repeat it. */
.account-page .settings-nav-label {
  display: none;
}

.settings-who {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-nav-list {
  display: grid;
  gap: 2px;
}

.settings-nav-list[hidden],
.settings-nav-group[hidden] {
  display: none;
}

.settings-nav-label {
  display: block;
  padding: 0 10px 6px;
  color: var(--quiet);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.settings-nav-item svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-nav-item:hover:not(.active) {
  background: var(--panel-soft);
  color: var(--ink);
}

.settings-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ---------- main pane ---------- */

.settings-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.account-page .settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 40px 20px;
  border-bottom: 1px solid var(--line);
}

.account-page .settings-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.settings-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-body {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  padding: 28px 40px 48px;
  overflow-y: auto;
}

.settings-section {
  max-width: 880px;
}

.settings-section[hidden] {
  display: none;
}

/* Key/value lists become a bordered card. */
.settings-section .settings-grid {
  gap: 0;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.settings-section .settings-grid .kv {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.settings-section .settings-grid .kv:last-child {
  border-bottom: 0;
}

.settings-field-row input {
  background: var(--surface);
}

.settings-field-row button {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.settings-tag {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.settings-tag-muted {
  border-color: var(--line);
  background: var(--chip-bg);
  color: var(--muted);
}

/* ---------- admin overview ---------- */

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.admin-stat {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.admin-stat-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-stat-value {
  overflow: hidden;
  color: var(--ink);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-stat-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-stat-ok .admin-stat-value,
.admin-stat-bad .admin-stat-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-stat-compact .admin-stat-value {
  padding: 4px 0 3px;
  font-size: 15px;
}

/* Host names are long; give that card room instead of truncating. */
.admin-stat-compact {
  grid-column: span 2;
}

.admin-stat-ok .admin-stat-value { color: var(--ok-ink); }
.admin-stat-bad .admin-stat-value { color: var(--bad-ink); }

.admin-stat-ok .admin-stat-value::before,
.admin-stat-bad .admin-stat-value::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent);
}

.admin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.admin-card strong {
  font-size: 14px;
}

.admin-card-note {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Toggle switch */
.switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 150ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 150ms ease;
}

.switch.on {
  background: var(--accent);
}

.switch.on .switch-thumb {
  transform: translateX(18px);
}

/* ---------- admin accounts ---------- */

.admin-users-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

#adminUserSearch {
  flex: 1 1 auto;
  max-width: 320px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.admin-user-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
}

.admin-users-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.admin-users-headrow,
.admin-users .admin-user-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 110px 120px 180px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.admin-users-headrow {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-users {
  display: block;
  max-height: none;
  overflow: visible;
}

.admin-users .admin-user-row {
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.admin-users .admin-user-row:last-child {
  border-bottom: 0;
}

.admin-users .admin-user-row:hover {
  background: var(--panel-soft);
}

.admin-user-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.admin-user-name > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

.admin-user-status {
  display: inline-block;
  padding: 2px 9px;
  border: 0;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.admin-user-status-active { background: var(--ok-soft); color: var(--ok-ink); }
.admin-user-status-blocked { background: var(--bad-soft); color: var(--bad-ink); }
.admin-user-status-pending { background: var(--chip-bg); color: var(--muted); }

.admin-user-since {
  color: var(--muted);
  font-size: 13px;
}

.admin-user-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.admin-user-actions button {
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.admin-user-actions button:hover {
  border-color: var(--accent-line);
}

.admin-user-actions button.admin-danger {
  border-color: var(--bad-line);
  color: var(--bad-ink);
}

.admin-user-actions button.admin-danger:hover {
  background: var(--bad-soft);
  color: var(--bad-ink);
}

.admin-users-empty {
  margin: 0;
  padding: 18px 16px;
}

/* ---------- small screens: full-screen sheet, tabs across the top ---------- */

@media (max-width: 720px) {
  .account-page .settings-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-nav {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .settings-nav-head,
  .settings-nav-label {
    display: none;
  }

  .settings-nav-group:not([hidden]) {
    display: contents;
  }

  .settings-nav-list {
    display: flex;
    gap: 4px;
  }

  .settings-nav-item {
    width: auto;
    white-space: nowrap;
  }

  .account-page .settings-head {
    padding: 16px 18px 14px;
  }

  .account-page .settings-head h2 {
    font-size: 20px;
  }

  .settings-body {
    padding: 18px;
  }

  .admin-users-headrow {
    display: none;
  }

  .admin-users .admin-user-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .admin-user-since {
    display: none;
  }

  .admin-user-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

/* ---------- topbar account menu ---------- */

.account-menu {
  position: relative;
}

.account-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 3px 8px 3px 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.account-menu-button:hover,
.account-menu-button[aria-expanded="true"] {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.account-menu-button svg,
.account-menu-list svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.account-menu-button > svg {
  color: var(--muted);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

.account-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  display: grid;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.account-menu-list[hidden] {
  display: none;
}

.account-menu-head {
  padding: 8px 10px 10px;
  color: var(--muted);
  font-size: 12px;
}

.account-menu-head strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink);
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu-list [role="menuitem"] {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.account-menu-list [role="menuitem"][hidden] {
  display: none;
}

.account-menu-list [role="menuitem"]:hover,
.account-menu-list [role="menuitem"]:focus-visible {
  outline: 0;
  background: var(--panel-strong);
}

.account-menu-sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}

@media (max-width: 640px) {
  .account-menu-button .auth-user {
    display: none;
  }
}

/* ==========================================================================
   Interview Prep (#prep): the ordered practice track. Full-width page like
   Learn; steps are numbered cards whose problem chips open the workbench.
   ========================================================================== */

.workspace[data-view="prep"] > :not(#prepPane) {
  display: none;
}

.workspace:not([data-view="prep"]) > #prepPane {
  display: none;
}

.workspace[data-view="prep"] {
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
}

body[data-view="prep"] .app-shell {
  grid-template-columns: minmax(0, 1fr);
  width: 100vw;
  max-width: none;
  margin: 0;
}

body[data-view="prep"] .sidebar,
body[data-view="prep"] .sidebar-edge {
  display: none;
}

/* .learn-page caps max-width at 1040px; with the centering padding below that
   squeezed the column to ~500px. The pane spans the workspace and the padding
   alone centers a 920px reading column. */
#prepPane {
  display: block;
  overflow-y: auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 20px max(clamp(16px, 4vw, 56px), calc((100% - 920px) / 2)) 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.prep-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--muted);
}

.prep-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.prep-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width .2s ease;
}

.prep-reset {
  font-size: 12px;
  padding: 4px 10px;
}

.prep-day > h3 small {
  margin-left: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.prep-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.prep-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.prep-step.done .prep-body {
  opacity: .6;
}

/* Number badge, top-aligned with the title; turns into a check when done. */
.prep-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.prep-step.done .prep-num {
  background: var(--accent);
  color: #fff;
}

.prep-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 28px;
}

.prep-head h4 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink);
}

.prep-time {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}

.prep-check {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.prep-check:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.prep-check input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.prep-idea,
.prep-extra {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.prep-extra {
  font-style: italic;
}

.prep-problems {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.prep-problem {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}

.prep-problem:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.prep-problem .row-status:empty {
  display: none;
}

.prep-problem.solved .row-status {
  color: #34d399;
  font-weight: 800;
}

.prep-problem.missing {
  cursor: default;
  border-style: dashed;
  color: var(--quiet);
}

.prep-break {
  padding: 8px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.prep-aloud {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

@media (max-width: 640px) {
  .prep-step {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .prep-num {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .prep-head {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .prep-head h4 {
    flex-basis: 100%;
  }

  #prepButton {
    padding-inline: 8px;
  }
}
