/* ---------- Theme tokens ----------
   Every colour on every page comes from these tokens. There are three themes:
   light (default), dark and contrast (high contrast), set by data-theme on <html>.
   tests/validate.js reads these three blocks and checks WCAG AA contrast for text. */
:root, :root[data-theme="light"] {
  --font-scale: 1;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1d23;
  --muted: #4a5160;
  --border: #c9ced8;
  --focus: #ffbf00;
  --focus-ring: #1a1d23;
  --code-bg: #f0f2f5;
  --primary: #1f4fd1;
  --primary-text: #ffffff;
  --link: #1f4fd1;
  --pass: #157a3c;
  --pass-bg: #e6f4ea;
  --fail: #b3261e;
  --fail-bg: #fdecea;
  --on-danger: #ffffff;
  --up-bg: #e6f4ea;
  --down-bg: #fff4e0;

  /* Task type colours, used as backgrounds behind --on-type text */
  --fill: #1f5fbf;
  --parsons: #7a2fb5;
  --predict: #b54708;
  --write: #13723a;
  --trace: #0f6b75;
  --on-type: #ffffff;
  /* Exam Mode's own accent (exam.html, decision 16): a background behind --on-exam text, and --exam-ink as text */
  --exam: #8a1538;
  --on-exam: #ffffff;
  --exam-ink: #8a1538;

  --tok-k: #8a1fb0;
  --tok-s: #0b6b2f;
  --tok-n: #a33a00;
  --tok-c: #5b6270;
  --tok-f: #1f4fd1;
  --selection: #c7d6ff;
  --glow: #b8860b;          /* gold border of a completed unit card */
  --glow-outer: #f5c518;    /* the soft glow around it */
  /* Unit colours (secured.js): the same in every theme, always with a label, so colour is never the only signal.
     Two ramps: the freshness ramp for a secured unit (gold, light blue, blue, indigo: no red, a secured unit never
     falls below 50%) and the level ramp for a placed unit that isn't secured (red, amber, green, light green).
     Ink: dark on the light chips, white on the dark ones (contrast checked in tests/features.js). */
  --rag-ink: #111111;
  --rag-ink-light: #ffffff;
  --rag-gold: #ffd34d;      /* 100% Secured (glowing) */
  --rag-gold-glow: #f5c518;
  --rag-fresh: #a9d6ff;     /* 90% Fresh: light blue */
  --rag-fading: #1f63c6;    /* 80% Fading: blue */
  --rag-soon: #3f2f9e;      /* 50-70% Revisit soon: indigo */
  --lvl-red: #c62828;       /* levels 1-3 */
  --lvl-amber: #f5a524;     /* levels 4-6 */
  --lvl-green: #4fcb7d;     /* levels 7-9 */
  --lvl-top: #a8f0c4;       /* level 10: light green */
  --rag-none: #d0d4dc;      /* grey: placement to do (teacher view's Freshness) */
  --placement-bg: #ffffff;  /* "Placement to do" (student cards): a dashed blue outline, blue text */
  --placement-ink: #1f4fd1;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121418;
  --card: #1c1f26;
  --text: #e8eaf0;
  --muted: #b4bac6;
  --border: #4a5160;
  --focus: #ffbf00;
  --focus-ring: #e8eaf0;
  --code-bg: #24282f;
  --primary: #8ab4ff;
  --primary-text: #0b1220;
  --link: #8ab4ff;
  --pass: #6fdc8c;
  --pass-bg: #14301d;
  --fail: #ff8a80;
  --fail-bg: #3a1614;
  --on-danger: #1a0705;
  --up-bg: #14301d;
  --down-bg: #3a2a10;
  --fill: #8cc4ff;
  --parsons: #d4a8ff;
  --predict: #ffb46b;
  --write: #7ee2a0;
  --trace: #7fd8e0;
  --on-type: #0b1220;
  --exam: #ff9ab4;
  --on-exam: #0b1220;
  --exam-ink: #ff9ab4;
  --tok-k: #d6a8ff;
  --tok-s: #8fe0a3;
  --tok-n: #ffb27a;
  --tok-c: #a3abb9;
  --tok-f: #8ab4ff;
  --selection: #34496e;
  --glow: #ffd54a;
  --glow-outer: #b38600;
  color-scheme: dark;
}

:root[data-theme="contrast"] {
  --bg: #000000;
  --card: #000000;
  --text: #ffffff;
  --muted: #ffffff;
  --border: #ffffff;
  --focus: #ffff00;
  --focus-ring: #ffff00;
  --code-bg: #111111;
  --primary: #ffff00;
  --primary-text: #000000;
  --link: #ffff00;
  --pass: #7dff9c;
  --pass-bg: #000000;
  --fail: #ff8f8f;
  --fail-bg: #000000;
  --on-danger: #000000;
  --up-bg: #000000;
  --down-bg: #000000;
  --fill: #8cc4ff;
  --parsons: #e2b0ff;
  --predict: #ffb46b;
  --write: #7dff9c;
  --trace: #80f0ff;
  --on-type: #000000;
  --exam: #ffa3c0;
  --on-exam: #000000;
  --exam-ink: #ffa3c0;
  --tok-k: #ffb3ff;
  --tok-s: #9dffb0;
  --tok-n: #ffd27a;
  --tok-c: #d0d0d0;
  --tok-f: #9cd0ff;
  --selection: #4d4d00;
  --glow: #ffd700;
  --glow-outer: #ffd700;
  color-scheme: dark;
}

/* ---------- Base ---------- */
html { font-size: calc(112.5% * var(--font-scale)); } /* 18px at default */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  line-height: 1.5;
}
.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 1rem; }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--focus);
}

.skip-link { position: absolute; left: -999px; top: 0; background: var(--card); color: var(--text); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }

a { color: var(--link); }

kbd {
  font-family: Consolas, "Courier New", monospace;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 .3em;
  background: var(--code-bg);
}

/* ---------- Header ---------- */
.site-header { background: var(--card); border-bottom: 2px solid var(--border); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding-block: .75rem; }
.site-header h1 { font-size: 1.4rem; margin: 0; }
.header-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Buttons ---------- */
button {
  font: inherit;
  font-size: 1rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  min-height: 2.5rem;
}
button:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--text); }
button:disabled { opacity: .55; cursor: not-allowed; }
/* aria-disabled: greyed out but still focusable (the greyed "Show me how" and its tooltip). Greyed with theme colours,
   not opacity, so its focus ring stays at full strength. */
button[aria-disabled="true"] { color: var(--muted); background: var(--code-bg); border-color: var(--border); border-style: dashed; cursor: not-allowed; }

/* ---------- Dialog ("Unit secured at 100%", app.js openSecuredDialog) ----------
   Over the whole page, centred, at most 28rem wide and the screen's width less 32px (16px each side on a phone).
   Theme colours only: the page behind is dimmed (light: the text colour at half opacity); the box is a card with a gold top. */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; }
.modal-backdrop::before { content: ""; position: absolute; inset: 0; background: var(--text); opacity: .5; }
/* Dark and high contrast: their text colour is light, so the page is dimmed with the (dark) background colour instead. */
:root[data-theme="dark"] .modal-backdrop::before, :root[data-theme="contrast"] .modal-backdrop::before { background: var(--bg); opacity: .8; }
.modal {
  position: relative; box-sizing: border-box; width: 100%; max-width: 28rem; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--card); color: var(--text); border: 2px solid var(--border); border-top: 8px solid var(--glow); border-radius: 12px;
  padding: 1.1rem 1.25rem 1.25rem;
}
.modal-title { margin: 0 0 .5rem; font-size: 1.3rem; }
.modal-title:focus { outline: 3px solid var(--focus-ring); outline-offset: 3px; border-radius: 4px; }
.modal p { margin: 0; line-height: 1.5; }
/* "Assignment complete": the breakdown, one line each; the last line is the grade. */
.modal-stats { margin: 0; padding-left: 1.25rem; line-height: 1.6; }
.modal-stats li:last-child { font-weight: 700; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.modal-actions button { flex: 1 1 10rem; }

/* ---------- Tooltip (the greyed "Show me how": "Available after two wrong attempts") ----------
   Shown on mouse hover, on keyboard focus and, for a tap on a phone, for 4 seconds (.tip-open, app.js); Esc hides it
   (.tip-hide). Below the button, at most the screen's width less 2rem, and app.js placeTip moves it left if it would
   run off the right edge. Theme colours only: the page's text colour as its background. */
.tip-wrap { position: relative; display: inline-flex; }
.tip-wrap[hidden] { display: none; }
.tooltip {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 5;
  width: max-content; max-width: min(18rem, calc(100vw - 2rem)); box-sizing: border-box;
  padding: .4rem .65rem; border-radius: 6px; border: 2px solid var(--focus-ring);
  background: var(--text); color: var(--bg);
  font-size: .9rem; line-height: 1.35; font-weight: 600; white-space: normal;
  visibility: hidden; opacity: 0; transition: opacity .12s; pointer-events: none;
}
.tip-wrap:hover .tooltip, .tip-wrap:focus-within .tooltip, .tip-wrap.tip-open .tooltip { visibility: visible; opacity: 1; }
.tip-wrap.tip-hide .tooltip { visibility: hidden; opacity: 0; }
@media (prefers-reduced-motion: reduce) { .tooltip { transition: none; } }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
button.danger { background: var(--fail); border-color: var(--fail); color: var(--on-danger); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 1.25rem; padding-block: 1.25rem; align-items: start; }
/* One column on a narrow screen. minmax(0, 1fr), not 1fr: a long code line (a program shown, the expected output, the
   editor) then scrolls inside its own box instead of widening the whole page (2026-11, found with Debugging (GCSE)). */
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.task-card, .side-panel {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.task-card { border-top-width: 8px; }
.task-card.type-fill { border-top-color: var(--fill); }
.task-card.type-parsons { border-top-color: var(--parsons); }
.task-card.type-predict { border-top-color: var(--predict); }
.task-card.type-write, .task-card.type-scratch { border-top-color: var(--write); }
.task-card.type-trace { border-top-color: var(--trace); }
.task-card.type-partial-parsons { border-top-color: var(--parsons); }
.task-card:focus { outline: none; }

/* ---------- Type banner ---------- */
.type-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  border-radius: 8px; padding: .5rem .75rem; margin-bottom: 1rem;
  color: var(--on-type);
}
.type-banner.big { padding: 1rem 1.25rem; }
.type-banner.big .type-label { font-size: 1.35rem; }
.type-label { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.type-how { font-size: .95rem; }
.type-banner.type-fill { background: var(--fill); }
.type-banner.type-parsons { background: var(--parsons); }
.type-banner.type-predict { background: var(--predict); }
.type-banner.type-write, .type-banner.type-scratch { background: var(--write); }
.type-banner.type-trace { background: var(--trace); }
.type-banner.type-partial-parsons { background: var(--parsons); }

.task-card h2 { margin: 0 0 .25rem; font-size: 1.5rem; }
.meta { color: var(--muted); margin: 0 0 .75rem; font-size: .9rem; }
.description { font-size: 1.05rem; white-space: pre-line; }
/* A `code span` in a task description (prompt 31): text the program prints or the user types. Every space is kept
   exactly (pre-wrap, so a long one still wraps on a phone instead of scrolling sideways). */
.description code { font-family: Consolas, "Cascadia Mono", "Courier New", monospace; font-size: .95em; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3em; }
/* A description with numbered steps (prompt 32): each line is its own block, with a small gap above each step and each
   example line, so a long write task isn't one dense block on a phone. */
.description .desc-line { display: block; }
.description .desc-step, .description .desc-example { margin-top: .35rem; }
.small { font-size: .9rem; color: var(--muted); }

/* ---------- Code ---------- */
pre, code, textarea, .blank { font-family: Consolas, "Cascadia Mono", "Courier New", monospace; }
pre.code, pre.output, .compare pre, .io-lines pre, .option pre, .worked pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
  overflow-x: auto;
  font-size: 1rem;
  line-height: 1.6;
  margin: .5rem 0;
  white-space: pre;
}
.tok-k { color: var(--tok-k); font-weight: 600; }
.tok-s { color: var(--tok-s); }
.tok-n { color: var(--tok-n); }
.tok-c { color: var(--tok-c); font-style: italic; }
.tok-f { color: var(--tok-f); }
.nothing { color: var(--muted); font-style: italic; font-family: "Segoe UI", Arial, sans-serif; }

.blank {
  font-size: 1rem;
  padding: .1rem .3rem;
  border: 2px dashed var(--fill);
  border-radius: 4px;
  background: var(--card);
  color: var(--text);
}

.editor-label { font-weight: 600; display: block; margin-bottom: .25rem; }
.editor {
  width: 100%;
  box-sizing: border-box;
  font-size: 1rem;
  line-height: 1.6;
  padding: .75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--text);
  tab-size: 4;
  resize: vertical;
  min-height: 12rem;
}

/* ---------- CodeMirror editor, themed with the same tokens ---------- */
.CodeMirror {
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 1rem; line-height: 1.6; height: auto;
  border: 2px solid var(--border); border-radius: 8px;
  background: var(--code-bg); color: var(--text);
}
.CodeMirror-scroll { min-height: 12rem; }
.CodeMirror-focused { outline: 3px solid var(--focus-ring); outline-offset: 2px; box-shadow: 0 0 0 6px var(--focus); }
.CodeMirror-gutters { background: var(--card); border-right: 1px solid var(--border); border-radius: 6px 0 0 6px; }
.CodeMirror-linenumber { color: var(--muted); }
.CodeMirror-cursor { border-left: 2px solid var(--text); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected, .CodeMirror-line::selection, .CodeMirror-line > span::selection { background: var(--selection); }
.cm-s-default .cm-keyword { color: var(--tok-k); font-weight: 600; }
.cm-s-default .cm-string { color: var(--tok-s); }
.cm-s-default .cm-number { color: var(--tok-n); }
.cm-s-default .cm-comment { color: var(--tok-c); font-style: italic; }
.cm-s-default .cm-builtin { color: var(--tok-f); }
.cm-s-default .cm-variable, .cm-s-default .cm-def, .cm-s-default .cm-operator, .cm-s-default .cm-property,
.cm-s-default .cm-variable-2, .cm-s-default .cm-punctuation { color: var(--text); }
.cm-s-default .cm-error { color: var(--fail); }
.CodeMirror-matchingbracket { color: var(--text) !important; background: var(--down-bg); outline: 2px solid var(--predict); }
.CodeMirror-nonmatchingbracket { color: var(--fail) !important; text-decoration: underline wavy; }

/* ---------- Predict ---------- */
/* min-width: 0 (prompt 36). A fieldset's browser default is min-width: min-content, and a flex item's is auto: either way
   the longest answer used to set the width of the whole page, so a phone scrolled sideways (typ-L1a, 38 to 68px). Now
   the options shrink to the card, and a long answer wraps onto more lines (every space still kept). */
.options { border: none; padding: 0; margin: 1rem 0 0; min-width: 0; min-inline-size: 0; }
.options legend { font-weight: 700; margin-bottom: .5rem; font-size: 1.05rem; }
.option {
  display: flex; align-items: flex-start; gap: .75rem;
  border: 2px solid var(--border); border-radius: 8px;
  padding: .25rem .75rem; margin-bottom: .5rem; cursor: pointer; min-width: 0;
}
.option input { width: 1.25rem; height: 1.25rem; margin-top: 1rem; flex: none; }
.option pre { flex: 1; margin: .4rem 0; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Each printed line of an answer is a block with a hanging indent (prompt 37): a line too long for the box wraps with its
   continuation indented, so it can't be taken for a second printed line. An empty printed line keeps its height. */
.option pre .out-line { display: block; padding-left: 2ch; text-indent: -2ch; }
.option pre .out-line:empty::before { content: "\200b"; }
/* A code box that scrolls sideways is reachable with Tab (app.js markScrollers): show where the focus is. */
pre[tabindex="0"]:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.option:has(input:checked) { border-color: var(--predict); border-width: 3px; }
.option.correct { border-color: var(--pass); background: var(--pass-bg); }
.option.wrong { border-color: var(--fail); background: var(--fail-bg); }
.inputs-note kbd { font-size: 1rem; }

/* ---------- Trace tables ---------- */
pre.code.numbered .ln { color: var(--muted); margin-right: 1rem; user-select: none; }
.trace-h { margin: 1rem 0 .25rem; font-size: 1.05rem; }
.trace-wrap { overflow-x: auto; max-width: 100%; margin: .5rem 0; }
.trace-table { border-collapse: collapse; background: var(--card); }
.trace-table th, .trace-table td { border: 1px solid var(--border); padding: .2rem .35rem; text-align: center; min-width: 3.5rem; font-family: Consolas, "Cascadia Mono", "Courier New", monospace; }
.trace-table thead th { background: var(--code-bg); }
.trace-table tbody th { color: var(--muted); font-weight: 600; }
.trace-cell { width: 6ch; min-width: 100%; box-sizing: border-box; font-size: 1rem; padding: .15rem .25rem; border: 2px dashed var(--trace); border-radius: 4px; background: var(--card); color: var(--text); font-family: inherit; text-align: center; }
.trace-cell.wrong { border-style: solid; border-color: var(--fail); background: var(--fail-bg); }
.trace-cell:disabled { border-style: solid; border-color: var(--border); }

/* ---------- Pick the missing line ---------- */
.partial-code .gap { display: inline-block; min-width: 18ch; border: 2px dashed var(--parsons); border-radius: 4px; padding: 0 .3rem; }
.partial-code .gap.empty { color: var(--muted); font-style: italic; }
.pp-options .option code { flex: 1; margin: .5rem 0; white-space: pre-wrap; min-width: 0; overflow-wrap: anywhere; padding-left: 2ch; text-indent: -2ch; } /* prompt 36: as .option pre; prompt 37: hanging indent */
.pp-options .option input { margin-top: .55rem; }
.pp-options .option:has(input:checked) { border-color: var(--parsons); }
.unit-note { margin-top: .25rem; }

/* ---------- The error question (Debugging (GCSE): part 1, then part 2 fixes it) ---------- */
.ek-bug-h, .ek-step { margin: 1rem 0 .25rem; font-size: 1.05rem; }
.error-kind { border: 2px solid var(--border); border-radius: 8px; padding: .5rem .9rem .75rem; margin: 1rem 0; background: var(--card); }
.error-kind h3 { margin: .25rem 0 .5rem; font-size: 1.05rem; }
.error-kind .ek-part { margin-top: .5rem; min-width: 0; }
.error-kind .option { align-items: center; padding: .55rem .75rem; line-height: 1.4; }
.error-kind .option input { margin-top: 0; }
.error-kind .option:has(input:checked) { border-color: var(--primary); }
.error-kind .option.correct { border-color: var(--pass); background: var(--pass-bg); }
.error-kind .option.wrong { border-color: var(--fail); background: var(--fail-bg); }
.ek-line { display: inline-block; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-weight: 400; background: var(--code-bg); border-radius: 4px; padding: 0 .3rem; }
.ek-answers { margin: .5rem 0 0; padding-left: 1.25rem; }
.ek-answers li { margin: .2rem 0; }

/* ---------- Parsons ---------- */
/* minmax(0, 1fr): a long line can't widen its column past the task card (it ran under the side panel); it wraps. */
.parsons { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 700px) { .parsons { grid-template-columns: minmax(0, 1fr); } }
.parsons-col { min-width: 0; }
.parsons-col h3 { margin: .25rem 0 .5rem; font-size: 1.05rem; }
.p-list {
  list-style: none; margin: 0; padding: .5rem;
  min-height: 6rem;
  border: 2px dashed var(--border); border-radius: 8px;
  background: var(--code-bg);
}
.p-list.program { border-color: var(--parsons); border-style: solid; }
/* flex-wrap: a line too long to share its row with the arrow buttons takes the whole row; the buttons go under it. */
.p-line {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: .35rem .5rem;
  margin-bottom: .4rem;
  cursor: grab;
}
/* A long line wraps instead of running off to the side. Its first line starts at the line's indent (--p-indent, set
   in app.js); the rest hang 4ch further in, past the start of the code, so a wrapped line still reads as one line. */
.p-line code {
  flex: 1 1 auto; min-width: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem;
  padding-left: calc(var(--p-indent, 0ch) + 4ch); text-indent: -4ch;
}
#p-avail .p-line:hover { border-color: var(--parsons); }
.p-btns { display: flex; gap: .2rem; flex: none; margin-left: auto; }
.p-btns button { padding: .1rem .45rem; min-height: 2rem; font-size: .8rem; }
.p-empty { color: var(--muted); font-style: italic; padding: .5rem; }

/* ---------- Actions, hints, results ---------- */
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.hints { padding-left: 0; list-style: none; }
.hints li {
  background: var(--down-bg);
  border-left: 5px solid var(--predict);
  padding: .5rem .75rem;
  margin-bottom: .4rem;
  border-radius: 4px;
}
:root[data-theme="contrast"] .hints li { border: 2px solid var(--predict); border-left-width: 6px; }

.results h3 { margin: .5rem 0; font-size: 1.1rem; }
.running { font-style: italic; color: var(--muted); }
.success { color: var(--pass); background: var(--pass-bg); font-weight: 700; padding: .6rem .8rem; border-radius: 8px; border: 2px solid var(--pass); }
.problem { color: var(--fail); background: var(--fail-bg); padding: .6rem .8rem; border-radius: 8px; border: 2px solid var(--fail); }
.notice { padding: .6rem .8rem; border-radius: 8px; font-weight: 600; border: 2px solid var(--border); }
.notice-up { background: var(--up-bg); border-color: var(--pass); }
.notice-down { background: var(--down-bg); border-color: var(--predict); }

.test-results { list-style: none; padding: 0; }
.test-results li { border: 2px solid var(--border); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .5rem; }
.test-results li.pass { border-color: var(--pass); background: var(--pass-bg); }
.test-results li.fail { border-color: var(--fail); background: var(--fail-bg); }
.test-results .mark { font-weight: 800; }
.test-results li.pass .mark { color: var(--pass); }
.test-results li.fail .mark { color: var(--fail); }
.inputs { color: var(--muted); font-size: .9rem; margin-left: .5rem; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .4rem; }
@media (max-width: 600px) { .compare { grid-template-columns: 1fr; } }
.compare pre { background: var(--card); }
.io-lines { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .75rem; align-items: baseline; margin: .5rem 0 0; }
.io-lines dt { font-size: .9rem; font-weight: 700; }
.io-lines dd { margin: 0; min-width: 0; }
/* A failed test's input, expected output and the student's output (TaskView.testResultsHtml). Long output wraps, so
   nothing scrolls sideways on a phone; on a phone each label sits above its value. */
.io-lines pre { background: var(--card); margin: 0; padding: .3rem .6rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.io-lines .error-line { color: var(--fail); font-weight: 700; }
.io-lines .not-run { margin: 0; font-style: italic; }
@media (max-width: 600px) { .io-lines { grid-template-columns: 1fr; } }
.worked { border: 2px solid var(--primary); background: var(--card); border-radius: 8px; padding: .5rem .9rem; margin-top: .75rem; }
.worked h3 { margin-top: .2rem; }
/* The explainer (A-level tasks): one sentence naming the idea, shown after a pass or the second wrong check. */
.explainer { border: 2px solid var(--border); border-left: 6px solid var(--primary); background: var(--card); border-radius: 8px; padding: .5rem .9rem; margin: .75rem 0; }
.explainer p { margin: 0; }
.failure p { margin: .3rem 0; }
.failure .misconception { color: var(--text); background: var(--card); border-radius: 6px; padding: .4rem .6rem; }
.failure .try-next { color: var(--text); }
.tip { margin: .4rem 0 0; }
.error-box { border: 2px solid var(--fail); background: var(--card); border-radius: 8px; padding: .6rem .8rem; margin-top: .5rem; }
.error-box p { margin: .25rem 0 0; }

/* ---------- Placement intro and level buttons ---------- */
.placement-intro { background: var(--up-bg); border: 2px solid var(--primary); border-radius: 8px; padding: .5rem .9rem; margin-bottom: 1rem; }
.placement-intro p { margin: .25rem 0; }
.level-buttons { display: flex; flex-wrap: wrap; gap: .6rem; margin: .75rem 0; }
.level-btn { font-size: .95rem; }

/* ---------- Side panel ---------- */
.side-panel h2 { margin: 0; font-size: 1.1rem; }
.cat-bar { grid-column: 1 / -1; height: .4rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.cat-bar span { display: block; height: 100%; background: var(--primary); }
.cat-tag {
  display: inline-block; font-weight: 700; color: var(--text);
  border: 2px solid var(--border); border-radius: 999px; padding: 0 .55rem; margin-right: .35rem;
}
.streak-info { font-size: .9rem; }
.py-status { font-size: .9rem; }
.keys-help { font-size: .9rem; margin: .75rem 0; }
.keys-help ul { padding-left: 1.1rem; }
.reset-area { margin-top: 1rem; }
.reset-confirm { font-size: .9rem; }
.reset-confirm button { margin: .25rem .25rem 0 0; }
.privacy { font-size: .85rem; color: var(--muted); }
.loading { font-style: italic; }

/* ---------- Landing page, name screen, unit cards ---------- */
.home { padding-block: 1.25rem; }
.home:focus { outline: none; }
.student-chip { font-size: .95rem; }
.home-link { color: inherit; text-decoration: none; }
.unit-crumb { font-weight: 400; }
.name-card { max-width: 32rem; border-top-color: var(--primary); }
.text-input {
  font: inherit; font-size: 1.1rem; width: 100%; box-sizing: border-box;
  padding: .5rem .75rem; border: 2px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text);
}
.known-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
/* Backend mode: landing choices, the new code and PIN, and the "not saved yet" notice */
.landing-choices { gap: .75rem; }
.login-details { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; font-size: 1.3rem; }
.login-details dd { margin: 0; font-family: Consolas, "Cascadia Mono", "Courier New", monospace; letter-spacing: .08em; }
.class-code { font-family: Consolas, "Cascadia Mono", "Courier New", monospace; letter-spacing: .08em; }
.retention-note { margin-top: 1.5rem; }
.backend-status { margin: 0; padding: .5rem 1rem; background: var(--down-bg); border-bottom: 2px solid var(--predict); color: var(--text); text-align: center; }
.unit-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.unit-card {
  display: block; height: 100%; box-sizing: border-box;
  background: var(--card); color: var(--text); text-decoration: none;
  border: 2px solid var(--border); border-top: 8px solid var(--primary); border-radius: 12px;
  padding: 1rem 1.25rem;
}
a.unit-card { color: var(--text); }
a.unit-card:hover { border-color: var(--primary); }
.unit-card h3, .unit-card h4, .unit-card h5 { margin: 0 0 .25rem; font-size: 1.25rem; }
.unit-card p { margin: .25rem 0; }
/* Stars (prompt 23, secured.js starsHtml): five outlines, one filled each time a unit came back to 100%. The shape and
   the count read out ("3 of 5 stars") carry it, not the colour alone. */
.unit-stars { display: inline-flex; gap: 3px; vertical-align: middle; line-height: 1; }
.unit-stars .star { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linejoin: round; }
.unit-stars .star.star-on { fill: var(--rag-gold); stroke: var(--text); }
.unit-stars-row { margin: .4rem 0 0 !important; }
.programmes-count { font-weight: 700; }
.unit-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; font-size: .9rem; margin-top: .75rem !important; }
/* Glowing gold card: a level 10 task has been passed in this unit. CSS only; the colours are theme tokens. */
.unit-card.unit-complete, a.unit-card.unit-complete:hover {
  border-color: var(--glow);
  box-shadow: 0 0 0 2px var(--glow), 0 0 14px 4px var(--glow-outer);
  animation: glow-pulse 2.4s ease-in-out infinite;
}
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--glow), 0 0 6px 1px var(--glow-outer); }
  50% { box-shadow: 0 0 0 2px var(--glow), 0 0 20px 7px var(--glow-outer); }
}
@media (prefers-reduced-motion: reduce) {
  .unit-card.unit-complete, a.unit-card.unit-complete:hover { animation: none; } /* static glow, no pulsing */
}
.complete-note { font-weight: 700; margin-top: .5rem !important; }
.unit-levels { list-style: none; padding: 0; margin: .5rem 0 .75rem; }
.unit-progress { display: grid; gap: .2rem; margin: .5rem 0 .75rem; }
.unit-name { font-weight: 700; }
.menu-links { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }

/* ---------- Tutorial overlay (tour.js) ----------
   A card fixed to the bottom of the screen, not a backdrop: the page stays usable, and closing it removes it.
   The control a step is about gets a ring (tour-target). While it is open the page gets room at the bottom
   (tour-open), so every control can be scrolled above the card. */
.tour-card {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 1000; box-sizing: border-box;
  max-width: 28rem; margin-left: auto; max-height: 50vh; overflow: auto;
  background: var(--card); color: var(--text); border: 3px solid var(--primary); border-radius: 10px; padding: .6rem 1rem .75rem;
}
.tour-card .tour-title { font-size: 1.15rem; margin: .1rem 0 .4rem; }
.tour-card .tour-text { margin: 0 0 .5rem; }
.tour-card .tour-count, .tour-card .tour-where { margin: 0 0 .35rem; color: var(--muted); }
.tour-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 0; }
.tour-buttons .tour-skip { margin-left: auto; }
.tour-target { outline: 4px solid var(--focus); outline-offset: 4px; scroll-margin-top: 5rem; }
body.tour-open { padding-bottom: 55vh; }
/* Phone width (review finding B10): the card is at most a third of the screen tall, and its text scrolls inside it. */
@media (max-width: 600px) {
  .tour-card { max-height: 33vh; }
  body.tour-open { padding-bottom: 38vh; }
}
.tour-reminders { display: grid; gap: .5rem; margin-bottom: 1rem; }
.tour-reminder p { margin: .2rem 0; }
.tour-reminder .teacher-controls { margin-bottom: 0; }
.menu-link {
  display: inline-block; font-weight: 700; text-decoration: none; padding: .5rem 1rem;
  border: 2px solid var(--primary); border-radius: 8px; color: var(--link); background: var(--card);
}
.menu-link:hover { background: var(--code-bg); }
.menu-link[hidden] { display: none; }
/* Leaderboards (leaderboard.html, teacher.html): two boards side by side when there is room */
.points-summary { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: .5rem 0 1rem; padding: .75rem 1rem; }
.points-summary .stat strong { font-size: 1.4rem; display: block; }
.boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.board { min-width: 0; }
.board h3, .board h4 { margin: 0 0 .25rem; }
.board .small { margin-top: 0; }
.board-table { width: 100%; border-collapse: collapse; }
.board-table th, .board-table td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.board-table th.num, .board-table td.num { text-align: right; white-space: nowrap; }
/* The teacher's Most points boards (prompt 23) have more columns: they scroll sideways in their own wrapper instead of
   breaking words inside a heading. */
.board .table-wrap .board-table th, .board .table-wrap .board-table td { overflow-wrap: normal; }
.board-table tr.board-me td { background: var(--code-bg); font-weight: 700; }
.board-table tr.board-me td:first-child { box-shadow: inset 4px 0 0 var(--primary); }
/* Certificates (teacher view): the student page's panel and the Certificates page */
.cert-list { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .4rem; }
.cert-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem;
  background: var(--card); border: 2px solid var(--border); border-radius: 8px; padding: .5rem .75rem; }
.cert-class { margin-bottom: 1.25rem; }
.cert-who { min-width: 0; overflow-wrap: break-word; }
.cert-who strong { display: block; }
.unit-points { margin: .5rem 0 1rem; }
.unit-points .board-table th, .unit-points .board-table td { overflow-wrap: normal; padding: .35rem .4rem; }
/* Progress summary */
.unit-card .stat-row { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-top: .5rem; }
.unit-card .stat strong { font-size: 1.3rem; display: block; }
button.unit-card { width: 100%; text-align: left; font: inherit; cursor: pointer; }
button.unit-card:hover { border-color: var(--primary); }
.skill-list { list-style: none; padding: 0; display: grid; gap: .4rem; }
.skill-list li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; background: var(--card); border: 2px solid var(--border); border-radius: 8px; padding: .5rem .75rem; }
.status { font-weight: 700; border-radius: 999px; padding: .05rem .65rem; border: 2px solid currentColor; white-space: nowrap; }
/* My progress: the long "Unit completed – endless mode unlocked" pill may wrap, so it never makes a phone scroll sideways. */
.unit-meta .status { white-space: normal; max-width: 100%; }
.status-secured { color: var(--pass); background: var(--pass-bg); }
.status-in-progress { color: var(--text); background: var(--down-bg); }
.status-not-started { color: var(--muted); }
/* Endless mode */
.endless-list { list-style: none; padding: 0; display: grid; gap: .5rem; max-width: 40rem; }
.endless-list li { background: var(--card); border: 2px solid var(--border); border-radius: 10px; padding: .6rem .9rem; }
.endless-list label { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.endless-list input[type="checkbox"] { width: 1.3rem; height: 1.3rem; }
.endless-list li.locked { color: var(--muted); border-style: dashed; }
.endless-list li.locked label { font-weight: 400; }
.endless-list .lock-msg { margin: .2rem 0 0 1.9rem; font-size: .9rem; }
.unit-level { font-size: 1.6rem; font-weight: 800; }
.unit-progress .cat-bar span { display: block; height: 100%; background: var(--primary); }

/* ---------- Teacher view ---------- */
tr.row-alert td, tr.row-alert th { background: var(--fail-bg); }
tr.row-alert td:first-child { box-shadow: inset 6px 0 0 var(--fail); }
.teacher-controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.teacher-controls select { font: inherit; padding: .35rem; max-width: 100%; }
.teacher-controls label { max-width: 100%; }
/* display: flex above would otherwise show a hidden row of controls (the Add a teacher form for a co-teacher) */
.teacher-controls[hidden] { display: none; }
/* The Teachers panel on the Classes page (class sharing): one row per teacher, owner first */
.teacher-list { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .4rem; }
.teacher-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem;
  background: var(--card); border: 2px solid var(--border); border-radius: 8px; padding: .5rem .75rem; }
.teacher-who { min-width: 0; overflow-wrap: anywhere; }
.teacher-email { display: block; }
.teacher-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
#tb-add-teacher input[type=email] { width: min(20rem, 100%); max-width: 100%; box-sizing: border-box; }
.table-wrap { overflow-x: auto; background: var(--card); border: 2px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--border); }
th { background: var(--code-bg); position: sticky; top: 0; }
th button { all: unset; cursor: pointer; font-weight: 700; }
th button:focus-visible { outline: 3px solid var(--focus-ring); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .85rem; font-weight: 700; color: var(--on-type); }
.badge.type-fill { background: var(--fill); }
.badge.type-parsons { background: var(--parsons); }
.badge.type-predict { background: var(--predict); }
.badge.type-write, .badge.type-scratch { background: var(--write); }
.badge.type-trace { background: var(--trace); }
.badge.type-partial-parsons { background: var(--parsons); }
.res-pass { color: var(--pass); font-weight: 700; }
.res-fail { color: var(--fail); font-weight: 700; }
.res-none { color: var(--muted); }
/* The teacher view: a side menu of pages, beside the page on show (stacked on narrow screens). */
.teacher-shell { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; margin-top: 1rem; }
.side-nav { flex: 0 0 12rem; display: flex; flex-direction: column; gap: .3rem; position: sticky; top: .75rem; }
.side-nav-links { display: flex; flex-direction: column; gap: .3rem; }
.side-nav a { padding: .55rem .9rem; text-decoration: none; font-weight: 700; border: 2px solid transparent; border-radius: 8px; }
.side-nav a[aria-current="page"] { background: var(--card); border-color: var(--border); color: var(--text); }
.teacher-pages { flex: 999 1 32rem; min-width: 0; }
/* The phone menu's button (review finding L8): hidden on wider screens, where the list always shows. */
.nav-toggle { display: none; }
@media (max-width: 700px) {
  .side-nav { flex-basis: 100%; position: static; }
  .nav-toggle { display: block; width: 100%; text-align: left; }
  .nav-toggle::after { content: " ▾" / ""; } /* the arrow isn't read out */
  .side-nav.nav-open .nav-toggle::after { content: " ▴" / ""; }
  .side-nav-links { flex-direction: row; flex-wrap: wrap; }
  .side-nav:not(.nav-open) .side-nav-links { display: none; }
}
.class-bar .teacher-controls { margin-bottom: .5rem; }
.code-card { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; background: var(--card); border: 2px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin: .75rem 0; }
.big-code { font-size: 1.8rem; letter-spacing: .15em; }
.five-tasks { border: 2px solid var(--border); border-radius: 8px; margin: .75rem 0; padding: .25rem .9rem .5rem; }
.assignment-tasks { margin: .25rem 0 .75rem; }
/* The assignment builder's list: each task with Change and Remove; Change opens the other tasks at that level. */
.as-task-list li { margin: .35rem 0; }
.as-task-list button { margin-left: .25rem; padding: .15rem .55rem; font-size: .85rem; }
.as-swap { list-style: none; padding-left: 1rem; margin: .35rem 0; }
.as-swap li { margin: .2rem 0; }
/* The frame takes the height of the task view inside it (teacher.js fitFrame), so the page scrolls, not the frame.
   The height here is only used until the task view has loaded. */
.practice-frame { display: block; box-sizing: border-box; width: 100%; max-width: 100%; height: 20rem; border: 2px solid var(--border); border-radius: 8px; background: var(--bg); }
.tb-practice-bar { margin-top: .5rem; }
/* Teacher practice (practice.html inside the teacher view's Task browser): no student header or links. */
.teacher-practice .site-header, .teacher-practice .privacy, .teacher-practice .skip-link { display: none; }

/* Secured score bands. Fixed colours with dark text (white on red) read the same in every theme, and each band always
   shows its label too, so colour is never the only signal. */
.rag { display: inline-block; font-weight: 700; font-size: .85rem; border-radius: 6px; padding: .1rem .45rem; color: var(--rag-ink); border: 1px solid var(--rag-ink); }
/* Freshness ramp: a secured unit. */
.rag-gold { background: var(--rag-gold); box-shadow: 0 0 .6rem var(--rag-gold-glow); }
.rag-fresh { background: var(--rag-fresh); }
.rag-fading { background: var(--rag-fading); color: var(--rag-ink-light); }
.rag-soon { background: var(--rag-soon); color: var(--rag-ink-light); }
/* Level ramp: a placed unit that isn't secured yet ("Level N"). */
.rag-lv-red { background: var(--lvl-red); color: var(--rag-ink-light); }
.rag-lv-amber { background: var(--lvl-amber); }
.rag-lv-green { background: var(--lvl-green); }
.rag-lv-top { background: var(--lvl-top); }
.rag-none { background: var(--rag-none); }
.rag-placement { background: var(--placement-bg); color: var(--placement-ink); border: 2px dashed var(--placement-ink); }
.rag-key .rag { margin: .1rem .1rem; }
.flag-block { display: inline-flex; flex-direction: column; align-items: flex-start; margin-right: .3rem; vertical-align: top; }
/* The nine summary tiles, in two labelled rows (prompt 25): Freshness (four tiles), then Level (five). Each row fills
   the page's width; under 700px each row wraps two tiles to a line, in the same order. Each tile can shrink to its
   column, so there is never sideways scrolling, and its label chip takes the tile's full width and wraps only between
   words (break-word splits a word only if it can't fit on a line by itself, which these labels never need). */
.rag-summary { margin: .75rem 0; }
/* OCR specification codes (prompt 28): the small grey label under each unit's heading on the Students page, and the
   Curriculum page's table (it scrolls sideways inside its own box on a phone). */
.spec-code { display: block; font-size: .72rem; font-weight: 400; color: var(--muted); margin-top: .1rem; white-space: nowrap; }
.cc-versions { margin: .25rem 0 .75rem; }
.cc-wrap { overflow-x: auto; }
.cc-table { border-collapse: collapse; width: 100%; min-width: 44rem; }
.cc-table th, .cc-table td { text-align: left; padding: .35rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.cc-table thead th { border-bottom: 2px solid var(--text); }
.cc-block th { background: var(--code-bg); font-weight: 700; }
.cc-code { white-space: nowrap; }
.cc-flag { display: block; font-size: .8rem; font-style: italic; color: var(--muted); }
.cc-none { font-weight: 700; padding: .5rem .6rem; }
/* Read out to a screen reader, not shown (for example "opens in a new tab"). */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
/* The glossary (prompt 27): glossary.html, and its links in task text and hints. */
.term-link { text-decoration-style: dotted; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.side-glossary { font-size: .95rem; }
.gloss-search-row { max-width: 32rem; margin: 1rem 0; }
.gloss-search-row .text-input { width: 100%; }
.gloss-letters { display: flex; flex-wrap: wrap; gap: .35rem .6rem; margin: .5rem 0 1rem; font-weight: 700; }
.gloss-letters a { padding: .15rem .35rem; }
.gloss-letter-h { font-size: 1.4rem; border-bottom: 2px solid var(--border); padding-bottom: .2rem; margin: 1.5rem 0 .5rem; }
.gloss-entry { min-width: 0; border: 2px solid var(--border); border-radius: 8px; background: var(--card); padding: .6rem .9rem; margin: .6rem 0; scroll-margin-top: 1rem; }
.gloss-entry.gloss-target { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus); }
.gloss-term { font-size: 1.15rem; margin: 0 0 .3rem; overflow-wrap: anywhere; }
.gloss-group { font-size: .78rem; font-weight: 600; color: var(--muted); margin-left: .35rem; white-space: nowrap; }
.gloss-def { margin: 0 0 .5rem; overflow-wrap: anywhere; }
/* The example wraps on a phone instead of scrolling sideways. */
.gloss-example { margin: 0; padding: .5rem .7rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }
.gloss-none { font-weight: 700; }
/* The Classes page (prompt 26): Create several classes, its summary, and the class code cards list. */
.batch-create { margin: .5rem 0 1rem; }
.batch-create summary { cursor: pointer; font-weight: 600; }
.batch-create textarea { width: 100%; max-width: 32rem; }
.batch-list { margin: .25rem 0 .75rem; padding-left: 1.25rem; }
.class-cards { margin-top: 1.5rem; }
.card-list { list-style: none; padding: 0; margin: .5rem 0; }
.card-row { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
/* The teacher's student page: Progress summary (prompt 25), four figures that wrap two to a line on a phone. */
.summary-figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin: .5rem 0; }
.summary-figure { min-width: 0; overflow-wrap: break-word; border: 2px solid var(--border); border-radius: 8px; padding: .5rem .9rem; background: var(--card); }
.summary-figure dt { font-size: .85rem; color: var(--muted); }
.summary-figure dd { margin: .2rem 0 0; font-size: 1.3rem; font-weight: 700; }
@media (max-width: 699.98px) { .summary-figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } .summary-figure dd { font-size: 1.1rem; } }
.rag-row-label { font-size: .85rem; font-weight: 700; margin: .5rem 0 .3rem; }
.rag-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin: 0 0 .5rem; }
.rag-tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rag-tiles-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 699.98px) { .rag-tiles-4, .rag-tiles-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rag-tile { min-width: 0; overflow-wrap: break-word; border: 2px solid var(--border); border-radius: 8px; padding: .5rem .9rem; background: var(--card); }
.rag-tile .rag { display: block; }
.rag-tile strong { display: block; font-size: 1.8rem; }
@media (max-width: 600px) {
  .rag-tiles { gap: .4rem; }
  .rag-tile { padding: .35rem .45rem; border-left-width: 6px !important; }
  .rag-tile .rag { font-size: .72rem; }
  .rag-tile strong { font-size: 1.4rem; }
}
/* Summary tiles (teacher.js): the band's colour on the left edge and on the label chip, the same colours as the cells. */
.rag-tile-gold { border-left: 10px solid var(--rag-gold); }
.rag-tile-fresh { border-left: 10px solid var(--rag-fresh); }
.rag-tile-fading { border-left: 10px solid var(--rag-fading); }
.rag-tile-soon { border-left: 10px solid var(--rag-soon); }
.rag-tile-lv-red { border-left: 10px solid var(--lvl-red); }
.rag-tile-lv-amber { border-left: 10px solid var(--lvl-amber); }
.rag-tile-lv-green { border-left: 10px solid var(--lvl-green); }
.rag-tile-lv-top { border-left: 10px solid var(--lvl-top); }
.rag-tile-none { border-left: 10px solid var(--rag-none); }
.unit-averages { margin: .5rem 0 1rem; line-height: 2; }
.flag-easy { background: var(--lvl-green); color: var(--rag-ink); border-color: var(--rag-ink); cursor: help; }
.flag-hard { background: var(--lvl-red); color: var(--rag-ink-light); border-color: var(--rag-ink); cursor: help; }
.flag-key { margin: .25rem 0 .75rem; }
.score-bar { margin-bottom: .9rem; }
.score-bar .bar { height: .6rem; border: 1px solid var(--border); border-radius: 999px; background: var(--code-bg); overflow: hidden; margin-top: .3rem; }
.score-bar .bar span { display: block; height: 100%; }
.secured-note { margin-top: .5rem !important; }
.score-note { margin: .5rem 0 0; font-size: .95rem; } /* My progress: what a unit's score means (secured.js studentNote) */
.quick-look { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.quick-look section { background: var(--card); border: 2px solid var(--border); border-radius: 8px; padding: .5rem .9rem; }
.quick-look h3 { margin: .25rem 0 .5rem; font-size: 1.05rem; }
.quick-look ul, .quick-look ol { margin: 0; padding-left: 1.2rem; font-size: .92rem; }
.unit-cell .lvl { font-weight: 800; }

/* ---------- Students page: two rows per student (Freshness, Level), one table per group of units ----------
   Each table has every unit of its group. It scrolls sideways inside its own wrapper (.overview-wrap); the page
   never does (the grid tracks are minmax(0, 1fr), so a wide table can't widen them). The Name and Shows columns are
   sticky on the left, so the name stays in view at every scroll position. Widths are custom properties on the
   wrapper: --ov-name and --ov-shows (the sticky columns), --ov-avg and --ov-unit (each unit column's least width).
   A table whose units fit shares the spare width between them (table-layout: fixed, width at least 100%). */
.overview-tables { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; container-type: inline-size; }
/* The export popup (teacher.js openExport): what the file contains, a sample row as column/value pairs, Download. */
.export-dialog { width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-sizing: border-box; overflow: auto;
  background: var(--card); color: var(--text); border: 2px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; }
.export-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.export-dialog h3 { margin-top: 0; }
.export-sample { width: 100%; font-size: .85rem; table-layout: fixed; }
.export-sample th, .export-sample td { overflow-wrap: anywhere; text-align: left; vertical-align: top; }
.export-sample th[scope="row"] { width: 40%; font-weight: 600; }
/* Each group of units is a collapsible block (collapse.js), like the student view's groups. The [hidden] rule is
   needed because display: grid would otherwise beat the browser's own [hidden] { display: none }: that is why the
   block buttons used to change but the table stayed on show. */
.overview-block { border: 2px solid var(--border); border-radius: 12px; background: var(--card); padding: .25rem .75rem .5rem; min-width: 0; }
.overview-block > .group-heading { font-size: 1.1rem; }
.overview-block > .group-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-bottom: .5rem; }
.overview-block > .group-body[hidden] { display: none; }
.group-state { flex: none; font-size: .85rem; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 .55rem; }
.overview-wrap { --ov-name: 8.5rem; --ov-shows: 5.5rem; --ov-avg: 7rem; --ov-unit: 8.5rem;
  position: relative; overflow-x: auto; overscroll-behavior-x: contain; scroll-padding-left: calc(var(--ov-name) + var(--ov-shows)); }
.overview-wrap:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.overview-table { table-layout: fixed; font-size: .85rem; border-collapse: separate; border-spacing: 0;
  width: max(100%, calc(var(--ov-name) + var(--ov-shows) + var(--ov-avg) + var(--ov-units, 1) * var(--ov-unit))); }
/* The block's heading already names the group: the caption is for screen readers only. */
.overview-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.overview-table .ov-col-name { width: var(--ov-name); }
.overview-table .ov-col-shows { width: var(--ov-shows); }
.overview-table .ov-col-avg { width: var(--ov-avg); }
.overview-table th, .overview-table td { padding: .35rem .4rem; vertical-align: top; overflow-wrap: anywhere; hyphens: auto; }
.overview-table thead th { vertical-align: bottom; }
.overview-table tbody th { top: auto; }
/* Sticky on the left: Name, then Shows beside it. An opaque background so the units scroll underneath, and a line on
   the Shows column's right edge so it is clear where the fixed part ends. */
.overview-table .ov-name { position: sticky; left: 0; z-index: 2; }
.overview-table .ov-shows { position: sticky; left: var(--ov-name); z-index: 2; box-shadow: inset -2px 0 0 var(--border); }
.overview-table thead .ov-name, .overview-table thead .ov-shows { z-index: 3; }
.overview-table .ov-name a { font-weight: 700; }
.overview-table .rag, .overview-table .badge-complete, .overview-table .flag { white-space: normal; }
.overview-table .flag, .overview-table .badge-complete { border-radius: 8px; }
.overview-table .ov-shows { color: var(--muted); font-weight: 700; }
.overview-table tr.ov-fresh > td, .overview-table tr.ov-fresh > .ov-shows { border-bottom: 1px dashed var(--border); }
.overview-table tbody.ov-student > tr:first-child > * { border-top: 2px solid var(--border); }
/* A phone or a narrow window (the tables' own width): narrower fixed columns and less padding, so a whole unit column
   fits beside the name at 390px. */
@container (max-width: 599px) {
  .overview-block { padding: .25rem .4rem .4rem; }
  .overview-wrap { --ov-name: 6.25rem; --ov-shows: 4.75rem; --ov-avg: 6.5rem; --ov-unit: 7rem; }
  .overview-table { font-size: .8rem; }
  .overview-table th, .overview-table td { padding: .3rem .3rem; }
}
.flag { display: inline-block; font-size: .78rem; font-weight: 700; border: 1px solid var(--border); border-radius: 999px; padding: 0 .4rem; margin-left: .2rem; }
.flag-alert { color: var(--fail); border-color: var(--fail); }
.badge-complete { color: var(--text); border: 2px solid var(--glow); border-radius: 999px; padding: 0 .4rem; font-size: .78rem; font-weight: 700; margin-left: .2rem; }
.export-bar { margin-top: 1.5rem; padding-top: 1rem; border-top: 2px solid var(--border); }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 700px) { .side-by-side { grid-template-columns: 1fr; } }
.side-by-side pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem; overflow-x: auto; margin: .25rem 0; }
td details summary { cursor: pointer; }
td pre { white-space: pre-wrap; margin: .25rem 0; font-size: .85rem; }

/* ---------- Display tools: theme, overlay ---------- */
.display-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.display-tools select { font: inherit; font-size: 1rem; padding: .35rem; border-radius: 8px; border: 2px solid var(--border); background: var(--card); color: var(--text); }
.overlay-menu { position: relative; }
.overlay-menu summary {
  list-style: none; cursor: pointer; padding: .45rem 1rem; border-radius: 8px;
  border: 2px solid var(--border); background: var(--card); min-height: 1.5rem;
}
.overlay-menu summary::-webkit-details-marker { display: none; }
.overlay-menu[open] summary { border-color: var(--text); }
.overlay-panel {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 50; width: 16rem;
  background: var(--card); color: var(--text); border: 2px solid var(--border); border-radius: 10px;
  padding: .75rem 1rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.overlay-panel fieldset { border: none; margin: 0; padding: 0; }
.overlay-panel legend { font-weight: 700; margin-bottom: .25rem; }
.tint-option { display: flex; align-items: center; gap: .5rem; padding: .15rem 0; }
.tint-swatch { width: 1.1rem; height: 1.1rem; border-radius: 4px; border: 1px solid var(--border); flex: none; }
.overlay-panel input[type="range"] { width: 100%; }
/* The overlay sits over everything but never takes clicks or focus. */
#reading-overlay {
  position: fixed; inset: 0; z-index: 2147483647;
  pointer-events: none; display: none;
}
#reading-overlay.on { display: block; }

/* ---------- Expected output box (practice page and Task browser) ---------- */
.expected-box { border: 2px solid var(--border); border-radius: 8px; background: var(--code-bg); padding: .6rem .9rem; margin: .75rem 0 1rem; }
.expected-box h3 { margin: 0 0 .3rem; font-size: 1rem; }
.expected-box p { margin: .25rem 0; }
.expected-box pre.expected-output { margin: .35rem 0; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: .45rem .7rem; white-space: pre-wrap; }
.expected-none { font-style: italic; color: var(--muted); }

/* ---------- Class assignments ---------- */
.assignments { margin-bottom: 1.5rem; }
.assignment-intro { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .5rem; }
.assignment-task { width: 100%; text-align: left; margin: .15rem 0; }
.assignment-task.current { border-width: 3px; font-weight: 700; }
.assignment-card h3 .flag { font-size: .8rem; vertical-align: middle; }

/* ---------- Homework (student home page and teacher view) ---------- */
.homework-card { border-top-color: var(--write); }
.homework-card.homework-complete { border-top-color: var(--pass); }
.homework-label { font-weight: 700; }
.hw-fields label { display: flex; flex-direction: column; gap: .2rem; font-weight: 700; }
.hw-fields .text-input { width: auto; min-width: 10rem; max-width: 100%; }
.hw-units { border: 2px solid var(--border); border-radius: 8px; padding: .5rem .9rem .75rem; margin: 0 0 1rem; min-width: 0; }
.hw-units legend { font-weight: 700; padding: 0 .3rem; }
.hw-block { border-bottom: 1px solid var(--border); padding: .35rem 0; }
.hw-block:last-child { border-bottom: 0; }
.hw-block summary { cursor: pointer; font-weight: 700; padding: .25rem 0; }
.hw-all { display: block; margin: .35rem 0; font-weight: 700; }
.hw-unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .25rem 1rem; padding-left: 1.4rem; }
.hw-unit-grid label { overflow-wrap: anywhere; }
.hw-list { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .6rem; }
.hw-item h4 { margin: 0 0 .25rem; }
.hw-item p { margin: .25rem 0; }
.hw-item .teacher-controls { margin: .5rem 0 0; }
.hw-list-h { margin-top: 1.25rem; }
/* Student home: the header's Change nickname link stays on one line (it moves down whole on a phone). */
#rename-link { white-space: nowrap; }
/* Student home: Delete everything saved for me, apart from Change my nickname (review finding L5). */
.delete-zone { margin-top: 2rem; padding-top: 1rem; border-top: 2px solid var(--border); }
/* Students page: the longer colour rules, folded away under the key (review findings L4 and S1). */
.rag-more { margin: .25rem 0 .75rem; }
.rag-more summary { cursor: pointer; font-size: .9rem; font-weight: 600; }
.rag-more p { margin: .4rem 0 0; }
/* "How it works": the longer help on Leaderboards, Certificates, Homework and Reports, closed at first (review finding S11). */
.how-it-works { margin: .25rem 0 .75rem; }
.how-it-works summary { cursor: pointer; font-size: .9rem; font-weight: 600; }
.how-it-works p { margin: .4rem 0 0; }
/* A homework's report opens inside its own card (review finding L2), under a line. */
.hw-report { margin-top: .75rem; padding-top: .5rem; border-top: 2px solid var(--border); min-width: 0; }
.hw-report h3 { margin: .25rem 0; font-size: 1.05rem; }
.hw-item { min-width: 0; }
.hw-report-table td, .hw-report-table th { vertical-align: top; }
.hw-report-table td:nth-child(3) { min-width: 9rem; }
.hw-flags { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.hw-flags .flag { margin-left: 0; margin-right: .3rem; }
/* On a phone each student's row is a block (name, then Done, Units and Paste flagged, labelled), so nothing is off
   to the side; the column headings stay as a row of sort buttons. */
@media (max-width: 600px) {
  .hw-report-table, .hw-report-table thead, .hw-report-table tbody, .hw-report-table tbody tr, .hw-report-table tbody th, .hw-report-table td { display: block; width: auto; }
  .hw-report-table thead tr { display: flex; flex-wrap: wrap; gap: 0 .9rem; padding: .3rem .7rem; }
  .hw-report-table thead th { border: 0; padding: .25rem 0; }
  .hw-report-table tbody tr { border-top: 1px solid var(--border); padding: .35rem 0 .5rem; }
  .hw-report-table tbody th, .hw-report-table td { border: 0; padding: .15rem .7rem; text-align: left; min-width: 0; }
  .hw-report-table td::before { content: attr(data-label) ": "; font-weight: 700; }
}
.paste-flag { margin-top: 0; margin-bottom: 1rem; }
.paste-flag p { margin: 0; }
/* An assignment's flagged task: Clear code under the message. */
.paste-flag .paste-clear { margin-top: .5rem; }

/* ---------- Paste flags on the Students page (teacher view) ---------- */
/* A small red flag next to the level (with "3 flags" when there are several); it opens the details dialog. */
.paste-flag-btn {
  display: inline-flex; align-items: center; gap: .2rem; vertical-align: middle; cursor: pointer;
  color: var(--fail); background: var(--card); border: 1px solid var(--fail); border-radius: 999px;
  padding: .05rem .35rem; margin: 0; font: inherit; font-size: .78rem; font-weight: 700; line-height: 1.3; min-height: 0; min-width: 0;
}
.paste-flag-btn:hover { background: var(--fail-bg); }
.paste-flag-btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.paste-flag-icon { display: block; flex: none; }
.paste-flag-key { color: var(--fail); display: inline-block; vertical-align: middle; }
/* The details dialog: wider than the other dialogs on a big screen, the screen's width on a phone. */
.modal.modal-wide { max-width: 44rem; }
.paste-flag-list { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .9rem; }
.paste-flag-item { border-top: 1px solid var(--border); padding-top: .75rem; min-width: 0; }
.paste-flag-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .8rem; margin: 0; }
.paste-flag-facts dt { font-weight: 700; }
.paste-flag-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.modal p.paste-next { margin-top: .5rem; font-weight: 700; }
/* The code of the next check: monospace, long lines wrap inside the dialog (never a sideways scroll of the page);
   a long program scrolls up and down inside its own box. */
.paste-code {
  margin: .4rem 0 0; padding: .5rem .7rem; box-sizing: border-box; max-width: 100%; max-height: 16rem; overflow: auto;
  background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace; font-size: .85rem; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.paste-code:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- "Needs review" on the Misconceptions page (review-rules.js) ---------- */
.review-item { border: 2px solid var(--border); border-radius: 8px; background: var(--card); padding: .5rem .9rem .75rem; margin: 0 0 .75rem; min-width: 0; }
.review-item h4 { margin: .25rem 0 .4rem; }
.review-item h4 .flag { vertical-align: middle; }
.review-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .8rem; margin: 0 0 .4rem; }
.review-facts dt { font-weight: 700; }
.review-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
/* The student's code, as the attempt stored it: monospace, long lines wrap (no sideways scroll on a phone), a long
   program scrolls inside its own box. */
.review-code {
  margin: .25rem 0 0; padding: .5rem .7rem; box-sizing: border-box; max-width: 100%; max-height: 18rem; overflow: auto;
  background: var(--code-bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace; font-size: .9rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
}
.review-code:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Task browser (teacher view) ---------- */
.tb-results { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.tb-task { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: .5rem; }
.tb-task h4 { margin: 1.1rem 0 .4rem; }
.tb-lines, .tb-options { padding-left: 1.4rem; }
.tb-tests pre { margin: 0; white-space: pre-wrap; }

/* ---------- Logos: the light artwork, or the dark artwork in the Dark and High contrast themes ---------- */
.logo-for-dark { display: none; }
:root[data-theme="dark"] .logo-for-light, :root[data-theme="contrast"] .logo-for-light { display: none; }
:root[data-theme="dark"] .logo-for-dark, :root[data-theme="contrast"] .logo-for-dark { display: inline-block; }
.brand { margin: 0; line-height: 0; }
.brand-link { display: inline-block; }
.brand img { height: 2.75rem; width: auto; max-width: 100%; }
@media (max-width: 480px) { .brand img { height: 2.25rem; } }

/* ---------- Home page (index.html): logo in the middle, students left, teachers right ---------- */
.landing-tools { display: flex; justify-content: flex-end; padding: .75rem 16px; }
.landing {
  box-sizing: border-box; max-width: 1100px; margin: 0 auto; padding: 1rem 16px 2.5rem;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-areas: "students logo teachers"; align-items: center; gap: 2rem;
}
.landing:focus { outline: none; }
.landing-logo { grid-area: logo; margin: 0; text-align: center; }
.landing-logo-h { margin: 0; line-height: 0; }
.landing-logo img { max-width: 100%; width: auto; height: auto; max-height: 60vh; }
.landing-tagline { margin: 1rem auto 0; max-width: 28rem; font-size: 1.15rem; line-height: 1.45; }
.landing-students { grid-area: students; }
.landing-teachers { grid-area: teachers; }
.landing-buttons { display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.landing-label { font-size: 1.1rem; margin: 0; color: var(--muted); }
.landing-button {
  display: block; box-sizing: border-box; text-align: center; font-weight: 700; font-size: 1.15rem; text-decoration: none;
  padding: .9rem 1.25rem; border-radius: 10px; border: 2px solid var(--primary);
  background: var(--primary); color: var(--primary-text);
}
.landing-teachers .landing-button { background: var(--card); color: var(--link); }
.landing-button:hover { text-decoration: underline; }
/* Narrow screens: logo, then the student buttons, then the teacher buttons. */
@media (max-width: 760px) {
  .landing { grid-template-columns: minmax(0, 1fr); grid-template-areas: "logo" "students" "teachers"; gap: 1.5rem; }
  .landing-logo img { max-height: 40vh; }
}

/* ---------- Unit menu groups (app.html): each heading opens and closes its group ---------- */
.unit-groups { display: grid; gap: 1rem; }
.unit-group { border: 2px solid var(--border); border-radius: 12px; background: var(--card); padding: .25rem 1rem .5rem; }
.unit-group .unit-list { margin: .25rem 0 .75rem; }
.group-heading { margin: 0; font-size: 1.25rem; }
.group-toggle {
  width: 100%; display: flex; align-items: center; gap: .6rem; padding: .6rem 0; margin: 0;
  background: none; border: none; color: var(--text); font: inherit; font-weight: 700; text-align: left; cursor: pointer;
}
.group-arrow::before { content: "▾"; display: inline-block; transition: transform .15s; }
.group-toggle[aria-expanded="false"] .group-arrow::before { transform: rotate(-90deg); }
.group-count { margin-left: auto; font-size: .9rem; font-weight: 400; color: var(--muted); }
.unit-subsection { margin-top: .5rem; }
.subsection-heading { margin: .5rem 0 0; font-size: 1.1rem; color: var(--text); }
@media (prefers-reduced-motion: reduce) { .group-arrow::before { transition: none; } }
/* Teacher view sections (collapse.js): the same heading button, at the size of the teacher view's other headings. */
.teacher-section { margin-top: 1.25rem; }
.teacher-section > .group-heading { font-size: 1.17rem; }
.teacher-section > .group-heading .group-toggle { padding: .4rem 0; }

/* ---------- Exam Mode (exam.html, prompt EM1) ----------
   Its own look (decision 16): the --exam accent in the header, the pack cards and the question paper. (EM1b removed
   the tile on the student's main page: the menu item stays.)
   Every colour is a theme token (contrast checked in tests/validate.js). */
.exam-header { border-bottom: 4px solid var(--exam); }
.exam-title { display: inline-block; background: var(--exam); color: var(--on-exam); padding: .15rem .6rem; border-radius: 6px; margin-right: .4rem; }
.exam-home { font-size: 1rem; font-weight: 600; }
.exam-nav { display: flex; flex-wrap: wrap; gap: .5rem; padding-bottom: .6rem; }
.exam-nav a { padding: .3rem .7rem; border: 2px solid var(--exam-ink); border-radius: 999px; color: var(--exam-ink); text-decoration: none; font-weight: 600; }
.exam-nav a[aria-current="page"] { background: var(--exam); border-color: var(--exam); color: var(--on-exam); }
.exam-main { padding-block: 1.25rem; }
.exam-card { border-top: 8px solid var(--exam); }
.exam-paper { border: 2px solid var(--border); border-left: 6px solid var(--exam); border-radius: 8px; padding: .75rem 1rem; margin: .75rem 0; background: var(--card); }
.exam-paper p { margin: .35rem 0; }
.exam-stem { font-weight: 600; }
.exam-bullets { margin: .35rem 0; }
.exam-rider { font-style: italic; }
.exam-marks { text-align: right; font-weight: 700; }
.exam-format { margin-top: 0; }
.say-simply { margin: .5rem 0; }
.say-text { border-left: 4px solid var(--exam-ink); padding: .4rem .75rem; background: var(--code-bg); border-radius: 0 6px 6px 0; }
.lang-toggle { margin: .5rem 0; }
.em-q { border: 2px solid var(--border); border-radius: 8px; margin: 1rem 0; padding: .5rem 1rem .75rem; }
.em-q legend { font-weight: 700; padding: 0 .3rem; }
.em-check { display: block; padding: .3rem 0; }
/* Rung 1 (EM1b): code options, and two answers side by side (one above the other on a phone) */
.em-code-option { display: flex; gap: .5rem; align-items: baseline; }
.em-code-option code { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.em-answers { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; margin: .5rem 0; }
.em-answers figure { margin: 0; min-width: 0; }
.em-answers figcaption { font-weight: 700; }
.em-answers pre { margin: .25rem 0 0; }
@media (max-width: 600px) { .em-answers { grid-template-columns: minmax(0, 1fr); } }
.em-q .em-q { margin: .5rem 0; }
.em-why { margin: .2rem 0 0 1.5em; }
.em-part { margin-top: 1.5rem; }
/* The landing page's pack cards and the tutorial (EM1b) */
.em-packs { list-style: none; padding: 0; }
.em-pack-card { border: 2px solid var(--border); border-left: 6px solid var(--exam); border-radius: 10px; padding: .6rem 1rem; margin: .75rem 0; background: var(--card); }
.em-pack-card h4 { margin: .2rem 0 .3rem; font-size: 1.1rem; }
.em-pack-card p { margin: .3rem 0; }
.em-continue { display: inline-block; background: var(--exam); color: var(--on-exam); border: 2px solid var(--exam); border-radius: 8px; padding: .35rem .9rem; font-weight: 700; text-decoration: none; margin-right: .75rem; }
.em-continue:hover { text-decoration: underline; }
.em-count { color: var(--muted); margin: 0; }
.em-example { border-left: 4px solid var(--exam-ink); padding: .3rem .75rem; background: var(--code-bg); border-radius: 0 6px 6px 0; }
.em-example p { margin: .3rem 0; }
.em-points { list-style: none; padding: 0; }
.em-points > li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.em-mark { display: inline-block; width: 1.5em; font-weight: 700; }
.em-yes { color: var(--pass); }
.em-no { color: var(--fail); }
.em-unsure { color: var(--exam-ink); }
.em-right { font-weight: 700; color: var(--pass); }
.em-feedback { margin: .3rem 0 0 1.5em; }
.em-note { border: 2px solid var(--exam-ink); border-radius: 8px; padding: .5rem .75rem; }
.em-self { margin: .4rem 0 0 1.5em; border-left: 4px solid var(--exam-ink); padding-left: .75rem; }
.em-after { margin-top: 1rem; }
.em-blocks { padding-left: 0; list-style: none; }
.em-block { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: .1rem .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.em-block-id { grid-row: span 3; font-weight: 700; color: var(--exam-ink); }
.em-block-name, .em-block-status { grid-column: 2; }
.em-rungs > li { margin: .6rem 0; }
.em-steps { padding-left: 1.4rem; }
.em-step { padding: .2rem .4rem; border-radius: 6px; }
.em-step-now { border: 2px solid var(--exam-ink); font-weight: 600; }
.em-scores { border-collapse: collapse; width: 100%; }
.em-scores th, .em-scores td { border: 1px solid var(--border); padding: .35rem .6rem; text-align: left; }
