:root {
  --bg: #0b1220; --panel: #121a2b; --panel-2: #0f1626; --line: #22304a; --text: #e6ecf5; --muted: #93a1b8;
  --accent: #f5b841; --teal: #3ad1c4; --ok: #58d68d; --bad: #ff6b6b; --warn: #f5b841; --info: #7fb3ff;
  --control: #5c6f93; /* form-control borders: >= 3:1 against every panel colour (WCAG 1.4.11) */
  color-scheme: dark;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); }
a { color: var(--teal); }
button, .btn { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 8px 14px; }
.btn { display: inline-block; text-decoration: none; line-height: 1.5; text-align: center; }
button.primary, .btn.primary { background: var(--accent); color: #1a1200; border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [tabindex="-1"]:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
code, pre, textarea, .mono { font-family: var(--mono); font-size: 14px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--accent); color: #000; padding: 6px 10px; z-index: 10; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: #0a0f1b; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.onair { font: 700 11px/1 var(--mono); letter-spacing: .12em; color: #1a0a00; background: var(--bad); padding: 5px 7px; border-radius: 4px; box-shadow: 0 0 12px rgba(255,107,107,.6); }
.brand-text { color: var(--muted); } .brand-text strong { color: var(--text); margin-right: 6px; }
.topnav { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; } .topnav a { color: var(--muted); text-decoration: none; } .topnav a:hover { color: var(--text); }
.score { font-family: var(--mono); font-size: 13px; color: var(--accent); }
/* Per-chapter progress in the top bar: six small segments, each a link to its chapter. */
.chapterprog { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.chapterprog .chap { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 28px; padding: 3px 0; border-radius: 6px; color: var(--muted); text-decoration: none; font: 600 11px/1 var(--mono); border: 1px solid transparent; }
.chapterprog .chap .bar { width: 20px; height: 4px; margin: 0; background: var(--line); } .chapterprog .chap .bar > span { background: var(--muted); }
.chapterprog .chap.partial .bar > span { background: var(--accent); } .chapterprog .chap.done { color: var(--ok); } .chapterprog .chap.done .bar > span { background: var(--ok); }
.chapterprog .chap.current { border-color: var(--control); color: var(--text); } .chapterprog .chap:hover { color: var(--text); }
@media (max-width: 480px) { .chapterprog { display: none; } }
.shell { display: flex; align-items: flex-start; }
.shell > .app { flex: 1 1 auto; min-width: 0; }
.app { max-width: 1400px; margin: 0 auto; padding: 20px; }
.foot { max-width: 1400px; margin: 30px auto; padding: 0 20px 30px; color: var(--muted); font-size: 13px; }

/* Case switcher on the home page: one tab per case, the current one outlined, a finished one green. */
.cases ol { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; margin: 0 0 14px; padding: 0; }
.casetab { display: flex; flex-direction: column; gap: 2px; min-width: 180px; max-width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); text-decoration: none; }
.casetab.current { border-color: var(--teal); background: rgba(58,209,196,.08); } .casetab.done { border-color: var(--ok); } .casetab:hover { border-color: var(--teal); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.eyebrow { font: 600 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--teal); margin-bottom: 8px; }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 10px; } h2 { font-size: 20px; margin: 0 0 10px; } h3, h2.sub { font-size: 16px; margin: 0 0 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.story p { margin: 0 0 12px; } .story p:last-child { margin: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-top: 14px; }
.chapter-card { display: block; color: inherit; text-decoration: none; }
.chapter-card:hover { border-color: var(--teal); }
.chapter-card .num { font: 700 28px/1 var(--mono); color: var(--accent); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; } .bar > span { display: block; height: 100%; background: var(--teal); }
.pill { display: inline-block; font: 600 11px/1 var(--mono); letter-spacing: .08em; padding: 5px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.watch { color: var(--info); border-color: var(--info); } .pill.build { color: var(--accent); border-color: var(--accent); } .pill.solo { color: var(--teal); border-color: var(--teal); } .pill.read { color: var(--muted); }
.pill.done { color: var(--ok); border-color: var(--ok); }
.list { list-style: none; padding: 0; margin: 0; } .list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; } .list li:first-child { border-top: 0; }
.list a { color: var(--text); text-decoration: none; } .list a:hover { color: var(--teal); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; } .chips li { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.notice { border-left: 3px solid var(--warn); padding: 10px 14px; background: rgba(245,184,65,.06); border-radius: 0 8px 8px 0; }
.toggle { display: flex; gap: 10px; align-items: flex-start; } .toggle input { margin-top: 5px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; } th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; } th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel-2); }
.people td { overflow-wrap: anywhere; } .people td:first-child { font-weight: 600; }
@media (min-width: 481px) { .people td:first-child { white-space: nowrap; } }

/* Mission layout */
.mission { display: grid; grid-template-columns: minmax(320px, 42%) 1fr; gap: 18px; align-items: start; }
@media (max-width: 1023px) { .mission { grid-template-columns: 1fr; } .desk { position: static !important; max-height: none !important; } }
.lesson .crumbs { color: var(--muted); font-size: 13px; margin-bottom: 8px; } .lesson .crumbs a { color: var(--muted); }
.beat { font-size: 17px; }
.question { border-left: 3px solid var(--teal); padding: 10px 14px; background: rgba(58,209,196,.06); border-radius: 0 8px 8px 0; margin: 14px 0; font-weight: 600; }
.concept { background: var(--panel-2); } .concept .eyebrow { color: var(--accent); }
.explain { margin: 0; padding: 0; list-style: none; } .explain li { padding: 10px 0; border-top: 1px solid var(--line); } .explain li:first-child { border-top: 0; }
.explain code { color: var(--accent); display: block; margin-bottom: 4px; white-space: pre-wrap; }
.hints .hint { outline-offset: -2px; border-left: 3px solid var(--info); padding: 8px 12px; margin-top: 8px; background: rgba(127,179,255,.06); border-radius: 0 8px 8px 0; }
.hints .hint pre { font-size: 13px; }
.clue { border: 1px solid var(--ok); background: rgba(88,214,141,.07); } .clue .eyebrow { color: var(--ok); }
.recap { border-left: 3px solid var(--info); } .recap .eyebrow { color: var(--info); } .recap ul { margin: 0 0 8px; padding-left: 20px; } .recap li { margin: 4px 0; }
.recap.complete { border-left-color: var(--ok); } .recap.complete .eyebrow { color: var(--ok); }
/* Mission map: one segment per mission, coloured by kind, filled when complete. Links, so keyboard users get one stop each. */
.mmap .legend { display: flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); }
.mmap .legend li { display: flex; align-items: center; gap: 5px; } .swatch { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--muted); }
.swatch.watch { border-color: var(--info); } .swatch.build { border-color: var(--accent); } .swatch.solo { border-color: var(--teal); } .swatch.read { border-color: var(--muted); }
.strip { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 10px 0 0; padding: 0; }
.seg { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 34px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font: 600 12px/1 var(--mono); }
.seg .fill { display: block; width: 22px; height: 4px; border-radius: 2px; background: var(--line); }
.seg.watch { border-color: var(--info); } .seg.build { border-color: var(--accent); } .seg.solo { border-color: var(--teal); } .seg.read { border-color: var(--muted); }
.seg.partial .fill { background: var(--accent); } .seg.done { color: var(--ok); border-color: var(--ok); } .seg.done .fill { background: var(--ok); }
.seg:hover { color: var(--text); }
.columns { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 14px; } .columns .card + .card { margin-top: 0; }
.closed ul { margin: 0; padding-left: 20px; } .closed li { margin: 6px 0; }
.closed.facts { border-top: 3px solid var(--ok); } .closed.hypotheses { border-top: 3px solid var(--accent); } .closed.gaps { border-top: 3px solid var(--bad); }
.bridge { border-left: 3px solid var(--teal); } .bridge .skill p { margin: 0; }
.skills .skill { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; } .skills .skill.complete { border-color: var(--ok); } .skills ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; } .skills li { margin: 3px 0; }
.keys { line-height: 2; }
/* Rule missions: the two test cases beside the question. */
.tests { border-left: 3px solid var(--accent); } .tests .eyebrow { color: var(--accent); }
.testcases { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 14px; } .testcases dt { color: var(--muted); } .testcases dd { margin: 0; overflow-wrap: anywhere; }
.caveat { font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 10px; }
.navrow { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 14px; } .navrow .btn { max-width: 100%; }

.desk { position: sticky; top: 64px; max-height: calc(100vh - 76px); overflow: auto; }
.deskbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.deskbar label { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; max-width: 100%; }
.deskbar select { flex: 1 1 160px; min-width: 0; }
select, input[type=text] { font: inherit; background: var(--panel-2); color: var(--text); border: 1px solid var(--control); border-radius: 8px; padding: 7px 10px; max-width: 100%; }
textarea.editor { width: 100%; min-height: 180px; resize: vertical; background: #0a0f1b; color: #e8f0ff; border: 1px solid var(--control); border-radius: 10px; padding: 12px 14px; line-height: 1.5; tab-size: 2; }
textarea.editor:disabled { opacity: .7; }
.feedback { margin-top: 10px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); }
.feedback.ok { border-color: var(--ok); } .feedback.bad { border-color: var(--bad); } .feedback.warn { border-color: var(--warn); } .feedback.info { border-color: var(--info); }
.feedback .title { font-weight: 600; } .feedback .fix { color: var(--muted); font-size: 14px; } .feedback .examples { margin-top: 6px; color: var(--text); font-family: var(--mono); font-size: 13px; }
.results { margin-top: 12px; }
.results .summary { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 13px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.tablewrap { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.tablewrap tr.row-btn { cursor: pointer; } .tablewrap tr.row-btn:hover td { background: rgba(58,209,196,.08); }
.tablewrap td button { padding: 2px 8px; font-size: 12px; font-family: var(--sans); }
.tablewrap td { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.raw { margin-top: 8px; outline-offset: -2px; background: #0a0f1b; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; max-height: 260px; overflow: auto; }
.raw dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; } .raw dt { color: var(--muted); } .raw dd { margin: 0; word-break: break-all; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.part { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.part h2 { display: flex; justify-content: space-between; align-items: baseline; } .part h2 .pts { font: 600 12px var(--mono); color: var(--muted); }
.options { list-style: none; padding: 0; margin: 8px 0; border: 0; min-width: 0; } .options li { padding: 6px 0; } .options label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; } .options input { margin-top: 5px; }
.scorebox { margin-top: 14px; display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.scorebox span { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); } .scorebox span.on { color: var(--ok); border-color: var(--ok); }
.fields, .entities { margin-top: 8px; } .fields summary, .entities summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.fields ul, .entities ul { columns: 2; list-style: none; padding: 0; margin: 8px 0 0; font-family: var(--mono); font-size: 12px; } .fields li, .entities li { padding: 2px 0; } .fields li span, .entities li span { color: var(--muted); }
.entities ul { columns: 1; } .entities code { color: var(--accent); overflow-wrap: anywhere; }
.lists { margin-top: 8px; } .lists summary { cursor: pointer; color: var(--muted); font-size: 13px; } .lists ul { list-style: none; padding: 0; margin: 4px 0 0; }
.lists .listlist { columns: 1; } .lists .listlist li { padding: 8px 0; border-top: 1px solid var(--line); } .lists .listlist li:first-child { border-top: 0; }
.lists .listlist code { color: var(--accent); } .lists .items { font-family: var(--mono); font-size: 12px; color: var(--text); overflow-wrap: anywhere; margin-top: 3px; }
.tablewrap td.arr { white-space: normal; max-width: 420px; overflow-wrap: anywhere; }
kbd { font: 11px var(--mono); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (max-width: 480px) { .app { padding: 14px; } h1 { font-size: 24px; } .top { padding: 10px 14px; } .brand-text { display: none; } }

/* Casebook drawer. Wide screens: a column beside the page, in the flow, so the desk shifts and nothing is covered.
   Narrow screens: a full-screen sheet. Every entry renders as text; forms are small and labelled. */
.cbtn { padding: 6px 12px; font-size: 13px; color: var(--text); border-color: var(--control); }
.cbtn[aria-expanded="true"] { border-color: var(--teal); color: var(--teal); }
.casebook { flex: 0 0 440px; width: 440px; max-width: 100%; position: sticky; top: 64px; max-height: calc(100vh - 64px); overflow: auto; border-left: 1px solid var(--line); background: var(--panel); padding: 14px 16px 20px; }
.casebook[hidden] { display: none; }
.cbhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; } .cbhead h2 { margin: 0; font-size: 18px; }
.cbintro { margin: 6px 0 10px; }
.cbname { margin-top: 8px; } .cbname > label { display: block; margin-bottom: 3px; }
.cbname input { width: 100%; font: inherit; font-weight: 600; background: var(--panel-2); color: var(--text); border: 1px solid var(--control); border-radius: 8px; padding: 7px 10px; }
.cbname input::placeholder, textarea.freeform::placeholder { color: var(--muted); opacity: .7; }
textarea.freeform { width: 100%; min-height: 260px; resize: vertical; background: #0a0f1b; color: var(--text); border: 1px solid var(--control); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin-top: 6px; }
.cbtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.cbtabs [role="tab"] { padding: 5px 9px; font-size: 13px; border-radius: 999px; background: transparent; color: var(--muted); }
.cbtabs [role="tab"].on { color: var(--text); border-color: var(--teal); background: rgba(58,209,196,.08); }
.cbtabs .cnt { display: inline-block; margin-left: 6px; font: 600 11px/1 var(--mono); color: var(--accent); }
.cbpanel .teach { border-left: 3px solid var(--info); padding: 6px 10px; margin: 0 0 10px; color: var(--text); background: rgba(127,179,255,.06); border-radius: 0 8px 8px 0; }
.cbpanel h3 { font-size: 14px; margin: 12px 0 4px; }
.entries { list-style: none; margin: 0 0 10px; padding: 0; }
.entry { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 8px; background: var(--panel-2); outline-offset: -2px; }
.entry p { margin: 6px 0; overflow-wrap: anywhere; } .entry pre { font-size: 12px; margin-top: 4px; }
.ehead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.entry .problems { margin: 6px 0 0; padding-left: 18px; color: var(--warn); } .entry .passes { color: var(--ok); margin-top: 6px; }
.entry .done { text-decoration: line-through; color: var(--muted); }
button.small { padding: 3px 8px; font-size: 12px; }
.cbform { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 8px; }
.cbfield { margin-top: 8px; } .cbfield > label { display: block; font-size: 13px; margin-bottom: 3px; }
.cbfield textarea, .cbfield input[type=text], .cbfield select { width: 100%; font: inherit; background: var(--panel-2); color: var(--text); border: 1px solid var(--control); border-radius: 8px; padding: 7px 10px; }
.cbfield textarea { resize: vertical; min-height: 60px; } .cbfield textarea.mono { font-family: var(--mono); font-size: 13px; }
.cbfield .source { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--panel-2); } .cbfield .source pre { font-size: 12px; max-height: 120px; overflow: auto; }
.rlist { margin-top: 10px; } .cbpanel .empty { padding: 6px 0; text-align: left; margin: 4px 0 0; }
.ticket { margin-top: 10px; } .ticket summary { cursor: pointer; color: var(--muted); font-size: 13px; } .ticket pre { font-size: 12px; margin-top: 6px; background: var(--panel-2); padding: 8px 10px; border-radius: 8px; }
.cbfoot { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.cbmeter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; } .cbmeter > span { display: block; height: 100%; background: var(--teal); }
.cbstatus { margin-top: 8px; outline-offset: 2px; min-height: 1em; } .cbstatus.ok { color: var(--ok); } .cbstatus.bad { color: var(--bad); } .cbstatus.warn { color: var(--warn); }
@media (max-width: 1023px) { .casebook { position: fixed; inset: 0; width: auto; flex: none; max-height: none; height: 100%; z-index: 20; border-left: 0; padding-top: 12px; } }
/* Log it: the casebook entry a mission earns, shown in the lesson pane once the investigative part is done. */
.logit { border: 1px solid var(--accent); background: rgba(245,184,65,.06); } .logit .eyebrow { color: var(--accent); }
.logit ul { margin: 6px 0; padding-left: 20px; } .logit li { margin: 3px 0; overflow-wrap: anywhere; }
.logit .feedback { margin-top: 8px; }
/* The brief: the learner's casebook beside the authored model, one section per row. */
.brief { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: start; margin-top: 8px; }
.brief > div { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); min-width: 0; }
.brief .eyebrow { margin-bottom: 4px; } .brief ul { margin: 0; padding-left: 18px; font-size: 14px; } .brief li { margin: 3px 0; overflow-wrap: anywhere; } .brief p { margin: 4px 0; font-size: 14px; overflow-wrap: anywhere; }
.brief .missing { color: var(--muted); font-size: 13px; }
@media (max-width: 640px) { .brief { grid-template-columns: 1fr; } }
.closedbook pre { font-size: 12.5px; background: var(--panel-2); padding: 10px 12px; border-radius: 8px; max-height: 320px; overflow: auto; }
