*{box-sizing:border-box}
:root{ --ink:#1A1917; --muted:#6B6862; --line:#D6CFBF; --line-soft:#E7E1D6; --paper:#FFFFFF; --bg:#F6F3EC; --ash:#EFEBE2; --zebra:#F6F3EC; --red:#C8321F; --red-dark:#A82A19; --blue:#1D4ED8; --blue-dark:#1E40AF; --green:#047857; --sec-formula:#B91C1C; --sec-words:#0E7490; --sec-worked:#047857; --sec-mistake:#9A3412; --sec-table:#1D4ED8; --sec-exam:#3730A3; --sec-formula-bg:#FBF6F6; --sec-words-bg:#F4FAFB; --sec-worked-bg:#F5FAF6; --sec-mistake-bg:#FBF7F4; --tag-info-ink:#0E7490; --tag-info-bg:#CFFAFE; --tag-ref-ink:#3730A3; --tag-ref-bg:#E0E7FF; --tag-warn-ink:#92400E; --tag-warn-bg:#FEF3C7; --tag-warn-line:#FCD34D; --tag-note-bg:#EFF6FF; }
html,body{margin:0}
body{font-family:'Segoe UI',Arial,sans-serif;color:var(--ink);background:var(--ash)}
/* ---- control bar (never printed) ---- */
.bar{background:#fff;border-bottom:1px solid var(--line);padding:12px 18px;position:sticky;top:0;z-index:20}
.bar h1{font-size:18px;margin:0 0 3px}.bar h1 span{color:var(--red)}
.bar .sub{font-size:12.5px;color:var(--muted);margin:0 0 10px}
.fgroup{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:7px}
.flab{font-size:12px;font-weight:700;color:var(--muted);min-width:88px}
.pill{border:1.5px solid var(--blue);color:var(--blue);background:#fff;border-radius:20px;
      padding:5px 13px;font-size:13px;font-weight:600;cursor:pointer;user-select:none}
.pill.on{background:var(--blue);color:#fff}
.pill.none{opacity:.4;cursor:not-allowed;border-style:dashed}
.actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:4px}
.btn{font-family:inherit;font-weight:700;font-size:14px;border:none;border-radius:9px;padding:9px 18px;cursor:pointer}
.btn.gen{background:var(--red);color:#fff}
.btn.re{background:#fff;color:var(--ink);border:1.5px solid var(--line)}
.btn.print{background:var(--red);color:#fff}.btn:disabled{opacity:.45;cursor:default}
.ord{font-size:13px;color:var(--muted)}
.ord select{font-family:inherit;font-size:13px;padding:5px 6px;border:1.5px solid var(--line);border-radius:7px}
.avail{font-size:12.5px;color:var(--muted);margin-top:7px}
.avail b{color:var(--ink)}
.avail.warn{color:var(--tag-warn-ink);background:var(--tag-warn-bg);border:1px solid var(--tag-warn-line);border-radius:7px;padding:5px 9px;display:inline-block}
.avail.bad{color:#991b1b;background:#fee2e2;border:1px solid #fecaca;border-radius:7px;padding:5px 9px;display:inline-block}
/* ---- the sheet (printed) ---- */
.stage{padding:22px;display:flex;justify-content:center}
.sheet{background:#fff;width:210mm;min-height:297mm;padding:10mm;box-shadow:0 6px 26px rgba(0,0,0,.14);position:relative}
.sh-hd{display:flex;align-items:baseline;justify-content:space-between;border-bottom:2px solid var(--ink);padding-bottom:5px;margin-bottom:8px}
.sh-hd h2{font-size:19px;margin:0;font-weight:800}.sh-hd .meta{font-size:12px;color:var(--muted)}
.instr{font-size:12.5px;color:var(--muted);margin:0 0 10px}
/* STANDING RULE: an equation must never split across two lines on a printed resource. */
.katex{white-space:nowrap}
.q{break-inside:avoid;page-break-inside:avoid;margin-bottom:11px}
.qh{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;margin-bottom:4px}
.qn{background:var(--ink);color:#fff;border-radius:5px;padding:1px 8px;font-weight:700;font-size:12.5px}
.src{font-weight:700;font-size:11.5px;color:var(--blue)}
.qmeta{font-size:10.5px;color:var(--muted)}
.syn{background:var(--tag-ref-bg);color:var(--tag-ref-ink);border-radius:4px;padding:0 5px;font-size:9.5px;font-weight:700}
.qb{font-size:13.5px;line-height:1.4}
.qb .stem{margin:3px 0}
/* STANDING RULE: figures sit BELOW full-width text, never in a thin column beside a float. */
/* A DIAGRAM SIZING RULE MUST NOT REACH THE MATHS — see build_pastpaper_pack.js. display:block
   matters here too: applied to KaTeX's inline radical <svg> it also breaks the symbol's baseline. */
.qb svg:not(.katex *){max-width:100%;height:auto;display:block;margin:5px 0}
.qb .katex svg{max-width:none;height:revert-layer;display:inline;margin:0}
/* DIRECT CHILD ONLY. A descendant selector also matches the span.katex KaTeX injects for every
   $...$ fragment, which turns each fragment into its own block and stacks an MCQ one word per
   line. Every automated check passes that; only the render shows it. */
.qb .opts > span{display:block;margin:2px 0 2px 14px}
/* Answer-line + working-space markup comes from renderQBody (build_remix_paper.js is what it is
   written against), so style THEIRS rather than adding a second set: marks land in the right
   margin at the end of the answer space, and the tool inherits future renderer improvements. */
.aline{display:flex;align-items:flex-end;gap:5px}
.aslot{flex:1 1 auto;min-width:0}
.asuf{font-size:13.5px;white-space:nowrap}
.dots{flex:1 1 auto;min-width:80px;border-bottom:1.5px dotted #333;height:14px}
.mk{flex:0 0 auto;min-width:34px;text-align:right;white-space:nowrap;font-weight:bold}
.pend{display:flex;align-items:flex-end;gap:8px;margin-top:6px}
/* Working space stays PROPORTIONAL TO MARKS while the sheet grows to fill the page count: the fill
   loop scales the unit, never a flat pad, so a 5-mark question keeps more room than a 1-mark one. */
.ws{min-height:calc(var(--wsh,3) * var(--wsu,20px))}
.empty{color:var(--muted);text-align:center;padding:80px 0;font-size:15px}
/* teacher answer key on its own printed page(s) */
.keypage{break-before:page;page-break-before:always;padding-top:2mm}
.kh{font-size:16px;font-weight:800;border-bottom:2px solid var(--ink);padding-bottom:4px;margin-bottom:8px}
.ms{break-inside:avoid;page-break-inside:avoid;margin-bottom:9px;border:1px solid var(--line-soft);border-radius:8px;padding:8px 10px}
.msh{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;margin-bottom:5px}
.msh .kn{background:var(--blue);color:#fff;border-radius:5px;padding:1px 7px;font-weight:700;font-size:12px}
.sch{border-collapse:collapse;width:100%;font-size:12.5px}
.sch td{border-top:1px solid var(--ash);padding:3px 6px;vertical-align:top}
.sch .mkc{width:44px;font-weight:700;color:#166534;white-space:nowrap}
.nosch{font-size:12px;color:var(--muted);font-style:italic}
.ft{position:absolute;bottom:4mm;left:0;right:0;display:flex;align-items:center;justify-content:center;
    gap:6px;font-size:8.5px;color:var(--muted)}
.ft img{height:11px;opacity:.75}.ft span{position:relative;top:1.5px}
@media print{
  .bar{display:none!important}
  body{background:#fff;print-color-adjust:exact;-webkit-print-color-adjust:exact}
  .stage{padding:0}
  svg line,svg path{shape-rendering:geometricPrecision}
  /* the on-screen page-preview min-height must not leak into print, or the sheet spills a blank page */
  .sheet{box-shadow:none;width:auto;min-height:0!important;padding:0!important}
  /* STANDING RULE: logo + footer pinned to the bottom of EVERY printed page. An absolutely
     positioned footer lands once, on the last page; a fixed one repeats per printed page. */
  .ft{position:fixed;bottom:0;left:0;right:0}
  @page{size:A4;margin:10mm 10mm 13mm}
}
