:root {
  --bg: #f6f7f5; --surface: #fff; --surface-2: #eef2f0; --text: #17211d; --muted: #5b6862;
  --border: #dde3e0; --accent: #0f766e; --accent-text: #fff; --accent-soft: #d5efeb;
  --danger: #b42318; --danger-soft: #fee4e2; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --h-low: #fecaca; --h-mid: #fde68a; --h-ok: #bbf7d0; --h-high: #86efac; --h-none: transparent;
  --grid: #e7ebe9; --axis: #8a958f; --c1: #0f766e; --c2: #c2410c; --c3: #6d28d9; --c4: #0369a1;
  --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --surface: #18201d; --surface-2: #1f2925; --text: #e6ece9; --muted: #9aa8a1;
    --border: #2b3732; --accent: #2dd4bf; --accent-text: #062a26; --accent-soft: #123b36;
    --danger: #f97066; --danger-soft: #3b1512; --ok-soft: #10331f; --warn: #fbbf24; --warn-soft: #3a2c0b;
    --h-low: #5c1d1d; --h-mid: #5a4510; --h-ok: #14432a; --h-high: #1d6b3d;
    --grid: #24302b; --axis: #74817b; --c1: #2dd4bf; --c2: #fb923c; --c3: #a78bfa; --c4: #38bdf8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1412; --surface: #18201d; --surface-2: #1f2925; --text: #e6ece9; --muted: #9aa8a1;
  --border: #2b3732; --accent: #2dd4bf; --accent-text: #062a26; --accent-soft: #123b36;
  --danger: #f97066; --danger-soft: #3b1512; --ok-soft: #10331f; --warn: #fbbf24; --warn-soft: #3a2c0b;
  --h-low: #5c1d1d; --h-mid: #5a4510; --h-ok: #14432a; --h-high: #1d6b3d;
  --grid: #24302b; --axis: #74817b; --c1: #2dd4bf; --c2: #fb923c; --c3: #a78bfa; --c4: #38bdf8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
header.site { background: var(--surface); border-bottom: 1px solid var(--border); }
header.site .inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 16px; align-items: center; }
header.site .brand { font-weight: 700; text-decoration: none; color: var(--text); }
header.site nav { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: .92rem; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 64px; }
h1 { font-size: 1.45rem; margin: 0 0 4px; } h2 { font-size: 1.1rem; margin: 28px 0 10px; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.btn, button.btn { display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
form p { margin: 0 0 12px; } label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.helptext, .helptext ul { font-size: .8rem; color: var(--muted); }
.errorlist { color: var(--danger); font-size: .85rem; padding-left: 18px; margin: 4px 0; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 10px; background: var(--ok-soft); margin-bottom: 6px; }
.messages li.error { background: var(--danger-soft); }
.narrow { max-width: 460px; margin: 24px auto; }
.chip { display: inline-block; font-size: .75rem; background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 1px 9px; }
.chip.marks { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.empty { color: var(--muted); padding: 12px 0; }

/* builder */
.builder { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .builder { grid-template-columns: 1fr; } }
.filters { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.cand { border-top: 1px solid var(--border); padding: 12px 0; }
.cand .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.cand .text { margin-bottom: 8px; }
.sel-q { border-top: 1px solid var(--border); padding: 10px 0; }
.sel-item { display: grid; grid-template-columns: 3.2rem 1fr auto; gap: 8px; align-items: start; padding: 6px 0; }
.sel-item .num { font-weight: 700; } .sel-item .tools { display: flex; gap: 4px; }
.sticky { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
details summary { cursor: pointer; font-weight: 600; } details { margin-top: 12px; }
.checks ul { list-style: none; padding: 0; margin: 0 0 8px; } .checks label { font-weight: 400; display: flex; gap: 8px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

/* graphs */
svg.graph { width: 100%; max-width: 420px; height: auto; display: block; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); margin: 6px 0; }
svg.graph .grid { stroke: var(--grid); stroke-width: 1; } svg.graph .axis { stroke: var(--axis); stroke-width: 1.5; }
svg.graph .curve { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
svg.graph .c1 { stroke: var(--c1); } svg.graph .c2 { stroke: var(--c2); } svg.graph .c3 { stroke: var(--c3); } svg.graph .c4 { stroke: var(--c4); }
svg.graph .lbl { fill: var(--muted); font-size: 15px; font-style: italic; }

/* marks grid & insights */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.grid { border-collapse: collapse; font-size: .9rem; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: center; white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.grid thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
table.grid input { width: 3.4rem; text-align: center; padding: 5px 4px; }
table.grid input.err { border-color: var(--danger); background: var(--danger-soft); }
.h-low { background: var(--h-low); } .h-mid { background: var(--h-mid); } .h-ok { background: var(--h-ok); } .h-high { background: var(--h-high); }
.legend { display: flex; gap: 12px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; margin: 8px 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.bigstat { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.topicrow { display: grid; grid-template-columns: minmax(0, 1fr) 3.5rem; gap: 4px 12px; align-items: center; padding: 6px 0; }
.topicrow .bar { grid-column: 1 / -1; }
header.site .tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  background: var(--accent-soft); color: var(--text); border-radius: 99px; padding: 2px 9px; margin-left: -8px; }

/* ---- cropped resources (diagrams, tables, passages) and multiple-choice options ---- */
.resource { margin: 8px 0 12px; }
.resource img { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 8px; padding: 4px; border: 1px solid var(--border); }
.resource-data_sheet img { max-height: 60vh; object-fit: contain; }
.options { list-style: none; margin: 10px 0 4px; padding: 0; display: grid; gap: 6px; }
.options li { display: flex; gap: 10px; align-items: flex-start; }
.options img { max-width: min(100%, 260px); background: #fff; border-radius: 6px; padding: 2px; border: 1px solid var(--border); }
.opt-letter { font-weight: 700; min-width: 1.4em; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 700; font-size: .9rem; padding: 0 4px; }
.newtest .checks ul, .newtest .checks div > div { list-style: none; padding: 0; margin: 0 0 8px; }
.newtest .checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; }

/* ---- test page header: build -> print -> mark ---- */
.testbar { margin-bottom: 20px; }
.testbar h1 { margin: 0; }
.testbar p { margin: 2px 0 0; }
.stages { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, .8fr) minmax(0, 1fr) minmax(0, 1.5fr); }
.stage { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.stage b { display: block; margin-bottom: 4px; }
.stage-n { flex: none; width: 1.7rem; height: 1.7rem; border-radius: 99px; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; background: var(--accent); color: var(--accent-text); }
.stage.done .stage-n { background: var(--accent-soft); color: var(--text); }
.stage.off { opacity: .6; } .stage.off .stage-n { background: var(--border); color: var(--muted); }
.stage-mark:not(.off) { background: var(--accent-soft); border-color: var(--accent); }
.stage > div { min-width: 0; flex: 1; }
.row.tight { gap: 6px; }
.row.tight select, .row.tight input[type=date] { width: auto; padding: 4px 8px; font-size: .85rem; }
.stage .hint { margin: 0 0 6px; font-weight: 600; }
.sittings { list-style: none; padding: 0; margin: 8px 0 0; font-size: .9rem; }
.sittings li { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; padding: 3px 0; }
.edit-details { margin: 0; position: relative; }
.edit-details summary { font-weight: 600; font-size: .9rem; color: var(--accent); list-style: none; }
.edit-details summary::-webkit-details-marker { display: none; }
.edit-details[open] > form { position: absolute; right: 0; top: 1.8rem; z-index: 5; width: min(420px, calc(100vw - 32px));
  box-shadow: 0 8px 24px rgb(0 0 0 / .15); }
.quiet { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted);
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.quiet form { display: inline; } .quiet .linkbtn { color: var(--danger); font-size: .85rem; }
@media (max-width: 860px) {
  .stages { grid-template-columns: 1fr; }
  .testbar.has-items .stage-mark { order: -1; }    /* once there's a test, marking is the step teachers return for */
}
.test-classes { display: block; font-size: .82rem; }
.datasheet { margin: 0 0 10px; } .datasheet summary { font-weight: 600; color: var(--accent); font-size: .9rem; }
@media (max-width: 600px) {
  header.site .inner { flex-wrap: wrap; gap: 6px 12px; }
  header.site nav { gap: 12px; } header.site nav > .muted { display: none; }   /* the name: no room on a phone */
}

/* ---- progress by topic ---- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 6px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: .92rem; }
.tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); }
table.progress { width: 100%; }
table.progress thead th { white-space: normal; min-width: 6.5rem; vertical-align: bottom; }
table.progress thead th a { color: var(--text); }
table.progress tr.classrow td { border-top: 2px solid var(--border); }
.thin { opacity: .55; font-style: italic; }
.legend i.thin-key { background: var(--surface-2); border: 1px dashed var(--muted); }
.trend { font-style: normal; font-weight: 700; margin-left: 2px; }
.trend.up { color: #15803d; } .trend.down { color: var(--danger); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .trend.up { color: #4ade80; } }
:root[data-theme="dark"] .trend.up { color: #4ade80; }
.checks li label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.subject-h { font-size: 1.25rem; margin: 28px 0 10px; padding-bottom: 4px; border-bottom: 2px solid var(--accent); }

/* builder: a part whose earlier parts (it uses their answers) aren't in the test */
.needs { display: block; margin-top: 4px; padding: 4px 8px; border-radius: 8px; background: var(--h-mid); color: var(--text); }
.needs .linkbtn { color: var(--text); font-weight: 600; }
.messages li.warning { background: var(--h-mid); }

/* colour theme toggle (theme.js) */
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
  color: var(--muted); font: inherit; font-size: .82rem; cursor: pointer; white-space: nowrap; }
.theme-toggle:hover { color: var(--text); }

/* learner page: "Where marks were lost", one collapsible card per topic */
.lost-topic { margin-top: 10px; }
.lost-topic > summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-weight: 400; }
.lost-topic > summary .lost-name { font-weight: 600; }
.lost-topic .list { margin-top: 8px; }
.lost-topic .more { margin-top: 4px; } .lost-topic .more > summary { font-size: .88rem; color: var(--accent); }
.lost-score { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.lost-topic > summary { list-style: none; } .lost-topic > summary::-webkit-details-marker { display: none; }
.lost-topic > summary .lost-name::before { content: "▸ "; color: var(--accent); }
.lost-topic[open] > summary .lost-name::before { content: "▾ "; }
/* learner login codes */
.login-code { font: 600 .85rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.codes-box { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.codes-box p { margin: 0 0 10px; }

/* Dashboard: needs-your-attention list and class cards with a trend line */
.attention { margin-top: 16px; } .attention h2 { margin: 0 0 8px; }
.attention .list li { border-top: 0; }
.att { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 14px !important; border-radius: 10px; margin-top: 8px; }
.att svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.att-text { flex: 1 1 300px; min-width: 0; } .att form { margin: 0; }
.att-capture { background: var(--warn-soft); } .att-capture svg { color: var(--warn); }
.att-drop { background: var(--danger-soft); } .att-drop svg { color: var(--danger); }
.att-weak { background: var(--surface-2); } .att-weak svg { color: var(--accent); }
.att-bar { width: 110px; background: var(--h-mid); } .att-bar i { background: var(--warn); }
.class-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.class-card { display: flex; flex-direction: column; gap: 10px; }
.class-line { display: flex; align-items: center; gap: 14px; }
.class-pct { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.class-line .trend { margin: 0; }
.spark { flex: none; width: 150px; height: 40px; margin-left: auto; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--accent); }
.spark .ref { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; vector-effect: non-scaling-stroke; }
.spark-empty { flex: 1 1 auto; min-height: 40px; display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1px dashed var(--border); border-radius: 8px; padding: 0 8px; }
