/* Dry Run
   Layout: a marked exam script. Cool paper, ink text, a highlighter for the line being run,
   red/green ticks for results. Python is set in JetBrains Mono; pseudocode in Courier Prime,
   the exam's own typewriter face. */
:root {
  --paper: #f8fafc;
  --surface: #ffffff;
  --sunk: #f1f5f9;
  --ink: #0f172a;
  --muted: #64748b;
  --rule: #e2e8f0;
  --rule-strong: #cbd5e1;
  --cobalt: #2563eb;
  --cobalt-ink: #ffffff;
  --cobalt-soft: #dbeafe;
  --graphite: #334155;
  --marker: #ffe45c;
  --marker-soft: #fff3b0;
  --pass: #1d7a46;
  --pass-soft: #e2f3e8;
  --fail: #b42318;
  --fail-soft: #fbe7e5;
  --warn: #8f5600;
  --warn-soft: #fbf0dc;
  --support: #6c8a2f;
  --tk-k: #2563eb;
  --tk-s: #0b7a52;
  --tk-n: #b0440d;
  --tk-c: #6f7b88;
  --tk-b: #7a3eb1;
  --tk-t: #0e6e80;
  --font-ui: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-py: "JetBrains Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  --font-pc: "Courier Prime", "Courier New", Courier, monospace;
  --radius: 8px;
  --header-h: 56px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b0f19; --surface: #0f172a; --sunk: #020617; --ink: #f8fafc; --muted: #94a3b8; --rule: #1e293b; --rule-strong: #334155;
    --cobalt: #3b82f6; --cobalt-ink: #ffffff; --cobalt-soft: #1e3a8a; --graphite: #cbd5e1;
    --marker: rgba(255, 214, 10, 0.32); --marker-soft: rgba(255, 214, 10, 0.16);
    --pass: #5fd08f; --pass-soft: #12301f; --fail: #ff8a7f; --fail-soft: #3a1714; --warn: #f2b45c; --warn-soft: #34260f; --support: #b5cf6b;
    --tk-k: #60a5fa; --tk-s: #6fd3a6; --tk-n: #ffab70; --tk-c: #7f8b98; --tk-b: #d1a2ff; --tk-t: #6fd0e0;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0b0f19; --surface: #0f172a; --sunk: #020617; --ink: #f8fafc; --muted: #94a3b8; --rule: #1e293b; --rule-strong: #334155;
  --cobalt: #3b82f6; --cobalt-ink: #ffffff; --cobalt-soft: #1e3a8a; --graphite: #cbd5e1;
  --marker: rgba(255, 214, 10, 0.32); --marker-soft: rgba(255, 214, 10, 0.16);
  --pass: #5fd08f; --pass-soft: #12301f; --fail: #ff8a7f; --fail-soft: #3a1714; --warn: #f2b45c; --warn-soft: #34260f; --support: #b5cf6b;
  --tk-k: #60a5fa; --tk-s: #6fd3a6; --tk-n: #ffab70; --tk-c: #7f8b98; --tk-b: #d1a2ff; --tk-t: #6fd0e0;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--font-ui);
  min-height: 100vh;
}
a { color: var(--cobalt); text-underline-offset: 2px; }
code, pre { font-family: var(--font-py); font-size: 0.92em; font-variant-ligatures: none; }
.dialect-note code { background: var(--sunk); padding: 1px 4px; border-radius: 3px; }
.task--pseudocode code, .task--pseudocode pre, .code-block--pseudocode, .md-code--pseudocode { font-family: var(--font-pc); }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.75rem; margin: 0 0 0.4em; }
h2 { font-size: 1.15rem; margin: 1.4em 0 0.5em; }
h3 { font-size: 1rem; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.header-inner {
  display: flex; align-items: center; gap: 20px; min-height: var(--header-h);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: 0.01em; }
.brand-mark { width: 28px; height: 28px; }
.bm-bg { fill: var(--cobalt); }
.bm-lines { stroke: var(--cobalt-ink); stroke-width: 2; }
.bm-mark { fill: #ffe45c; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: var(--radius); font-weight: 700; font-size: 0.95rem; }
.nav-link:hover { color: var(--ink); background: var(--sunk); }
.nav-link.is-active { color: var(--ink); box-shadow: inset 0 -3px 0 var(--cobalt); border-radius: 0; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.level-switch, .mode-toggle, .lang-switch { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.level-btn, .mode-btn {
  font: inherit; font-size: 0.85rem; font-weight: 700; border: 0; background: var(--surface); color: var(--muted);
  padding: 5px 10px; cursor: pointer; display: inline-flex; gap: 6px; align-items: baseline;
}
.level-btn + .level-btn, .mode-btn + .mode-btn { border-left: 1px solid var(--rule-strong); }
.level-btn[aria-checked="true"], .mode-btn[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.level-code { font-weight: 400; opacity: 0.75; font-size: 0.8em; }
.py-status { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.py-status[data-state="ready"]::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pass); margin-right: 6px; vertical-align: 1px; }
.py-status[data-state="failed"] { color: var(--fail); }

main { outline: none; }
.boot { padding: 40px max(16px, env(safe-area-inset-left, 0px)); color: var(--muted); }
.page {
  max-width: 1040px; margin: 0 auto; padding-block: 32px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.lead { font-size: 1.08rem; color: var(--muted); max-width: 66ch; }
.meta-quiet { color: var(--muted); font-size: 0.88rem; }
.pane-note { color: var(--muted); font-size: 0.92rem; margin: 0.4em 0 0.8em; max-width: 70ch; }
.pane-h { margin: 1em 0 0.4em; font-size: 0.95rem; }

/* ---------------------------------------------------------------- buttons */
.btn {
  font: inherit; font-weight: 700; font-size: 0.92rem; cursor: pointer;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  border-radius: var(--radius); padding: 7px 14px; line-height: 1.2; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-run { background: var(--cobalt); border-color: var(--cobalt); color: var(--cobalt-ink); }
.btn-run::before { content: ""; width: 0; height: 0; border-left: 8px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.btn-run:hover { filter: brightness(1.08); border-color: var(--cobalt); }
.btn-check { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-check:hover { filter: brightness(1.15); }
.btn-step { background: var(--marker); border-color: transparent; color: var(--ink); }
.btn-stop { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn-next { background: var(--cobalt); border-color: var(--cobalt); color: var(--cobalt-ink); }
.btn-quiet { background: transparent; }
.btn-small { padding: 5px 10px; font-size: 0.85rem; }
.btn-icon { font: inherit; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); border-radius: 4px; width: 28px; height: 28px; cursor: pointer; padding: 0; }
.btn-icon:hover { border-color: var(--ink); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }

/* ---------------------------------------------------------------- home */
.home-hero { padding: 8px 0 20px; }
.home-title { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -0.01em; margin-bottom: 0.25em; }
.home-lead { font-size: 1.12rem; color: var(--muted); max-width: 60ch; margin: 0; }
.continue {
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: baseline;
  margin: 8px 0 28px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--rule);
  border-left: 6px solid var(--marker); border-radius: var(--radius); text-decoration: none; color: var(--ink); max-width: 640px;
}
.continue:hover { border-color: var(--rule-strong); border-left-color: var(--marker); }
.continue-label { color: var(--muted); font-size: 0.9rem; grid-row: span 2; }
.continue-title { font-weight: 700; font-size: 1.1rem; }
.continue-unit { color: var(--muted); font-size: 0.9rem; }
.home-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; }
.home-section { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px 20px; min-width: 0; }
.home-section--pseudocode .hs-head h2 { font-family: var(--font-pc); font-size: 1.35rem; }
.hs-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hs-head h2 { margin: 0; font-size: 1.3rem; }
.hs-head h2 a { color: var(--ink); text-decoration: none; }
.hs-count { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.hs-blurb { color: var(--muted); margin: 6px 0 12px; font-size: 0.95rem; }
.hs-start { margin-top: 14px; }
.unit-table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.unit-table th, .unit-table td { border-top: 1px solid var(--rule); padding: 7px 0; vertical-align: middle; text-align: left; }
.unit-table th { font-weight: 400; padding-right: 12px; width: 52%; }
.unit-table th a { color: var(--ink); text-decoration: none; }
.unit-table th a:hover { text-decoration: underline; }
.home-foot { color: var(--muted); font-size: 0.92rem; margin-top: 28px; }

/* status cells: the progress grid reads like a trace table */
.cells { display: flex; flex-wrap: wrap; gap: 3px; }
.cell { width: 14px; height: 14px; border: 1.5px solid var(--rule-strong); border-radius: 2px; background: var(--surface); flex: none; display: inline-block; }
.cell--attempted { border-color: var(--warn); background: var(--warn-soft); }
.cell--passed { border-color: var(--pass); background: var(--pass); }
.cell--support { border-color: var(--pass); background: repeating-linear-gradient(135deg, var(--pass) 0 3px, var(--pass-soft) 3px 6px); }

/* ---------------------------------------------------------------- section and unit pages */
.unit-list { list-style: none; padding: 0; margin: 24px 0 0; border-top: 1px solid var(--rule); counter-reset: unit; }
.unit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--rule); counter-increment: unit; }
.unit-link { text-decoration: none; color: var(--ink); display: grid; gap: 2px; min-width: 0; }
.unit-title { font-weight: 700; font-size: 1.05rem; }
.unit-title::before { content: counter(unit) "  "; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.unit-summary { color: var(--muted); font-size: 0.93rem; }
.unit-link:hover .unit-title { text-decoration: underline; }
.unit-progress { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 240px; }
.task-list { list-style: none; padding: 0; margin: 20px 0 0; border-top: 1px solid var(--rule); }
.task-row { border-bottom: 1px solid var(--rule); }
.task-link { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 11px 4px; text-decoration: none; color: var(--ink); }
.task-link:hover { background: var(--surface); }
.task-row-title { font-weight: 700; }
.task-row-status { color: var(--muted); font-size: 0.85rem; min-width: 9em; text-align: right; }
.level-tag { font-size: 0.78rem; color: var(--muted); border: 1px dashed var(--rule-strong); padding: 1px 6px; border-radius: 3px; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.syllabus-ref { font-size: 0.85rem; color: var(--muted); margin: 0.2em 0 1em; }

.type-chip { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.type-exam { background: var(--ink); color: var(--paper); }
.type-scenario { background: var(--cobalt-soft); color: var(--cobalt); }
.type-predict, .type-trace { background: var(--marker-soft); color: var(--ink); }
.type-fix { background: var(--fail-soft); color: var(--fail); }

/* ---------------------------------------------------------------- task page */
.task {
  display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  height: calc(100vh - var(--header-h) - env(safe-area-inset-top, 0px));
  min-height: 520px;
}
.brief {
  overflow-y: auto; padding: 22px 22px 40px max(16px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-right: 1px solid var(--rule);
}
.task-title { font-size: 1.45rem; margin: 2px 0 8px; }
.task--pseudocode .task-title { font-family: var(--font-pc); font-size: 1.55rem; }
.task-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.status-pill { font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; border: 1.5px solid var(--rule-strong); color: var(--muted); }
.status-pill[data-status="attempted"] { border-color: var(--warn); color: var(--warn); }
.status-pill[data-status="passed"] { border-color: var(--pass); background: var(--pass); color: var(--surface); }
.status-pill[data-status="support"] { border-color: var(--pass); color: var(--pass); }
.prompt { max-width: 68ch; }
.prompt p { margin: 0.6em 0; }
.prompt code { background: var(--sunk); padding: 1px 4px; border-radius: 3px; }
.prompt ul, .prompt ol { padding-left: 1.3em; }
.prompt li { margin: 0.2em 0; }
.md-code, .code-block {
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto;
  font-size: 0.88rem; line-height: 1.5; margin: 0.7em 0; white-space: pre;
}
.md-code code { background: none; padding: 0; }
.md-table { overflow-x: auto; }
.md-table table { border-collapse: collapse; font-size: 0.9rem; }
.md-table th, .md-table td { border: 1px solid var(--rule); padding: 4px 10px; text-align: left; }
.examples h2, .help h2, .after h2 { font-size: 0.95rem; margin: 1.6em 0 0.5em; }
.example { border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px; background: var(--paper); }
.ex-row { display: grid; grid-template-columns: 5.5em minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 0.9rem; }
.ex-row pre { margin: 0; white-space: pre-wrap; }
.ex-label { color: var(--muted); font-size: 0.82rem; }
.dialect-note { font-size: 0.85rem; color: var(--muted); border-left: 3px solid var(--rule-strong); padding-left: 10px; }
.hint { border-top: 1px solid var(--rule); padding: 10px 0; }
.hint--locked { color: var(--muted); }
.hint-label { font-weight: 700; font-size: 0.85rem; margin-bottom: 2px; }
.hint-body p { margin: 0.3em 0; }
.hint-body code { background: var(--sunk); padding: 1px 4px; border-radius: 3px; }
.alt { border-top: 1px solid var(--rule); padding: 8px 0; }
.alt summary { cursor: pointer; font-weight: 700; font-size: 0.92rem; }
.alt-note { font-size: 0.9rem; color: var(--muted); }
.next-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.scenario-mp { margin: 16px 0; border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px 12px; }
.scenario-mp summary { cursor: pointer; font-weight: 700; }

.work { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px;
  padding-right: max(16px, env(safe-area-inset-right, 0px)); border-bottom: 1px solid var(--rule); background: var(--surface);
}
.toolbar-right { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.exam-flag { font-weight: 700; font-size: 0.85rem; padding: 4px 10px; background: var(--ink); color: var(--paper); border-radius: var(--radius); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 4px 10px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius); }
.timer--over { border-color: var(--fail); color: var(--fail); }
.inline-confirm { display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--warn-soft); flex-wrap: wrap; font-size: 0.92rem; }
.editor-host { flex: 1 1 52%; min-height: 220px; position: relative; display: flex; }
.panel { flex: 1 1 40%; min-height: 160px; display: flex; flex-direction: column; border-top: 1px solid var(--rule-strong); background: var(--surface); min-width: 0; }
.task--predict .editor-host, .task--trace .editor-host { flex-basis: 34%; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--rule); overflow-x: auto; flex: none; }
.tab { font: inherit; font-size: 0.88rem; font-weight: 700; border: 0; background: none; color: var(--muted); padding: 9px 10px 8px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.pane { overflow: auto; padding: 12px 16px 20px; flex: 1; min-height: 0; }

/* the editor */
.ed { --ed-lh: 22px; --ed-pad: 12px; flex: 1; min-width: 0; background: var(--surface); position: relative; display: flex; }
.ed--pseudo { --ed-lh: 23px; }
.ed-scroller { flex: 1; overflow: auto; position: relative; min-width: 0; }
.ed-inner { display: flex; min-height: 100%; min-width: max-content; }
.ed-gutter {
  position: sticky; left: 0; z-index: 2; flex: none; min-width: 3.4em; padding: var(--ed-pad) 10px var(--ed-pad) 6px;
  background: var(--paper); border-right: 1px solid var(--rule); color: var(--muted); text-align: right;
  font: 13px/var(--ed-lh) var(--font-py); user-select: none; font-variant-numeric: tabular-nums;
}
.ed-ln { cursor: pointer; position: relative; padding-left: 12px; }
.ed-ln:hover { color: var(--ink); }
.ed-ln--bp::before { content: ""; position: absolute; left: 0; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: var(--fail); }
.ed-ln--err { color: var(--fail); font-weight: 700; }
.ed-ln--exec { color: var(--ink); font-weight: 700; }
.ed-code { position: relative; flex: 1; min-width: 0; }
.ed-hl, .ed-input {
  margin: 0; border: 0; padding: var(--ed-pad) 24px var(--ed-pad) 14px; font-size: 15px; line-height: var(--ed-lh);
  white-space: pre; tab-size: 4; letter-spacing: 0; font-variant-ligatures: none; word-wrap: normal; overflow-wrap: normal;
}
.ed--python .ed-hl, .ed--python .ed-input { font-family: var(--font-py); font-size: 14.5px; }
.ed--pseudo .ed-hl, .ed--pseudo .ed-input { font-family: var(--font-pc); font-size: 16px; }
.ed-hl { position: relative; z-index: 1; pointer-events: none; color: var(--ink); min-height: 100%; }
.ed-input {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; resize: none; overflow: hidden;
  background: transparent; color: transparent; caret-color: var(--ink); outline: none;
}
.ed-input::selection { background: rgba(35, 72, 184, 0.22); color: transparent; }
.ed--readonly .ed-input { caret-color: transparent; }
.ed--focus { box-shadow: inset 0 0 0 2px var(--cobalt); }
.ed-marks { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.ed-mark { position: absolute; left: 4px; right: 0; height: var(--ed-lh); }
.ed-mark--exec {
  background: linear-gradient(176deg, transparent 0 8%, var(--marker) 12% 88%, transparent 92%);
  border-radius: 2px 8px 3px 6px;
}
.ed-mark--err { background: var(--fail-soft); box-shadow: inset 3px 0 0 var(--fail); }
.ed--plain .ed-hl { color: var(--ink); }
.tk-k { color: var(--tk-k); font-weight: 600; }
.ed--pseudo .tk-k { font-weight: 700; }
.tk-kl { text-decoration: underline wavy var(--warn); text-underline-offset: 3px; }
.tk-s { color: var(--tk-s); }
.tk-n { color: var(--tk-n); }
.tk-c { color: var(--tk-c); font-style: italic; }
.tk-b { color: var(--tk-b); }
.tk-f { font-weight: 700; }
.tk-t { color: var(--tk-t); font-weight: 700; }
.tk-a { color: var(--tk-k); font-weight: 700; }

/* console, tests and issues */
.console { font-size: 0.95rem; }
.console-empty { color: var(--muted); margin: 0; }
.console-out { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 0.92rem; line-height: 1.5; }
.task--pseudocode .console-out { font-family: var(--font-pc); font-size: 1rem; }
.c-in { color: var(--cobalt); font-weight: 700; }
.c-prompt { color: var(--ink); }
.c-quiet { color: var(--muted); }
.console-input-line { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.console-input { font: inherit; font-family: var(--font-py); flex: 1; max-width: 420px; padding: 5px 8px; border: 2px solid var(--cobalt); border-radius: 4px; background: var(--surface); color: var(--ink); }
.console-hint { font-size: 0.8rem; color: var(--muted); }
.run-info { font-size: 0.8rem; color: var(--muted); min-height: 1.2em; margin-bottom: 4px; }
.err-box { border: 1px solid var(--fail); background: var(--fail-soft); border-radius: var(--radius); padding: 10px 12px; margin-top: 10px; color: var(--ink); }
.err-box p { margin: 4px 0 0; }
.err-head { display: flex; gap: 10px; align-items: baseline; color: var(--fail); }
.err-tech { margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.err-tech summary { cursor: pointer; }
.line-ref { font: inherit; font-size: 0.8rem; font-weight: 700; border: 0; background: var(--sunk); color: var(--ink); border-radius: 3px; padding: 1px 6px; cursor: pointer; white-space: nowrap; }
button.line-ref:hover { background: var(--marker); }
.compile-report { border-radius: var(--radius); padding: 10px 12px; border: 1px solid var(--fail); background: var(--fail-soft); }
.compile-head { margin: 0 0 6px; }
.compile-ok { margin: 0 0 8px; color: var(--pass); font-weight: 700; font-size: 0.9rem; }
.issue-list { list-style: none; padding: 0; margin: 0; }
.issue { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 0.93rem; }
.issue:last-child { border-bottom: 0; }
.issue--style .line-ref, .issue--declare .line-ref { background: var(--warn-soft); }
.check-summary { font-weight: 700; margin: 0 0 10px; padding: 8px 12px; border-radius: var(--radius); }
.check-summary--pass { background: var(--pass-soft); color: var(--pass); }
.check-summary--fail { background: var(--fail-soft); color: var(--fail); }
.test-list, .rule-list { list-style: none; padding: 0; margin: 0; }
.test, .rule { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.mark { font-weight: 700; width: 1.2em; flex: none; text-align: center; font-size: 1.05rem; line-height: 1.4; }
.test--pass .mark, .rule--pass .mark, .ok .mark { color: var(--pass); }
.test--fail .mark, .rule--fail .mark, .bad .mark { color: var(--fail); }
.test-body { min-width: 0; flex: 1; }
.test-name { font-weight: 700; font-size: 0.93rem; }
.test-msg { margin: 2px 0; font-size: 0.92rem; }
.test-note { margin: 2px 0; font-size: 0.85rem; color: var(--muted); }
.test-detail summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.test-detail pre { margin: 0; white-space: pre-wrap; }
.file-card { border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 10px; }
.file-name { font-weight: 700; font-size: 0.85rem; padding: 4px 10px; border-bottom: 1px solid var(--rule); background: var(--paper); }
.file-body { margin: 0; padding: 8px 10px; white-space: pre-wrap; font-size: 0.88rem; max-height: 220px; overflow: auto; }

/* stepper and variables */
.stepper { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 16px; background: var(--marker-soft); border-bottom: 1px solid var(--rule); }
.step-pos { font-size: 0.85rem; font-variant-numeric: tabular-nums; margin: 0 6px; }
.vars-wrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.vars { border-collapse: collapse; font-size: 0.92rem; min-width: 220px; }
.vars caption { text-align: left; font-weight: 700; font-size: 0.85rem; padding-bottom: 4px; }
.vars th, .vars td { border: 1px solid var(--rule); padding: 3px 10px; text-align: left; }
.vars thead th { background: var(--paper); font-size: 0.8rem; color: var(--muted); }
.vars tbody th { font-weight: 700; font-family: var(--font-py); font-size: 0.9rem; }
.task--pseudocode .vars tbody th { font-family: var(--font-pc); }
.vars tr.changed td { background: var(--marker); }
.step-out { margin-top: 14px; }
.step-out-label { font-size: 0.8rem; color: var(--muted); }
.step-out pre { margin: 4px 0 0; padding: 8px; background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; white-space: pre-wrap; }

/* predict, trace, parsons, questions, test data, exam */
.predict, .trace, .parsons, .choice, .testdata, .exam-mark {
  padding: 14px 16px; padding-right: max(16px, env(safe-area-inset-right, 0px)); border-top: 1px solid var(--rule); background: var(--surface); overflow-y: auto;
}
.choice, .testdata, .parsons { flex: 1 1 auto; min-height: 0; border-top: 0; }
.predict, .trace, .exam-mark { flex: 0 1 auto; min-height: 0; max-height: 55%; }
.task--parsons .panel { flex: 0 0 32%; }
.task--choice .work, .task--testdata .work { overflow-y: auto; }
.field-label { display: block; font-weight: 700; font-size: 0.92rem; margin-bottom: 4px; }
.field-label.inline { display: inline; margin: 0; }
.prediction, .task-json, .copy-fallback {
  width: 100%; font: 0.95rem/1.5 var(--font-py); padding: 8px 10px; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); resize: vertical;
}
.task--pseudocode .prediction { font-family: var(--font-pc); font-size: 1rem; }
.predict .btn-check { margin-top: 8px; }
.compare { border-collapse: collapse; margin-top: 8px; font-size: 0.92rem; }
.compare th, .compare td { border: 1px solid var(--rule); padding: 3px 10px; text-align: left; }
.compare tr.bad td { background: var(--fail-soft); }
.trace-wrap { overflow-x: auto; }
.trace-table { border-collapse: collapse; font-size: 0.95rem; }
.trace-table th, .trace-table td { border: 1px solid var(--rule-strong); padding: 0; }
.trace-table th { padding: 5px 10px; background: var(--paper); font-family: var(--font-py); font-size: 0.88rem; min-width: 80px; }
.task--pseudocode .trace-table th { font-family: var(--font-pc); font-size: 0.95rem; }
.trace-table th.col-ok { background: var(--pass-soft); color: var(--pass); }
.trace-table th.col-bad { background: var(--fail-soft); color: var(--fail); }
.trace-table td input { width: 100%; min-width: 80px; border: 0; padding: 5px 8px; font: inherit; font-family: var(--font-py); background: var(--surface); color: var(--ink); }
.trace-table td input:focus { background: var(--marker-soft); outline: none; box-shadow: inset 0 0 0 2px var(--cobalt); }
.trace-table .rownum { color: var(--muted); font-size: 0.78rem; padding: 0 6px; text-align: right; background: var(--paper); min-width: 0; }
.trace-table--answer td { padding: 4px 10px; font-family: var(--font-py); }
.trace-table--answer caption { text-align: left; font-size: 0.85rem; color: var(--muted); padding-bottom: 4px; }
.p-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.p-list { list-style: none; padding: 0; margin: 0; min-height: 60px; border: 1px dashed var(--rule-strong); border-radius: var(--radius); padding: 6px; }
.p-prog { border-style: solid; background: var(--paper); counter-reset: pl; }
.p-block { margin: 4px 0; }
.p-move { font: inherit; width: 100%; text-align: left; border: 1px solid var(--rule); background: var(--surface); border-radius: 4px; padding: 6px 8px; cursor: pointer; color: var(--ink); }
.p-move:hover { border-color: var(--cobalt); }
.p-block--placed { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px calc(8px + var(--indent, 0) * 26px); border: 1px solid var(--rule); background: var(--surface); border-radius: 4px; }
.p-line { flex: 1; min-width: 0; overflow-x: auto; }
.p-code { white-space: pre; font-size: 0.92rem; }
.p-ctl { display: flex; gap: 3px; flex: none; }
.p-empty { color: var(--muted); font-size: 0.9rem; padding: 10px; }
.q { border: 1px solid var(--rule); border-radius: var(--radius); margin: 0 0 14px; padding: 10px 14px; }
.q legend { font-weight: 700; padding: 0 4px; }
.q--ok { border-color: var(--pass); }
.q--bad { border-color: var(--fail); }
.opt { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
.fb-ok { color: var(--pass); font-weight: 700; margin: 6px 0 0; }
.fb-bad { color: var(--fail); font-weight: 700; margin: 6px 0 0; }
.q-explain { font-size: 0.92rem; }
.td-cat { border: 1px solid var(--rule); border-radius: var(--radius); margin: 0 0 12px; padding: 8px 14px 12px; }
.td-cat legend { font-weight: 700; padding: 0 4px; }
.td-cat .meta-quiet { margin: 0 0 6px; }
.td-field { display: flex; gap: 10px; align-items: center; margin: 4px 0; flex-wrap: wrap; }
.td-field label { min-width: 16em; font-size: 0.92rem; }
.td-field input { font: inherit; font-family: var(--font-py); padding: 4px 8px; border: 1px solid var(--rule-strong); border-radius: 4px; width: 10em; background: var(--surface); color: var(--ink); }
.td-fb { font-size: 0.92rem; margin-top: 4px; }
.exam-mark h2 { margin-top: 0; }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 20px; }
.mark-points { list-style: none; padding: 0; margin: 0; }
.mark-points li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 0.93rem; }
.mark-points input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.mark-points--plain li { display: list-item; margin-left: 1.2em; list-style: disc; border: 0; padding: 2px 0; }
.just-passed .status-pill { animation: pop 0.6s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* progress page */
.progress-top { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: center; justify-content: space-between; }
.field-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field-inline label { font-size: 0.9rem; color: var(--muted); }
.field-inline input { font: inherit; padding: 6px 10px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.progress-actions label.btn { cursor: pointer; }
.table-wrap { overflow-x: auto; margin-bottom: 18px; }
.skills { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); font-size: 0.93rem; }
.skills caption { text-align: left; font-weight: 700; padding: 10px 0 6px; font-size: 1rem; }
.skills th, .skills td { border-bottom: 1px solid var(--rule); padding: 7px 10px; text-align: left; vertical-align: middle; }
.skills thead th { font-size: 0.8rem; color: var(--muted); background: var(--paper); }
.skills tbody th { font-weight: 400; }
.skills select { font: inherit; font-size: 0.88rem; padding: 3px 4px; background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: 4px; }
.tick { display: inline-block; width: 18px; height: 18px; border: 1.5px solid var(--rule-strong); border-radius: 3px; margin-right: 8px; vertical-align: -4px; text-align: center; line-height: 15px; font-size: 13px; font-weight: 700; }
.tick--on { border-color: var(--pass); color: var(--pass); }
.skill-status { font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.skill-status--secure { color: var(--pass); }
.skill-status--practising { color: var(--warn); }
.skill-status--not-yet, .skill-status--no-tasks-yet { color: var(--muted); }
.danger-zone { margin-top: 40px; border-top: 1px solid var(--rule); }

/* teachers */
.task-json { min-height: 320px; font-size: 0.85rem; }
.validate-card { border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; background: var(--surface); }
.validate-card h3 { margin: 0 0 6px; }

/* toast and dialog */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--radius); font-weight: 700; z-index: 60;
  transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.dialog-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 20, 0.45); display: grid; place-items: center; z-index: 70; padding: 16px; }
.dialog { background: var(--surface); border-radius: var(--radius); padding: 18px; max-width: 640px; width: 100%; }
.copy-fallback { min-height: 240px; margin: 8px 0; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 960px) {
  .task { grid-template-columns: minmax(0, 1fr); height: auto; }
  .brief { border-right: 0; border-bottom: 1px solid var(--rule); max-height: none; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .work { overflow: visible; }
  .editor-host { min-height: 300px; height: 56vh; flex: none; }
  .panel { min-height: 240px; }
  .pane { max-height: 60vh; }
  .header-right { margin-left: 0; }
}
@media (max-width: 640px) {
  .task-link { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .task-link .type-chip, .task-link .level-tag { display: none; }
  .task-row-status { min-width: 0; }
  .unit-row { grid-template-columns: minmax(0, 1fr); }
  .unit-progress { align-items: flex-start; }
  .p-cols { grid-template-columns: minmax(0, 1fr); }
  .toolbar-right { margin-left: 0; }
  .td-field label { min-width: 0; }
  .nav-link { padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- weekly challenge */
.home-challenge:empty { display: none; }
.ch-card {
  display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: baseline;
  margin: 4px 0 18px; padding: 14px 18px; max-width: 640px; text-decoration: none; color: var(--ink);
  background: var(--marker-soft); border: 1px solid var(--rule); border-radius: var(--radius);
}
.ch-card:hover { border-color: var(--rule-strong); }
.ch-card-label { color: var(--muted); font-size: 0.9rem; grid-row: span 2; }
.ch-card-title { font-weight: 700; font-size: 1.1rem; }
.ch-card-status { color: var(--muted); font-size: 0.9rem; }
.page--challenge { max-width: 860px; }
.ch-kicker { color: var(--muted); margin: 0 0 4px; font-weight: 700; font-size: 0.95rem; }
.ch-title { font-size: clamp(1.8rem, 4vw, 2.4rem); }
.ch-meta { color: var(--muted); font-size: 0.92rem; }
.ch-banner:empty { display: none; }
.ch-banner { margin: 18px 0; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--rule); background: var(--surface); }
.ch-banner p { margin: 4px 0 0; }
.ch-banner--done { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; border-color: var(--pass); background: var(--pass-soft); }
.ch-banner--practice { background: var(--warn-soft); border-color: var(--warn); }
.ch-score { display: flex; flex-direction: column; align-items: center; line-height: 1.1; color: var(--pass); }
.ch-score-num { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ch-list { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 22px; }
.ch-q { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px 20px; min-width: 0; }
.ch-q--ok { border-left: 5px solid var(--pass); }
.ch-q--bad { border-left: 5px solid var(--fail); }
.ch-q-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.85rem; }
.ch-num { font-weight: 700; color: var(--muted); }
.ch-diff { font-weight: 700; padding: 1px 9px; border-radius: 99px; border: 1.5px solid currentColor; }
.ch-diff--easy { color: var(--pass); }
.ch-diff--medium { color: var(--warn); }
.ch-diff--hard { color: var(--fail); }
.ch-pts { color: var(--muted); }
.ch-result { margin-left: auto; font-weight: 700; }
.ch-q--ok .ch-result { color: var(--pass); }
.ch-q--bad .ch-result { color: var(--fail); }
.ch-q-title { margin: 8px 0 4px; font-size: 1.2rem; }
.ch-story { max-width: 70ch; }
.ch-ask { font-weight: 700; margin-top: 10px; }
.ch-fig { margin: 12px 0; overflow-x: auto; }
.ch-fig svg { display: block; max-width: 100%; height: auto; }
.ch-fig img { max-width: 100%; }
.ch-answer { margin-top: 10px; }
.ch-options { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.ch-options--pics { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.ch-opt {
  display: flex; gap: 10px; align-items: center; padding: 9px 12px; border: 1.5px solid var(--rule-strong);
  border-radius: var(--radius); cursor: pointer; background: var(--surface); min-width: 0;
}
.ch-opt:hover { border-color: var(--ink); }
.ch-opt:has(input:checked) { border-color: var(--cobalt); background: var(--cobalt-soft); }
.ch-opt input { width: 18px; height: 18px; flex: none; accent-color: var(--cobalt); }
.ch-opt--right, .ch-opt--right:has(input:checked) { border-color: var(--pass); background: var(--pass-soft); }
.ch-opt--wrong, .ch-opt--wrong:has(input:checked) { border-color: var(--fail); background: var(--fail-soft); }
.ch-opt-media { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ch-opt-svg svg { width: 84px; height: 84px; display: block; }
.ch-answer--number input, .ch-answer--text input {
  font: inherit; font-size: 1.1rem; padding: 8px 12px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius);
  width: min(100%, 260px); background: var(--surface); color: var(--ink);
}
.ch-answer input:disabled { opacity: 0.85; }
.ch-order { list-style: none; padding: 0; margin: 0; counter-reset: ord; display: grid; gap: 6px; max-width: 360px; }
.ch-order-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface); counter-increment: ord; }
.ch-order-item::before { content: counter(ord); font-weight: 700; color: var(--muted); width: 1.2em; }
.ch-order-item .p-ctl { margin-left: auto; }
.ch-feedback { margin-top: 16px; border-top: 1px solid var(--rule); padding-top: 10px; }
.ch-feedback h3 { font-size: 0.95rem; margin: 10px 0 2px; }
.ch-correct { margin: 4px 0; }
.ch-connect { margin-top: 10px; padding: 8px 14px; border-left: 4px solid var(--marker); background: var(--paper); border-radius: 0 var(--radius) var(--radius) 0; }
.ch-source { font-size: 0.8rem; color: var(--muted); margin-top: 10px; }
.ch-footer { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 22px 0; }
.ch-archive { margin-top: 36px; }
.ch-archive-list { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.ch-archive-list li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--rule); }

/* challenge diagrams: inline SVG coloured from the theme */
svg.cg { font-family: var(--font-ui); }
.cg text { fill: var(--ink); }
.cg .cg-muted { fill: var(--muted); }
.cg-box { fill: var(--surface); stroke: var(--rule-strong); stroke-width: 1.5; }
/* black and white here mean real black and white (the questions depend on it), so they do not follow the theme */
.cg-px-on { fill: #111418; stroke: #8a95a3; stroke-width: 1.5; }
.cg-px-off { fill: #ffffff; stroke: #8a95a3; stroke-width: 1.5; }
.cg-parity { fill: var(--sunk); stroke: var(--rule-strong); stroke-width: 1.5; }
.cg-book { fill: var(--cobalt-soft); stroke: var(--cobalt); stroke-width: 2; }
.cg-line { stroke: var(--ink); stroke-width: 1.5; }
.cg-thick { stroke-width: 3; stroke-linecap: round; }
.cg-edge { stroke: var(--rule-strong); stroke-width: 3; }
.cg-node { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.cg-accent-node { fill: var(--marker); stroke: var(--ink); stroke-width: 2; }
.cg-accent { fill: var(--cobalt); }
.cg-weight-bg { fill: var(--paper); stroke: var(--rule-strong); stroke-width: 1; }
.cg .cg-weight { fill: var(--cobalt); }
.cg-bead-on { fill: #111418; stroke: #8a95a3; stroke-width: 2; }
.cg-bead-off { fill: #ffffff; stroke: #8a95a3; stroke-width: 2; }
.cg-qbox { fill: var(--cobalt-soft); stroke: var(--cobalt); stroke-width: 1.5; }
.cg-leaf { fill: var(--surface); stroke: var(--rule-strong); stroke-width: 1.5; }
.cg-comp { stroke: var(--cobalt); stroke-width: 3; }
.cg-comp-dot { fill: var(--cobalt); }

/* challenge: sign-in, user bar, year-band tabs */
.ch-user { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 0.92rem; padding: 8px 12px;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); margin-bottom: 18px; }
.ch-signin { display: grid; gap: 6px; max-width: 360px; margin-top: 18px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.ch-signin label { font-weight: 700; font-size: 0.92rem; margin-top: 6px; }
.ch-signin input { font: inherit; font-size: 1.05rem; padding: 8px 10px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius); background: var(--paper); color: var(--ink); }
.ch-signin .btn { justify-self: start; margin-top: 8px; }
.ch-signin .fb-bad:empty { display: none; }
.ch-bands { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 6px; }
.ch-band-tab { font: inherit; font-weight: 700; display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 14px; border: 1.5px solid var(--rule-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; position: relative; text-align: left; }
.ch-band-tab[aria-selected="true"] { border-color: var(--ink); box-shadow: inset 0 -4px 0 var(--cobalt); }
.ch-band-note { font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.ch-band-done { position: absolute; top: 4px; right: 8px; color: var(--pass); font-weight: 700; }
.ch-band-help { margin-top: 0; }
.ch-banner--entered { border-color: var(--cobalt); background: var(--cobalt-soft); }
.cg-puddle { fill: #7fb3e6; stroke: #3a77b8; stroke-width: 1.5; }
.cg-fish { fill: #f2994a; stroke: #b25f17; stroke-width: 1.5; }
.cg-cat-ear { fill: var(--marker); stroke: var(--ink); stroke-width: 1.5; }

/* ---------------------------------------------------------------- long course */
.year-select { font: inherit; font-weight: 700; font-size: 0.9rem; padding: 6px 8px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); max-width: 13em; }
.year-chooser { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--cobalt); border-radius: var(--radius); padding: 16px 20px; margin: 18px 0; }
.year-chooser h2 { margin-top: 0; }
.year-chooser--compact h2 { font-size: 1rem; }
.year-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-top: 10px; }
.year-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; }
.year-btn span { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.plan-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 20px; margin: 18px 0; }
.plan-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.plan-head h2 { margin: 0; }
.unit-list--plan { margin-top: 10px; }
.plan-status { font-weight: 700; margin: 12px 0 4px; }
.plan-status--ok { color: var(--pass); }
.plan-status--behind { color: var(--warn); }
.catch-up summary { cursor: pointer; }
.catch-list { margin: 8px 0; padding-left: 1.4em; columns: 2 18em; column-gap: 2em; }
.catch-list li { break-inside: avoid; margin-bottom: 2px; }
.cell--covered { border-color: var(--pass); background: var(--pass-soft); }
.section-tools { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; margin: 8px 0 0; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 0.92rem; cursor: pointer; }
.stage { margin-top: 28px; }
.stage-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.stage-num { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cobalt); font-weight: 700; }
.stage .unit-list { margin-top: 10px; }
.unit-when { grid-column: 1 / -1; font-size: 0.82rem; color: var(--muted); margin-top: -4px; }
.unit-refs { display: flex; flex-direction: column; gap: 2px; font-size: 0.88rem; color: var(--muted); margin: 6px 0 4px; }
.unit-refs strong { color: var(--ink); }
.tasks-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-top: 28px; }
.tasks-h .meta-quiet { font-weight: 400; font-size: 0.9rem; }
.task-row--optional .task-row-title { font-weight: 400; }
.course-tag { font-size: 0.72rem; font-weight: 700; color: var(--cobalt); background: var(--cobalt-soft); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.course-tag--ext { color: var(--warn); background: var(--warn-soft); }
.level-tag--cp { border-style: solid; border-color: var(--pass); color: var(--pass); font-weight: 700; }
.cp-note { background: var(--pass-soft); border: 1px solid var(--pass); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0 4px; font-size: 0.95rem; }
.later { margin-top: 18px; }
.later summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.tl-box { margin: 10px 0 24px; }
.tl-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; min-width: 560px; }
.tl-table th, .tl-table td { border: 1px solid var(--rule); padding: 8px 10px; vertical-align: top; text-align: left; }
.tl-table thead th { background: var(--sunk); }
.tl-unit { margin-bottom: 3px; }

/* ---------------------------------------------------------------- lessons and playground */
.lesson { margin: 18px 0 8px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.lesson-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 14px 20px; cursor: pointer; list-style: none; }
.lesson-summary::-webkit-details-marker { display: none; }
.lesson-summary::before { content: "▸"; color: var(--cobalt); font-weight: 700; }
.lesson-details[open] > .lesson-summary::before { content: "▾"; }
.lesson-summary h2 { margin: 0; }
.lesson-parts { list-style: none; margin: 0; padding: 0 20px 8px; }
.lesson-part { border-top: 1px solid var(--rule); padding: 16px 0 18px; }
.lesson-title { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 1.05rem; }
.lesson-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--cobalt); color: var(--cobalt-ink); font-size: 0.85rem; flex: none; }
.lesson-body { max-width: 72ch; }
.mini { border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; margin-top: 10px; background: var(--surface); max-width: 860px; }
.mini-editor { display: flex; min-height: 60px; max-height: 340px; }
.mini-editor .ed { min-height: 60px; }
.mini--big .mini-editor { min-height: 300px; max-height: 60vh; }
.mini-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--rule); background: var(--sunk); }
.mini-info { font-size: 0.85rem; }
.mini-out:not(:empty) { padding: 8px 12px; border-top: 1px solid var(--rule); max-height: 320px; overflow: auto; }
.mini-out .console-out { margin: 0; white-space: pre-wrap; }
.mini-draw:not(:empty) { padding: 10px 12px 0; border-top: 1px solid var(--rule); }
.page--play .toggle { margin: 4px 0 8px; }

/* ---------------------------------------------------------------- turtle drawings */
.turtle-view { margin: 0 0 12px; }
.turtle-stage { width: 100%; max-width: 420px; }
.mini .turtle-stage { max-width: 320px; }
.mini--big .turtle-stage { max-width: 440px; }
.turtle-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; border: 1px solid var(--rule-strong); border-radius: 4px; background: #fff; }
.turtle-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: 0.85rem; }
.turtle-compare { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 4px; }
.turtle-mini { margin: 0; width: 180px; max-width: 46%; }
.turtle-mini figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.draw-host:not(:empty) { margin-bottom: 8px; }
@media (max-width: 640px) {
  .header-right { gap: 8px; }
  .year-select { max-width: 9.5em; font-size: 0.85rem; }
  .lesson-parts { padding: 0 12px 8px; }
  .lesson-summary { padding: 12px; }
  .catch-list { columns: 1; }
}
#level.level-switch { border: 0; overflow: visible; }
.task-link { grid-template-columns: 18px minmax(0, 1fr) auto auto; }
.task-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
@media (max-width: 640px) {
  .task-link { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .task-chips { grid-column: 2 / -1; justify-content: flex-start; }
  .task-chips .type-chip, .task-chips .level-tag { display: inline; }
  .task-row-status { grid-column: 3; grid-row: 1; min-width: 0; font-size: 0.78rem; }
  .task-chips { grid-row: 2; }
}

/* ---------------------------------------------------------------- accounts and must-dos */
.acct { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22em; }
#level.level-switch { display: inline-flex; gap: 8px; align-items: center; }
.must-tag { font-size: 0.72rem; font-weight: 700; color: var(--ink); background: var(--marker); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.must-card { border-left: 4px solid var(--marker); }
.must-list { border-top: 1px solid var(--rule); padding: 12px 0 4px; margin-top: 10px; }
.must-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-bottom: 6px; }
.must-left { margin: 8px 0 0; padding-left: 1.2em; columns: 2 18em; column-gap: 2em; }
.must-left li { break-inside: avoid; margin-bottom: 2px; }
.must-list--late .must-top .meta-quiet { color: var(--fail); font-weight: 700; }
.page--signin .ch-signin h1 { margin-bottom: 0.2em; }
@media (max-width: 640px) { .acct { max-width: 9em; } .must-left { columns: 1; } }

/* ---------------------------------------------------------------- touch typing */
.ty-bar { display: flex; gap: 10px; margin: 8px 0 12px; flex-wrap: wrap; }
.ty-stat { font-family: var(--font-py); font-weight: 600; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 6px 12px; min-width: 6.5em; text-align: center; }
.ty-text { position: relative; font-family: var(--font-py); font-size: 1.25rem; line-height: 1.9; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 18px; height: calc(7.6em + 30px); overflow: hidden; color: var(--muted); white-space: pre-wrap; }
.ty-text .ok { color: var(--pass); }
.ty-text .bad { color: var(--fail); background: var(--fail-soft); border-radius: 2px; }
.ty-text .cur { color: var(--ink); background: var(--marker); border-radius: 2px; }
.ty-input { width: 100%; margin-top: 10px; font-family: var(--font-py); font-size: 1.1rem; padding: 10px 12px; border: 1.5px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); resize: none; }
.ty-big { font-size: 1.3rem; }
.ty-history { border-collapse: collapse; min-width: 420px; }
.ty-history th, .ty-history td { border-bottom: 1px solid var(--rule); padding: 7px 10px; text-align: left; }
.ty-history .num { text-align: right; }
.ty-qualified { font-weight: 700; color: var(--pass); }
