:root {
  --bg: #0f1115;
  --bg-elev: #161922;
  --bg-elev-2: #1d2130;
  --bg-input: #0b0d12;
  --border: #2a2f3d;
  --border-strong: #3a4154;
  --text: #e6e8ee;
  --text-dim: #9aa3b5;
  --text-faint: #6b7385;
  --accent: #4f8cff;
  --accent-strong: #3a74e6;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --pass: #3fb950;
  --pass-soft: rgba(63, 185, 80, 0.14);
  --fail: #f85149;
  --fail-soft: rgba(248, 81, 73, 0.14);
  --warn: #d29922;
  --warn-soft: rgba(210, 153, 34, 0.15);
  --design: #a371f7;
  --radius: 8px;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SFMono-Regular", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); font-variant-ligatures: none; }
code { font-size: 0.92em; background: var(--bg-elev-2); padding: 1px 5px; border-radius: 4px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
kbd {
  font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 4px; color: var(--text-dim);
}
h1, h2, h3 { margin: 0; font-weight: 600; }
.loading { padding: 48px; color: var(--text-dim); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.pass { color: var(--pass); }
.fail { color: var(--fail); }
.warn { color: var(--warn); }
.hidden { display: none !important; }

/* ---------- buttons & inputs ---------- */
button {
  font: inherit; color: var(--text); background: var(--bg-elev-2);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover:not(:disabled) { border-color: var(--text-faint); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
button.success { background: var(--pass); border-color: var(--pass); color: #fff; font-weight: 600; }
button.danger { color: var(--fail); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
button.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border); }
button.small { padding: 3px 8px; font-size: 12px; }

/* ---------- top nav (home/history/review) ---------- */
.topnav {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--accent);
  display: grid; place-items: center; font: 700 13px var(--mono); color: #fff;
}
.topnav nav { display: flex; gap: 4px; }
.topnav nav a { color: var(--text-dim); padding: 6px 12px; border-radius: 6px; }
.topnav nav a.active, .topnav nav a:hover { color: var(--text); background: var(--bg-elev-2); text-decoration: none; }
/* the link across to the site's other section (practice <-> jobs), at the right of the bar */
.nav-spacer { flex: 1; }
.nav-out { color: var(--text-dim); white-space: nowrap; }
.nav-out:hover { color: var(--text); }
/* icon button to the source on GitHub, last in the bar; the auto margin pushes it right where there is no spacer */
.nav-icon {
  flex: none; margin-left: auto; width: 32px; height: 32px; border-radius: 6px;
  display: grid; place-items: center; color: var(--text-dim);
}
.nav-icon:hover { color: var(--text); background: var(--bg-elev-2); text-decoration: none; }
.nav-icon svg { width: 20px; height: 20px; fill: currentColor; }

.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.page h1 { font-size: 26px; margin-bottom: 6px; }
.page > p.lead { color: var(--text-dim); margin: 0 0 28px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 32px 0 12px; }

/* ---------- home ---------- */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; border: 1px solid var(--accent); background: var(--accent-soft);
  border-radius: var(--radius); margin-bottom: 8px;
}
.mode-help { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text-dim); }
.mode-help strong { color: var(--text); }
.lang-picker { margin: 14px 0 0; padding: 0; border: 0; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.lang-picker legend { float: left; margin-right: 4px; color: var(--text-dim); }
.lang-picker label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.lang-note { margin: 6px 0 12px; font-size: 12px; color: var(--text-dim); }
.random-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); margin-bottom: 14px;
}
.random-row label { color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
.problem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.problem-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.problem-card:hover { border-color: var(--border-strong); }
.problem-card .num { font: 600 12px var(--mono); color: var(--accent); }
.problem-card h3 { font-size: 16px; }
.problem-card p { margin: 0; color: var(--text-dim); flex: 1; }
.problem-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.problem-card .study-links { display: flex; flex-wrap: wrap; gap: 6px; }
a.tab { text-decoration: none; }
.level-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.level-dots i { width: 10px; height: 10px; border-radius: 2px; background: var(--border-strong); display: inline-block; }
.level-dots i.on { background: var(--pass); }
.level-dots i.over { background: var(--warn); }

/* ---------- session layout ---------- */
.session { display: grid; grid-template-rows: 52px 1fr; height: 100vh; overflow: hidden; }
.session-bar {
  display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--bg-elev); border-bottom: 1px solid var(--border); min-width: 0;
}
.session-bar .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-bar .spacer { flex: 1; }
.level-pills { display: flex; gap: 4px; }
.level-pill {
  font: 600 12px var(--mono); padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-faint);
}
.level-pill.done { border-color: var(--pass); color: var(--pass); background: var(--pass-soft); }
.level-pill.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.mode-badge { font-size: 12px; color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.timer {
  font: 600 20px var(--mono); letter-spacing: 0.02em; padding: 2px 10px; border-radius: 6px;
  min-width: 96px; text-align: center; font-variant-numeric: tabular-nums;
}
.timer.low { color: var(--warn); }
.timer.critical { color: var(--fail); }
.timer.overtime { color: var(--fail); background: var(--fail-soft); font-size: 16px; }
.timer.paused { color: var(--text-dim); }

.workspace {
  display: grid; grid-template-columns: var(--left-width, 38%) 6px 1fr;
  min-height: 0; position: relative;
}
.gutter { background: var(--border); cursor: col-resize; }
.gutter:hover, .gutter.dragging { background: var(--accent); }
.gutter.horizontal { cursor: row-resize; }

.statement-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--border); background: var(--bg-elev); flex-wrap: wrap; }
.tab {
  background: transparent; border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0; padding: 6px 12px; color: var(--text-dim); font-size: 13px;
}
.tab.active { background: var(--bg); border-color: var(--border); color: var(--text); margin-bottom: -1px; }
.tab .badge {
  font-size: 11px; border-radius: 999px; padding: 0 6px; background: var(--bg-elev-2); color: var(--text-dim);
}
.tab .badge.bad { background: var(--fail-soft); color: var(--fail); }
.tab .badge.good { background: var(--pass-soft); color: var(--pass); }
.tab .badge.warnb { background: var(--warn-soft); color: var(--warn); }
.scroll { overflow: auto; min-height: 0; flex: 1; }
.statement { padding: 18px 22px 40px; }
.statement h2 { font-size: 18px; margin-bottom: 4px; }
.statement .level-meta { color: var(--text-dim); font-size: 12px; margin-bottom: 14px; }
.statement ul { padding-left: 20px; }
.statement li { margin: 6px 0; }
.statement p { margin: 8px 0; }
.statement table, .md table { border-collapse: collapse; margin: 10px 0; }
.statement th, .statement td, .md th, .md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.statement pre, .md pre { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 10px 0; font-size: 12.5px; }
.statement pre code, .md pre code { background: none; padding: 0; }
.conventions { margin: 12px 22px 0; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-elev); }
.conventions summary { padding: 8px 12px; cursor: pointer; color: var(--text-dim); font-size: 13px; }
.conventions .md { padding: 0 12px 8px; font-size: 13px; }
.conventions ul { padding-left: 18px; margin: 4px 0; }
.stub-box { margin-top: 22px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.stub-box header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim);
}
.stub-box pre { padding: 10px 12px; font-size: 12.5px; background: var(--bg-input); max-height: 280px; overflow: auto; white-space: pre; word-break: normal; }
.passed-note { margin-top: 10px; color: var(--pass); font-size: 13px; }

.code-pane { display: grid; grid-template-rows: auto 1fr 6px var(--bottom-height, 36%); min-height: 0; min-width: 0; }
.editor-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-bottom: 1px solid var(--border); background: var(--bg-elev); flex-wrap: wrap;
}
.editor-toolbar .file-tabs { display: flex; gap: 2px; margin-right: auto; }
.file-tab { background: transparent; border: 1px solid transparent; color: var(--text-dim); font: 13px var(--mono); padding: 4px 10px; }
.file-tab.active { color: var(--text); background: var(--bg); border-color: var(--border); }
.file-tab .ro { font: 11px var(--sans); color: var(--text-faint); margin-left: 4px; }
.save-state { font-size: 12px; color: var(--text-faint); min-width: 60px; text-align: right; }
.editor-host { min-height: 0; position: relative; }
.editor-host > div { position: absolute; inset: 0; }

.results-pane { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.results-body { padding: 10px 14px 24px; }
.empty { color: var(--text-faint); padding: 18px 4px; }
.summary-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.chip {
  font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-strong);
  color: var(--text-dim); display: inline-flex; gap: 6px; align-items: center;
}
.chip.good { border-color: var(--pass); color: var(--pass); background: var(--pass-soft); }
.chip.bad { border-color: var(--fail); color: var(--fail); background: var(--fail-soft); }
.level-results { width: 100%; border-collapse: collapse; margin: 4px 0 12px; font-size: 13px; }
.level-results th, .level-results td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.level-results th { color: var(--text-dim); font-weight: 500; }
.callout { border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; border: 1px solid; }
.callout.bad { border-color: var(--fail); background: var(--fail-soft); }
.callout.good { border-color: var(--pass); background: var(--pass-soft); }
.callout.info { border-color: var(--accent); background: var(--accent-soft); }
.callout pre { margin-top: 6px; font-size: 12.5px; }
details.test { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; background: var(--bg-elev); }
details.test > summary {
  cursor: pointer; padding: 7px 10px; display: flex; gap: 10px; align-items: center; list-style: none;
}
details.test > summary::-webkit-details-marker { display: none; }
details.test > summary::before { content: "▸"; color: var(--text-faint); width: 10px; }
details.test[open] > summary::before { content: "▾"; }
details.test .test-name { flex: 1; }
details.test .body { padding: 0 10px 10px; }
.steps { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); }
.steps td, .steps th { padding: 3px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.steps th { font: 500 11px var(--sans); color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.steps tr.bad td { background: var(--fail-soft); }
.steps td.call { word-break: break-all; }
.steps td.mark { width: 18px; }
.block-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 10px 0 4px; }
.out { background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 12.5px; max-height: 260px; overflow: auto; }
.lint-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.lint-list li { display: flex; gap: 10px; padding: 5px 6px; border-bottom: 1px solid var(--border); cursor: pointer; }
.lint-list li:hover { background: var(--bg-elev); }
.lint-list .pos { font-family: var(--mono); color: var(--text-faint); min-width: 56px; }
.lint-list .code { font-family: var(--mono); color: var(--warn); min-width: 64px; }

.overlay {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(10, 12, 16, 0.55); backdrop-filter: blur(14px);
}
.overlay .card { background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 12px; padding: 28px 36px; text-align: center; max-width: 420px; }
.overlay .card h2 { font-size: 22px; margin-bottom: 8px; }
.overlay .card p { color: var(--text-dim); margin: 0 0 18px; }
.blurred { filter: blur(10px); pointer-events: none; user-select: none; }

/* ---------- modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 12px; padding: 22px 24px; width: min(480px, 100%); }
.modal h2 { font-size: 19px; margin-bottom: 8px; }
.modal p { color: var(--text-dim); margin: 0 0 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--bg-elev-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 16px; box-shadow: 0 6px 24px rgba(0,0,0,0.4); }
.toast.good { border-color: var(--pass); }
.toast.bad { border-color: var(--fail); }

/* ---------- review & history ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--text-dim); }
.table { width: 100%; border-collapse: collapse; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.table th { color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-elev-2); }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--bg-elev-2); }
.review-tabs { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.review-tabs .tabs { padding-top: 8px; }
.review-panel { padding: 18px 22px; background: var(--bg); }
.review-panel.code { padding: 0; height: 560px; }
.md h1, .md h2, .md h3 { margin: 18px 0 8px; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md ul { padding-left: 22px; }
.md li { margin: 4px 0; }
.level-block { margin-bottom: 26px; }
.level-block h3 { font-size: 16px; margin-bottom: 6px; }

/* ---------- home: track chooser ---------- */
.track-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.track-card {
  display: flex; flex-direction: column; gap: 12px; padding: 22px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; color: var(--text);
}
.track-card:hover { border-color: var(--accent); text-decoration: none; }
.track-head { display: flex; align-items: center; gap: 12px; }
.track-head h2 { font-size: 20px; }
.track-mark {
  width: 36px; height: 36px; border-radius: 8px; background: var(--accent); flex: none;
  display: grid; place-items: center; font: 700 14px var(--mono); color: #fff;
}
.track-mark.design { background: var(--design); font-size: 18px; }
.track-mark.tech { background: var(--warn); font-size: 20px; }
.track-card p { margin: 0; color: var(--text-dim); }
.track-card p.track-note { font-size: 12px; color: var(--text-faint); }
.track-facts { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.track-facts li { font-size: 12px; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 10px; color: var(--text-dim); }
.track-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.track-cta { color: var(--accent); font-weight: 600; }

/* ---------- system design: list and guide ---------- */
.guide .md table { width: 100%; }
.md th { background: var(--bg-elev-2); font-weight: 500; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: none; }
.checks label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checks input { margin-top: 3px; accent-color: var(--pass); }
.checks.static li::before { content: "☐"; margin-right: 10px; color: var(--text-faint); }
details.walkthrough { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
details.walkthrough summary { padding: 12px 16px; cursor: pointer; font-weight: 600; }
details.walkthrough .md { padding: 0 16px 16px; }

/* ---------- system design: session ---------- */
.prompt-card {
  margin: 16px 18px 6px; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--design); background: rgba(163, 113, 247, 0.1);
}
.prompt-card .num { font: 600 12px var(--mono); color: var(--design); }
.prompt-card h2 { font-size: 18px; margin: 2px 0 6px; }
.prompt-card p { margin: 0; font-size: 15px; line-height: 1.55; }
.cur-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 4px; vertical-align: middle; }
/* the side pane: the question, then the interviewer */
.side-pane .prompt-card { flex: none; }
.ask-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px 18px 14px; }
.ask-title { flex: none; margin: 0; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.persona-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: none; }
.persona {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; white-space: normal; text-align: left;
  padding: 8px 10px; background: var(--bg-elev);
}
.persona span { font-size: 12px; color: var(--text-dim); line-height: 1.35; }
.persona.on { border-color: var(--design); background: rgba(163, 113, 247, 0.12); }
.hint-log { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 60px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.hint-log.review { overflow: visible; max-width: 760px; }
.hint-empty { font-size: 13px; padding: 6px 2px; }
.hint-entry { border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: 6px; padding: 8px 10px; background: var(--bg-elev); }
.hint-entry.strict { border-left-color: var(--fail); }
.hint-entry.helpful { border-left-color: var(--pass); }
.hint-meta { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.hint-meta strong { color: var(--text-dim); font-weight: 600; }
.hint-q { font-size: 13px; color: var(--text-dim); margin: 3px 0; white-space: pre-wrap; }
.hint-a { font-size: 13.5px; white-space: pre-wrap; display: flex; gap: 8px; align-items: baseline; }
.verdict { font-weight: 700; flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; }
.verdict.yes { color: var(--pass); background: var(--pass-soft); }
.verdict.no { color: var(--fail); background: var(--fail-soft); }
.ask-form { flex: none; display: flex; flex-direction: column; gap: 8px; }
.ask-form textarea, .ai-form input, .ai-form select, .prompt-copy {
  font: 13px var(--sans); color: var(--text); background: var(--bg-input);
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 7px 9px; width: 100%; resize: vertical;
}
.ask-form textarea:focus, .ai-form input:focus, .ai-form select:focus { outline: none; border-color: var(--accent); }
.ask-actions { display: flex; align-items: center; gap: 10px; }
.ask-actions [data-ai-settings] { margin-left: auto; }
.ask-status { font-size: 12.5px; color: var(--text-dim); min-width: 0; }
.ask-status.fail { color: var(--fail); }
.ask-mode { font-size: 12px; margin: 0; }
.paste-back { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px dashed var(--border-strong); border-radius: 6px; }
.ai-form { display: grid; gap: 12px; margin: 12px 0; }
.ai-form .check { display: flex; gap: 8px; align-items: center; color: var(--text-dim); cursor: pointer; }
.ai-form .check input { width: auto; }
.prompt-copy { font: 12px var(--mono); margin-top: 8px; }

/* the record button in the session bar */
.rec-btn { font-variant-numeric: tabular-nums; }
.rec-btn.on { color: var(--fail); border-color: var(--fail); background: var(--fail-soft); }
.rec-btn.on:not(.held) { animation: rec-pulse 1.6s ease-in-out infinite; }
.rec-btn.held { color: var(--text-dim); }
.rec-status { font-size: 12px; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
@keyframes rec-pulse { 50% { border-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .rec-btn.on:not(.held) { animation: none; } }

/* ---------- whiteboard ---------- */
.board-pane { position: relative; min-height: 0; min-width: 0; }
.board-host { position: absolute; inset: 0; }
.wb {
  display: flex; flex-direction: column; height: 100%; background: var(--bg); position: relative;
  container-type: inline-size;
}
.wb-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; row-gap: 6px;
  padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--bg-elev); font-size: 12px;
}
.wb-group { display: flex; gap: 3px; flex-wrap: wrap; }
.wb-group + .wb-group { padding-left: 10px; border-left: 1px solid var(--border); }
.wb-toolbar .wb-add { gap: 4px; padding: 3px 6px; }
/* A narrow board keeps the symbols on one row: icons only, named by their tooltips. */
@container (max-width: 860px) {
  .wb-add span { display: none; }
  .wb-toolbar .wb-add { padding: 3px 7px; }
}
.wb-icon { fill: none; stroke: currentColor; stroke-width: 1.3; flex: none; }
.wb-toolbar button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wb-zoom { min-width: 48px; justify-content: center; font-variant-numeric: tabular-nums; }
.wb-canvas { flex: 1; min-height: 0; overflow: auto; position: relative; outline: none; }
.wb-canvas:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }
.wb-canvas .wb-svg {
  display: block; user-select: none; touch-action: none;
  background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 20px 20px;
}
.wb.can-pan .wb-svg { cursor: grab; }
.wb.panning .wb-svg { cursor: grabbing; }
.wb-hint {
  position: absolute; left: 10px; bottom: 8px; pointer-events: none; font-size: 11.5px;
  color: var(--text-faint); background: rgba(15, 17, 21, 0.85); padding: 2px 6px; border-radius: 4px;
}
.wb.readonly .wb-hint { display: none; }
.wb-input {
  position: absolute; z-index: 5; resize: none; overflow: hidden;
  font-family: var(--sans); color: var(--text); background: var(--bg-input);
  border: 1px solid var(--accent); border-radius: 6px; outline: none; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
/* shapes */
.wb-body { fill: var(--bg-elev-2); stroke: var(--border-strong); stroke-width: 1.5; }
.wb-hit { fill: transparent; stroke: none; }
.wb-label { fill: var(--text); font: 14px var(--sans); pointer-events: none; white-space: pre; }
.wb-strong { font-weight: 600; }
.wb-node { cursor: move; }
.wb.readonly .wb-node { cursor: default; }
/* lines and arrows */
.wb-line { stroke: var(--text-dim); stroke-width: 1.6; fill: none; }
.wb-edge.dashed .wb-line { stroke-dasharray: 6 4; }
.wb-arrowhead { fill: var(--text-dim); }
.wb-edge-hit { stroke: transparent; stroke-width: 12; cursor: pointer; }
.wb-edge.selected .wb-line { stroke: var(--accent); stroke-width: 2.4; }
.wb-edge-label {
  fill: var(--text-dim); font: 13px var(--sans); pointer-events: none; white-space: pre;
  /* A halo wide enough to bridge the gaps between words, so the line never shows through. */
  paint-order: stroke; stroke: var(--bg); stroke-width: 7px; stroke-linejoin: round;
}
/* selection and handles (the overlay layer) */
.wb-sel { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 5 3; pointer-events: none; }
.wb-target { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; pointer-events: none; }
.wb-marquee { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; pointer-events: none; }
.wb-rubber { stroke: var(--accent); stroke-dasharray: 5 4; pointer-events: none; }
.wb-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; cursor: crosshair; }
.wb-resize { fill: var(--bg); stroke: var(--accent); stroke-width: 1.5; cursor: nwse-resize; }
.wb-end { fill: var(--bg); stroke: var(--accent); stroke-width: 2; cursor: move; }
.wb.drawing .wb-svg, .wb.drawing .wb-node, .wb.drawing .wb-edge-hit { cursor: crosshair; }
/* a board on the review page */
.board-view { overflow: auto; max-height: 75vh; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; background: var(--bg); cursor: zoom-in; }
.wb-static { display: block; }
.board-full { position: fixed; inset: 0; z-index: 120; background: var(--bg); display: flex; flex-direction: column; outline: none; }
.board-full-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg-elev); font-weight: 600; }
.board-full-body { flex: 1; overflow: auto; padding: 16px; }
.clips { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; max-width: 640px; }
.clip { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: 12px 14px; display: grid; gap: 8px; }
.clip-meta { font-size: 13px; color: var(--text-dim); }
.clip-meta strong { color: var(--text); }
.clip audio { width: 100%; }
.clip-actions { display: flex; gap: 8px; align-items: center; }
a.button-link {
  font-size: 12px; color: var(--text); background: var(--bg-elev-2); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 3px 8px;
}
a.button-link:hover { text-decoration: none; border-color: var(--text-faint); }

/* ---------- system design: review ---------- */
.hint-box div + div { margin-top: 6px; }
.hint-box .chip { margin: 2px 2px 0 0; }
.hint-box .foundation-group { margin-top: 4px; }
.hint-box .foundation-group > .faint { display: inline-block; min-width: 150px; font-size: 12.5px; }
.assess-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.assess-grid h3 { font-size: 15px; margin: 0 0 10px; }
.notes-block h4 { margin: 14px 0 6px; font-size: 13px; color: var(--text-dim); }
.notes-block:first-of-type h4 { margin-top: 0; }
.notes-block pre {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 12.5px;
}
.notes-block p { margin: 0; }

/* ---------- algorithms ---------- */
.track-mark.algo { background: var(--pass); font-size: 13px; }
.diff {
  font: 600 11.5px var(--sans); padding: 1px 8px; border-radius: 999px; border: 1px solid;
  white-space: nowrap; vertical-align: middle;
}
.diff.easy { color: var(--pass); border-color: var(--pass); background: var(--pass-soft); }
.diff.medium { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.diff.hard { color: var(--fail); border-color: var(--fail); background: var(--fail-soft); }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filter-row input[type="search"], .filter-row select {
  font: inherit; color: var(--text); background: var(--bg-input); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 10px;
}
.filter-row input[type="search"] { min-width: 220px; }
.filter-row label { display: flex; gap: 6px; align-items: center; }
.algo-card .card-top { display: flex; align-items: center; gap: 8px; }
.algo-card .card-top .faint { margin-left: auto; font-size: 12px; }
.algo-card h3 a { color: var(--text); }
.pattern-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pattern-chips .chip { font-size: 11.5px; padding: 1px 7px; }
.hide-patterns .pattern-chips { display: none; }
.solved-badge {
  font: 600 12px var(--sans); color: var(--pass); border: 1px solid var(--pass);
  background: var(--pass-soft); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.overview-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.algo-study { line-height: 1.6; }
.algo-study h2 {
  font-size: 19px; margin: 30px 0 8px; padding-top: 14px; border-top: 1px solid var(--border);
}
.algo-study > h2:first-child, .algo-study .hint-box + h2 { border-top: none; padding-top: 0; margin-top: 8px; }
.algo-study h3 { font-size: 16px; margin: 20px 0 6px; }
.algo-study p { margin: 8px 0; }
.algo-session .steps th { width: 90px; }
.results-body .steps td.call { white-space: pre-wrap; }

/* ---------- foundations (study pages) ---------- */
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.learn-card {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
}
.learn-card:hover { border-color: var(--border-strong); background: var(--bg-elev-2); text-decoration: none; }
.learn-card h3 { margin: 0; font-size: 15px; }
.learn-card p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.5; flex: 1; }
.learn-card .num, .learn-index-item .num {
  font: 600 11px var(--mono); color: var(--accent); letter-spacing: 0.06em;
}
.learn-card > .faint { font-size: 12px; }
.learn-page { max-width: 1240px; }
.learn-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 36px; align-items: start; }
.learn-toc {
  position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; padding-right: 6px;
  font-size: 13px;
}
.learn-toc h4 { margin: 8px 0 8px; font-size: 14px; }
.learn-toc ul { list-style: none; margin: 0; padding: 0; }
.learn-toc ul ul { padding-left: 12px; font-size: 12.5px; }
.learn-toc a { display: block; padding: 3px 8px; border-left: 2px solid transparent; color: var(--text-dim); }
.learn-toc a:hover { color: var(--text); text-decoration: none; }
.learn-toc a.active { color: var(--text); border-left-color: var(--accent); background: var(--accent-soft); }
.learn-article { min-width: 0; max-width: 900px; }
.learn-article .crumbs { margin: 0 0 4px; }
.learn-body { font-size: 14.5px; line-height: 1.65; }
.learn-body h2 {
  font-size: 21px; margin: 40px 0 10px; padding-top: 16px; border-top: 1px solid var(--border);
  scroll-margin-top: 72px;
}
.learn-body h3 { font-size: 16.5px; margin: 26px 0 8px; scroll-margin-top: 72px; }
.learn-body h4 { font-size: 14.5px; margin: 18px 0 6px; color: var(--text-dim); }
.learn-body p, .learn-body li { line-height: 1.65; }
.learn-body ul, .learn-body ol { padding-left: 22px; }
.learn-body li { margin: 4px 0; }
.learn-body table { width: 100%; font-size: 13.5px; }
.learn-body th { background: var(--bg-elev); }
.learn-body blockquote, .md blockquote {
  margin: 14px 0; padding: 8px 14px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 6px 6px 0;
}
.learn-body blockquote p, .md blockquote p { margin: 4px 0; }
.learn-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; }
.learn-nav {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; min-width: 200px;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
}
.learn-nav.next { text-align: right; }
.learn-nav:hover { border-color: var(--border-strong); text-decoration: none; }
.learn-index-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.learn-index-item h2 { margin: 0 0 4px; font-size: 18px; display: flex; gap: 10px; align-items: baseline; }
.learn-index-item p { margin: 0 0 8px; }
.learn-sections { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; padding: 0; margin: 0; font-size: 13px; }
/* ```include blocks (pages.py): the file's path as a tab on top of its code. */
.code-file {
  margin: 16px 0 0; padding: 4px 12px; width: fit-content; max-width: 100%;
  font: 12px var(--mono); color: var(--text-dim); overflow-wrap: anywhere;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-bottom: none; border-radius: 6px 6px 0 0;
}
.md .code-file + pre { margin-top: 0; border-top-left-radius: 0; }
.code-file a { color: inherit; }
.code-file a::after { content: " ↗"; color: var(--text-faint); }
.code-file a:hover { color: var(--accent); }

/* ---------- tech investigations: Guide | Files tabs and the file browser (files.js) ---------- */
.project-tabs { display: flex; gap: 4px; margin: 8px 0 18px; border-bottom: 1px solid var(--border); }
.project-tab { padding: 6px 14px; margin-bottom: -1px; color: var(--text-dim); border-bottom: 2px solid transparent; }
.project-tab:hover { color: var(--text); text-decoration: none; }
.project-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.project-tab .faint { font: 400 11px var(--mono); margin-left: 2px; }
.learn-files { margin: 0 0 8px; font-size: 13.5px; }
.files-page { max-width: 1400px; }
.files-page .crumbs { margin: 0 0 4px; }
.files-lead { margin: 0 0 16px; font-size: 13.5px; }
.files-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.file-tree {
  position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; padding: 8px 6px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); font: 13px var(--mono);
}
.file-tree ul { list-style: none; margin: 0; padding: 0; }
.file-tree ul ul { padding-left: 14px; }
.file-tree summary { cursor: pointer; padding: 2px 6px; color: var(--text-dim); border-radius: 4px; white-space: nowrap; }
.file-tree summary:hover { color: var(--text); background: var(--bg-elev-2); }
.file-tree a {
  display: block; padding: 2px 8px 2px 18px; color: var(--text-dim); border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-tree a:hover { color: var(--text); background: var(--bg-elev-2); text-decoration: none; }
.file-tree a.active { color: var(--text); background: var(--accent-soft); }
.file-view { min-width: 0; }
.file-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; min-height: 30px; }
.file-path { flex: 1; min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.file-guide { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); }
/* Line numbers and code are two <pre>s side by side with the same metrics, and neither wraps, so
   line N of one sits next to line N of the other; long lines scroll sideways instead. */
.code-view {
  display: flex; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px; line-height: 1.6;
}
.code-view pre { margin: 0; padding: 10px 14px; white-space: pre; word-break: normal; font-size: inherit; line-height: inherit; }
.code-view code { font-size: inherit; background: none; padding: 0; border-radius: 0; }
.code-view .gutter { flex: none; color: var(--text-faint); text-align: right; user-select: none; border-right: 1px solid var(--border); }
.code-view .code { flex: 1; min-width: 0; overflow-x: auto; }
@media (max-width: 960px) {
  .files-layout { grid-template-columns: 1fr; }
  .file-tree { position: static; max-height: 40vh; }
}
.chip.link { color: var(--text); border-color: var(--accent); }
.chip.link:hover { background: var(--accent-soft); text-decoration: none; }
@media (max-width: 960px) {
  .learn-layout { grid-template-columns: 1fr; }
  .learn-toc { position: static; max-height: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
}

/* ---------- diagrams in study pages (diagrams.py SVG + mermaid) ---------- */
.ds-figure, .mermaid-figure {
  margin: 14px 0; padding: 14px 16px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto;
}
.mermaid-figure { text-align: center; }
.mermaid-figure svg { max-width: 100%; height: auto; }
/* Mermaid sizes each label in a scratch element under <body> before it lands here; page rules such
   as `.learn-body p` (taller lines) or `.statement p` (margins) would then overflow the measured box
   and clip the last line. Give labels the body's metrics back. */
.mermaid-figure p, .learn-body .mermaid-figure p, .statement .mermaid-figure p { margin: 0; line-height: 1.5; }
.mermaid-figure.pending { color: var(--text-faint); font-size: 12px; text-align: left; }
svg.ds { display: block; max-width: 100%; height: auto; overflow: visible; }
.ds-cell { fill: var(--bg-elev-2); stroke: var(--border-strong); stroke-width: 1; }
.ds-cell.hl, .ds-node.hl { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.6; }
.ds-cell.dim, .ds-node.dim, .ds-val.dim { opacity: 0.4; }
.ds-node { fill: var(--bg-elev-2); stroke: var(--border-strong); stroke-width: 1.5; }
.ds-val { fill: var(--text); font: 13px var(--mono); }
.ds-idx { fill: var(--text-faint); font: 11px var(--mono); }
.ds-label { fill: var(--text-dim); font: 13px var(--mono); }
.ds-null { fill: var(--text-faint); font: 12px var(--mono); }
.ds-cap { fill: var(--text-dim); font: 12.5px var(--sans); }
.ds-ptr { fill: var(--warn); font: 600 12px var(--mono); }
.ds-ptr-line { stroke: var(--warn); stroke-width: 1.4; }
.ds-edge { stroke: var(--text-dim); stroke-width: 1.6; fill: none; }
.ds-arrowhead { fill: var(--text-dim); }
.ds-arrowhead-ptr { fill: var(--warn); }
.ds-arrowhead-path { fill: var(--pass); }
.ds-path { stroke: var(--pass); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.ds-bar { fill: var(--accent-soft); stroke: var(--accent); }
.ds-bar.hl { fill: var(--pass-soft); stroke: var(--pass); }
.ds-bar-text { fill: var(--text); font: 11.5px var(--mono); }
.ds-axis { stroke: var(--text-faint); stroke-width: 1; }
.ds-ring { fill: none; stroke: var(--border-strong); stroke-width: 2; }
.ds-ring-walk { fill: none; stroke: var(--accent); stroke-width: 4; opacity: 0.55; stroke-linecap: round; }
.ds-key { fill: var(--warn); }
.ds-sep { stroke: var(--border); stroke-dasharray: 3 4; }
.diagram-error {
  margin: 12px 0; padding: 10px 12px; border: 1px solid var(--fail); border-radius: 6px;
  background: var(--fail-soft); font-size: 13px;
}
.diagram-error pre { margin-top: 6px; font-size: 12px; }

@media (max-width: 900px) {
  .assess-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .page { padding: 20px 16px 48px; }
  .topnav { padding: 0 16px; gap: 12px; }
  /* The links scroll sideways inside the bar rather than widening the page. */
  .brand { flex: none; }
  .topnav nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topnav nav a { white-space: nowrap; padding: 6px 8px; }
  .nav-out, .nav-spacer { display: none; }
}
