:root {
  --bg: #f6f7f5; --surface: #fff; --surface-2: #eef2f0; --text: #17211d; --muted: #5b6862; --border: #dde3e0;
  --accent: #0f766e; --accent-text: #fff; --accent-soft: #d5efeb; --radius: 16px; color-scheme: light;
  --good: #15803d; --good-soft: #dcfce7; --grid: #e7ebe9; --axis: #8a958f; --c1: #0f766e; --c2: #c2410c; --c3: #6d28d9; --c4: #0369a1;
}
@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; color-scheme: dark;
    --good: #4ade80; --good-soft: #10331f; --grid: #24302b; --axis: #74817b; --c1: #2dd4bf; --c2: #fb923c; --c3: #a78bfa; --c4: #38bdf8;
  }
}
: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; color-scheme: dark;
  --good: #4ade80; --good-soft: #10331f; --grid: #24302b; --axis: #74817b; --c1: #2dd4bf; --c2: #fb923c; --c3: #a78bfa; --c4: #38bdf8;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
header.top { border-bottom: 1px solid var(--border); background: var(--surface); }
header.top .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
header.top nav { margin-left: auto; display: flex; gap: 16px; font-size: .95rem; }
header.top nav a { text-decoration: none; font-weight: 600; }
.btn { display: inline-block; padding: 12px 20px; border-radius: 12px; font-weight: 700; text-decoration: none;
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.muted { color: var(--muted); }
.hero { padding: 56px 0 40px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.1; margin: 0 0 16px; letter-spacing: -.02em; max-width: 16ch; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 46ch; margin: 0 0 24px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.facts { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 32px; }
.facts b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.facts span { color: var(--muted); font-size: .9rem; }
section.block { padding: 36px 0; border-top: 1px solid var(--border); }
section.block h2 { font-size: 1.4rem; margin: 0 0 6px; }
.steps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 18px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.step b { display: block; margin-bottom: 4px; }
.step .n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 99px;
  background: var(--accent-soft); color: var(--text); font-weight: 800; font-size: .85rem; margin-bottom: 10px; }
.teacher { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: center; }
.teacher ul { margin: 12px 0 20px; padding-left: 20px; } .teacher li { margin: 6px 0; }
.page { padding-top: 32px; padding-bottom: 64px; }
.page h1 { font-size: 1.8rem; margin: 0 0 6px; }
.subject h2 { font-size: 1.15rem; margin: 28px 0 12px; }
.papers { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 8px; }
.paper.soon { background: var(--surface-2); }
.paper h3 { margin: 0; font-size: 1.2rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: .75rem; font-weight: 700; border-radius: 99px; padding: 2px 10px; background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.paper .stat { font-size: .9rem; color: var(--muted); }
.paper .btn { margin-top: auto; text-align: center; }
footer { border-top: 1px solid var(--border); padding: 24px 0 40px; font-size: .85rem; color: var(--muted); }

/* ---- hero with sample question ---- */
.hero { display: grid; gap: 40px; align-items: center; }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.sample { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 20px;
  box-shadow: 0 12px 32px -16px rgba(15, 40, 35, .25); }
.sample-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: .8rem; }
.eyebrow { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.sample-head .src { color: var(--muted); }
.sample-head .marks { margin-left: auto; background: var(--accent-soft); border-radius: 99px; padding: 2px 10px; font-weight: 700; }
.sample .qtext { font-size: 1.05rem; margin: 6px 0 4px; }
.sample .hint { font-size: .85rem; color: var(--muted); margin: 0 0 12px; }
.memo summary { display: inline-block; cursor: pointer; list-style: none; font-weight: 700; padding: 10px 16px;
  border-radius: 12px; background: var(--accent); color: var(--accent-text); }
.memo summary::-webkit-details-marker { display: none; }
.memo[open] summary { background: var(--surface-2); color: var(--text); }
.memo .ans { background: var(--good-soft); border-radius: 10px; padding: 8px 12px; margin: 12px 0 8px; }
.memo .ans-label { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--good); }
.memo .ans-math { overflow-x: auto; overflow-y: hidden; }  /* long formulas scroll instead of breaking the card */
.tick-prompt { font-size: .85rem; color: var(--muted); margin: 4px 0 6px; }
.ticks { list-style: none; margin: 0; padding: 0; font-size: .92rem; display: grid; gap: 6px; }
.ticks label { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; }
.ticks input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.ticks .tick-text { flex: 1; }
.ticks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.selfscore { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; font-weight: 600; }
.selfscore b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.selfscore.full b { color: var(--good); }
.ticks .tick-marks { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.sample-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .92rem; }
.sample-foot a { font-weight: 700; text-decoration: none; }
.another { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.another:hover { color: var(--text); }
svg.graph { width: 100%; height: auto; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin: 4px 0 10px; }
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; }
.sample svg.graph { max-height: 220px; }

/* ---- printed test preview (always paper-coloured, like the real thing) ---- */
.preview { position: relative; margin: 0; padding: 8px 40px 48px 8px; }
.sheet { background: #fff; color: #111; font: 11px/1.45 "Times New Roman", Times, serif; padding: 22px 24px;
  border-radius: 4px; box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .45); transform: rotate(-1.5deg); max-width: 430px; }
.sheet-school { text-align: center; text-transform: uppercase; letter-spacing: .08em; font-size: 9px; }
.sheet-title { text-align: center; font-weight: bold; font-size: 14px; margin: 2px 0 8px; padding-bottom: 6px; border-bottom: 1.5px solid #111; }
.sheet-facts, .sheet-name { display: flex; justify-content: space-between; gap: 16px; font-weight: bold; }
.sheet-name { font-weight: normal; margin: 8px 0 10px; } .sheet-name span { flex: 1; border-bottom: 1px solid #111; padding-top: 8px; }
.sheet-q { font-weight: bold; margin: 6px 0 4px; }
.sheet svg.graph { background: #fff; border-color: #bbb; max-height: 130px; margin: 2px 0 6px; }
.sheet svg.graph .grid { stroke: #ececec; } .sheet svg.graph .axis { stroke: #111; }
.sheet svg.graph .curve { stroke: #111; stroke-width: 2.2; } .sheet svg.graph .c2 { stroke-dasharray: 9 5; }
.sheet svg.graph .lbl { fill: #111; }
.sheet-item { display: grid; grid-template-columns: 24px 1fr auto; gap: 6px; margin: 4px 0; }
.sheet-total { text-align: right; font-weight: bold; }
.sheet .katex { font-size: 1em; }
.slip { position: absolute; right: 0; bottom: 0; width: min(62%, 290px); background: #f3faf7; color: #111;
  border: 1px solid #cfe5dc; border-left: 4px solid #0f766e; border-radius: 6px; padding: 12px 14px;
  font: 11px/1.45 "Times New Roman", Times, serif; box-shadow: 0 16px 34px -16px rgba(0, 0, 0, .45); transform: rotate(2deg); }
.slip-title { font: 800 10px/1 system-ui, sans-serif; letter-spacing: .1em; color: #0f766e; margin-bottom: 6px; }
.slip-item { margin-bottom: 6px; } .slip ul { list-style: none; margin: 2px 0 0; padding: 0; }
.slip .katex { font-size: 1em; }
@media (max-width: 520px) { .preview { padding-right: 16px; } .slip { position: relative; width: auto; margin-top: -24px; margin-left: 24px; } }
@media (max-width: 480px) { .facts { gap: 18px; } .facts b { font-size: 1.3rem; } .facts span { font-size: .8rem; } }
.memo .when-open, .memo[open] .when-closed { display: none; }
.memo[open] .when-open { display: inline; }

/* ---- 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; }
.sheet .resource { margin: 2px 0 6px; } .sheet .resource img { max-height: 130px; border: 1px solid #bbb; padding: 0; border-radius: 0; }

/* 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); }
header.top nav a { white-space: nowrap; }
header.top .brand { white-space: nowrap; }
@media (max-width: 480px) {
  header.top .wrap { flex-wrap: wrap; row-gap: 0; padding-top: 6px; padding-bottom: 6px; }
  header.top nav { gap: 12px; align-items: center; } header.top .theme-name { display: none; }
  /* toggle sits top-right beside the brand; links get their own full row */
  header.top .theme-toggle { order: 1; margin-left: auto; }
  header.top nav { order: 2; width: 100%; margin-left: 0; }
}
/* learner code login */
.code-card { max-width: 440px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.code-card h1 { margin-top: 0; }
.code-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 20px 0; }
.code-form label { font-weight: 600; }
.code-form input { width: 100%; min-width: 0; font: 600 1.4rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
@media (max-width: 480px) { .code-card { padding: 20px 16px; } .code-form input { letter-spacing: .08em; } }
.code-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button.btn { cursor: pointer; font: inherit; font-weight: 700; line-height: inherit; }
.actions form { margin: 0; display: flex; }
.code-error { margin: 0; color: #b91c1c; font-weight: 600; }
:root[data-theme="dark"] .code-error { color: #f87171; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .code-error { color: #f87171; } }
.small { font-size: .85rem; }
header.top nav form { display: inline; margin: 0; }
header.top nav .linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
header.top nav .linkbtn:hover { text-decoration: underline; }
header.top nav .linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- what comes up most ---- */
.small { font-size: .85rem; }
.most-asked .lead { max-width: 62ch; }
.most-asked .band { margin-top: 28px; }
.most-asked .band h2 { font-size: 1.2rem; margin: 0; display: flex; gap: 10px; align-items: baseline; }
.most-asked .band > p { margin: 2px 0 10px; }
.freq { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.freq li { display: grid; grid-template-columns: minmax(0, 1fr) 160px 170px; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.freq-name, .freq-num { display: flex; flex-direction: column; min-width: 0; }
.freq-num { font-variant-numeric: tabular-nums; }
.freq-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.freq-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.paper .more { font-size: .9rem; }
@media (max-width: 640px) {
  .freq li { grid-template-columns: 1fr auto; }
  .freq-bar { grid-column: 1 / -1; grid-row: 2; }
}
