/* ==========================================================================
   v2.0 design layer — "Answer Sheet"
   Loaded after app.css. Re-skins every page through shared tokens and components; page markup and class names
   are unchanged, so removing this file (and the font links) returns the previous look.

   Ideas carried through the product:
   - Blue-black ink on cool exam paper: the colours of an answer booklet, not of a generic dashboard.
   - The notebook margin: a thin red rule down the left of every working page, the line students write beside.
   - Answer bubbles: the brand mark and the "you are here" marker are filled bubbles; marigold is the one bright
     colour and always means "current / needs your attention".
   - Atkinson Hyperlegible Next for reading (built for legibility: 1/l/I and 0/O never look alike — this matters in
     exam questions); Schibsted Grotesk for headings and numbers.
   ========================================================================== */

@font-face { font-family: "Atkinson Next"; src: url("../fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("../fonts/atkinson-hyperlegible-next-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("../fonts/atkinson-hyperlegible-next-latin-600-normal.woff2") format("woff2"); font-weight: 500 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Next"; src: url("../fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2"); font-weight: 700 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Schibsted"; src: url("../fonts/schibsted-grotesk-latin-500-normal.woff2") format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Schibsted"; src: url("../fonts/schibsted-grotesk-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Schibsted"; src: url("../fonts/schibsted-grotesk-latin-800-normal.woff2") format("woff2"); font-weight: 800 900; font-display: swap; }

:root {
  --paper: #F3F5F8;
  --surface: #FFFFFF;
  --ink: #15204A;          /* blue-black ink */
  --ink-2: #3B4466;
  --muted: #5E6787;        /* 5.6:1 on white */
  --rule: #DCE1EA;
  --rule-2: #EBEEF4;
  --tint: #EEF1F7;         /* ink at 6% */
  --margin: #D9534F;       /* notebook margin red */
  --marigold: #F2A900;
  --marigold-50: #FFF5D6;
  --link: #2B3DA0;
  --ok: #12795A;   --ok-50: #E6F4EE;
  --bad: #B3361F;  --bad-50: #FBEBE7;
  --warn: #8A5A00; --warn-50: #FFF5D6;
  --review: #5A3EB3; --review-50: #EFEBFA;
  --info: #2B3DA0; --info-50: #ECEFFA;

  /* old token names used by app.css, re-pointed */
  --navy: var(--ink); --accent: var(--ink); --accent-600: #0D1534; --accent-50: var(--tint);
  --bg: var(--paper); --card: var(--surface); --line: var(--rule); --line-2: var(--rule-2);
  --violet: var(--review); --violet-50: var(--review-50); --orange: var(--warn); --orange-50: var(--warn-50); --pink: var(--bad); --pink-50: var(--bad-50);
  --r-sm: 7px; --r: 10px; --r-lg: 12px;
  --shadow: none; --shadow-lg: 0 18px 40px -18px rgba(21, 32, 74, .35);
  --side-bg: #FBFCFD; --side-ink: var(--ink-2); --side-muted: var(--muted); --side-hover: var(--tint); --side-active: var(--tint); --side-accent: var(--marigold);
  --font: "Atkinson Next", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", Arial, sans-serif;
  --display: "Schibsted", "Atkinson Next", "Segoe UI", system-ui, sans-serif;
  --bs-body-font-family: var(--font); --bs-body-color: var(--ink); --bs-body-bg: var(--paper);
  --bs-primary: var(--ink); --bs-primary-rgb: 21, 32, 74;
  --bs-link-color: var(--link); --bs-link-color-rgb: 43, 61, 160; --bs-link-hover-color: var(--ink);
  --bs-border-color: var(--rule); --bs-border-radius: var(--r-sm);
  --bs-success-rgb: 18, 121, 90; --bs-danger-rgb: 179, 54, 31; --bs-warning-rgb: 242, 169, 0; --bs-info-rgb: 43, 61, 160;
  --gutter: clamp(1rem, 2.4vw, 2.25rem);
}

/* ---------- base type ---------- */
body { font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--paper); font-variant-numeric: lining-nums; }
h1, .h1, h2, .h2, h3, .h3, .h4, .h5, .h6, h4, h5, h6 { font-family: var(--display); color: var(--ink); letter-spacing: -.012em; }
h1 { font-size: clamp(1.55rem, 1.2rem + 1vw, 2.05rem); font-weight: 800; letter-spacing: -.025em; line-height: 1.15; }
h2.h5, .h5 { font-size: 1.12rem; font-weight: 700; }
h2.h6, .h6, h3.h6 { font-size: 1rem; font-weight: 700; }
.tabular, .kpi-n, .stat-n, .score-n { font-variant-numeric: tabular-nums; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
.text-muted { color: var(--muted) !important; }
::selection { background: var(--marigold-50); color: var(--ink); }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible { outline: 3px solid var(--marigold); outline-offset: 1px; box-shadow: none; }

/* ---------- buttons ---------- */
.btn { font-weight: 600; border-radius: var(--r-sm); padding: .48rem .95rem; letter-spacing: .005em; }
.btn-sm { padding: .3rem .65rem; font-size: .86rem; }
.btn-lg { padding: .7rem 1.25rem; font-size: 1.02rem; }
.btn-primary { --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); --bs-btn-hover-bg: #0D1534; --bs-btn-hover-border-color: #0D1534; --bs-btn-active-bg: #0A1029; --bs-btn-active-border-color: #0A1029; --bs-btn-disabled-bg: #6B7290; --bs-btn-disabled-border-color: #6B7290; color: #fff; }
.btn-outline-primary { --bs-btn-color: var(--ink); --bs-btn-border-color: var(--ink); --bs-btn-hover-bg: var(--ink); --bs-btn-hover-border-color: var(--ink); --bs-btn-hover-color: #fff; --bs-btn-active-bg: var(--ink); background: var(--surface); }
.btn-outline-secondary { --bs-btn-color: var(--ink-2); --bs-btn-border-color: var(--rule); --bs-btn-hover-bg: var(--tint); --bs-btn-hover-border-color: #C5CCDA; --bs-btn-hover-color: var(--ink); background: var(--surface); }
.btn-light { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--rule); --bs-btn-hover-bg: var(--tint); --bs-btn-hover-border-color: #C5CCDA; color: var(--ink); }
.btn-success { --bs-btn-bg: var(--ok); --bs-btn-border-color: var(--ok); --bs-btn-hover-bg: #0D5F46; --bs-btn-hover-border-color: #0D5F46; }
.btn-danger { --bs-btn-bg: var(--bad); --bs-btn-border-color: var(--bad); --bs-btn-hover-bg: #8F2A17; --bs-btn-hover-border-color: #8F2A17; }
.btn-outline-danger { --bs-btn-color: var(--bad); --bs-btn-border-color: #E3B4AA; --bs-btn-hover-bg: var(--bad); --bs-btn-hover-border-color: var(--bad); }
.btn-warning { --bs-btn-bg: var(--marigold); --bs-btn-border-color: var(--marigold); --bs-btn-color: var(--ink); --bs-btn-hover-bg: #DB9900; --bs-btn-hover-border-color: #DB9900; --bs-btn-hover-color: var(--ink); }
.btn-link { color: var(--link); font-weight: 600; }
.btn .ic { width: 17px; height: 17px; }

/* ---------- forms ---------- */
.form-control, .form-select { border-color: #CDD4E0; border-radius: var(--r-sm); background-color: var(--surface); color: var(--ink); }
.form-control::placeholder { color: #8A91AA; }
.form-control:focus, .form-select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 169, 0, .35); }
.form-label { font-weight: 600; color: var(--ink); font-size: .9rem; margin-bottom: .3rem; }
.form-text { color: var(--muted); }
.form-check-input { border-color: #A9B1C6; }
.form-check-input:checked { background-color: var(--ink); border-color: var(--ink); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(242, 169, 0, .35); border-color: var(--ink); }
.form-check-input[type=radio]:checked { background-color: var(--ink); }

/* ---------- badges ---------- */
.badge { font-family: var(--font); font-weight: 700; letter-spacing: .01em; border-radius: 999px; padding: .28em .62em; }
.text-bg-success { background: var(--ok-50) !important; color: var(--ok) !important; border: 1px solid #B9DFCF; }
.text-bg-secondary { background: var(--tint) !important; color: var(--ink-2) !important; border: 1px solid var(--rule); }
.text-bg-warning { background: var(--marigold-50) !important; color: var(--warn) !important; border: 1px solid #F1D68A; }
.text-bg-danger { background: var(--bad-50) !important; color: var(--bad) !important; border: 1px solid #EBC0B6; }
.text-bg-info { background: var(--info-50) !important; color: var(--info) !important; border: 1px solid #C9D0F0; }
.text-bg-light { background: var(--surface) !important; color: var(--ink-2) !important; border: 1px solid var(--rule); }
.badge.st-live::before { background: var(--marigold); box-shadow: 0 0 0 2px rgba(242, 169, 0, .3); }
.badge-soft { background: var(--tint); color: var(--ink-2); border-color: var(--rule); }
.key-pill { background: var(--ink); color: #fff; border-color: var(--ink); width: auto; min-width: 26px; padding: 0 .45rem; border-radius: 999px; font-size: .78rem; }
.level { font-family: var(--font); }

/* ---------- alerts ---------- */
.alert { border-radius: var(--r); border: 1px solid var(--rule); border-left-width: 4px; background: var(--surface); color: var(--ink); padding: .8rem 1rem; }
.alert .ic { width: 18px; height: 18px; vertical-align: -3px; }
.alert-success { border-left-color: var(--ok); }
.alert-info { border-left-color: var(--info); }
.alert-warning { border-left-color: var(--marigold); background: #FFFCF2; }
.alert-danger { border-left-color: var(--bad); background: #FFF9F7; }
.alert-secondary { border-left-color: #A9B1C6; }
.sub-banner { font-size: .93rem; }

/* ---------- shell: top bar ---------- */
.topbar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--rule); box-shadow: none; height: 64px; padding: 0 1rem 0 .75rem; }
.topbar :focus-visible, .sidebar :focus-visible { outline: 3px solid var(--marigold); outline-offset: 1px; }
.icon-btn { color: var(--ink-2); }
.icon-btn:hover { background: var(--tint); color: var(--ink); }
.brand, .brand:hover { color: var(--ink); }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--brand, var(--ink)); color: #fff; }
.brand-mark .bmark { width: 28px; height: 28px; }
.mark-fill { fill: var(--marigold); }
.brand-text strong { font-family: var(--display); font-weight: 800; font-size: 1.04rem; letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: .8rem; }
.notif-dot { background: var(--marigold); color: var(--ink); font-weight: 800; border: 2px solid var(--surface); }
.user-btn { color: var(--ink); border-radius: 999px; padding: .2rem .55rem .2rem .2rem; }
.user-btn:hover { background: var(--tint); }
.avatar { background: var(--ink); color: #fff; font-family: var(--display); font-weight: 700; }
.user-meta small { color: var(--muted); }
.dropdown-menu { border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: .35rem; }
.dropdown-item { border-radius: 6px; color: var(--ink); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--tint); color: var(--ink); }
.dropdown-header { color: var(--ink); font-weight: 700; }

/* ---------- shell: sidebar ---------- */
.sidebar, .sidebar.offcanvas-lg { background-color: var(--side-bg) !important; color: var(--ink-2); border-right: 1px solid var(--rule); }
.sidebar.offcanvas-lg { --bs-offcanvas-bg: var(--side-bg); --bs-offcanvas-color: var(--ink); }
.sidebar .offcanvas-header { color: var(--ink); border-bottom: 1px solid var(--rule); }
.sidebar .btn-close-white { filter: none; }
.sidebar::-webkit-scrollbar-thumb { background: #CDD4E0; }
.sidebar { scrollbar-color: #CDD4E0 transparent; }
.side-nav { padding: .9rem .7rem .5rem; }
.side-group { margin: 1.05rem .8rem .3rem; font-family: var(--display); font-size: .78rem; font-weight: 700; letter-spacing: .01em; text-transform: none; color: var(--muted); }
.side-link { color: var(--ink-2); font-weight: 500; font-size: .93rem; border-radius: 8px; padding: .5rem .75rem .5rem 2rem; }
.side-link .ic { color: #7A82A0; width: 18px; height: 18px; }
.side-link:hover { background: var(--tint); color: var(--ink); }
.side-link:hover .ic { color: var(--ink); }
/* The current page is a filled answer bubble in the margin. */
.side-link::after { content: ""; position: absolute; left: .7rem; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; border: 1.5px solid #C5CCDA; background: transparent; }
.side-link.active { background: var(--tint); color: var(--ink); font-weight: 700; }
.side-link.active::before { display: none; }
.side-link.active::after { background: var(--marigold); border-color: var(--marigold); box-shadow: 0 0 0 3px rgba(242, 169, 0, .22); }
.side-link.active .ic { color: var(--ink); }
.side-card { background: var(--surface); border: 1px solid var(--rule); color: var(--ink-2); border-radius: var(--r); }
.side-card strong, .side-plan { color: var(--ink); }
.side-muted, .side-storage { color: var(--muted); }
.side-days { color: var(--ink-2); }
.side-days.warn { color: var(--warn); background: var(--marigold-50); }
.side-card .meter { background: var(--rule-2); }
.side-card .meter span { background: var(--ink); }
.side-foot { color: var(--muted); display: flex; flex-direction: column; gap: .35rem; font-size: .74rem; line-height: 1.4; }
.side-foot a { color: var(--ink-2); margin-right: .7rem; }
@media (min-width: 992px) {
  body.sb-collapsed .side-link { padding: .6rem; }
  body.sb-collapsed .side-link::after { display: none; }
  body.sb-collapsed .side-link.active { box-shadow: inset 3px 0 0 var(--marigold); }
  body.sb-collapsed .side-group { background: var(--rule); }
}

/* ---------- the notebook margin ---------- */
.content { padding: 1.6rem var(--gutter) 3rem calc(var(--gutter) + 18px); position: relative; }
@media (min-width: 768px) {
  .content::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--gutter) - 2px); width: 2px; background: var(--margin); opacity: .38; pointer-events: none; }
}
@media (max-width: 767.98px) { .content { padding-left: var(--gutter); } }

/* ---------- page heads ---------- */
.page-head { align-items: flex-end; gap: 1rem; margin-bottom: 1.35rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.page-sub { color: var(--muted); font-size: .98rem; max-width: 70ch; margin: .3rem 0 0; }
.date-chip { background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; box-shadow: none; }

/* ---------- panels & cards ---------- */
.panel, .card-plain, .filter-panel, .card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: none; }
.panel { padding: 1.15rem 1.25rem; }
.panel-head { border-bottom: 0; padding-bottom: .1rem; margin-bottom: .7rem; }
.panel-head h2, .panel > h2.h6, .panel-title { font-family: var(--display); font-size: 1.04rem; font-weight: 700; color: var(--ink); }
.panel-head h2 .ic { color: var(--ink-2); }
.panel-head a { font-weight: 600; }
details.panel > summary { font-family: var(--display); font-weight: 700; }

/* KPI tiles: one ink colour, large numerals; the meter is the only graphic. */
.kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: none; padding: 1rem 1.1rem; }
.kpi-ic { background: var(--tint) !important; color: var(--ink) !important; border-radius: 10px; }
.kpi-n { font-family: var(--display); font-weight: 800; font-size: 2rem; color: var(--ink) !important; letter-spacing: -.03em; line-height: 1.05; }
.kpi-n small { font-family: var(--display); font-weight: 600; color: var(--muted); }
.kpi-label { color: var(--ink-2); font-weight: 600; }
.kpi-foot { color: var(--muted); }
.tone-blue, .tone-violet, .tone-green, .tone-orange { background: var(--surface) !important; }
.meter { background: var(--rule-2); border-radius: 999px; }
.meter span { background: var(--ink); border-radius: 999px; }
.meter.warn span { background: var(--marigold); }
.progress { background: var(--rule-2); }
.progress-bar { background-color: var(--ink); }

.stat { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: none; }
.stat-n { font-family: var(--display); font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.stat.ok .stat-n { color: var(--ok); }

/* Quick actions and centre links: same paper card, no rainbow. */
.qa { background: var(--surface) !important; border: 1px solid var(--rule) !important; border-radius: var(--r-lg); box-shadow: none; color: var(--ink); }
.qa:hover { border-color: var(--ink) !important; transform: none; box-shadow: 0 0 0 1px var(--ink); color: var(--ink); text-decoration: none; }
.qa-ic { background: var(--tint) !important; color: var(--ink) !important; }
.qa strong { font-family: var(--display); color: var(--ink); }
.qa small { color: var(--muted); }
.qa-go { color: var(--ink-2); border-color: var(--rule); }
.act-ic, .act-ic.g { background: var(--tint); color: var(--ink); }

/* ---------- tables: ledger style ---------- */
.table { --bs-table-bg: transparent; color: var(--ink); }
.table thead th { font-family: var(--display); text-transform: none; letter-spacing: 0; font-size: .82rem; font-weight: 700; color: var(--ink-2); background: transparent; border-bottom: 1.5px solid var(--ink) !important; padding-top: .55rem; padding-bottom: .55rem; }
.table > :not(caption) > * > * { border-bottom-color: var(--rule-2); }
.table-hover > tbody > tr:hover > *, .data-table tbody tr:hover > * { background: #F8F9FC; --bs-table-bg-state: #F8F9FC; }
.table-responsive { border: 0; }
.panel .table-responsive { border: 1px solid var(--rule-2); border-radius: var(--r); }
.code-badge { background: var(--tint); color: var(--ink-2); border-color: var(--rule); font-family: var(--font); }

/* ---------- tabs, chips, filters ---------- */
.status-tabs { border-bottom: 1px solid var(--rule); gap: .25rem; }
.status-tabs a { color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; }
.status-tabs a:hover { color: var(--ink); background: transparent; }
.status-tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--marigold); background: transparent; }
.status-tabs .count { color: var(--muted); font-weight: 500; margin-left: .2rem; }
.chip { background: var(--surface); border: 1px solid var(--rule); color: var(--ink-2); font-weight: 600; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on span { color: rgba(255,255,255,.75); }
.filter-panel { padding: 1rem; }
.pagination { --bs-pagination-color: var(--ink); --bs-pagination-active-bg: var(--ink); --bs-pagination-active-border-color: var(--ink); --bs-pagination-hover-bg: var(--tint); --bs-pagination-border-color: var(--rule); }
.bulk-panel.has-selection { border-color: var(--marigold); background: #FFFCF2; }

/* ---------- empty states ---------- */
.empty-state { border: 1.5px dashed #C9D0DD; background: transparent; border-radius: var(--r-lg); }
.empty-ic { color: #A3AAC0; }
.empty-title { font-family: var(--display); font-weight: 700; color: var(--ink); }

/* ---------- section titles & test cards (student) ---------- */
.section-title { font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.section-title .count { background: var(--ink); color: #fff; }
.test-card { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--rule); border-radius: var(--r-lg); box-shadow: none; }
.test-card.available { border-left-color: var(--ink); }
.test-card.in_progress { border-left-color: var(--marigold); background: #FFFCF2; }
.test-card h3 { font-family: var(--display); font-weight: 700; }
.test-meta { color: var(--muted); }

/* ---------- result review ---------- */
.q-options li.key { background: var(--ok-50); border-color: #B9DFCF; }
.chosen-wrong { background: var(--bad-50) !important; border-color: #EBC0B6 !important; }
.verdict.right { color: var(--ok); } .verdict.wrong { color: var(--bad); } .verdict.dropped { color: var(--warn); }
.key-revision { border-left: 4px solid var(--marigold); background: #FFFCF2; padding: .5rem .75rem; border-radius: 6px; margin-bottom: .6rem; }
.score-hero { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: none; }
.score-hero .score-facts > div { background: var(--paper); border-color: var(--rule-2); }
.score-n { font-family: var(--display); font-weight: 800; }

/* ---------- answer-key corrections page ---------- */
.explainer { background: var(--surface); border-left: 4px solid var(--ink); }
.key-list { display: grid; gap: .75rem; }
.key-q.revised { border-color: var(--marigold); box-shadow: inset 4px 0 0 var(--marigold); }
.key-q-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.key-q-no { font-family: var(--display); font-weight: 800; font-size: 1.05rem; }
.key-opts li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.pick { position: relative; min-width: 96px; height: 22px; border-radius: 999px; background: var(--rule-2); display: inline-flex; align-items: center; justify-content: flex-end; padding: 0 .5rem; font-size: .78rem; font-weight: 700; overflow: hidden; flex-shrink: 0; }
.pick-bar { position: absolute; left: 0; top: 0; bottom: 0; background: #C9D0E6; }
.key-opts li.key .pick-bar { background: #9BD3BD; }
.pick .tabular { position: relative; }
.key-form { display: grid; gap: .6rem; margin-top: .6rem; max-width: 720px; }
.key-form fieldset { border: 0; padding: 0; margin: 0; }

/* ---------- enquiries ---------- */
.enq-list { display: grid; gap: .75rem; }
.enq-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .6rem; }
.enq-facts { display: flex; flex-wrap: wrap; gap: .5rem 1.6rem; margin: 0 0 .6rem; }
.enq-facts dt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.enq-facts dd { margin: 0; font-weight: 600; }
.enq-msg { background: var(--paper); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .8rem; }

/* ---------- plain pages (sign in, legal, installer) ---------- */
body.plain { background: var(--paper); }
.plain-head .brand-mark { background: var(--ink); }
.plain-foot { color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 575.98px) {
  body { font-size: 15.5px; }
  .page-head { align-items: stretch; }
  .panel { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print {
  .content::before { display: none; }
}

/* ---------- refinements ---------- */
.btn:hover, .btn:focus { text-decoration: none; }
/* Expanded sidebar: the answer-bubble column replaces the icons; collapsed sidebar shows icons only. */
@media (min-width: 992px) {
  body:not(.sb-collapsed) .side-link .ic { display: none; }
  body:not(.sb-collapsed) .side-link { padding-left: 2.1rem; }
}
@media (max-width: 991.98px) { .side-link .ic { display: none; } .side-link { padding-left: 2.1rem; } }
@media (max-width: 1679.98px) { .recent-tests .col-format { display: none; } .recent-tests .t-sub .fmt-inline { display: inline; } }

/* ---------- plain pages: a single sheet on ruled paper ---------- */
body.plain { background-color: var(--paper); background-image: linear-gradient(to bottom, transparent 31px, rgba(43, 61, 160, .06) 31px, rgba(43, 61, 160, .06) 32px); background-size: 100% 32px; min-height: 100vh; }
.plain-wrap { padding-top: clamp(2rem, 8vh, 5rem); }
.plain-head { gap: .75rem; margin-bottom: 1.25rem; }
.plain-head .brand-mark { width: 44px; height: 44px; border-radius: 11px; background: var(--ink); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.plain-head .brand-mark .bmark { width: 30px; height: 30px; }
.plain-head strong { font-family: var(--display); font-weight: 800; font-size: 1.1rem; }
.card-plain { padding: clamp(1.25rem, 4vw, 2rem); border-radius: 14px; border-top: 4px solid var(--ink); }
.signin h1 { font-weight: 800; letter-spacing: -.02em; }
.form-control-lg { font-size: 1.05rem; }
.plain-head { color: var(--ink); }
.plain-head small { color: var(--muted); display: block; }
.plain-head .brand-mark, .plain-head .brand-mark:hover { color: #fff; background: var(--ink) !important; text-decoration: none; }
.bmark { display: block; background: transparent; }
.bmark circle:not(.mark-fill) { stroke: #fff; fill: none; }

/* ---------- student home ---------- */
.student-head { align-items: flex-end; flex-wrap: wrap; }
.student-links { display: flex; flex-wrap: wrap; gap: .4rem; }
.student-links a { padding: .4rem .8rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: .9rem; text-decoration: none; }
.student-links a:hover { border-color: var(--ink); }
.upnext { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem 2rem; background: var(--ink); color: #fff; border-radius: 16px; padding: clamp(1.25rem, 3vw, 2rem) clamp(1.25rem, 3vw, 2.25rem); margin-bottom: 1.75rem; position: relative; overflow: hidden; }
.upnext::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; border: 18px solid rgba(255, 255, 255, .06); pointer-events: none; }
.upnext.resume { box-shadow: inset 6px 0 0 var(--marigold); }
.upnext-label { color: var(--marigold); font-weight: 700; margin: 0 0 .3rem; }
.upnext h2 { color: #fff; font-size: clamp(1.35rem, 1rem + 1.4vw, 2rem); font-weight: 800; letter-spacing: -.02em; margin: 0 0 .35rem; max-width: 40ch; }
.upnext-meta { color: rgba(255, 255, 255, .78); margin: 0; }
.upnext-note { color: #fff; margin: .5rem 0 0; font-weight: 600; }
.upnext-act { position: relative; z-index: 1; }
.student-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
@media (max-width: 1199.98px) { .student-grid { grid-template-columns: 1fr; } }
.student-side { display: grid; gap: 1rem; }
.score-list, .acc-list, .rec-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .75rem; }
.score-list a { display: flex; justify-content: space-between; gap: .75rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.score-list a:hover .sl-title { text-decoration: underline; }
.sl-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-score { font-family: var(--display); font-weight: 800; }
.sl-score small { color: var(--muted); font-weight: 600; }
.bar { display: block; height: 6px; background: var(--rule-2); border-radius: 999px; margin-top: .3rem; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: 999px; }
.bar > span.low { background: var(--marigold); }
.acc-list li { display: grid; grid-template-columns: 1fr auto; gap: 0 .5rem; font-weight: 600; }
.acc-list .bar { grid-column: 1 / -1; }
.rec-list li { display: flex; flex-direction: column; gap: .1rem; padding-left: .8rem; border-left: 3px solid var(--marigold); }
.rec-list a { font-weight: 700; }
.rec-list span { color: var(--muted); font-size: .88rem; }
.test-cards { gap: .6rem; }
.test-meta span + span::before { content: "·"; margin-right: .6rem; color: #A3AAC0; }
.test-meta span { gap: 0; }
.student-side, .student-side .panel, .score-list li, .student-main { min-width: 0; }
.test-card { flex-wrap: wrap; }
.key-opts { counter-reset: opt; padding-left: 0; list-style: none; }
.key-opts li { counter-increment: opt; }
.key-opts li > span:first-child { flex: 1; }
.key-opts li::before { content: counter(opt, upper-alpha); font-family: var(--display); font-weight: 800; width: 1.6rem; flex-shrink: 0; }

/* ---------- result page (2.1) ---------- */
.score-band { background: var(--ink); color: #fff; border-radius: 16px; padding: clamp(1.25rem, 3vw, 2rem); margin-bottom: 1.25rem; }
.score-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.score-big { margin: 0; display: flex; align-items: baseline; gap: .6rem; }
.score-band .score-n { font-family: var(--display); font-weight: 800; font-size: clamp(2.8rem, 2rem + 3vw, 4.2rem); line-height: 1; letter-spacing: -.04em; color: #fff; }
.score-band .score-of { color: rgba(255, 255, 255, .78); font-size: 1.05rem; }
.score-band .score-pct { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.8rem; color: var(--marigold); }
.answer-strip { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .15); margin: 1.1rem 0 1rem; }
.answer-strip span { display: block; height: 100%; }
.as-c { background: #2FB37E; } .as-w { background: #E8664F; } .as-u { background: rgba(255, 255, 255, .35); }
.score-band .score-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: .25rem 1.25rem; margin: 0 0 .9rem; }
.score-band .score-facts > div { background: transparent; border: 0; border-top: 1px solid rgba(255, 255, 255, .18); border-radius: 0; padding: .5rem 0 0; }
.score-band .score-facts dt { color: rgba(255, 255, 255, .78); font-size: .8rem; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.score-band .score-facts dd { color: #fff; margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot.c { background: #2FB37E; } .dot.w { background: #E8664F; } .dot.u { background: rgba(255, 255, 255, .5); }
.score-note { color: rgba(255, 255, 255, .78); font-size: .84rem; margin: 0; max-width: 95ch; }
.result-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 991.98px) { .result-grid { grid-template-columns: 1fr; } }
.subj-bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.sb-top { display: flex; justify-content: space-between; gap: 1rem; }
.sb-top span { font-family: var(--display); font-weight: 700; }
.sb-meta { display: block; color: var(--muted); font-size: .84rem; margin-top: .3rem; }
.lost-list { padding-left: 1.2rem; margin: 0 0 .6rem; display: grid; gap: .45rem; }
.lost-list li { padding-left: .2rem; }
.lost-list li::marker { font-family: var(--display); font-weight: 800; color: var(--ink); }
.lost-list li { display: list-item; }
.lost-list li span:last-child { float: right; font-weight: 700; color: var(--bad); margin-left: 1rem; }
details.panel > summary { cursor: pointer; }

/* ---------- teacher home: work queue (2.1) ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 1199.98px) { .home-grid { grid-template-columns: 1fr; } }
.queue { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.q-item { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr); gap: 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 1rem 1.15rem; }
.q-count { font-family: var(--display); font-weight: 800; font-size: 2.1rem; line-height: 1; color: var(--ink); text-align: center; padding-top: .15rem; }
.q-live { border-left: 4px solid var(--marigold); } .q-live .q-count { color: #8A5A00; }
.q-release { border-left: 4px solid var(--ink); }
.q-issues { border-left: 4px solid var(--bad); } .q-issues .q-count { color: var(--bad); }
.q-closing, .q-drafts { border-left: 4px solid var(--rule); }
.q-label { font-family: var(--display); font-weight: 700; font-size: 1.05rem; margin: 0; }
.q-hint { color: var(--muted); margin: .15rem 0 .5rem; font-size: .92rem; }
.q-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.q-links li { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--rule-2); padding-top: .3rem; }
.q-links a { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-links span { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.caught-up { border: 1.5px dashed #C9D0DD; border-radius: var(--r-lg); padding: 1.25rem; color: var(--ink-2); }
.cu-title { font-family: var(--display); font-weight: 800; font-size: 1.2rem; color: var(--ink); margin-bottom: .25rem; }
.sub-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.sub-list li { border-top: 1px solid var(--rule-2); padding-top: .55rem; }
.sub-list li:first-child { border-top: 0; padding-top: 0; }
.sub-list a { display: flex; justify-content: space-between; gap: .75rem; color: var(--ink); font-weight: 600; text-decoration: none; }
.sub-list a:hover .sl-name { text-decoration: underline; }
.sl-meta { display: block; color: var(--muted); font-size: .85rem; }
.sl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- test page: folded health check (2.1) ---------- */
details.health > summary.health-sum { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; list-style: none; font-family: var(--font); }
details.health > summary.health-sum::before { display: none; }
details.health > summary::-webkit-details-marker { display: none; }
.hs-title { font-family: var(--display); font-weight: 700; display: inline-flex; align-items: center; gap: .4rem; }
.hs-verdict { font-weight: 600; }
.hs-verdict.ok { color: var(--ok); } .hs-verdict.warn { color: var(--warn); } .hs-verdict.bad { color: var(--bad); }
.hs-more { margin-left: auto; color: var(--link); font-weight: 600; font-size: .9rem; }
details.health[open] .hs-more { visibility: hidden; }
.dash-single { display: block; }

/* ---------- key figures strip (2.1) ---------- */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 1.5rem; border-top: 2px solid var(--ink); }
.figures > div { padding: .8rem 1rem .2rem 0; }
.figures > div + div { padding-left: 1rem; border-left: 1px solid var(--rule); }
.figures dt { color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.figures dd { margin: 0; }
.figures dd.tabular { font-family: var(--display); font-weight: 800; font-size: 2rem; letter-spacing: -.03em; line-height: 1.1; }
.fig-sub { color: var(--muted); font-size: .84rem; }
@media (max-width: 767.98px) { .figures { grid-template-columns: 1fr 1fr; } .figures > div:nth-child(3) { padding-left: 0; border-left: 0; } }

/* ---------- installable app (2.2) ---------- */
.is-app .app-only-hide { display: none !important; }
.install-chip { padding: .4rem .8rem; border: 1px solid var(--ink); border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; font-size: .9rem; }
.install-chip[hidden], [data-install-app][hidden], [data-install-ios][hidden], [data-install-done][hidden], [data-app-running][hidden] { display: none !important; }
.app-page ol, .app-page ul { padding-left: 1.2rem; }
.app-page li { margin-bottom: .3rem; }
.app-status p { margin: .5rem 0 1rem; font-weight: 600; }
.offline-page { max-width: 560px; margin: 12vh auto 0; padding: 0 1.25rem; }
.offline-page h1 { font-weight: 800; letter-spacing: -.02em; }
/* Installed app on a phone: leave room for the status bar / notch. */
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); height: calc(64px + env(safe-area-inset-top)); } }
