/* Colours: see themes.css (generated by tools/themes.py). */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (min-width: 1600px) { body { font-size: 17px; } }
.wrap { max-width: 1480px; margin: 0 auto; padding: 16px; }
.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; max-width: 1480px; margin: 0 auto; padding: 14px 16px 0; }
.brand { font-weight: 700; letter-spacing: 0.01em; }
.themes { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.swatches { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.swatch { width: 22px; height: 22px; border: 0; padding: 0; margin: 0; cursor: pointer; position: relative; }
.swatch.auto { background: var(--surface); color: var(--ink); font: 15px/22px system-ui, sans-serif; text-align: center; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 4px var(--surface); }
.swatch:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
h1 { font-size: 1.6rem; margin: 8px 0; }
h2 { font-size: 1.2rem; margin: 6px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
/* Strings (words) are boxed so a single symbol like 0 reads as a word, not as text. */
code { font: 600 0.95em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--str-line); border-radius: 6px; padding: 0 6px; margin: 0 1px; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.tiny { font-size: 0.78rem; }
.center { text-align: center; }
.hidden { display: none; }
.prose { max-width: 72ch; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; margin: 12px 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.row.end { justify-content: flex-end; }

.btn {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 8px; padding: 9px 14px; font: inherit; cursor: pointer; min-height: 42px;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.sm { padding: 6px 10px; min-height: 38px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--warn); text-decoration: none; font-size: 1.2rem; }
input:not([type="radio"]):not([type="checkbox"]), select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 40px; max-width: 100%;
}
input[type="radio"], input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* map */
.levels { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card.level {
  display: grid; gap: 4px; text-align: left; width: 100%; cursor: pointer; align-content: start;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; font: inherit;
}
.card.level:hover { border-color: var(--accent); }
.card.level.mastered { border-left: 5px solid var(--good); }
.lid { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.ltitle { font-weight: 650; font-size: 1.05rem; }
.lstate { display: flex; gap: 10px; align-items: center; }
.lmeta, .lleft { font-size: 0.85rem; color: var(--muted); }

.dots { display: inline-flex; gap: 4px; vertical-align: middle; }
/* Mastery dots: grey outline = not done yet; filled amber = done, practice only; filled blue = counted (Q83). */
.dots { gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--muted); display: inline-block; }
.dot.done { background: var(--dot-practice); border-color: var(--dot-practice); }
.dot.on { background: var(--accent); border-color: var(--accent); }
.badge { background: var(--good-soft); color: var(--good); border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.crumbs { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crumbs .right { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }

/* two-column layouts on wide screens */
.lesson { display: grid; gap: 8px 32px; grid-template-areas: "head" "fig" "text"; }
.lesson .lesson-head { grid-area: head; }
.lesson .lesson-text { grid-area: text; }
.lesson .lesson-fig { grid-area: fig; }
.practice { display: grid; gap: 8px 32px; grid-template-areas: "task" "side" "fb"; }
.practice .p-task { grid-area: task; min-width: 0; }
.practice .p-side { grid-area: side; min-width: 0; }
.practice .p-fb { grid-area: fb; min-width: 0; }
@media (min-width: 1000px) {
  .lesson.has-fig { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "head head" "text fig"; }
  .lesson.has-fig .lesson-fig { position: sticky; top: 16px; align-self: start; }
  .practice { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "task side" "fb side"; }
  .practice .p-side { position: sticky; top: 16px; align-self: start; }
}

/* prototype markers: levels not built yet */
.protonote { background: var(--warn-soft); border-radius: 8px; padding: 8px 12px; display: inline-block; }
.card.level.tbd { cursor: default; border-style: dashed; background: transparent; color: var(--muted); }
.card.level.tbd:hover { border-color: var(--line); }
.card.level.tbd .ltitle { color: var(--muted); }
.tbdbadge { margin-left: 6px; border: 1px solid var(--muted); border-radius: 999px; padding: 0 8px; font-size: 0.75rem; font-weight: 600; }

/* inspect mode (founders and reviewers) */
.inspect-toggle { font: inherit; font-size: 0.85rem; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px; min-height: 30px; cursor: pointer; }
.inspect-toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--insp); background: var(--insp-soft); }
.inspectbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; max-width: 1480px; margin: 8px auto 0; padding: 6px 16px; border-top: 2px solid var(--insp); border-bottom: 2px solid var(--insp); background: var(--insp-soft); }
.inspectbar.hidden { display: none; }
.itab { font: inherit; font-size: 0.9rem; background: transparent; color: var(--ink); border: 1px solid transparent; border-radius: 6px; padding: 3px 12px; min-height: 32px; cursor: pointer; }
.itab[aria-current="page"] { border-color: var(--insp); background: var(--surface); font-weight: 650; }
.inspect-page h1 { margin-top: 4px; }
.prose-wide { max-width: 1100px; }
.gloss { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.93rem; }
.gloss th, .gloss td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.gloss thead th { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.gloss tbody th { font-weight: 600; white-space: nowrap; }
.igrid { display: grid; gap: 8px 32px; }
@media (min-width: 1000px) { .igrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.pbar { display: inline-block; width: 160px; max-width: 45vw; height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); vertical-align: middle; overflow: hidden; }
.pbar > span { display: block; height: 100%; background: var(--accent); }
.pbar.mis > span { background: var(--warn); }
.pnum { font: 600 0.85rem ui-monospace, Menlo, monospace; }
pre.json { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 280px; overflow: auto; font-size: 0.78rem; }
details summary { cursor: pointer; color: var(--accent); margin: 8px 0; }
.bktfig { width: 100%; max-width: 560px; height: auto; display: block; margin: 8px 0; }
.bktfig .fig-node { fill: var(--surface-2); stroke: var(--ink); stroke-width: 1.6; }
.bktfig .fig-node.known { fill: var(--good-soft); stroke: var(--good); }
.bktfig .fig-t { fill: var(--ink); font: 600 15px system-ui, sans-serif; text-anchor: middle; }
.bktfig .fig-s { fill: var(--muted); font: 13px system-ui, sans-serif; text-anchor: middle; }
.bktfig .fig-edge { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.bktfig .fig-edge.dashed { stroke-dasharray: 5 4; stroke: var(--muted); }
.bktfig .fig-ink { fill: var(--ink); }

/* diagram */
.diagram { width: 100%; height: auto; max-height: 440px; display: block; margin: 8px 0; }
.diagram .edge { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.diagram .edge.active { stroke: var(--hl); stroke-width: 3.2; }
.diagram .arrowhead { fill: var(--muted); }
.diagram .arrowhead.hl { fill: var(--hl); }
.diagram .elabel { fill: var(--ink); font: 13px ui-monospace, Menlo, monospace; text-anchor: middle; }
.diagram .elabel .hlsym { fill: var(--hl); font-weight: 800; font-size: 15px; }
.diagram .node circle { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; }
.diagram .node circle.inner { fill: none; }
.diagram .node text { fill: var(--ink); font: 600 14px system-ui, sans-serif; text-anchor: middle; }
.diagram .node.active circle:first-child { fill: var(--hl-fill); stroke: var(--hl); stroke-width: 3.2; }
.diagram .node.active text { fill: var(--hl-ink); }
.diagram .node.prev circle:first-child { stroke: var(--hl); stroke-dasharray: 4 3; }

/* trace stepper */
.tape { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; font: 600 1rem ui-monospace, Menlo, monospace; }
.cell-t { min-width: 30px; height: 34px; border: 1px solid var(--line); border-radius: 6px; display: grid; place-items: center; background: var(--surface); }
.cell-t.done { opacity: 0.45; }
.cell-t.cur { background: var(--hl-fill); border: 2px solid var(--hl); color: var(--hl-ink); }
.cell-t.next { border-style: dashed; border-color: var(--muted); }
.status { margin: 6px 0; }
.status .ok { color: var(--good); }
.status .no { color: var(--warn); }
.controls { margin-top: 4px; }

/* editor + feedback */
.ttable { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.95rem; }
.ttable th, .ttable td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; }
.ttable thead th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.ttable select { min-width: 64px; }
.cell { font: inherit; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer; min-height: 38px; }
.cell:hover { border-color: var(--accent); }
.fb { border-radius: 8px; padding: 10px 12px; margin: 10px 0; border: 1px solid transparent; }
.fb p { margin: 4px 0; }
.fb.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.fb.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.fb.neutral { background: var(--surface-2); }
.hintbox { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.hintbox p { margin: 4px 0; }
.why { border: 1px dashed var(--accent); border-radius: 8px; padding: 12px; margin: 12px 0; }

/* state-meaning matching grid: one radio group per state (column) */
.match { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.93rem; }
.match th, .match td { border-bottom: 1px solid var(--line); padding: 8px 6px; }
.match thead th { font-size: 0.85rem; color: var(--muted); text-align: center; }
.match thead th:first-child { text-align: left; }
.match tbody th { text-align: left; font-weight: 400; }
.match td { text-align: center; width: 56px; }
.match td label { display: grid; place-items: center; min-height: 40px; cursor: pointer; }
.match tbody tr:hover { background: var(--surface-2); }

.meanings { padding-left: 18px; margin: 6px 0; font-size: 0.93rem; }
.worked li { margin: 8px 0; }
.q { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { font: inherit; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; min-height: 42px; }
.opt.picked { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.qfb.good { color: var(--good); }
.qfb.warn { color: var(--warn); }
.prose ol { padding-left: 20px; }

@media (max-width: 480px) {
  .panel { padding: 14px; }
  .ttable { font-size: 0.85rem; }
  .ttable select { min-width: 54px; padding: 6px; }
  .match td { width: 44px; }
  h2 { font-size: 1.08rem; }
}

/* worked-example self-explanation prompts (Q75) */
.worked .sep { margin: 6px 0 2px; }
.opt.sm { min-height: 36px; padding: 5px 10px; font-size: 0.92rem; }
.worked .reason { display: block; margin-top: 4px; }
.worked .reason.hidden { display: none; }

/* debug glide (Inspect mode only) */
.dbgrow { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.dbg { font: inherit; font-size: 0.82rem; background: var(--surface); color: var(--ink); border: 1px solid var(--insp); border-radius: 6px; padding: 2px 8px; min-height: 30px; cursor: pointer; }
.dbg:hover { background: var(--insp-soft); }
