/* Trialbank: bold, chunky and friendly. One strong brand colour, buttons that press down, a cartoon mascot. */
:root {
  --bg: #fbfaf7;          /* warm paper */
  --paper: #ffffff;
  --soft: #f6f4ef;
  --hover: #f0ede6;
  --ink: #1f2329;
  --on-ink: #ffffff;
  --muted: #6b707a;
  --rule: #e6e2d9;        /* card borders and the 3D edge under neutral buttons */
  --rule-strong: #cfc9bc;
  --biro: #2f5be8;        /* brand colour, changes with the chosen accent */
  --biro-dark: #1d3fb8;   /* the pressed-down edge under brand buttons */
  --biro-soft: #e8eefe;
  --marker: #e5484d;
  --hl: #fff1a1; --hl-edge: #e9cf4f;
  --good: #1fa45a; --good-dark: #157d43; --good-soft: #e1f6e9;
  --bad: #e5484d; --bad-dark: #b8343a; --bad-soft: #fdeaea;
  --warn: #c27400; --mid: #f0a020;
  --top-bg: color-mix(in srgb, var(--bg) 92%, transparent);
  --veil: color-mix(in srgb, var(--bg) 80%, transparent);
  --shadow: rgba(31,35,41,.12);
  --r-lg: 20px; --r: 14px; --r-sm: 12px;
  --max: 900px;
  --font: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: var(--font);
  --pen: var(--font);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14161b; --paper: #1d2027; --soft: #22262e; --hover: #282c35;
  --ink: #eef0f4; --on-ink: #14161b; --muted: #9ba2ae;
  --rule: #30343e; --rule-strong: #454b57;
  --biro-soft: color-mix(in srgb, var(--biro) 22%, var(--paper));
  --hl: #5b4d12; --hl-edge: #8a7520;
  --good-soft: #163a26; --bad-soft: #432023;
  --shadow: rgba(0,0,0,.4);
  color-scheme: dark;
}
/* accent colours a student can pick */
:root[data-accent="green"]  { --biro: #1fa45a; --biro-dark: #157d43; --biro-soft: #e1f6e9; }
:root[data-accent="purple"] { --biro: #7c4dde; --biro-dark: #5a31b0; --biro-soft: #efe9fc; }
:root[data-accent="orange"] { --biro: #f07818; --biro-dark: #c05a08; --biro-soft: #fdeedf; }
:root[data-accent="pink"]   { --biro: #e0457b; --biro-dark: #b02b5c; --biro-soft: #fce8ef; }
:root[data-accent="teal"]   { --biro: #0f9aa8; --biro-dark: #0a7480; --biro-soft: #e0f4f6; }
:root[data-accent="graphite"] { --biro: #3a3f4a; --biro-dark: #1f2329; --biro-soft: #ebecef; }
:root[data-theme="dark"][data-accent="graphite"] { --biro: #c9ced8; --biro-dark: #8a909c; }
:root[data-theme="dark"][data-accent] { --biro-soft: color-mix(in srgb, var(--biro) 22%, var(--paper)); }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--biro); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.85rem; line-height: 1.15; margin: .2rem 0 .35rem; letter-spacing: -.015em; font-weight: 800; }
h2 { font-size: 1.08rem; margin: 0 0 .4rem; font-weight: 700; }
p { margin: .45rem 0; }
.lead { margin: 0 0 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.error { color: var(--bad); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--biro); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--top-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.top-in { max-width: var(--max); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.12rem; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 4px; }
.mainnav a { display: flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: var(--r-sm); color: var(--muted); font-weight: 500; }
.mainnav a:hover { color: var(--ink); background: var(--hover); text-decoration: none; }
.mainnav a.on { color: var(--ink); background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); }
.mainnav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.account { position: relative; }
.avatar { width: 36px; height: 36px; border-radius: 50%; padding: 0; background: var(--ink); color: var(--on-ink); border: 0; font-weight: 700; font-size: .9rem; }
.menu { position: absolute; right: 0; top: 44px; min-width: 220px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 6px; box-shadow: 0 10px 30px rgba(30,36,48,.14); }
.menu-email { padding: 6px 10px; margin: 0 0 4px; border-bottom: 1px solid var(--rule); word-break: break-all; }
.menu a, .menu-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); background: none; border: 0; font-size: .95rem; }
.menu a:hover, .menu-item:hover { background: var(--bg); text-decoration: none; }

main { max-width: var(--max); margin: 0 auto; padding: 22px 16px 64px; }
footer { max-width: var(--max); margin: 0 auto; padding: 0 16px 40px; text-align: center; }

/* ---------- controls ---------- */
button, .button { font: inherit; cursor: pointer; border-radius: var(--r-sm); border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink); padding: 9px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; }
button:hover, .button:hover { border-color: var(--rule-strong); text-decoration: none; }
.primary { background: var(--biro); color: #fff; border-color: var(--biro); font-weight: 700; }
.primary:hover { background: var(--biro-dark); border-color: var(--biro-dark); }
.ghost { background: none; border-color: transparent; color: var(--biro); }
.ghost:hover { background: var(--hover); border-color: transparent; }
.wide { width: 100%; }
.big { width: 100%; padding: 14px; font-size: 1.05rem; }
.link { background: none; border: none; padding: 0; color: var(--biro); cursor: pointer; font: inherit; font-weight: 500; display: inline; }
/* contrast (WCAG AA): links on the dark theme, and links inside sentences are underlined */
:where(:root[data-theme="dark"]) a, :where(:root[data-theme="dark"]) .link { color: color-mix(in srgb, var(--biro) 60%, #fff); }
p.muted a, .auth-card p a { text-decoration: underline; }
.link:hover { text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; margin: 12px 0; font-size: .9rem; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
label.inline input { width: 90px; margin: 0; }
label.check input { width: auto; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--paper); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--biro); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; margin: 6px 0; }
input[type=search] { margin: 0 0 12px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.row.end { justify-content: space-between; margin-top: 18px; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 18px; margin: 14px 0; }
.card.question { padding: 12px; }
.card img { display: block; width: 100%; height: auto; border-radius: 6px; }
.card.scroll { max-height: 70vh; overflow-y: auto; padding: 10px; }
.back { display: inline-block; margin-bottom: 6px; }

/* ---------- auth ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; align-items: center; min-height: 62vh; }
.auth-brand { font-weight: 800; font-size: 1.1rem; margin: 0 0 14px; }
.auth-h { font-size: 2.4rem; line-height: 1.08; margin-bottom: 14px;
  background-image: repeating-linear-gradient(transparent 0 2.45rem, var(--rule) 2.45rem calc(2.45rem + 1px)); padding-bottom: 6px; }
.auth-card { padding: 24px; }

/* ---------- home ---------- */
.hello { font-size: 2.1rem; }
.resume { display: flex; justify-content: space-between; align-items: center; gap: 14px; background: var(--hl); border-radius: var(--r-lg); padding: 14px 18px; margin: 0 0 18px; }
.resume p { margin: 2px 0 0; }
.actions { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 14px; }
.action { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.action p { margin: 0 0 4px; flex: 1; }
.action.main { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.action.main .muted { color: var(--rule-strong); }
.action.main .primary { background: #fff; color: var(--ink); border-color: #fff; }
.action.main .primary:hover { background: var(--hl); border-color: var(--hl); }
.action.main .ghost { color: #fff; }
.action.main .ghost:hover { background: rgba(255,255,255,.1); }
.action .row { margin: 0; }
.action > button { align-self: flex-start; }
.times summary { cursor: pointer; color: var(--muted); list-style: none; }
.times summary::-webkit-details-marker { display: none; }
.times summary span { color: var(--biro); text-decoration: underline dotted; }
.times .options { margin: 8px 0 4px; gap: 6px; }
h2.sec { margin: 30px 0 10px; font-size: 1.15rem; }
.list { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.li { width: 100%; border: 0; border-radius: 0; border-bottom: 1px solid var(--rule); background: none; padding: 14px 18px;
  display: flex; justify-content: space-between; align-items: center; text-align: left; gap: 12px; }
.li:last-child { border-bottom: 0; }
.li:hover { background: var(--soft); }
.li > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.li .go { color: var(--muted); font-size: 1.5rem; line-height: 1; }

/* ---------- practise builder ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border-radius: 999px; padding: 6px 12px; font-size: .9rem; }
.chip .n { color: var(--muted); margin-left: 6px; font-size: .8rem; }
.chip.on { background: var(--hl); border-color: var(--hl-edge); color: var(--ink); }
.options { display: grid; gap: 12px; }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.opt > span { color: var(--muted); font-size: .9rem; }
.opt input { width: 90px; margin: 0; text-align: right; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; background: var(--paper); }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--rule); padding: 7px 12px; font-size: .9rem; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--on-ink); }
.startbar { position: sticky; bottom: 12px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 10px 10px 10px 18px; box-shadow: 0 8px 24px rgba(30,36,48,.12); margin-top: 14px; }
.startbar .primary { padding: 11px 26px; }

/* ---------- set ---------- */
.setbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.setbar #set-pos { font-weight: 700; }
.progress { height: 6px; background: var(--rule); border-radius: 3px; margin: 10px 0 8px; overflow: hidden; }
.progress div { height: 100%; background: var(--biro); width: 0; transition: width .3s; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.choices button { min-width: 60px; padding: 12px 18px; font-size: 1.1rem; font-weight: 700; }
.choices button.correct { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.choices button.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.choices button.picked { outline: 2px solid var(--ink); }
.verdict { font-family: var(--pen); font-size: 1.45rem; line-height: 1.2; margin: 10px 0; }
.verdict.good { color: var(--good); } .verdict.bad { color: var(--marker); } .verdict.warn { color: var(--warn); }
.keys { margin-top: 26px; text-align: center; }

/* ---------- summary / marks ---------- */
.score-mark { font-family: var(--pen); color: var(--marker); font-size: 3.2rem; line-height: 1; display: inline-block;
  border: 3px solid var(--marker); border-radius: 50% 46% 52% 48%; padding: 14px 26px 8px; margin: 8px 0 14px; transform: rotate(-4deg); }
.big-number { font-size: 2.4rem; font-weight: 800; margin: 4px 0 12px; }
.bars { display: grid; gap: 12px; }
.bar { display: grid; gap: 5px; font-size: .92rem; }
.bar .lbl { display: flex; justify-content: space-between; gap: 10px; }
.bar .track { height: 9px; background: var(--hover); border-radius: 5px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 5px; background: var(--biro); }
.bar.low .fill { background: var(--marker); } .bar.mid .fill { background: var(--mid); } .bar.high .fill { background: var(--good); }
.bar.clickable { cursor: pointer; border-radius: 6px; padding: 4px; margin: -4px; }
.bar.clickable:hover { background: var(--soft); }
.bar.clickable:hover .lbl span:first-child { text-decoration: underline; }

/* ---------- papers ---------- */
.folder { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); margin: 10px 0; overflow: hidden; }
.folder summary { cursor: pointer; padding: 14px 18px; display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; list-style: none; }
.folder summary::-webkit-details-marker { display: none; }
.folder summary::after { content: "›"; color: var(--muted); margin-left: 10px; transition: transform .15s; }
.folder[open] summary::after { transform: rotate(90deg); }
.folder summary > span:first-child { flex: 1; }
.prow { display: flex; gap: 14px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--rule); color: var(--ink); }
.prow:hover { background: var(--soft); text-decoration: none; }
.prow .yr { font-weight: 700; width: 48px; }
.prow .tag { margin-left: auto; }
.tag { font-family: var(--pen); color: var(--marker); font-size: 1.05rem; white-space: nowrap; }
.paper-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 6px; }
.pa { flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; padding: 14px 16px; border-radius: var(--r-lg); gap: 3px; }
.pa strong { color: var(--biro); }
.pa:first-child { background: var(--biro); border-color: var(--biro); }
.pa:first-child strong { color: #fff; }
.qcard { scroll-margin-top: 150px; }
.qcard .row { margin-bottom: 0; }

/* ---------- exam ---------- */
.exambar { position: sticky; top: 57px; z-index: 6; background: var(--bg); border-bottom: 1px solid var(--rule);
  padding: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.exambar .row { margin: 0; }
.clock { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.clock.warn { color: var(--warn); } .clock.bad { color: var(--marker); }
.jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.jump button { padding: 3px 9px; font-size: .8rem; border-radius: 999px; }
.jump button.done { background: var(--hl); border-color: var(--hl-edge); }

/* ---------- lost marks, automarker ---------- */
.lost { border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; margin: 10px 0; background: var(--paper); }
.lost p { margin: 0 0 8px; }
.lost .chips, .chips.small { margin-bottom: 8px; }
.chips button { padding: 7px 12px; font-size: .9rem; border-radius: 999px; }
.lost .chips button.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chips button.tagged { background: var(--hl); border-color: var(--hl-edge); }
.automark { border-style: dashed; border-width: 2px; }
.automark .row input[type=file] { flex: 1; min-width: 0; margin: 0; }
.ai-note { background: var(--biro-soft); padding: 9px 12px; border-radius: var(--r); font-size: .92rem; margin: 8px 0; }

/* ---------- tables, admin ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--paper); border-radius: var(--r); }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--rule); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td .link { color: var(--bad); font-size: .85rem; }
#exam-history { border: 1px solid var(--rule); border-collapse: separate; border-spacing: 0; overflow: hidden; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; max-height: 320px; overflow-y: auto; border-top: 1px solid var(--rule); }
ul.plain li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: .9rem; }
ul.plain li .link { color: var(--bad); font-size: .85rem; }
code { background: var(--hover); padding: 2px 6px; border-radius: 4px; }

.loading { position: fixed; top: 0; left: 0; height: 3px; width: 40%; background: var(--biro); z-index: 50; animation: load 1s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* focus mode: no main nav while answering */
body.focus .mainnav, body.focus .top-right { display: none; }
body.focus .top-in { justify-content: flex-start; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .actions { grid-template-columns: 1fr; }
  .paper-actions { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; gap: 18px; min-height: 0; }
  .auth-h { font-size: 1.9rem; background-image: repeating-linear-gradient(transparent 0 2.05rem, var(--rule) 2.05rem calc(2.05rem + 1px)); }
}
@media (max-width: 640px) {
  h1 { font-size: 1.55rem; } .hello { font-size: 1.75rem; }
  .top-in { gap: 10px; padding: 8px 12px; }
  .top { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .mainnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0;
    background: var(--top-bg); backdrop-filter: blur(8px); border-top: 1px solid var(--rule); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mainnav a { flex-direction: column; gap: 2px; font-size: .72rem; padding: 4px 10px; }
  .mainnav a.on { background: none; box-shadow: none; color: var(--biro); }
  .mainnav svg { width: 22px; height: 22px; }
  main { padding-bottom: 96px; }
  footer { padding-bottom: 90px; }
  .startbar { bottom: 74px; }
  .opt { flex-direction: column; align-items: flex-start; }
  .choices button { flex: 1; }
  .exambar { top: 53px; }
  .exambar .examtitle { display: none; }
  .clock { font-size: 1.6rem; }
  #exam-history th:nth-child(4), #exam-history td:nth-child(4) { display: none; }
  .keys { display: none; }
}

/* ---------- papers as first-page thumbnails ---------- */
.pschool { margin: 22px 0 6px; }
.pschool h2 { font-size: 1rem; margin-bottom: 10px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px; }
.ptile { display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
.ptile:hover { text-decoration: none; }
.pthumb { position: relative; aspect-ratio: 1 / 1.414; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(30,36,48,.06); transition: transform .12s, box-shadow .12s; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: .8rem; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.ptile:hover .pthumb { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(30,36,48,.12); border-color: var(--rule-strong); }
.ptile:focus-visible .pthumb { outline: 3px solid var(--biro); }
.pthumb .tag { position: absolute; right: 6px; bottom: 6px; background: var(--paper); border-radius: 999px; padding: 0 8px; box-shadow: 0 1px 3px rgba(30,36,48,.15); }
.pname { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 0 2px; }

@media (max-width: 640px) { .pgrid { grid-template-columns: repeat(3, 1fr); gap: 10px; } .pname .small { display: none; } }
.hint { margin-top: 4px; }

/* ---------- home: one next step, then quieter options ---------- */
.hello { margin-bottom: 0; }
#home-sub { margin: 2px 0 18px; }
.next { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 30px 30px 26px;
  box-shadow: 0 2px 4px rgba(30,36,48,.04), 0 12px 32px rgba(30,36,48,.08); }
.next h2 { font-size: 1.9rem; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; margin: 0 0 6px; }
.next > p.muted { font-size: 1.02rem; margin: 0 0 20px; }
.next-go { font-size: 1.05rem; padding: 13px 34px; border-radius: var(--r); }
.mini { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: .88rem; color: var(--muted); }
.mini-item { display: inline-flex; align-items: center; gap: 7px; }
.mini .num { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700; border: 1.5px solid var(--rule); color: var(--muted); }
.mini-item.done .num { background: var(--good); border-color: var(--good); color: #fff; }
.mini-item.done { color: var(--ink); }
.mini #onboard-hide { margin-left: auto; color: var(--muted); }
.ob-subjects { display: inline-flex; gap: 4px; }
.ob-subjects button { padding: 2px 9px; font-size: .78rem; border-radius: 999px; }
.ob-subjects button.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.others { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-top: 14px; border: 1px solid var(--rule); border-radius: var(--r-lg); background: transparent; overflow: hidden; }
.other { display: block; padding: 0; color: var(--ink); }
.other + .other { border-left: 1px solid var(--rule); }
.other > summary, a.other { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; cursor: pointer; list-style: none; }
.other > summary::-webkit-details-marker { display: none; }
.other > summary:hover, a.other:hover { background: var(--paper); text-decoration: none; }
.other[open] > summary { background: var(--paper); }
.other strong { font-weight: 600; }
.other-body { padding: 4px 18px 16px; background: var(--paper); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.other-body select { margin: 0; }
.other-body .options { width: 100%; gap: 6px; }
.hint { background: var(--hl); border-radius: var(--r); padding: 8px 12px; margin: 4px 0 10px; }
h2.sec { color: var(--muted); font-size: .95rem; font-weight: 600; margin-top: 34px; }
@media (max-width: 640px) {
  .next { padding: 22px 20px; }
  .next h2 { font-size: 1.5rem; }
  .next-go { width: 100%; }
  .others { grid-template-columns: 1fr; }
  .other + .other { border-left: 0; border-top: 1px solid var(--rule); }
}
.preview-bar { background: var(--ink); color: var(--on-ink); text-align: center; font-size: .88rem; padding: 7px 12px; }
.preview-bar .link { color: var(--hl); margin-left: 10px; }

/* ---------- spotlight tour ---------- */
.tour-wall { position: fixed; z-index: 1000; background: rgba(17,20,28,.68); }
.tour-spot { position: fixed; z-index: 1001; border-radius: 10px; pointer-events: none; box-shadow: 0 0 0 3px #fff, 0 0 0 7px color-mix(in srgb, var(--biro) 55%, transparent); animation: tourpulse 1.6s ease-in-out infinite; }
@keyframes tourpulse { 50% { box-shadow: 0 0 0 3px #fff, 0 0 0 12px color-mix(in srgb, var(--biro) 25%, transparent); } }
.tour-tip { position: fixed; z-index: 1002; background: var(--paper); color: var(--ink); border-radius: var(--r-lg); padding: 14px 16px 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.tour-tip p { margin: 0 0 10px; font-size: 1rem; font-weight: 700; line-height: 1.35; }
.tour-row { display: flex; align-items: center; gap: 12px; }
.tour-n { font-size: .8rem; color: var(--muted); margin-right: auto; }
.tour-skip { color: var(--muted); font-size: .88rem; }
@media (prefers-reduced-motion: reduce) { .tour-spot { animation: none; } }

/* ---------- subject picker ---------- */
.modal { position: fixed; inset: 0; z-index: 900; background: rgba(17,20,28,.55); display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--paper); border-radius: var(--r-lg); padding: 24px; width: min(460px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-card h2 { font-size: 1.35rem; margin-bottom: 14px; }
.subj-grid { display: grid; gap: 6px; max-height: min(52vh, 420px); overflow-y: auto; padding: 2px; }
#subj-search { margin: 0 0 10px; }
.subj { justify-content: flex-start; padding: 10px 14px; font-size: .95rem; font-weight: 500; border-radius: var(--r); text-align: left; }
.subj > span:first-child { flex: 1; }
.subj .ready { font-size: .75rem; font-weight: 700; color: var(--good); }
.subj .soon-tag { font-size: .75rem; color: var(--muted); }
.subj::before { content: ""; width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--rule); margin-right: 4px; flex: none; }
.subj.on { border-color: var(--biro); background: var(--biro-soft); }
.subj.on::before { background: var(--biro); border-color: var(--biro); box-shadow: inset 0 0 0 3px var(--biro-soft); }
.soon-label { margin: 10px 0 0; min-height: 1.2em; }
.tour-tip.center { text-align: center; padding: 26px 22px 22px; }
.tour-tip.center p { font-size: 1.4rem; font-weight: 800; margin-bottom: 16px; }

.subject { position: relative; background: none; padding: 0; border-radius: 0; }
.subj-btn { gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--hover); border: 0; font-size: .875rem; font-weight: 600; color: var(--ink); max-width: 44vw; }
.subj-btn:hover { background: var(--rule); }
.subj-btn .caret { width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); flex: none; }
.subj-menu { top: 42px; right: 0; max-height: 64vh; overflow-y: auto; width: 270px; padding: 6px; }
.subj-menu .menu-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-sm);
  white-space: nowrap; font-size: .92rem; font-weight: 500; color: var(--ink); background: none; border: 0; }
.subj-menu .menu-item > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.subj-menu .menu-item:hover { background: var(--bg); }
.subj-menu .menu-item.on { background: var(--biro-soft); font-weight: 700; }
.subj-menu .cur { width: 8px; height: 8px; border-radius: 50%; background: var(--biro); font-size: 0; flex: none; }
.subj-menu .group { font-size: .75rem; font-weight: 600; color: var(--muted); padding: 10px 12px 4px; margin-top: 4px; border-top: 1px solid var(--rule); }
.subj-menu .menu-item.soon { color: var(--muted); font-weight: 400; }
.subj-menu .add-subj { margin-top: 6px; border-top: 1px solid var(--rule); border-radius: 0; padding-top: 12px; color: var(--biro); font-weight: 600; justify-content: flex-start; }
.subj-btn:focus:not(:focus-visible) { outline: none; }
.soon-card { text-align: center; width: min(320px, 100%); }
.soon-card p { margin: 0 0 16px; }

.field-label { font-size: .9rem; color: var(--muted); margin: 14px 0 8px; }
#subj-name { margin-top: 4px; }
.checkup { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--paper); border: 1px dashed var(--rule-strong); border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 12px; }
.checkup > div { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 640px) { .checkup { flex-direction: column; align-items: stretch; } }

.chip.notlearnt { opacity: .5; text-decoration: line-through; }
.chip.notlearnt.on { opacity: 1; text-decoration: none; }
.muted-link { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 950; background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: var(--r); font-size: .92rem; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.toast .link { color: var(--hl); margin-left: 10px; }
@media (max-width: 640px) { .toast { bottom: 84px; } }
.confirm-row { justify-content: center; margin-top: 16px; }
.confirm-row button { min-width: 90px; }

/* =====================================================================
   Brand layer: chunky, bouncy, friendly. Everything below overrides the base.
   ===================================================================== */
html, body { font-weight: 600; }
body { background-color: var(--bg); min-height: 100vh; }
h1, h2, h3, .brand, .big-number, .clock, .hello { font-family: var(--display); font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; line-height: 1.1; }
h2 { font-size: 1.2rem; line-height: 1.2; }
.muted { font-weight: 600; }
::selection { background: var(--hl); }

/* backgrounds a student can pick */
:root[data-bg="dots"] body { background-image: radial-gradient(var(--rule-strong) 1.3px, transparent 1.6px); background-size: 22px 22px; }
:root[data-bg="grid"] body { background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px); background-size: 26px 26px; }
:root[data-bg="lined"] body { background-image: repeating-linear-gradient(transparent 0 31px, color-mix(in srgb, var(--biro) 22%, transparent) 31px 32px); }
:root[data-bg="photo"] body { background-image: linear-gradient(var(--veil), var(--veil)), var(--bg-photo, none); background-size: cover; background-position: center; background-attachment: fixed; }

/* header */
.top { background: var(--top-bg); border-bottom: 2px solid var(--rule); }
.brand { font-size: 1.55rem; color: var(--biro); line-height: 1; letter-spacing: -.03em; }
.brand:hover { transform: rotate(-2deg) scale(1.03); }
.brand { transition: transform .15s; }
.mainnav a { font-family: var(--display); font-weight: 700; font-size: 1rem; border-radius: var(--r-sm); border: 2px solid transparent; padding: 6px 12px; }
.mainnav a:hover { background: var(--hover); }
.mainnav a.on { background: var(--biro-soft); color: var(--biro); box-shadow: none; border-color: color-mix(in srgb, var(--biro) 35%, transparent); }
.mainnav svg { stroke-width: 2.4; }
.avatar { width: 40px; height: 40px; background: var(--biro); color: #fff; font-family: var(--display); font-size: 1rem; overflow: hidden;
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px color-mix(in srgb, var(--biro) 40%, transparent); transition: transform .15s; }
.avatar:hover { transform: scale(1.06); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.menu { border: 2px solid var(--rule); border-radius: var(--r); box-shadow: 0 12px 32px var(--shadow); animation: drop .16s ease-out; }
.menu-item, .menu a { font-weight: 700; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* chunky press-down buttons */
button, .button { border: 2px solid var(--rule); border-radius: var(--r-sm); box-shadow: 0 4px 0 var(--rule); background: var(--paper); color: var(--ink);
  font-family: var(--display); font-weight: 700; font-size: 1rem; padding: 9px 18px 8px; line-height: 1.3;
  transition: transform .08s, box-shadow .08s, filter .15s, background .15s; }
button:hover, .button:hover { border-color: var(--rule-strong); background: var(--soft); }
button:active:not(:disabled), .button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rule); }
.primary, .primary:hover { background: var(--biro); border-color: var(--biro); color: #fff; box-shadow: 0 4px 0 var(--biro-dark); }
.primary:hover { filter: brightness(1.07); }
.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--biro-dark); }
.ghost { box-shadow: none; }
button:disabled { box-shadow: 0 4px 0 var(--rule); }
/* things that are buttons in code but should stay flat */
.link, .li, .menu-item, .avatar, .subj-btn, .seg button, .subj-menu .menu-item, .tour-skip, .tour-tip .link, .toast button, .preview-bar button,
.link:active, .li:active, .menu-item:active, .seg button:active { box-shadow: none !important; transform: none; }
.link { font-family: inherit; font-weight: 700; border: 0; padding: 0; background: none !important; }
.li { border: 0; border-bottom: 2px solid var(--rule); font-family: var(--font); }
.li strong { font-family: var(--display); font-size: 1.05rem; }
.menu-item { border: 0; }
.avatar { border: 0; padding: 0; }

/* inputs */
input, select, textarea { border: 2px solid var(--rule); border-radius: var(--r-sm); background: var(--soft); font-weight: 600; padding: 11px 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--biro); background: var(--paper); }

/* cards */
.card, .list, .folder, .action, .lost, .startbar, .checkup, .others, .modal-card, .tour-tip { border: 2px solid var(--rule); border-radius: var(--r-lg); }
.card { box-shadow: 0 3px 0 var(--rule); }
.card.question { background: var(--paper); }
.card.question img, .card.scroll img { background: #fff; border-radius: 10px; }
:root[data-theme="dark"] .card.question, :root[data-theme="dark"] .card.scroll { background: #f4f2ec; border-color: #f4f2ec; box-shadow: 0 3px 0 #0b0c0f; }
.list { box-shadow: 0 3px 0 var(--rule); }

/* home hero: the one bold, coloured thing on the page */
.hello { font-size: 2.3rem; }
.next { position: relative; overflow: hidden; background: var(--biro); color: #fff; border: 0; border-radius: 26px; padding: 30px 34px 28px;
  box-shadow: 0 6px 0 var(--biro-dark); display: grid; grid-template-columns: 1fr auto; column-gap: 20px; align-items: center; }
.next > *:not(.next-mascot) { grid-column: 1; }
.next h2 { color: #fff; font-size: 2.2rem; }
.next > p.muted, .next .muted { color: rgba(255,255,255,.88); }
.next .primary.next-go { background: #fff; color: var(--biro); border-color: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.22); font-size: 1.2rem; padding: 13px 38px 11px; justify-self: start; }
.next .primary.next-go:active { box-shadow: 0 1px 0 rgba(0,0,0,.22); }
.next .error { color: #fff; background: rgba(0,0,0,.18); border-radius: 8px; padding: 4px 8px; }
.next .mini { border-top-color: rgba(255,255,255,.28); color: rgba(255,255,255,.88); }
.next .mini a, .next .mini .link { color: #fff; }
.next .mini .num { border-color: rgba(255,255,255,.6); color: #fff; }
.next .mini-item.done .num { background: #fff; color: var(--biro); border-color: #fff; }
.next .mini-item.done { color: #fff; }
.next .ob-subjects button { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.35); box-shadow: none; }
.next .ob-subjects button.on { background: #fff; color: var(--biro); }
.next::before { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.08); }
.next-mascot { grid-column: 2; grid-row: 1 / span 6; width: 170px; align-self: end; margin: -10px -6px -30px 0; position: relative; }
.others { border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 3px 0 var(--rule); }
.other + .other { border-left: 2px solid var(--rule); }
.other strong { font-family: var(--display); font-weight: 700; font-size: 1.08rem; }
.other > summary:hover, a.other:hover { background: var(--soft); }
.checkup { border: 2px dashed var(--rule-strong); background: var(--paper); }
.checkup strong { font-family: var(--display); font-size: 1.08rem; }
h2.sec { font-family: var(--display); color: var(--ink); font-size: 1.3rem; font-weight: 800; }

/* practise */
.chip, .chips button { border-radius: 999px; box-shadow: 0 3px 0 var(--rule); padding: 6px 14px 5px; font-size: .95rem; }
.chip.on, .chips button.tagged { background: var(--biro-soft); border-color: var(--biro); color: var(--biro); box-shadow: 0 3px 0 var(--biro); animation: pop .22s ease-out; }
.chip.on .n { color: var(--biro); }
.lost .chips button.on { background: var(--biro); border-color: var(--biro); color: #fff; box-shadow: 0 3px 0 var(--biro-dark); }
.seg { border: 2px solid var(--rule); border-radius: var(--r-sm); }
.seg button { border-right: 2px solid var(--rule); font-size: .95rem; }
.seg button.on { background: var(--biro); color: #fff; }
.startbar { box-shadow: 0 8px 24px var(--shadow); }

/* answering */
.progress { height: 16px; background: var(--hover); border-radius: 999px; }
.progress div { background: var(--good); border-radius: 999px; position: relative; transition: width .45s cubic-bezier(.3,1.5,.5,1); }
.progress div::after { content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.35); }
.choices button { min-width: 66px; font-size: 1.25rem; padding: 12px 20px 10px; }
.choices button.correct { background: var(--good-soft); border-color: var(--good); color: var(--good); box-shadow: 0 4px 0 var(--good); animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
.choices button.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); box-shadow: 0 4px 0 var(--bad); animation: shake .4s; }
.choices button.picked { outline: 3px solid var(--biro); outline-offset: 2px; }
.verdict { display: flex; align-items: center; gap: 12px; animation: pop .3s cubic-bezier(.3,1.6,.5,1); font-size: 1.6rem; }
.verdict .vm { width: 72px; flex: none; }
.verdict.good { color: var(--good); } .verdict.bad { color: var(--bad); }

/* results */
.summary-hero { display: flex; align-items: center; gap: 18px; }
.summary-hero .sm-mascot { width: 140px; flex: none; }
.score-mark { animation: stamp .55s cubic-bezier(.2,1.6,.4,1) both; animation-delay: .15s; }
.bar .track { height: 14px; border-radius: 999px; background: var(--hover); }
.bar .fill { border-radius: 999px; transform-origin: left; animation: grow .9s cubic-bezier(.2,.9,.3,1) both; }
.bar .lbl span:first-child { font-family: var(--display); font-weight: 700; }

/* papers */
.pthumb { border: 2px solid var(--rule); border-radius: 12px; box-shadow: 0 3px 0 var(--rule); }
.ptile:hover .pthumb { transform: translateY(-4px) rotate(-1.2deg); box-shadow: 0 8px 0 var(--rule); border-color: var(--rule-strong); }
.pname strong { font-family: var(--display); }
.pa { box-shadow: 0 4px 0 var(--rule); }
.pa:first-child { box-shadow: 0 4px 0 var(--biro-dark); }

/* modals, tour, toast */
.modal { background: rgba(10,12,16,.55); animation: fade .15s ease-out; }
.modal-card { box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .28s cubic-bezier(.3,1.5,.5,1); }
.subj { box-shadow: 0 3px 0 var(--rule); }
.subj.on { box-shadow: 0 3px 0 var(--biro); }
.subj-btn { background: var(--hover); font-family: var(--display); font-weight: 700; font-size: .95rem; }
.subj-btn:hover { background: var(--rule); }
.tour-tip { border: 0; }
.tour-tip p { font-family: var(--display); font-size: 1.1rem; }
.tour-mascot { width: 150px; margin: -70px auto 4px; display: block; }
.toast { border-radius: var(--r); font-weight: 700; animation: rise .25s cubic-bezier(.3,1.5,.5,1); }

/* page-to-page motion */
.view:not([hidden]) { animation: rise .32s cubic-bezier(.2,.9,.3,1); }

/* the mascot */
.mascot { display: block; width: 100%; aspect-ratio: 1; position: relative; }
.mascot img { display: block; width: 100%; height: 100%; object-fit: contain; transform-origin: 50% 100%; user-select: none;
  animation: m-in .45s cubic-bezier(.3,1.6,.5,1) both, m-idle 3.4s ease-in-out .45s infinite; }
.mascot.wave img { animation: m-in .45s cubic-bezier(.3,1.6,.5,1) both, m-wave 2.4s ease-in-out .45s infinite; }
.mascot.cheer img { animation: m-in .4s cubic-bezier(.3,1.6,.5,1) both, m-jump .55s cubic-bezier(.3,1.4,.5,1) .4s 3 alternate, m-idle 3s ease-in-out 2.1s infinite; }
.mascot.sad img { animation: m-slump .6s ease-out both, m-idle 4s ease-in-out .6s infinite; }
.mascot.think img { animation: m-in .45s ease-out both, m-ponder 4s ease-in-out .45s infinite; }
.mascot.proud img { animation: m-in .45s cubic-bezier(.3,1.6,.5,1) both, m-idle 3.4s ease-in-out .45s infinite; }
@keyframes m-in { from { opacity: 0; transform: translateY(14px) scale(.85); } }
@keyframes m-idle { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.012, .985) translateY(1px); } }
@keyframes m-wave { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-3deg); } 40% { transform: rotate(2.5deg); } 60% { transform: rotate(-2deg); } 80% { transform: rotate(0); } }
@keyframes m-jump { 0% { transform: scale(1.06, .92); } 100% { transform: translateY(-16px) scale(.97, 1.04); } }
@keyframes m-slump { 0% { opacity: 0; transform: translateY(-8px); } 60% { opacity: 1; transform: translateY(3px) scale(1.02, .96); } 100% { transform: none; } }
@keyframes m-ponder { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-2.5deg); } }

/* personalise */
.me-card { width: min(520px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.me-top { display: flex; align-items: center; gap: 16px; }
.me-top .avatar { width: 76px; height: 76px; font-size: 1.7rem; flex: none; }
.me-top .row { margin: 0; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 42px; height: 42px; padding: 0; border-radius: 50%; border: 0; background: var(--sw); box-shadow: 0 4px 0 color-mix(in srgb, var(--sw) 70%, #000); }
.swatch:hover { background: var(--sw); filter: brightness(1.08); }
.swatch.on { outline: 3px solid var(--ink); outline-offset: 3px; }
.bgs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.bgopt { flex-direction: column; gap: 6px; padding: 6px 6px 8px; font-size: .82rem; }
.bgopt i { display: block; width: 100%; aspect-ratio: 4/3; border-radius: 8px; background-color: var(--bg); border: 2px solid var(--rule); background-size: cover; background-position: center; }
.bgopt.on { border-color: var(--biro); box-shadow: 0 4px 0 var(--biro); color: var(--biro); }
.bgopt[data-v="dots"] i { background-image: radial-gradient(var(--rule-strong) 1.3px, transparent 1.6px); background-size: 9px 9px; }
.bgopt[data-v="grid"] i { background-image: linear-gradient(var(--rule-strong) 1px, transparent 1px), linear-gradient(90deg, var(--rule-strong) 1px, transparent 1px); background-size: 9px 9px; }
.bgopt[data-v="lined"] i { background-image: repeating-linear-gradient(transparent 0 8px, color-mix(in srgb, var(--biro) 40%, transparent) 8px 9px); }
.bgopt[data-v="photo"] i { display: grid; place-items: center; font-style: normal; font-size: 1.4rem; color: var(--muted); }
@media (max-width: 520px) { .bgs { grid-template-columns: repeat(3, 1fr); } }

/* confetti */
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 3px; z-index: 2000; pointer-events: none; animation: fall var(--d, 1.6s) cubic-bezier(.25,.6,.5,1) forwards; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes stamp { 0% { opacity: 0; transform: scale(2.2) rotate(-14deg); } 100% { opacity: 1; transform: scale(1) rotate(-4deg); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes jump { to { transform: translateY(-14px); } }
@keyframes sway { 50% { transform: rotate(-3deg); } }
@keyframes wave { 50% { transform: rotate(-28deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes fall { to { transform: translate(var(--x, 0), 105vh) rotate(var(--r, 540deg)); opacity: .9; } }

@media (max-width: 640px) {
  .next { grid-template-columns: 1fr; padding: 24px 22px 22px; }
  .next-mascot { position: absolute; right: 2px; top: 14px; width: 92px; margin: 0; }
  .next h2 { font-size: 1.7rem; padding-right: 84px; }
  .next > p.muted { padding-right: 84px; }
  .next .primary.next-go { width: 100%; }
  .other + .other { border-left: 0; border-top: 2px solid var(--rule); }
  .summary-hero .sm-mascot { width: 96px; }
  .mainnav { background: var(--top-bg); border-top: 2px solid var(--rule); }
  .mainnav a { border: 0; }
  .mainnav a.on { background: none; }
}
@media (prefers-reduced-motion: reduce) { .mascot *, .view, .confetti { animation: none !important; } }

/* sign-in page */
.auth-mascot { width: 150px; margin: 0 0 6px -10px; }
.auth-brand { font-family: var(--display); color: var(--biro); font-size: 2rem; letter-spacing: -.03em; line-height: 1; margin: 0 0 12px; }
.auth-h { background-image: none; font-size: 2.6rem; }
@media (max-width: 760px) { .auth-mascot { width: 110px; } .auth-h { font-size: 2rem; } }
.avatar { display: inline-grid; place-items: center; line-height: 1; }

/* image mascot sizing: natural proportions, cropped where space is tight */
.mascot { aspect-ratio: auto; }
.mascot img { height: auto; }
.next-mascot { width: 150px; height: 240px; overflow: hidden; align-self: stretch; margin: -30px -12px -28px 0; }
.next-mascot .mascot { margin-top: 18px; }
.summary-hero .sm-mascot { width: 110px; }
.auth-mascot { width: 110px; }
.tour-mascot { width: 96px; margin: -96px auto 6px; }
.verdict .vm { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; background: var(--soft); border: 2px solid var(--rule); }
.verdict .vm { position: relative; }
.verdict .vm .mascot { position: absolute; inset: 0; width: auto; }
.verdict .vm .mascot img { position: absolute; height: 150px; width: auto; max-width: none; left: 30px; top: 2px; transform: translateX(calc(var(--hx) * -100%)); }
@media (max-width: 640px) {
  .next-mascot { position: absolute; right: 8px; top: 12px; width: 80px; height: 104px; margin: 0; }
  .next-mascot .mascot { margin-top: 0; }
  .summary-hero .sm-mascot { width: 80px; }
}
.verdict .vm .mascot img { animation: none !important; }
.verdict .vm { animation: pop .35s cubic-bezier(.3,1.6,.5,1); }

/* sprite mascot: real frames, so no whole-body wobble */
.mascot.sprite { display: block; width: 100%; aspect-ratio: 224 / 317; background-repeat: no-repeat; animation: m-in .4s cubic-bezier(.3,1.6,.5,1) both; }
.mascot img { animation: m-in .45s cubic-bezier(.3,1.6,.5,1) both !important; }
.next-mascot { width: 170px; height: 250px; }
.next-mascot .mascot { margin-top: 12px; }
.verdict .vm .mascot.sprite { position: absolute; width: auto; height: 150px; left: 30px; top: 2px; right: auto; bottom: auto; transform: translateX(-50%); animation: none; }
@media (max-width: 640px) {
  .next-mascot { width: 80px; height: 104px; }
  .next-mascot .mascot { margin-top: 0; }
}
.mascot.sprite { aspect-ratio: 440 / 686; background: none; position: relative; }
.mascot.sprite .mf { position: absolute; inset: 0; background-repeat: no-repeat; transition-property: opacity; transition-timing-function: ease-in-out; }
.mascot.sprite .mf.hi { z-index: 1; }
/* frames carry headroom for the jump arc; pull the figure up into place */
.next-mascot .mascot { margin-top: -14px; }
.verdict .vm .mascot.sprite { top: -11px; }
.summary-hero .sm-mascot .mascot.sprite, .tour-mascot .mascot.sprite { margin-top: -9%; }
@media (max-width: 640px) { .next-mascot .mascot { margin-top: -10px; } }

/* ---------- paper tabs and PDF preview ---------- */
.tabs { display: flex; gap: 4px; margin: 16px 0 14px; border-bottom: 2px solid var(--rule); }
.tabs button { border: 0; box-shadow: none !important; background: none; border-radius: 12px 12px 0 0; padding: 10px 18px 9px; margin-bottom: -2px;
  color: var(--muted); border-bottom: 3px solid transparent; font-size: 1.02rem; }
.tabs button:hover { background: var(--hover); color: var(--ink); }
.tabs button:active { transform: none; }
.tabs button.on { color: var(--biro); border-bottom-color: var(--biro); }
.tabpane { animation: rise .25s ease-out; }
.pdfbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 12px; }
.pdfview { display: flex; flex-direction: column; gap: 14px; }
.pdfpage { width: 100%; background: #fff; border-radius: 10px; border: 2px solid var(--rule); box-shadow: 0 3px 0 var(--rule); overflow: hidden; }
.pdfpage canvas { display: block; width: 100%; height: auto; }
.pdf-wait { padding: 40px 0; text-align: center; }
.pa { gap: 4px; }
.pa .muted { font-weight: 600; }
.pa:first-child .muted { color: rgba(255,255,255,.85); }
@media (max-width: 640px) { .tabs button { flex: 1; padding: 10px 6px 9px; } .pdfbar .primary { flex: none; } }

/* ---------- daily streak flame ---------- */
.top-right { position: relative; }
.streak { width: 36px; height: 42px; padding: 0; border: 0; background: none !important; box-shadow: none !important; display: grid; place-items: center; }
.streak:active { transform: scale(.94) !important; }
.streak svg, .sp-flame svg, .toast-flame svg { width: 100%; height: 100%; overflow: visible; }
.fo { fill: #ff9600; } .fi { fill: #ffc800; }
svg.out .fo { fill: var(--rule-strong); } svg.out .fi { fill: var(--hover); }
.streak .fl, .sp-flame .fl { transform-origin: 16px 37px; animation: flicker 2.6s ease-in-out infinite; }
svg text { font-family: var(--display); font-weight: 800; font-size: 13px; fill: #fff; paint-order: stroke; stroke: #d96f00; stroke-width: 2.6px; stroke-linejoin: round; }
svg.out text { stroke: var(--muted); }
.streak.bump svg { animation: flame-pop .8s cubic-bezier(.3,1.7,.5,1); }
@keyframes flicker { 0%, 100% { transform: scale(1, 1) skewX(0); } 30% { transform: scale(.98, 1.05) skewX(-2deg); } 65% { transform: scale(1.02, .97) skewX(1.5deg); } }
@keyframes flame-pop { 0% { transform: scale(.4) rotate(-12deg); } 55% { transform: scale(1.35) rotate(6deg); } 100% { transform: none; } }
.streak-pop { position: absolute; top: 50px; right: 40px; z-index: 40; width: 270px; background: var(--paper); border: 2px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 12px 32px var(--shadow); padding: 14px; animation: drop .16s ease-out; }
.sp-top { display: flex; gap: 12px; align-items: center; }
.sp-top > div { display: flex; flex-direction: column; gap: 2px; }
.sp-top strong { font-family: var(--display); font-size: 1.2rem; }
.sp-flame { width: 46px; height: 54px; flex: none; }
.sp-flame text { font-size: 12px; }
.sp-week { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--rule); }
.sp-week span { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.sp-week i { width: 22px; height: 22px; border-radius: 50%; background: var(--hover); border: 2px solid var(--rule); }
.sp-week .hit i { background: #ff9600; border-color: #e07f00; }
.sp-week .today { color: var(--ink); }
.toast-flame { display: inline-block; width: 22px; height: 26px; vertical-align: middle; margin-right: 8px; }
@media (max-width: 640px) { .streak-pop { right: 0; } }
@media (prefers-reduced-motion: reduce) { .streak .fl, .sp-flame .fl, .streak.bump svg { animation: none; } }

/* ---------- difficulty badges: signal bars, easy to impossible ---------- */
.lvl { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 999px; font-family: var(--display); font-size: .8rem;
  vertical-align: middle; line-height: 1.2; background: var(--lv-soft); color: var(--lv); border: 2px solid color-mix(in srgb, var(--lv) 30%, transparent); }
.lvl b { font-weight: 800; }
.lvl .bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; }
.lvl .bars i { width: 4px; border-radius: 2px; background: color-mix(in srgb, var(--lv) 25%, transparent); }
.lvl .bars i:nth-child(1) { height: 5px; } .lvl .bars i:nth-child(2) { height: 8px; } .lvl .bars i:nth-child(3) { height: 11px; } .lvl .bars i:nth-child(4) { height: 14px; }
.lvl .bars i.on { background: var(--lv); }
.lvl-easy { --lv: #1fa45a; --lv-soft: #e1f6e9; }
.lvl-medium { --lv: #d98a00; --lv-soft: #fff3d6; }
.lvl-hard { --lv: #e5484d; --lv-soft: #fdeaea; }
.lvl-impossible { --lv: #8b2fd6; --lv-soft: #f1e6fc; }
.lvl-impossible .bars i.on { animation: lvl-throb 1.6s ease-in-out infinite; }
.lvl-impossible .bars i.on:nth-child(2) { animation-delay: .1s; } .lvl-impossible .bars i.on:nth-child(3) { animation-delay: .2s; } .lvl-impossible .bars i.on:nth-child(4) { animation-delay: .3s; }
@keyframes lvl-throb { 50% { transform: scaleY(.6); } }
:root[data-theme="dark"] .lvl { --lv-soft: color-mix(in srgb, var(--lv) 18%, var(--paper)); }
.pschool h2 { display: flex; align-items: center; gap: 10px; }
.pname { align-items: center; }
.pname .lvl { padding: 3px 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#paper-meta .lvl { margin-right: 6px; }
@media (prefers-reduced-motion: reduce) { .lvl-impossible .bars i.on { animation: none; } }

/* ---------- one page at a time, fitted to the screen ---------- */
.pdfview { display: block; position: relative; }
.pdfstage { position: relative; height: 100%; display: grid; place-items: center; background: var(--soft); border: 2px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.pdfstage canvas { display: block; background: #fff; border-radius: 6px; box-shadow: 0 2px 0 var(--rule), 0 10px 30px var(--shadow); }
.pdfstage canvas.in-next { animation: pg-next .22s ease-out; }
.pdfstage canvas.in-prev { animation: pg-prev .22s ease-out; }
@keyframes pg-next { from { opacity: 0; transform: translateX(28px); } }
@keyframes pg-prev { from { opacity: 0; transform: translateX(-28px); } }
.pdfhit { position: absolute; top: 0; bottom: 0; width: 30%; z-index: 2; border: 0; background: none !important; box-shadow: none !important; border-radius: 0; padding: 0; }
.pdfhit:active { transform: none !important; }
.pdfhit.prev { left: 0; cursor: w-resize; } .pdfhit.next { right: 0; cursor: e-resize; }
.pdfnav { display: flex; align-items: center; gap: 8px; }
.pgbtn { width: 44px; height: 40px; padding: 0; font-size: 1.6rem; line-height: 1; }
.pgnum { min-width: 64px; text-align: center; font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; }
.pdfbar { margin-bottom: 10px; }
#view-paper h1 { margin-bottom: 0; }
#view-paper .tabs { margin: 10px 0 12px; }
@media (max-width: 640px) { .pgbtn { width: 40px; } #view-paper .back { display: none; } }

/* HSC section and badge */
.lvl-hsc { --lv: #b8860b; --lv-soft: #fff6d8; padding: 3px 10px; letter-spacing: .04em; }
.lvl-hsc b { font-weight: 800; }
.pschool.hsc h2 { font-size: 1.25rem; }
.sec-note { font-family: var(--font); font-weight: 600; }
.pschool.hsc .pthumb { border-color: #e9cf4f; box-shadow: 0 3px 0 #e9cf4f; }
.used-up { color: var(--bad) !important; }
.cb-sub { display: block; margin-top: 8px; font-family: var(--font); font-size: .95rem; font-weight: 600; color: var(--muted); line-height: 1.4; }
.confirm-row .link { margin-right: auto; color: var(--muted); }
.soon-card:has(.confirm-row .link) { width: min(440px, 100%); }

/* papers: difficulty filter */
.papers-levels { margin: 12px 0 4px; }

/* practise: topics grouped by syllabus area on the left, the set and Start on the right */
.pr-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.pr-topics { margin: 0; }
.pr-tools { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.pr-tools input { flex: 1; margin: 0; }
.pr-links { white-space: nowrap; }
.tgroup { padding: 14px 0 4px; border-top: 2px dashed var(--rule); margin-top: 12px; }
.tgroup:first-child { border-top: 0; margin-top: 4px; }
.tg-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.tg-head h3 { font-size: 1.02rem; margin: 0; }
.tgroup.later .chip { opacity: .55; }
.tgroup.later .chip.on { opacity: 1; }
.pr-set { position: sticky; top: 84px; margin: 0; display: grid; gap: 14px; }
.pr-set h2 { margin: 0; }
.pr-set #pr-picked { margin: -8px 0 0; min-height: 1.3em; }
.pr-set .options { gap: 12px; }
.pr-set .opt { flex-direction: column; align-items: stretch; gap: 6px; }
.pr-set .seg { display: flex; }
.pr-set .seg button { flex: 1; padding: 8px 4px; }
.pr-set .startbar { position: static; border: 0; box-shadow: none; padding: 0; margin: 0; background: none; flex-direction: column; align-items: stretch; gap: 8px; }
.pr-set .startbar .primary { width: 100%; padding: 14px; font-size: 1.1rem; }
.pr-set #start-summary { text-align: center; color: var(--muted); }
@media (max-width: 900px) {
  .pr-grid { grid-template-columns: 1fr; }
  .pr-set { position: static; }
  .pr-tools { flex-direction: column; align-items: stretch; gap: 8px; }
  #view-practise { padding-bottom: 96px; }
  .pr-set .startbar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 6; background: var(--paper); border: 2px solid var(--rule); border-radius: var(--r-lg); padding: 10px 12px; margin: 0; flex-direction: row; align-items: center; box-shadow: 0 4px 0 var(--rule); }
  .pr-set .startbar .primary { width: auto; padding: 11px 26px; }
}
@media (max-width: 640px) { .pr-set .startbar { bottom: 74px; } #view-practise { padding-bottom: 160px; } }
.tg-all { font-size: .85rem !important; color: var(--muted) !important; }
.tg-all:hover { color: var(--biro) !important; }

/* questions most likely outside the 2024 syllabus */
.syl-flag { display: inline-block; vertical-align: middle; font-family: var(--font); font-size: .75rem; font-weight: 800; line-height: 1;
  padding: 4px 8px; border-radius: 999px; background: #fff4d6; color: #8a5a00; border: 2px solid #f2d27a; white-space: nowrap; }
[data-theme="dark"] .syl-flag { background: #3a2f12; color: #f4d58a; border-color: #6b5520; }
.q-syllabus { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.pr-head { align-items: center; }
.pr-head h1 { margin: 0; }
.syl-card { width: min(560px, 100%); max-height: 86vh; overflow: auto; }
.syl-card h3 { font-size: 1rem; margin: 16px 0 6px; }
.syl-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.pdf-syl { margin: 8px 0 0; display: block; line-height: 1.6; }
.pdf-syl .syl-flag { margin-right: 4px; }

/* admin: engagement stats */
.stats-head { align-items: center; flex-wrap: wrap; gap: 10px; }
.stats-head h2 { margin: 0; }
.stat-hero { display: flex; align-items: baseline; gap: 12px; margin: 14px 0 6px; }
.stat-hero b { font-family: var(--display, var(--font)); font-size: 3.4rem; line-height: 1; color: var(--biro); }
.stat-hero span { font-weight: 700; }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0 18px; }
.stat-tile { border: 2px solid var(--rule); border-radius: var(--r-sm); padding: 10px 12px; display: grid; gap: 2px; }
.stat-tile b { font-size: 1.35rem; }
.stat-tile span { font-size: .85rem; font-weight: 700; }
.stat-tile small { font-size: .78rem; }
.stat-charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.stat-chart { margin: 0; }
.stat-chart figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.sc-wrap { position: relative; padding-left: 28px; }
.sc-max { position: absolute; left: 0; top: -2px; }
.sc-plot { height: 110px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--rule);
  background: linear-gradient(var(--rule) 1px, transparent 1px) 0 0 / 100% 50%; background-blend-mode: normal; }
.sc-col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; }
.sc-col i { display: block; width: 100%; background: var(--biro); border-radius: 4px 4px 0 0; min-width: 2px; }
.sc-col:hover i { filter: brightness(1.15); }
.sc-col:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--ink); color: var(--on-ink, #fff); font-size: .78rem; font-weight: 700; padding: 4px 8px; border-radius: 6px; z-index: 3; pointer-events: none; }
.sc-axis { display: flex; justify-content: space-between; padding-left: 28px; margin-top: 4px; }
.stat-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; margin-top: 20px; }
.stat-list h3 { font-size: .98rem; margin: 0 0 8px; }
.sl-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: .85rem; margin: 5px 0; }
.sl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-bar { height: 8px; background: var(--rule); border-radius: 4px; overflow: hidden; }
.sl-bar i { display: block; height: 100%; background: var(--biro); border-radius: 4px; }
.sl-n { font-variant-numeric: tabular-nums; font-weight: 700; }
.stats-foot { margin-top: 16px; gap: 14px; flex-wrap: wrap; align-items: center; }
.stats-foot label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.stats-foot input[type=checkbox] { width: auto; margin: 0; }
@media (max-width: 640px) { .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* exam timer in the top bar */
.timer-btn { height: 38px; min-width: 38px; padding: 0 8px; border: 2px solid transparent; background: none !important; box-shadow: none !important;
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; color: var(--muted); }
.timer-btn:hover { color: var(--ink); }
.timer-btn.on { border-color: var(--rule); background: var(--paper) !important; color: var(--ink); }
.timer-btn.on b { font-variant-numeric: tabular-nums; font-size: .95rem; }
.timer-btn.reading { color: #b26a00; border-color: #f2d27a; }
.timer-btn.writing { color: var(--biro); border-color: var(--biro); }
.timer-btn.done { color: #fff; background: #e5484d !important; border-color: #e5484d; animation: pop .3s ease-out; }
.timer-btn.paused b { opacity: .55; }
.timer-pop { position: absolute; top: 50px; right: 80px; z-index: 40; width: 300px; background: var(--paper); border: 2px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 12px 32px var(--shadow); padding: 16px; animation: drop .16s ease-out; }
.timer-pop h3 { margin: 0 0 10px; font-size: 1.05rem; }
.tp-presets { margin-bottom: 12px; }
.tp-presets .chip { font-size: .82rem; padding: 5px 10px 4px; }
.tp-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tp-fields label { font-size: .85rem; font-weight: 700; display: grid; gap: 4px; margin: 0; }
.tp-in { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.tp-in input { width: 100%; margin: 0; font-size: 1.1rem; font-weight: 800; text-align: center; padding: 8px 6px; }
.tp-go { width: 100%; padding: 12px; }
.tp-big { font-family: var(--display, var(--font)); font-size: 2.8rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--biro); }
.tp-big.reading { color: #b26a00; }
.tp-big.done { color: #e5484d; font-size: 2rem; }
.tp-bar { height: 8px; background: var(--rule); border-radius: 4px; overflow: hidden; margin: 10px 0 8px; }
.tp-bar i { display: block; height: 100%; background: currentColor; color: var(--biro); border-radius: 4px; transition: width 1s linear; }
.tp-actions { gap: 12px; align-items: center; }
@media (max-width: 640px) { .timer-pop { right: 0; width: min(300px, calc(100vw - 24px)); } .timer-btn.on b { font-size: .85rem; } }
.timer-btn, .timer-btn b, .subj-btn { white-space: nowrap; flex-shrink: 0; }
.tp-big.done + .tp-bar i { background: #e5484d; }

/* release dial */
.feature-off { display: none !important; }
.rel-row { margin: 14px 0; }
.rel-head { display: flex; align-items: baseline; gap: 10px; }
.rel-head b { margin-left: auto; font-size: 1.3rem; color: var(--biro); font-variant-numeric: tabular-nums; }
.rel-row input[type=range] { width: 100%; accent-color: var(--biro); margin: 6px 0 2px; padding: 0; }
.rel-what { margin: 0; min-height: 2.6em; }
.release-note { margin: 6px 0 0; }

/* ---------- online questions (typed, like the online HSC) ---------- */
.ol-prompt { line-height: 1.55; }
.ol-prompt p { margin: 8px 0; }
.ol-prompt pre, .ol-sample pre, .ol-opt pre { background: var(--soft); border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 10px 12px; overflow-x: auto; font: 0.88rem/1.45 ui-monospace, Menlo, Consolas, monospace; margin: 8px 0; white-space: pre; }
.ol-prompt code, .ol-sol code, .ol-test code { font: 0.9em ui-monospace, Menlo, Consolas, monospace; }
.ol-hint { font-weight: 700; margin: 10px 0 4px; }
.ol-opts { display: grid; gap: 8px; margin: 12px 0; }
.ol-opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 10px 12px; font-weight: 400; background: var(--paper); }
.ol-opt .ol-text { flex: 1; min-width: 0; padding-top: 3px; }
.ol-opt .ol-text pre { margin: 0; }
.ol-box { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 2px solid var(--rule); font-weight: 800; background: var(--paper); }
.ol-opts.single .ol-box { border-radius: 50%; }
.ol-opts.multi .ol-box { border-radius: 7px; }
.ol-opt.picked { border-color: var(--ink); }
.ol-opt.picked .ol-box { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.ol-opt.correct { border-color: var(--good); background: var(--good-soft); }
.ol-opt.correct .ol-box { border-color: var(--good); }
.ol-opt.correct.picked .ol-box { background: var(--good); color: #fff; }
.ol-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.ol-opt.wrong .ol-box { background: var(--bad); border-color: var(--bad); color: #fff; }
.ol-match { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin: 12px 0; }
.ol-items { display: grid; gap: 8px; align-content: start; }
.ol-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 2px solid var(--rule); border-radius: var(--r-sm); background: var(--paper); margin: 0; }
.ol-item .ol-text { flex: 1; }
.ol-item select { width: 70px; margin: 0; flex: none; padding: 6px 8px; font-weight: 700; }
.ol-item.correct { border-color: var(--good); background: var(--good-soft); }
.ol-item.wrong { border-color: var(--bad); background: var(--bad-soft); }
.ol-num { font-weight: 800; width: 18px; }
.ol-key { font-weight: 800; color: var(--good); }
.ol-letters { list-style: none; margin: 0; padding: 12px; display: grid; gap: 8px; align-content: start; background: var(--soft); border-radius: var(--r-sm); }
.ol-letters li { display: flex; gap: 10px; align-items: flex-start; }
.ol-letters .ol-box { width: 26px; height: 26px; border-radius: 7px; font-size: .9rem; }
@media (max-width: 640px) { .ol-match { grid-template-columns: 1fr; } }
textarea.ol-written { min-height: 120px; line-height: 1.55; }
textarea.ol-code { font: 0.9rem/1.5 ui-monospace, Menlo, Consolas, monospace; tab-size: 4; white-space: pre; overflow-x: auto; min-height: 160px; }
.ol-run { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ol-tests { margin-top: 8px; }
.ol-sum { font-weight: 800; margin: 6px 0; }
.ol-sum.good { color: var(--good); } .ol-sum.bad { color: var(--bad); }
.ol-test { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 4px 0; font-size: .92rem; }
.ol-test.ok > span:first-child { color: var(--good); font-weight: 800; }
.ol-test.no > span:first-child { color: var(--bad); font-weight: 800; }
.ol-err { color: var(--bad); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
.ol-stdout { background: var(--soft); padding: 8px 10px; border-radius: var(--r-sm); font-size: .85rem; }
.ol-sol { margin-top: 14px; padding: 14px 16px; background: var(--soft); border-radius: var(--r); }
.ol-sol p { margin: 6px 0; }
.ol-crit { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .92rem; }
.ol-crit th, .ol-crit td { border: 1px solid var(--rule); padding: 6px 10px; text-align: left; vertical-align: top; background: var(--paper); }
.ol-crit td:last-child, .ol-crit th:last-child { width: 64px; text-align: center; }
#q-online { margin-top: 2px; }

/* ---------- phones and tablets ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button, select, label, summary, .ol-opt { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* iOS zooms into any field under 16px; keep them at 16px or more */
@supports (-webkit-touch-callout: none) { input, select, textarea { font-size: max(16px, 1em); } }
/* notch and home bar: header clears the status bar in the home-screen app, sides clear the notch in landscape */
.top { padding-top: env(safe-area-inset-top); }
.top-in, main, footer { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
/* iPad portrait and small laptops: the full nav, without crowding the header */
@media (min-width: 641px) and (max-width: 960px) {
  .top-in { gap: 10px; }
  .mainnav { gap: 2px; }
  .mainnav a { padding: 6px 9px; }
  .mainnav svg { display: none; }
  .brand { font-size: 1.35rem; }
}
/* touch screens have no hover: stop hover lifts sticking after a tap */
@media (hover: none) {
  .brand:hover, .avatar:hover { transform: none; }
  .ptile:hover .pthumb { transform: none; box-shadow: none; }
}
/* wide tables scroll sideways inside their card instead of widening the page */
@media (max-width: 760px) { table.tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; } }
/* online questions: code options wrap instead of pushing the page wide */
.ol-opt { min-width: 0; white-space: normal; }
.ol-opt .ol-text { overflow-x: auto; }
.ol-opt pre { white-space: pre-wrap; word-break: break-word; }
@media (max-width: 640px) {
  .ol-opt { padding: 10px; gap: 10px; }
  .ol-prompt pre, .ol-sample pre, .ol-opt pre { font-size: .8rem; }
  textarea.ol-code { font-size: 16px; }
  .ol-crit td, .ol-crit th { padding: 6px 8px; }
}
/* exam question chips: one swipeable row on phones instead of four rows */
@media (max-width: 640px) {
  .jump { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 8px; margin: 8px -2px; -webkit-overflow-scrolling: touch; }
  .jump::-webkit-scrollbar { display: none; }
  .jump button { flex: none; min-width: 36px; min-height: 34px; }
}
@media (display-mode: standalone) { body { overscroll-behavior-y: none; } }

/* ---------- juice: rewards for answering ---------- */
.jz-dot { position: fixed; z-index: 1200; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; pointer-events: none;
  animation: jz-fly .7s cubic-bezier(.15,.8,.3,1) forwards; }
@keyframes jz-fly { 0% { transform: translate(0,0) scale(var(--s)); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }
.jz-float { position: fixed; z-index: 1201; transform: translate(-50%, -50%); pointer-events: none; font: 800 1.5rem/1 var(--display); color: var(--good);
  text-shadow: 0 2px 0 var(--paper), 0 0 12px var(--paper); animation: jz-rise 1.05s cubic-bezier(.2,.8,.3,1) forwards; }
.jz-float.part { color: #e0a100; }
@keyframes jz-rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
.jz-pop { animation: jz-pop .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes jz-pop { 0% { transform: scale(1); } 35% { transform: scale(1.07); } 100% { transform: scale(1); } }
.jz-shake { animation: jz-shake .42s ease-in-out; }
@keyframes jz-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.jz-combo { position: fixed; z-index: 1150; left: 50%; top: calc(74px + env(safe-area-inset-top)); transform: translate(-50%, -140%); opacity: 0;
  display: flex; align-items: center; gap: 6px; padding: 8px 16px 8px 12px; border-radius: 999px; background: var(--ink); color: var(--paper);
  font: 800 1rem/1 var(--display); box-shadow: 0 6px 20px rgba(0,0,0,.18); transition: transform .35s cubic-bezier(.3,1.5,.5,1), opacity .25s; pointer-events: none; }
.jz-combo.on { transform: translate(-50%, 0); opacity: 1; }
.jz-combo b { font-size: 1.2rem; }
.jz-combo svg { width: 20px; height: 20px; fill: #ff8a3d; }
.jz-combo.big { background: linear-gradient(135deg, #ff8a3d, #ffd23f); color: #3a2400; }
.jz-combo.big svg { fill: #c0390b; }
.jz-combo.jz-bump { animation: jz-bump .4s cubic-bezier(.3,1.7,.5,1); }
@keyframes jz-bump { 0% { transform: translate(-50%, 0) scale(1); } 40% { transform: translate(-50%, 0) scale(1.18); } 100% { transform: translate(-50%, 0) scale(1); } }
.jz-stars { display: flex; gap: 8px; margin: 6px 0 2px; }
.jz-star svg { width: 44px; height: 44px; fill: var(--rule); stroke: var(--rule-strong, #cfc9bd); stroke-width: 1; stroke-linejoin: round; display: block; }
.jz-star.lit svg { fill: #ffc531; stroke: #e0a100; animation: jz-star .55s cubic-bezier(.3,1.7,.5,1) both; animation-delay: calc(.3s + var(--i) * .2s); }
@keyframes jz-star { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }
/* a new question slides in */
.card.question.enter, #q-online.enter { animation: jz-enter .35s cubic-bezier(.2,.9,.3,1); }
@keyframes jz-enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
/* the set progress bar springs forward */
#set-bar { transition: width .5s cubic-bezier(.3,1.4,.5,1); }
/* picking an answer feels physical */
.ol-opt.picked .ol-box, .choices button.picked { animation: jz-pop .35s cubic-bezier(.3,1.6,.5,1); }
.choices button.correct { animation: jz-pop .45s cubic-bezier(.3,1.6,.5,1); }
.jump button.done { animation: jz-pop .35s cubic-bezier(.3,1.6,.5,1); }
/* cards lift a touch under the mouse */
@media (hover: hover) {
  .card.qcard, .ptile, .prow { transition: transform .15s, box-shadow .15s; }
  .ptile:hover { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .jz-pop, .jz-shake, .jz-combo, .jz-star.lit svg, .card.question.enter, #q-online.enter, .ol-opt.picked .ol-box, .choices button, .jump button.done { animation: none !important; transition: none !important; }
}
/* ---------- every button: ripple, squish, spring back ---------- */
.jz-rw { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; z-index: 0; }
.jz-rp { position: absolute; border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0); animation: jz-rp .6s cubic-bezier(.2,.7,.3,1) forwards; }
.primary .jz-rp, .pa.primary .jz-rp { background: #fff; opacity: .3; }
@keyframes jz-rp { to { transform: scale(1); opacity: 0; } }
button, .button, a.other, .ol-opt, .pa, .ptile { transition: transform .28s cubic-bezier(.3,1.8,.5,1), box-shadow .2s, background-color .2s, border-color .2s; }
button:active:not(:disabled), .button:active, a.other:active, .ol-opt:active:not(:disabled), .pa:active { transform: translateY(3px) scale(.97); transition-duration: .06s; }
.ptile:active { transform: scale(.96); transition-duration: .06s; }
.mainnav a:active svg { transform: scale(.82); }
.mainnav a svg { transition: transform .3s cubic-bezier(.3,1.8,.5,1); }
.mainnav a.on svg { animation: jz-pop .4s cubic-bezier(.3,1.7,.5,1); }
/* the main call to action breathes so the eye finds it */
.primary.wide, #next:not([hidden]), #check-online:not([hidden]) { animation: jz-breathe 2.4s ease-in-out infinite; }
@keyframes jz-breathe { 0%,100% { box-shadow: 0 4px 0 var(--biro-dark), 0 0 0 0 color-mix(in srgb, var(--biro) 0%, transparent); } 50% { box-shadow: 0 4px 0 var(--biro-dark), 0 0 0 7px color-mix(in srgb, var(--biro) 18%, transparent); } }
@media (prefers-reduced-motion: reduce) { .jz-rp, .mainnav a.on svg, .primary.wide, #next, #check-online { animation: none !important; } }
/* ---------- full-screen transitions ---------- */
.jz-curtain { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; color: #fff; pointer-events: all;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--biro) 78%, #fff), var(--biro) 55%, var(--biro-dark));
  clip-path: circle(0 at var(--x) var(--y)); transition: clip-path .3s cubic-bezier(.6,0,.2,1), transform .32s cubic-bezier(.6,0,.3,1); }
.jz-curtain.in { clip-path: circle(150% at var(--x) var(--y)); }
.jz-curtain.out { transform: translateY(-104%); }
.jz-cin { text-align: center; padding: 24px; transform: translateY(18px) scale(.94); opacity: 0; transition: transform .3s cubic-bezier(.3,1.5,.5,1) .08s, opacity .18s .08s; }
.jz-curtain.in .jz-cin { transform: none; opacity: 1; }
.jz-curtain.out .jz-cin { transform: translateY(-20px); opacity: 0; transition-delay: 0s; }
.jz-cm .mascot { width: 120px; height: auto; margin: 0 auto 6px; display: block; filter: drop-shadow(0 8px 16px rgba(0,0,0,.2)); }
.jz-cm .mascot img { width: 100%; }
.jz-ct { font: 800 clamp(2.4rem, 9vw, 4rem)/1 var(--display); letter-spacing: -.02em; }
.jz-cs { margin-top: 10px; font-weight: 700; font-size: 1.05rem; opacity: .9; }
@media (prefers-reduced-motion: reduce) {
  .jz-curtain { clip-path: none; opacity: 0; transition: opacity .15s; }
  .jz-curtain.in { opacity: 1; } .jz-curtain.out { transform: none; opacity: 0; }
}
/* ---------- page transitions (View Transitions API: Safari 18+, Chrome) ----------
   Going deeper (home -> paper -> set) pushes in from the right like an iPhone app; going back slides the other way.
   Switching tabs is a quick cross-fade. The header and tab bar stay put. */
.has-vt .view:not([hidden]) { animation: none; }
.top { view-transition-name: tb-top; }
@media (max-width: 640px) { .mainnav { view-transition-name: tb-tabs; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .32s; animation-timing-function: cubic-bezier(.22,.8,.24,1); animation-fill-mode: both; }
html[data-vt="forward"]::view-transition-old(root) { animation-name: vt-push-out; }
html[data-vt="forward"]::view-transition-new(root) { animation-name: vt-push-in; }
html[data-vt="back"]::view-transition-old(root) { animation-name: vt-pop-out; z-index: 2; }
html[data-vt="back"]::view-transition-new(root) { animation-name: vt-pop-in; }
html[data-vt="fade"]::view-transition-old(root), html[data-vt="fade"]::view-transition-new(root) { animation-duration: .16s; animation-timing-function: ease-out; }
@keyframes vt-push-in { from { transform: translateX(100%); box-shadow: -12px 0 30px rgba(0,0,0,.12); } to { transform: none; box-shadow: -12px 0 30px rgba(0,0,0,0); } }
@keyframes vt-push-out { to { transform: translateX(-28%); filter: brightness(.94); } }
@keyframes vt-pop-in { from { transform: translateX(-28%); filter: brightness(.94); } to { transform: none; filter: none; } }
@keyframes vt-pop-out { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; } }

/* paper covers: a soft shimmer until the picture arrives, then it fades in */
.pthumb img { transition: opacity .3s ease-out; }
.pthumb.loading img { opacity: 0; }
.pthumb.loading { background: linear-gradient(100deg, var(--paper) 30%, var(--soft) 50%, var(--paper) 70%) 0 0 / 300% 100%; animation: tb-shimmer 1.3s linear infinite; }
@keyframes tb-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .pthumb.loading { animation: none; } }

/* the one remaining dashboard shortcut: auto-marking */
.others.marking { grid-template-columns: 1fr; }

.rel-lite { display: flex; gap: 12px; align-items: flex-start; margin: 12px 0; cursor: pointer; }
.rel-lite input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.rel-lite > span { display: grid; gap: 2px; }

/* ---------- annotation ---------- */
.ann-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: .9rem; font-weight: 700; border-radius: 999px; }
.ann-btn svg, .ann-bar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ann-btn.has:not(.on)::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--biro); }
.ann-btn.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ann-tools { display: flex; justify-content: flex-end; margin: -4px 0 8px; }
.ann-on { position: relative; }
.ann-canvas { position: absolute; left: 0; top: 0; z-index: 5; touch-action: none; cursor: crosshair; }
.ann-space { height: 460px; margin-top: 12px; border-radius: 10px; position: relative;
  background: repeating-linear-gradient(transparent 0 35px, color-mix(in srgb, var(--rule) 90%, transparent) 35px 36px); }
.ann-space span { position: absolute; left: 10px; top: -2px; font-size: .75rem; font-weight: 700; color: var(--muted); }
.ann-bar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1100;
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 999px; background: var(--paper); border: 2px solid var(--rule); box-shadow: 0 10px 30px rgba(20,24,34,.18); max-width: calc(100vw - 16px); overflow-x: auto; }
.ann-bar button { box-shadow: none; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center; }
.ann-bar .ann-sw i { width: 20px; height: 20px; border-radius: 50%; display: block; }
.ann-bar button.on { outline: 2px solid var(--ink); outline-offset: 1px; }
.ann-bar .ann-done { background: var(--ink); color: var(--paper); font-weight: 800; padding: 0 16px; }
.ann-sep { width: 1px; height: 26px; background: var(--rule); margin: 0 2px; flex: none; }
@media (max-width: 640px) { body.annotating .ann-bar { bottom: calc(80px + env(safe-area-inset-bottom)); } }

/* ---------- calculator (ClassWiz look) ---------- */
.calc-btn { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.calc-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* the fx-8200 AU replica: black body, light round keys, blue SHIFT labels, a green-grey LCD */
.cw { --cwk: #e4e5e8; --cwk-ink: #202328; --cwblue: #2f5bd8; --cwlbl: #5b8cff;
  position: fixed; right: 16px; bottom: 16px; z-index: 1050; width: 292px; max-width: calc(100vw - 16px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: auto;
  background: linear-gradient(180deg, #303236, #1f2023 60%, #1a1b1d); color: #fff; border-radius: 30px 30px 34px 34px; padding: 12px 14px 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.12), inset 0 -3px 0 rgba(0,0,0,.4); font-family: var(--font); user-select: none; -webkit-user-select: none; }
.cw[hidden] { display: none; }
.cw-top { display: flex; align-items: flex-start; justify-content: space-between; padding: 2px 6px 6px; cursor: grab; touch-action: none; }
.cw-brand b { display: block; font: 900 1.05rem/1 Arial, Helvetica, sans-serif; letter-spacing: .02em; }
.cw-brand span { display: block; font: 700 .58rem/1.3 Arial, Helvetica, sans-serif; letter-spacing: .06em; opacity: .85; margin-top: 2px; }
.cw-x { box-shadow: none; background: rgba(255,255,255,.1); border: 0; color: #fff; font-size: 1.1rem; width: 26px; height: 26px; padding: 0; border-radius: 50%; line-height: 1; }
.cw-lcdwrap { background: #121315; border-radius: 10px; padding: 7px 7px 3px; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
.cw-lcd { --ink: rgba(18,26,22,.75); background: linear-gradient(180deg, #cfe0d4, #c2d5c8); border-radius: 4px; height: 118px; padding: 2px 6px 4px; color: var(--ink);
  font: 500 13px/1.25 "Segoe UI", Roboto, Helvetica, Arial, sans-serif; overflow: hidden; position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.cw-lcd.off > * { visibility: hidden; }
.cw-wiz { text-align: right; font: 600 .56rem/1.8 Arial, sans-serif; letter-spacing: .32em; color: #9a9da3; padding-right: 4px; }
.cw-status { height: 13px; display: flex; gap: 5px; align-items: center; font: 700 9px/1 Arial, sans-serif; }
.cw-si { display: inline-flex; align-items: center; }
.cw-si.sh, .cw-si.ang { background: var(--ink); color: #c9dbcf; padding: 1px 2px; border-radius: 1px; font-size: 8px; }
.cw-io-m, .cw-io-d { display: inline-block; width: 13px; height: 8px; border: 1px solid currentColor; border-radius: 1px; position: relative; }
.cw-io-m::after { content: ""; position: absolute; left: 2px; right: 2px; top: 3px; border-top: 1px solid currentColor; }
.cw-io-d::after { content: "."; position: absolute; left: 4px; top: -5px; font-size: 10px; }
.cw-si.hs { margin-left: auto; font-size: 8px; letter-spacing: -1px; }
.cw-scr { height: 99px; position: relative; overflow: hidden; }
.cw-lcd.small .cw-scr { font-size: 11px; }
.cw-calc { height: 100%; display: flex; flex-direction: column; justify-content: space-between; }
.cw-in { font: 400 17px/1.5 "Cambria Math", "STIX Two Math", "Times New Roman", serif; white-space: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; min-height: 30px; padding-top: 2px; }
.cw-in::-webkit-scrollbar { display: none; }
.cw-res { text-align: right; font: 500 21px/1.25 "Cambria Math", "STIX Two Math", "Times New Roman", serif; white-space: nowrap; overflow: hidden; }
.cw-res.big { margin-top: 10px; }
.cw-tf { font: 800 18px Arial, sans-serif; letter-spacing: .04em; }
.cw-pol > div { font-size: 16px; }
.cw-x10 { font-size: .8em; margin-left: 1px; }
.cw-f { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; font-size: .82em; line-height: 1.15; }
.cw-f > span:first-child { border-bottom: 1.3px solid currentColor; padding: 0 2px; }
.cw-rt { white-space: nowrap; }
.cw-ol { border-top: 1.3px solid currentColor; padding: 0 2px; }
.cw-ri { font-size: .6em; margin-right: -4px; vertical-align: .9em; }
.cw-box { display: inline-block; min-width: .62em; height: .95em; border: 1px dotted currentColor; vertical-align: middle; }
.cw-caret { display: inline-block; width: 1.5px; height: 1em; background: currentColor; vertical-align: middle; animation: cw-blink 1s steps(1) infinite; margin: 0 -.75px; }
@keyframes cw-blink { 50% { opacity: 0; } }
.cw-e { font-family: Arial, sans-serif; font-size: .8em; }
.cw-op { font-family: Arial, sans-serif; font-weight: 700; font-size: .85em; }
.cw-rec { text-decoration: overline; }
.cw-big { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: .62em; line-height: 1; margin-right: 1px; }
.cw-bs { font-size: 1.9em; line-height: .9; }
.cw-vec { font-size: .9em; }
/* menus */
.cw-menu { position: relative; padding-right: 6px; font: 600 12.5px/1 "Segoe UI", Roboto, Arial, sans-serif; }
.cw-mi { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 5px; border-radius: 2px; white-space: nowrap; }
.cw-mi.sel { background: var(--ink); color: #cfe0d4; }
.cw-mi.dis { opacity: .4; }
.cw-ml { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cw-ml sup, .cw-ml sub { font-size: .7em; }
.cw-mn { font-size: 10.5px; opacity: .85; }
.cw-arr { font-size: 8px; }
.cw-rd { width: 9px; height: 9px; border: 1.3px solid currentColor; border-radius: 50%; flex: none; display: grid; place-items: center; }
.cw-rd.on::after { content: ""; width: 4px; height: 4px; background: currentColor; border-radius: 50%; }
.cw-sb { position: absolute; right: 0; top: 2px; bottom: 2px; width: 3px; border-left: 1px solid currentColor; }
.cw-sb i { position: absolute; left: -1px; right: -2px; background: currentColor; }
/* home */
.cw-home { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 4px; padding-top: 6px; }
.cw-app { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 0 2px; border-radius: 2px; font: 500 12.5px/1.1 "Segoe UI", Roboto, Arial, sans-serif; }
.cw-app svg { width: 26px; height: 19px; }
.cw-app.sel { background: var(--ink); color: #cfe0d4; }
/* boxes, forms, grids */
.cw-errbox, .cw-msg { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; font: 600 12px Arial, sans-serif; text-align: center; }
.cw-errbox b { font-size: 15px; margin-bottom: 4px; }
.cw-msg b { font-size: 13px; }
.cw-ctr { letter-spacing: -1px; }
.cw-ttl { font: 700 11.5px Arial, sans-serif; border-bottom: 1px solid currentColor; padding-bottom: 1px; margin-bottom: 2px; }
.cw-def .cw-lab { font: 600 13px Arial, sans-serif; }
.cw-form > div { display: flex; height: 21px; align-items: center; padding: 0 4px; font: 600 13px Arial, sans-serif; border-radius: 2px; white-space: nowrap; overflow: hidden; }
.cw-form > div > span:first-child { width: 52px; }
.cw-form .sel { background: var(--ink); color: #cfe0d4; }
.cw-exec { justify-content: center; }
.cw-grid { width: 100%; border-collapse: collapse; font: 600 12px/1.2 Arial, sans-serif; table-layout: fixed; }
.cw-grid th { font-weight: 600; border-bottom: 1px solid currentColor; padding: 1px 3px; text-align: center; }
.cw-grid td { padding: 2px 3px; text-align: right; white-space: nowrap; overflow: hidden; border-bottom: 1px dotted rgba(0,0,0,.25); height: 17px; }
.cw-grid td.rn, .cw-grid th:first-child { width: 18px; text-align: left; font-size: 10px; }
.cw-grid td.sel { background: var(--ink); color: #cfe0d4; }
.cw-gin { position: absolute; left: 0; right: 0; bottom: 0; text-align: right; font: 400 15px "Cambria Math", "Times New Roman", serif; border-top: 1px solid currentColor; padding: 1px 2px 0; height: 21px; white-space: nowrap; overflow: hidden; }
.cw-res-list > div { display: flex; justify-content: space-between; height: 23px; align-items: center; font: 500 14px "Cambria Math", "Times New Roman", serif; }
.cw-vedit { font: 500 16px "Cambria Math", "Times New Roman", serif; display: flex; gap: 6px; align-items: center; justify-content: center; height: 70px; }
.cw-vedit .sel { background: var(--ink); color: #cfe0d4; padding: 0 3px; }
/* keys */
.cw-keys { margin-top: 8px; }
.cw-nav { display: grid; grid-template-columns: 1fr 104px 34px; gap: 0 4px; align-items: center; padding: 0 2px 2px; }
.cw-nl { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 6px; }
.cw-small { display: flex; flex-direction: column; align-items: center; }
.cw-cap { font: 700 7.5px/1.4 Arial, sans-serif; letter-spacing: .04em; color: #eef0f3; height: 11px; white-space: nowrap; }
.cw-cap.blue { color: var(--cwlbl); }
.cw-k { box-shadow: none; border: 0; padding: 0; margin: 0; cursor: pointer; font-family: Arial, Helvetica, sans-serif; -webkit-tap-highlight-color: transparent; }
.cw-k.hit { animation: cw-press .14s; }
@keyframes cw-press { 50% { transform: translateY(1.5px) scale(.96); filter: brightness(.9); } }
.cw-dk, .cw-on { width: 32px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 50% 30%, #4a4d53, #2c2e32); color: #e8eaee; box-shadow: 0 2px 0 #0b0b0c, inset 0 1px 0 rgba(255,255,255,.12); display: grid; place-items: center; }
.cw-dk svg { width: 15px; height: 15px; }
.cw-on { width: 24px; height: 18px; border-radius: 8px; }
.cw-pad { position: relative; width: 104px; height: 74px; border-radius: 50%; background: radial-gradient(circle, #2f3135 40%, #26282b); box-shadow: 0 2px 0 #0b0b0c, inset 0 1px 0 rgba(255,255,255,.1); }
.cw-pad .cw-k { position: absolute; background: transparent; color: #e8eaee; font-size: 15px; width: 30px; height: 24px; display: grid; place-items: center; }
.cw-pu { left: 37px; top: 2px; } .cw-pd { left: 37px; bottom: 2px; } .cw-pl { left: 4px; top: 25px; } .cw-pr { right: 4px; top: 25px; }
.cw-pad .cw-ok { left: 33px; top: 21px; width: 38px; height: 32px; border-radius: 50%; background: radial-gradient(circle at 50% 30%, #44474c, #2a2c30); font: 800 10px Arial, sans-serif; box-shadow: 0 1px 0 #0b0b0c; }
.cw-pg { display: flex; flex-direction: column; gap: 0; border-radius: 16px; overflow: hidden; background: #2c2e32; box-shadow: 0 2px 0 #0b0b0c; }
.cw-pg .cw-k { height: 30px; background: transparent; color: #e8eaee; font-size: 9px; line-height: .55; }
.cw-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0 5px; margin-top: 2px; }
.cw-row.cw-num { grid-template-columns: repeat(5, 1fr); gap: 0 7px; margin-top: 3px; }
.cw-kw { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.cw-sh { font: 700 8.5px/1.25 Arial, sans-serif; color: var(--cwlbl); height: 12px; align-self: flex-start; padding-left: 2px; white-space: nowrap; overflow: visible; display: flex; align-items: flex-end; }
.cw-sh sup, .cw-sh sub { font-size: .75em; }
.cw-sh i { font-family: "Times New Roman", serif; font-size: 1.15em; }
.cw-fn .cw-sh { align-self: center; padding: 0; color: #eef0f3; font-size: 7.5px; letter-spacing: .03em; }
.cw-fn .cw-sh.blue { color: var(--cwlbl); }
.cw-fn .cw-k, .cw-sci .cw-k { width: 100%; max-width: 38px; height: 27px; border-radius: 50%; background: radial-gradient(circle at 50% 30%, #f4f5f6, var(--cwk)); color: var(--cwk-ink); font-size: 12.5px; font-weight: 700;
  box-shadow: 0 2px 0 #8d9097, inset 0 -1px 0 rgba(0,0,0,.1); display: grid; place-items: center; line-height: 1; }
.cw-fn .cw-k svg { width: 17px; height: 15px; }
.cw-shiftw .cw-k { background: radial-gradient(circle at 50% 30%, #4a76f0, var(--cwblue)) !important; box-shadow: 0 2px 0 #142f7a !important; }
.cw-keys.shifted .cw-shiftw .cw-k { outline: 2px solid #9db8ff; outline-offset: 1px; }
.cw-keys.shifted .cw-sh:not(.cw-cap) { color: #9db8ff; text-shadow: 0 0 6px rgba(120,160,255,.6); }
.cw-gap { visibility: hidden; }
.cw-fx { font-size: .8em; font-weight: 600; }
.cw-sci .cw-k i { font-family: "Times New Roman", serif; font-size: 1.25em; font-weight: 700; }
.cw-sci .cw-k sup, .cw-sci .cw-k sub { font-size: .65em; }
.cw-kbox { display: inline-block; width: 6px; height: 7px; border: 1.3px solid currentColor; border-radius: 1px; }
.cw-sqk { font-size: 1.1em; }
.cw-kf { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; }
.cw-kf i { width: 11px; border-top: 1.5px solid currentColor; }
.cw-kf.sm { transform: scale(.7); vertical-align: middle; }
.cw-krt { white-space: nowrap; }
.cw-num .cw-k { width: 100%; max-width: 46px; height: 36px; border-radius: 50%; background: radial-gradient(circle at 50% 30%, #f6f7f8, var(--cwk)); color: var(--cwk-ink); font: 600 20px/1 Arial, Helvetica, sans-serif;
  box-shadow: 0 2.5px 0 #8d9097, inset 0 -1px 0 rgba(0,0,0,.1); display: grid; place-items: center; }
.cw-num .cw-k svg { width: 22px; height: 16px; }
.cw-num .cw-k sup { font-size: .5em; }
.cw-num .red .cw-k, .cw-num .cw-k[data-a="ac"] { font-size: 16px; font-weight: 800; }
.cw-num .cw-k[data-a="exe"] { font-size: 14px; font-weight: 800; }
.cw-num .cw-k[data-a="ᴇ"] { font-size: 14px; }
.cw-fmt { display: flex; flex-direction: column; align-items: center; position: relative; width: 30px; height: 26px; }
.cw-fmt svg { position: absolute; inset: 0; width: 30px !important; height: 26px !important; }
.cw-fmt b { position: relative; font: 800 6.5px/26px Arial, sans-serif; letter-spacing: .01em; }
.cw-lbl-f { display: inline-flex; align-items: flex-end; }
.cw-neg { font-size: .8em; vertical-align: .15em; }
.cw svg text { fill: currentColor; stroke: none; }
.cw-kl { display: inline-block; white-space: nowrap; line-height: 1; }
.cw-kl sup { vertical-align: .55em; line-height: 0; }
.cw-kl sub { vertical-align: -.35em; line-height: 0; }
.cw-sh { letter-spacing: -.01em; }
@media (max-width: 640px) {
  .cw { left: 50% !important; right: auto !important; top: auto !important; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom)) !important; max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); }
  body.focus .cw { bottom: calc(8px + env(safe-area-inset-bottom)) !important; }
}
@media (prefers-reduced-motion: reduce) { .cw-k.hit { animation: none; } .cw-caret { animation: none; } }

/* annotation: touch mode switch (Fingers scroll / Pencil only / Fingers draw) */
.ann-bar .ann-mode { display: inline-flex; gap: 6px; padding: 0 12px; font: 700 .8rem var(--font); white-space: nowrap; }
.ann-bar .ann-mode.on { background: var(--biro); color: #fff; border-color: var(--biro); outline: none; }
.ann-hint { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); opacity: 0; z-index: 1101;
  background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: .85rem; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
.ann-hint.on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 640px) { .ann-hint { bottom: calc(140px + env(safe-area-inset-bottom)); } }

/* ---------- admin: access levels ---------- */
.lv-table { width: 100%; }
.lv-table th, .lv-table td { text-align: center; vertical-align: middle; }
.lv-table th:first-child, .lv-table td:first-child { text-align: left; }
.lv-table thead th { white-space: nowrap; }
.lv-table tr.lv-who td { font-size: .82em; color: var(--muted); }
.lv-yes { color: var(--biro); font-weight: 700; }
.lv-no { color: var(--rule-strong); }
.lv-pick { font: inherit; font-size: .9em; padding: .25em .5em; border-radius: var(--r-sm); border: 1px solid var(--rule-strong);
  background: var(--paper); color: inherit; transition: background-color .3s, border-color .3s; }
.lv-pick.pinned { border-color: var(--biro); font-weight: 600; }
.lv-pick.saved { background: color-mix(in srgb, var(--biro) 14%, transparent); }
.levels .row { margin-top: .75rem; }

/* ---------- celebration popups: the Home card's blue, one big word, the mascot ---------- */
.modal.cele { z-index: 2000; animation: cele-fade .2s ease-out; }
.modal.cele.out { opacity: 0; transition: opacity .2s; }
@keyframes cele-in { from { transform: translateY(18px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cele-fade { from { opacity: 0; } }
.tbp { width: min(400px, 100%); padding: 0; overflow: hidden; animation: cele-in .32s cubic-bezier(.2,1.25,.4,1); }
.tbp-panel { position: relative; overflow: hidden; margin: 10px 10px 0; min-height: 156px; border-radius: 18px; background: var(--biro); color: #fff;
  box-shadow: 0 5px 0 var(--biro-dark); display: grid; grid-template-columns: 1fr 128px; }
.tbp-panel::before { content: ""; position: absolute; right: -50px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.08); }
.tbp-big { position: relative; align-self: center; padding: 18px 0 20px 22px; min-width: 0; }
.tbp-big small { display: block; font-size: .8rem; font-weight: 800; color: rgba(255,255,255,.82); margin-bottom: 2px; }
.tbp-big b { display: block; font-family: var(--display); font-weight: 800; font-size: 3.5rem; line-height: .95; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbp-big span { display: block; font-weight: 700; color: rgba(255,255,255,.88); margin-top: 4px; }
.tbp-mascot { position: relative; align-self: end; height: 156px; overflow: hidden; }
.tbp-mascot .mascot { width: 128px; margin-top: 12px; }
.tbp-main { padding: 18px 22px 20px; }
.tbp-main h2 { font-family: var(--display); font-size: 1.5rem; line-height: 1.15; margin: 0 0 4px; }
.tbp-body { color: var(--muted); margin: 0 0 14px; }
.tbp-list { list-style: none; padding: 0; margin: -4px 0 18px; display: grid; gap: 7px; }
.tbp-list li { position: relative; padding-left: 26px; font-weight: 700; }
.tbp-list li::before { content: ""; position: absolute; left: 5px; top: .18em; width: .42em; height: .8em; border: solid var(--good); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.tbp-actions { display: flex; align-items: center; gap: 16px; }
.tbp-actions .primary { flex: 1; padding-top: 12px; padding-bottom: 11px; font-size: 1.05rem; }
.tbp-actions .link { flex: 0 0 auto; }
.tbp:focus { outline: none; }
.tbp-big span:empty { display: none; }
/* while a payment lands, the number breathes */
.tbp.pending .tbp-big b { animation: tbp-wait 1.3s ease-in-out infinite; }
@keyframes tbp-wait { 50% { opacity: .55; } }
/* Pro: the same card in ink, the word in gold */
.tbp-pro .tbp-panel { background: #1f2329; box-shadow: 0 5px 0 #0b0c0f; }
.tbp-pro .tbp-big b { color: #ffd36b; }
/* new subject: three of its papers fanned where the mascot usually stands */
.tbp-fan { position: relative; height: 156px; }
.tbp-fan img, .tbp-fan span { position: absolute; left: calc(50% - 38px); bottom: -18px; width: 76px; aspect-ratio: 1 / 1.414; border-radius: 4px; background: #fff;
  object-fit: cover; object-position: top; box-shadow: 0 4px 12px rgba(0,0,0,.25); transform-origin: 50% 100%;
  transform: translateX(calc((var(--i) - 1) * 20px)) rotate(calc((var(--i) - 1) * 9deg)); }
.tbp-fan :nth-child(2) { z-index: 1; }
@media (max-width: 420px) { .tbp-panel { grid-template-columns: 1fr 108px; min-height: 140px; } .tbp-big b { font-size: 3rem; } .tbp-mascot, .tbp-fan { height: 140px; } .tbp-mascot .mascot { width: 108px; } }
@media (prefers-reduced-motion: reduce) { .tbp, .modal.cele, .tbp.pending .tbp-big b { animation: none !important; } }

/* admin: view as a level */
.view-as-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.view-as-row select { font: inherit; padding: .15em .4em; border-radius: var(--r-sm); border: 1px solid var(--rule-strong); background: var(--paper); color: inherit; }

/* sign-in: say plainly that signing up is free */
.auth-free { display: inline-block; margin-top: 4px; padding: .35em .85em; border-radius: 999px; background: var(--good-soft); color: #0f5c31; font-size: .95rem; }
:root[data-theme="dark"] .auth-free { color: #8be0ad; }

/* made by JAI-OPS: like "Claude by Anthropic" */
.auth-by { margin: -6px 0 16px; }
.by-jaiops { color: var(--muted); font-weight: 700; font-size: .9rem; text-decoration: none; letter-spacing: .02em; }
.by-jaiops:hover { color: var(--ink); }
.made-by { color: inherit; font-weight: 700; }

/* ---------- Marking tab ---------- */
.mainnav a { position: relative; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--biro); color: #fff; font-size: .72rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.nav-badge.zero { background: var(--rule-strong); color: var(--ink); }
@media (max-width: 700px) { .nav-badge { position: absolute; top: 0; right: 4px; min-width: 17px; height: 17px; font-size: .65rem; padding: 0 4px; } }
.mk-lede { margin-top: -4px; max-width: 560px; }
.mk-balance { text-align: center; padding: 26px 22px 22px; }
.mk-big b { display: block; font-family: var(--display); font-size: clamp(4rem, 14vw, 5.6rem); line-height: .95; color: var(--biro); }
.mk-big span { display: block; font-weight: 800; font-size: 1.05rem; margin-top: 4px; }
.mk-tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 20px 0 18px; }
.mk-tile { flex: 1 1 140px; max-width: 200px; background: var(--soft); border-radius: var(--r); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.mk-tile b { font-family: var(--display); font-size: 1.7rem; line-height: 1.1; }
.mk-tile b em { font-style: normal; font-size: 1rem; color: var(--muted); }
.mk-tile span { font-weight: 800; font-size: .9rem; }
.mk-tile small { color: var(--muted); font-size: .78rem; }
.mk-tile.off { opacity: .6; }
.mk-pool { text-align: left; border-top: 1px solid var(--rule); padding-top: 14px; }
.mk-bar { height: 10px; border-radius: 5px; background: var(--soft); overflow: hidden; margin: 8px 0 6px; }
.mk-bar i { display: block; height: 100%; border-radius: 5px; background: var(--good); transition: width .6s ease; }
.mk-pool p { margin: 0; }
.mk-buy { margin-top: 16px; min-width: 220px; }
.mk-later { margin: 14px 0 0; }
.mk-upload h2 { margin-bottom: 4px; }
.mk-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.mk-row select { flex: 1 1 220px; }
.mk-how { list-style: none; counter-reset: s; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mk-how li { counter-increment: s; padding: 14px; border-radius: var(--r); background: var(--paper); border: 1px solid var(--rule); display: flex; flex-direction: column; gap: 3px; }
.mk-how li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--biro-soft); color: var(--biro); font-weight: 800; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.mk-how span { color: var(--muted); font-size: .9rem; }
@media (max-width: 600px) { .mk-how { grid-template-columns: 1fr; } }

/* ---------- pack picker ---------- */
.modal.buy { z-index: 1900; animation: cele-fade .18s ease-out; }
.modal.buy.out { opacity: 0; transition: opacity .18s; }
.buy-card { position: relative; max-width: 620px; width: calc(100% - 32px); text-align: center; padding: 26px 22px 20px; animation: cele-in .35s cubic-bezier(.2,1.3,.4,1); }
.buy-x { position: absolute; top: 12px; right: 14px; font-size: 1.1rem; color: var(--muted); }
.buy-card h2 { font-family: var(--display); font-size: 1.7rem; margin: 0 0 4px; }
.buy-sub { color: var(--muted); margin: 0 0 18px; }
.buy-packs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
.buy-pack { font: inherit; color: inherit; cursor: pointer; background: var(--paper); border: 2px solid var(--rule); border-radius: var(--r-lg); padding: 14px 10px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 5px 0 var(--rule); transition: transform .12s, box-shadow .12s, border-color .12s;
  animation: unlock-in .35s calc(.08s + var(--i) * .07s) cubic-bezier(.2,1.4,.4,1) both; }
.buy-pack:hover, .buy-pack:focus-visible { transform: translateY(-3px); border-color: var(--biro); box-shadow: 0 8px 0 var(--biro-soft); outline: none; }
.buy-pack:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--rule); }
.buy-pack.pop { border-color: var(--biro); box-shadow: 0 6px 0 var(--biro-dark); padding-top: 20px; }
.buy-tag { min-height: 1.1em; font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--biro); }
.buy-n { font-family: var(--display); font-size: 2.6rem; line-height: 1; margin-top: 4px; }
.buy-u { color: var(--muted); font-weight: 700; font-size: .9rem; }
.buy-price { font-family: var(--display); font-size: 1.35rem; margin-top: 10px; }
.buy-each { color: var(--muted); font-size: .8rem; }
.buy-go { margin-top: 12px; width: 100%; padding: .55em 0; border-radius: var(--r-sm); background: var(--soft); font-weight: 800; }
.buy-pack.pop .buy-go { background: var(--biro); color: #fff; }
.buy-points { list-style: none; padding: 0; margin: 18px 0 0; display: flex; gap: 6px 18px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.buy-points li { position: relative; padding-left: 16px; }
.buy-points li::before { content: ''; position: absolute; left: 2px; top: .35em; width: .3em; height: .6em; border: solid var(--good); border-width: 0 2px 2px 0; transform: rotate(45deg); }
@media (max-width: 520px) { .buy-packs { grid-template-columns: 1fr; } .buy-pack { flex-direction: row; justify-content: space-between; padding: 12px 14px; gap: 8px; }
  .buy-pack .buy-tag { display: none; } .buy-n { font-size: 1.8rem; margin: 0; } .buy-price { margin: 0 0 0 auto; } .buy-each { display: none; } .buy-go { width: auto; margin: 0 0 0 8px; padding: .45em .9em; } .buy-pack.pop { padding-top: 12px; } }
/* phones: five tabs fit the bottom bar */
@media (max-width: 640px) {
  .mainnav a { flex: 1 1 0; min-width: 0; padding: 5px 2px; font-size: .74rem; gap: 2px; }
  .mainnav a span { white-space: nowrap; }
}
/* phones: keep the header inside the screen (brand, subject, calculator, timer, account) */
@media (max-width: 420px) {
  .top-in { gap: 6px; }
  .top-right { gap: 5px; min-width: 0; }
  .subject .subj-btn { max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 10px; padding-right: 8px; }
  .calc-btn, .timer-btn { width: 36px; height: 36px; padding: 0; }
  .avatar { width: 36px; height: 36px; }
  .brand { font-size: 1.35rem; }
}
@keyframes unlock-in { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- tutor (prototype) ---------- */
.tu-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tu-head h1 { margin-bottom: 0; }
.tu-head p { margin: 2px 0 0; }
.tu-modes { display: flex; gap: 6px; margin: 16px 0 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tu-modes::-webkit-scrollbar { display: none; }
.tu-modes button { flex: 0 0 auto; border-radius: 999px; padding: 7px 14px; font-weight: 700; color: var(--muted); background: var(--paper); }
.tu-modes button.on { background: var(--biro-soft); color: var(--biro); border-color: color-mix(in srgb, var(--biro) 40%, transparent); }
.tu-modehint { margin: 0 0 4px 4px; min-height: 1.3em; }
.tu-start { padding: 24px 22px; }
.tu-start h2 { font-family: var(--display); font-size: 1.35rem; margin: 0 0 6px; }
.tu-start > p.muted { max-width: 560px; margin: 0 0 18px; }
.tu-start-row { display: flex; gap: 10px; flex-wrap: wrap; }
.tu-start-row select { flex: 1 1 220px; min-width: 0; }
.tu-start-row .primary { flex: 0 0 auto; padding-left: 28px; padding-right: 28px; font-size: 1.05rem; }
#tu-own { margin-top: 12px; }
.tu-ref { display: flex; gap: 8px; margin-top: 12px; }
.tu-ref input { flex: 1; min-width: 0; }
.tu-learnt { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--rule); }
.tu-learnt ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }

.tu-q { padding: 12px 14px; }
.tu-qbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #6b707a; margin-bottom: 8px; }
.tu-q img { display: block; max-width: 100%; margin: 0 auto; }
.tu-q.folded img { display: none; }
.tu-q.folded .tu-qbar { margin-bottom: 0; }

.tu-msg, .tu-done { scroll-margin-bottom: 170px; }
.tu-thread { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 12px; }
.tu-msg { max-width: min(88%, 620px); border-radius: 18px; padding: 10px 14px; line-height: 1.55; animation: tu-in .22s ease-out both; }
.tu-msg p { margin: 0; } .tu-msg p + p { margin-top: 8px; }
.tu-msg.tutor { align-self: flex-start; background: var(--paper); border: 1px solid var(--rule); border-bottom-left-radius: 6px; }
.tu-msg.student { align-self: flex-end; background: var(--biro-soft); color: var(--ink); border-bottom-right-radius: 6px; }
.tu-msg.err { background: var(--bad-soft); border-color: transparent; color: var(--ink); }
.tu-msg .katex { font-size: 1.08em; }
.tu-msg .katex-display { margin: 8px 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.tu-pics { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tu-pics img { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; display: block; }
.tu-note { margin-top: 8px; font-size: .8rem; color: var(--muted); }
.tu-diagram { margin-top: 10px; padding: 12px; border-radius: var(--r-sm); background: var(--soft); color: var(--ink); }
.tu-diagram svg { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; font-family: var(--font); overflow: visible; }
.tu-diagram .hl { stroke: var(--biro); }
.tu-diagram text.hl, .tu-diagram tspan.hl { fill: var(--biro); stroke: none; }
.tu-diagram marker * { stroke: none; }
.tu-sys { align-self: center; font-size: .78rem; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 3px 12px; }
.tu-msg.typing { display: flex; gap: 5px; padding: 14px 16px; }
.tu-msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--rule-strong); animation: tu-dot 1.1s infinite ease-in-out; }
.tu-msg.typing span:nth-child(2) { animation-delay: .15s; } .tu-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes tu-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes tu-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tu-done { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; text-align: center;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 16px; margin: 4px 0 14px; }
.tu-done p { flex-basis: 100%; margin: 0; }
.tu-score { display: flex; align-items: baseline; gap: 8px; }
.tu-score b { font-family: var(--display); font-size: 2.2rem; line-height: 1; color: var(--biro); }
.tu-score em { font-style: normal; font-size: 1.2rem; color: var(--muted); }
.tu-score span { font-weight: 700; }

.tu-compose { position: sticky; bottom: 12px; z-index: 5; background: var(--paper); border: 1px solid var(--rule); border-radius: 22px;
  padding: 8px; box-shadow: 0 6px 24px var(--shadow); }
.tu-quick { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 0 2px 8px; }
.tu-quick::-webkit-scrollbar { display: none; }
.tu-quick button { flex: 0 0 auto; border-radius: 999px; padding: 4px 11px; font-size: .84rem; color: var(--muted); background: var(--soft); border-color: transparent; }
.tu-quick button:hover, .tu-quick button[aria-expanded="true"] { color: var(--ink); border-color: var(--rule-strong); }
.tu-syms { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; padding: 0 2px 8px; }
.tu-syms button { padding: 6px 0; font-size: 1rem; }
.tu-photos { display: flex; gap: 8px; padding: 0 2px 8px; }
.tu-thumb { position: relative; }
.tu-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
.tu-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border-radius: 50%; line-height: 1; font-size: 15px; background: var(--ink); color: var(--on-ink); border: 0; }
.tu-input { display: flex; align-items: flex-end; gap: 6px; }
.tu-input textarea { flex: 1; min-width: 0; resize: none; border: 0; background: transparent; font: inherit; color: var(--ink); padding: 9px 6px; line-height: 1.4; max-height: 160px; outline: none; }
.tu-cam, .tu-send { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; padding: 0; cursor: pointer; }
.tu-cam { color: var(--muted); background: var(--soft); }
.tu-cam:hover { color: var(--ink); }
.tu-cam svg, .tu-send svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tu-compose:focus-within { border-color: color-mix(in srgb, var(--biro) 45%, var(--rule)); }
@media (max-width: 640px) {
  .tu-compose { bottom: 74px; border-radius: 20px; }
  .tu-msg, .tu-done { scroll-margin-bottom: 250px; }
  .tu-msg { max-width: 92%; }
  .tu-start-row .primary { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .tu-msg, .tu-msg.typing span { animation: none; } }
/* header: lines up with the page. The page column grows a little on laptops so all six tabs fit beside the tools */
@media (min-width: 961px) { :root { --max: 1060px; } .top-in { gap: 12px; } .top-right { gap: 8px; } .mainnav { gap: 2px; } .mainnav a { padding: 6px 9px; } }
@media (min-width: 961px) and (max-width: 1179px) { .mainnav svg { display: none; } }
/* tablets: tabs get their own row under the brand and tools */
@media (min-width: 641px) and (max-width: 960px) {
  .top-in { flex-wrap: wrap; row-gap: 4px; gap: 10px; }
  .mainnav { order: 3; flex-basis: 100%; justify-content: space-between; }
  .mainnav a { flex: 1 1 0; justify-content: center; }
}
:root[data-theme="dark"] .tbp-pro .tbp-panel { background: #0d0f13; box-shadow: 0 5px 0 #000, inset 0 0 0 1px rgba(255,211,107,.22); }
.tbp-subject .tbp-big { padding-right: 8px; }

/* popups: the payoff */
.confetti { z-index: 2100; }
.tbp-big b { transform-origin: 20% 60%; }
.tbp-big b.was { opacity: .5; text-decoration: line-through; text-decoration-thickness: 5px; }
.tbp-big b.slam { animation: tbp-slam .6s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes tbp-slam { 0% { transform: scale(2.1) rotate(-7deg); opacity: 0; } 50% { transform: scale(.88) rotate(1.5deg); opacity: 1; } 75% { transform: scale(1.06); } 100% { transform: none; } }
.tbp-panel::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.tbp-panel.flash::after { animation: tbp-flash .45s ease-out; }
@keyframes tbp-flash { 0% { opacity: .55; } 100% { opacity: 0; } }
.tbp-panel.flash { animation: tbp-thud .4s cubic-bezier(.2,1.6,.4,1); }
@keyframes tbp-thud { 30% { transform: scale(1.035); } 100% { transform: none; } }
.tbp-list li { opacity: 0; transform: translateY(8px) scale(.94); transition: opacity .25s, transform .35s cubic-bezier(.2,1.6,.4,1); }
.tbp-list li.in { opacity: 1; transform: none; }
.tbp-list li::before { transform: rotate(45deg) scale(0); transition: transform .3s cubic-bezier(.2,1.8,.4,1) .08s; }
.tbp-list li.in::before { transform: rotate(45deg) scale(1); }
.tbp-actions .primary.nudge { animation: tbp-nudge 1.4s ease-in-out 3; }
@keyframes tbp-nudge { 0%, 100% { transform: none; } 50% { transform: scale(1.045); } }
/* Pro: a single gold sheen runs across the word as it lands */
.tbp-pro .tbp-big b.slam { background: linear-gradient(100deg, #ffd36b 42%, #fff7da 50%, #ffd36b 58%) 160% 0 / 260% 100% no-repeat; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: tbp-slam .6s cubic-bezier(.2,1.6,.4,1) both, tbp-sheen 1.1s ease-in-out .55s both; }
@keyframes tbp-sheen { from { background-position: 160% 0; } to { background-position: -60% 0; } }
/* new subject: the covers are dealt in one by one */
.tbp-fan img, .tbp-fan span { animation: tbp-deal .5s cubic-bezier(.2,1.4,.4,1) calc(.25s + var(--i) * .13s) both; }
@keyframes tbp-deal { from { transform: translate(60px, 120px) rotate(30deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .tbp-big b.slam, .tbp-panel.flash, .tbp-panel.flash::after, .tbp-actions .primary.nudge, .tbp-fan img, .tbp-fan span { animation: none !important; }
  .tbp-list li, .tbp-list li::before { opacity: 1; transform: none; transition: none; }
  .tbp-list li::before { transform: rotate(45deg); }
}

/* Daily 5: five dots on the Home card, filled as you go */
.daily-dots { display: flex; gap: 8px; margin: 2px 0 12px; }
.daily-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.daily-dots i.on { background: #fff; border-color: #fff; animation: dotpop .35s ease-out both; }
@keyframes dotpop { 0% { transform: scale(.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.next-acts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.next .link#daily-alt { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.next .link.daily-mode { color: rgba(255,255,255,.85); text-decoration: underline dotted; text-underline-offset: 3px; }
@media (max-width: 640px) { .next-acts { gap: 10px; } .next-acts .link { width: 100%; text-align: center; } }
@media (prefers-reduced-motion: reduce) { .daily-dots i.on { animation: none; } }

/* ---------- friends ---------- */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sec-head .link { white-space: nowrap; }
.friends { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 8px; scrollbar-width: thin; }
.friends .fr { flex: none; width: 104px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px 10px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: 0 3px 0 var(--rule); text-align: center; }
.friends .fr b { font-size: .95rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friends .fr small { font-size: .74rem; color: var(--muted); font-weight: 700; }
.friends .fr.done .fr-st { color: #1a7f37; }
.friends .fr.me { background: var(--hover); }
.fr-flame { display: inline-block; width: 30px; height: 36px; }
.fr-flame svg { width: 100%; height: 100%; overflow: visible; }
.friends.empty { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 18px;
  background: var(--paper); border: 1px dashed var(--rule); border-radius: var(--r); }
.friends.empty p { margin: 0; }
.sp-fr { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 2px solid var(--rule); }
.fr-card { max-width: 420px; }
.fr-card h2 { margin: 0 0 4px; }
.fr-code { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 12px; padding: 14px; background: var(--hover); border-radius: var(--r); }
.fr-code b { font-family: var(--display); font-size: 1.6rem; letter-spacing: .12em; flex: 1; }
.fr-add { display: flex; gap: 8px; }
.fr-add input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: .1em; }
.fr-list { margin-top: 12px; max-height: 260px; overflow-y: auto; }
.fr-li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--rule); }
.fr-li .fr-flame { width: 24px; height: 29px; }
.fr-li b { flex: 1; }
.fr-li .link { color: var(--muted); font-weight: 600; }

/* ---------- pets, banners and borders ---------- */
.pet { --sz: 56px; position: relative; display: inline-grid; place-items: center; width: var(--sz); height: var(--sz); flex: none;
  border-radius: 50%; background: var(--pc, #3b6cf6); box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.pet img { width: 74%; height: 74%; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(0,0,0,.16)); user-select: none; }
.pet-sm { --sz: 34px; } .pet-md { --sz: 56px; } .pet-xl { --sz: 128px; }
.pet::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; pointer-events: none; }
.pet-sm::after { inset: -3px; }
.bd-bronze::after { border: 4px solid #c27c3e; }
.bd-silver::after { border: 4px solid #b8c0cc; box-shadow: 0 0 0 1px #8a94a3 inset; }
.bd-gold::after { border: 4px solid #f2b705; box-shadow: 0 0 10px rgba(242,183,5,.55); }
.bd-flame::after, .bd-diamond::after, .bd-pro::after { inset: -5px; padding: 4px; border: 0;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: ring-spin 4s linear infinite; }
.pet-sm.bd-flame::after, .pet-sm.bd-diamond::after, .pet-sm.bd-pro::after { inset: -4px; padding: 3px; }
.bd-flame::after { background: conic-gradient(#ff3d00, #ff9100, #ffd000, #ff9100, #ff3d00); filter: drop-shadow(0 0 6px rgba(255,120,0,.6)); }
.bd-diamond::after { background: conic-gradient(#9be7ff, #ffffff, #6ec6ff, #e0f7ff, #9be7ff); filter: drop-shadow(0 0 6px rgba(120,200,255,.7)); }
.bd-pro::after { background: conic-gradient(#ff4d6d, #ffb000, #2fd27a, #18b4f5, #7a5cff, #ff4d6d); filter: drop-shadow(0 0 7px rgba(122,92,255,.6)); }
@keyframes ring-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .pet::after { animation: none !important; } }
.avatar .pet img { width: 78%; height: 78%; object-fit: contain; }
.avatar .pet img.ph { width: 100%; height: 100%; object-fit: cover; }

/* profile page */
.pf-hero { position: relative; overflow: hidden; display: flex; align-items: center; gap: 28px; padding: 30px 32px; border-radius: 26px; color: #fff;
  background: var(--pc); box-shadow: 0 6px 0 rgba(0,0,0,.18); }
.pf-hero::before { content: ""; position: absolute; right: -70px; top: -70px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.1); }
.pf-hero .pet { background: rgba(255,255,255,.22); box-shadow: inset 0 -6px 0 rgba(0,0,0,.12); }
.pf-who { flex: 1; min-width: 0; position: relative; }
.pf-who h1 { color: #fff; margin: 0 0 6px; font-size: 2.2rem; }
.pf-lv { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 0 10px; }
.pf-lv b { font-size: 1.25rem; }
.pf-lv span { opacity: .9; font-weight: 600; font-size: .95rem; }
.pf-bar { height: 14px; border-radius: 99px; background: rgba(0,0,0,.22); overflow: hidden; }
.pf-bar i { display: block; height: 100%; border-radius: inherit; background: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); transition: width .8s cubic-bezier(.2,.9,.3,1); }
.pf-stats { display: flex; gap: 18px; flex-wrap: wrap; margin: 12px 0 0; font-weight: 700; font-size: .95rem; }
.pf-stats > span { display: inline-flex; align-items: center; gap: 6px; }
.pf-stats .fr-fl { width: 18px; height: 22px; }
.pf-earn { margin: 12px 2px 0; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.pf-grid.colors, .pf-grid.borders { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.pf-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 10px;
  background: var(--paper); border: 2px solid var(--rule); border-radius: var(--r); box-shadow: 0 3px 0 var(--rule); cursor: pointer; font: inherit; color: var(--ink); }
.pf-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--rule); }
.pf-tile > img { width: 52px; height: 52px; object-fit: contain; }
.pf-tile > span { font-size: .82rem; font-weight: 700; }
.pf-tile > i { width: 52px; height: 36px; border-radius: 10px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.pf-tile .pet { margin: 4px 0; }
.pf-tile.on { border-color: var(--biro); box-shadow: 0 3px 0 var(--biro); background: var(--hover); }
.pf-tile.on::after { content: "✓"; position: absolute; top: 6px; right: 8px; font-weight: 900; color: var(--biro); }
.pf-tile.locked > img, .pf-tile.locked > i, .pf-tile.locked .pet { filter: grayscale(1) brightness(.75); opacity: .45; }
.pf-tile.locked > span { color: var(--muted); }
.pf-tile em { font-style: normal; font-size: .7rem; font-weight: 800; color: var(--muted); background: var(--hover); border-radius: 99px; padding: 2px 8px; }
.pf-tile.pro em { color: #fff; background: linear-gradient(135deg, #7a5cff, #18b4f5); }
.pf-tile.shake { animation: tile-shake .35s; }
@keyframes tile-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.sec-links { display: inline-flex; gap: 14px; }
.pf-friends { flex-wrap: wrap; overflow: visible; }

/* friend cards with pets */
.friends .fr { width: 112px; gap: 4px; }
.friends .fr .pet { margin-bottom: 4px; }
.fr-meta { display: inline-flex; align-items: center; gap: 3px; }
.fr-fl { display: inline-block; width: 14px; height: 17px; }
.fr-fl svg { width: 100%; height: 100%; overflow: visible; }
.fr-fl text { display: none; }
.friends .fr.done .fr-st { color: #1a7f37; }
.fr-li .pet { margin-right: 2px; }
.tbp-mascot.tbp-pet { align-self: center; height: auto; overflow: visible; display: grid; place-items: center; padding: 12px 6px; }
.tbp-pet .pet { --sz: 104px; }
@media (max-width: 420px) { .tbp-pet .pet { --sz: 88px; } }
@media (max-width: 640px) {
  .pf-hero { flex-direction: column; text-align: center; gap: 14px; padding: 24px 18px; }
  .pf-lv, .pf-stats { justify-content: center; }
  .pf-who h1 { font-size: 1.8rem; }
  .pf-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .pf-tile { padding: 10px 2px 8px; } .pf-tile > img { width: 44px; height: 44px; } .pf-tile > span { font-size: .74rem; }
  .pf-grid.colors, .pf-grid.borders { grid-template-columns: repeat(4, 1fr); }
}

/* photos as profile pictures, and the pet + border wherever you appear */
.pet img.ph { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; filter: none; }
.pet.is-photo { background: var(--hover); }
.pf-tile.photo > img.ph { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.pf-plus { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 2px dashed var(--rule); color: var(--muted); font-size: 1.6rem; }
.avatar.has-pet { background: none !important; overflow: visible; display: grid; place-items: center; }
.avatar.has-pet .pet { --sz: 36px; }
.hello-row { display: flex; align-items: center; gap: 14px; }
.hello-row .hello { margin: 0; }
.home-pet { display: inline-grid; text-decoration: none; transition: transform .15s; }
.home-pet:hover { transform: scale(1.06) rotate(-3deg); }
.home-pet .pet { --sz: 52px; }
@media (max-width: 640px) { .home-pet .pet { --sz: 42px; } }

/* calculator button inside questions and exams */
.calc-open-btn { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.calc-open-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 640px) { .setbar .calc-open-btn span { display: none; } }

/* marking: search for the paper, or upload any paper */
.mk-find { margin-top: 10px; }
.mk-find input { width: 100%; font-size: 1rem; }
.mk-results { display: grid; gap: 6px; margin-top: 8px; }
.mk-hit { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; text-align: left; gap: 0 10px; padding: 10px 14px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: 0 2px 0 var(--rule); }
.mk-hit b { font-size: 1rem; } .mk-hit span { color: var(--muted); font-size: .85rem; grid-column: 1; }
.mk-hit em { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-style: normal; font-weight: 700; color: var(--biro); font-size: .9rem; }
.mk-hit:hover { border-color: var(--biro); }
.mk-upload > .link { margin-top: 12px; }
.own-files { display: grid; gap: 8px; margin-top: 12px; }
.own-f { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px 14px; border: 1px dashed var(--rule); border-radius: var(--r); background: var(--paper); margin: 0; }
.own-f span { display: flex; flex-direction: column; } .own-f small { color: var(--muted); }
.own-res { margin-top: 16px; }
.own-total { display: flex; align-items: baseline; gap: 8px; }
.own-total b { font-family: var(--display); font-size: 2.6rem; line-height: 1; }
.own-total span { font-size: 1.2rem; font-weight: 700; color: var(--muted); }
.own-total em { font-style: normal; margin-left: auto; font-weight: 800; font-size: 1.2rem; color: var(--biro); }
.own-tbl { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .92rem; }
.own-tbl td { padding: 8px 6px; border-top: 1px solid var(--rule); vertical-align: top; }
.own-tbl .ol { font-weight: 700; white-space: nowrap; width: 1%; }
.own-tbl .om { font-weight: 800; white-space: nowrap; width: 1%; }
.own-tbl .om small, .own-tbl .of small { display: block; font-weight: 600; color: var(--muted); font-size: .78rem; }
.own-tbl tr.full .om { color: #1a7f37; } .own-tbl tr.zero .om { color: #c0392b; } .own-tbl tr.part .om { color: #b7791f; }
#own-history { margin-top: 18px; }

/* Trialbank Pro */
.pro-card { max-width: 560px; }
.pro-kick { margin: 0; font: 800 .8rem/1 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--biro); }
.pro-feats { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; gap: 10px; text-align: left; }
.pro-feats li { display: flex; flex-direction: column; padding-left: 30px; position: relative; }
.pro-feats li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--biro); color: #fff; font-size: .75rem; font-weight: 900; display: grid; place-items: center; }
.pro-feats span { color: var(--muted); font-size: .9rem; }
.pro-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.pro-plan { font: inherit; color: inherit; cursor: pointer; background: var(--paper); border: 2px solid var(--rule); border-radius: var(--r-lg); padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 4px 0 var(--rule); transition: transform .12s; }
.pro-plan b { font-family: var(--display); font-size: 2rem; line-height: 1.1; }
.pro-plan b small { font-size: .9rem; color: var(--muted); font-weight: 700; margin-left: 2px; }
.pro-plan > span:not(.pro-tag) { color: var(--muted); font-size: .85rem; }
.pro-plan em { font-style: normal; font-weight: 800; margin-top: 8px; padding: 8px 14px; border-radius: var(--r); background: var(--hover); width: 100%; }
.pro-plan.best { border-color: var(--biro); box-shadow: 0 5px 0 var(--biro-dark, #1d47b8); }
.pro-plan.best em { background: var(--biro); color: #fff; }
.pro-tag { font-size: .72rem; font-weight: 800; color: var(--biro); min-height: 1em; text-transform: uppercase; letter-spacing: .05em; }
.pro-plan:hover { transform: translateY(-2px); }
.pro-status { font-weight: 700; margin: 6px 0 12px; }
.menu-pro { color: var(--biro); font-weight: 800; }
@media (max-width: 480px) { .pro-plans { grid-template-columns: 1fr; } }

.tu-ask { display: flex; gap: 8px; margin-bottom: 16px; }
.tu-ask input { flex: 1; min-width: 0; font-size: 1rem; }

/* tutor allowance */
.tu-left { display: grid; grid-template-columns: auto; gap: 4px; min-width: 190px; margin-left: auto; text-align: right; }
.tu-left-n { font-size: 14px; }
.tu-left-n b { font-variant-numeric: tabular-nums; }
.tu-left-bar, .pro-use-bar { display: block; height: 6px; border-radius: 99px; background: var(--rule); overflow: hidden; }
.tu-left-bar i, .pro-use-bar i { display: block; height: 100%; border-radius: inherit; background: var(--biro); transition: width .4s ease; }
.tu-left.low .tu-left-bar i { background: var(--warn); }
.tu-left.low .tu-left-n b { color: var(--warn); }
.tu-left.out .tu-left-n { color: var(--bad); font-weight: 700; }
.pro-usage { display: grid; gap: 10px; margin: 4px 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--soft); text-align: left; }
.pro-usage > p { margin: 0; }
.pro-use { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.pro-use b { font-variant-numeric: tabular-nums; }
.pro-use b small { font-weight: 400; opacity: .7; }
.pro-use .pro-use-bar, .pro-use .small { grid-column: 1 / -1; }
@media (max-width: 560px) { .tu-head { flex-wrap: wrap; } .tu-left { order: 3; width: 100%; text-align: left; margin-left: 0; } }

.tu-left-bar, .pro-use-bar { position: relative; overflow: visible; }
.tu-left-bar i, .pro-use-bar i { overflow: hidden; }
.tu-left-bar::after, .pro-use-bar::after { content: ''; position: absolute; top: -3px; bottom: -3px; left: var(--tick, 100%); width: 2px; margin-left: -1px; border-radius: 2px; background: var(--ink); opacity: .45; }
.pace-ok { color: var(--muted); }
.pace-warn { color: var(--warn); font-weight: 600; }
.pace-out { color: var(--bad); font-weight: 600; }

/* tutor: send a whole paper to Auto-mark */
.tu-offer { align-self: stretch; padding: 14px 16px; border-radius: var(--r); background: var(--paper); box-shadow: var(--shadow); }
.tu-offer-h { font-weight: 700; margin: 0 0 4px; }
.tu-offer p { margin: 0 0 10px; }
.tu-offer-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tu-marked { max-width: 100%; }
.tu-am { text-align: left; }
.tu-am-f { display: grid; gap: 6px; margin: 12px 0; font-weight: 600; }
.tu-am-f em { font-weight: 400; font-style: normal; }
.tu-am-chk { display: flex; gap: 8px; align-items: center; margin: -4px 0 6px; }

/* tutor: photos from earlier */
.tu-recent { padding: 2px 2px 8px; }
.tu-recent p { margin: 0 0 6px; }
.tu-recent-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.tu-recent-row button { flex: none; width: 64px; height: 64px; padding: 0; border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; background: var(--paper); cursor: pointer; }
.tu-recent-row button:hover { border-color: var(--biro); }
.tu-recent-row img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Pro free week and referrals */
.pro-trial { width: 100%; font-size: 17px; padding: 14px 18px; }
.pro-trial-note { margin: 6px 0 14px; text-align: center; }
.pro-plans.after-trial .pro-plan.best { box-shadow: none; }
.pro-keep { font-weight: 700; margin: 4px 0 8px; }
.pro-ref { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); text-align: left; }
.pro-ref p { margin: 0 0 8px; font-size: 14px; }
.pro-ref-row { display: flex; gap: 8px; }
.pro-ref-row input { flex: 1; min-width: 0; font-size: 13px; }
.pro-plans.after-trial .pro-plan.best em { background: var(--hover); color: var(--ink); }

/* Explain my mistake */
.explain-btn { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0 10px; padding: 9px 14px; border-radius: var(--r); background: var(--biro-soft); color: var(--biro-dark); border: 0; font-weight: 700; cursor: pointer; }
.explain-btn:hover { filter: brightness(.97); }
.explain-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pro-chip { font-style: normal; font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 2px 7px; border-radius: 99px; background: var(--biro); color: #fff; }

/* custom practice paper */
.cp-card { margin-top: 18px; }
.cp-card h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.cp-card .cp-head p { margin: 0 0 12px; }
.cp-opts { display: grid; gap: 10px; }
.cp-opts .seg { flex-wrap: wrap; }
.cp-go { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }

/* tutor allowance bar above the chat box */
.tu-meter { padding: 2px 4px 10px; }
.tu-meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; font-size: 14px; }
.tu-meter-top b { font-variant-numeric: tabular-nums; font-size: 15px; }
.tu-meter-bar { position: relative; height: 10px; border-radius: 99px; background: var(--soft); box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.tu-meter-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--biro), #6f8cff); box-shadow: 0 1px 6px rgba(52,93,232,.35); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.tu-meter-bar::after { content: ''; position: absolute; top: -3px; bottom: -3px; left: var(--tick, 100%); width: 2px; margin-left: -1px; border-radius: 2px; background: var(--ink); opacity: .4; }
.tu-meter.low .tu-meter-bar i { background: linear-gradient(90deg, var(--warn), #f5b84a); box-shadow: 0 1px 6px rgba(217,119,6,.35); }
.tu-meter.low .tu-meter-top b { color: var(--warn); }
.tu-meter.out #tu-meter-n { color: var(--bad); font-weight: 700; }

/* HSC estimate: predicted band and ATAR */
.hsc-lead { margin-top: -6px; }
.hsc-kick { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--biro); margin: 0 0 6px; }
.hsc-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.hsc-big { font-family: var(--display); font-size: clamp(40px, 8vw, 64px); line-height: 1; margin: 0; letter-spacing: -.02em; }
.hsc-meta { font-size: 15px; }
.hsc-h3 { margin: 22px 0 8px; font-size: 16px; }
.hsc-hold { position: relative; }
.hsc-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--rule); }
.hsc-row b { color: var(--warn); font-variant-numeric: tabular-nums; }
.hsc-hold.locked .hsc-row { filter: blur(5px); user-select: none; }
.hsc-lock { position: absolute; inset: 0; display: grid; place-content: center; gap: 4px; text-align: center; background: color-mix(in srgb, var(--paper) 55%, transparent); }
.hsc-lock button { margin: 8px auto 0; }
.hsc-others { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.hsc-atar { margin-top: 18px; }
.atar-big { font-family: var(--display); font-size: clamp(44px, 9vw, 72px); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.atar-rows { display: grid; gap: 8px; margin: 16px 0 10px; }
.atar-row { display: grid; grid-template-columns: minmax(0, 1fr) 128px 150px 28px; gap: 10px; align-items: center; }
.atar-row select { min-width: 0; }
.atar-mark { display: flex; align-items: center; gap: 6px; }
.atar-mark input { width: 70px; }
.atar-foot { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.atar-note { margin-top: 12px; }
.hsc-teaser { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; text-decoration: none; color: inherit; }
.hsc-teaser b { font-size: 22px; font-family: var(--display); }
.hsc-teaser-go { margin-left: auto; color: var(--biro); font-weight: 700; }
@media (max-width: 560px) {
  .atar-row { grid-template-columns: auto minmax(0, 1fr) 24px; grid-template-areas: "c c x" "m s s"; row-gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
  .atar-row select { grid-area: c; } .atar-row .atar-mark { grid-area: m; } .atar-row .atar-sc { grid-area: s; } .atar-row .atar-x { grid-area: x; }
  .hsc-row { grid-template-columns: minmax(0, 1fr) auto auto; row-gap: 2px; }
  .hsc-row .hsc-t { grid-column: 1 / -1; font-weight: 600; }
  .hsc-row .hsc-pct { white-space: nowrap; }
}
.atar-hint { margin: -2px 0 12px; color: var(--biro-dark); }
.atar-mark span { white-space: nowrap; }

/* admin: AI spending and Pro */
.au-hero { margin: 6px 0 16px; }
.au-hero-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 15px; }
.au-hero-top b { font-size: 22px; font-variant-numeric: tabular-nums; }
.au-bar { height: 12px; }
.au-hero.low .au-bar i { background: linear-gradient(90deg, var(--warn), #f5b84a); }
.au-hero p { margin: 8px 0 0; }
.au-tiles .stat-tile em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 2px; }
.au-tiles .stat-tile.warn b { color: var(--warn); }
.au-controls { display: grid; gap: 10px; margin: 18px 0 6px; padding-top: 14px; border-top: 1px solid var(--rule); }
.au-cap { display: inline-flex; align-items: center; gap: 6px; }
.au-cap input { width: 90px; }
.au-h3 { margin: 18px 0 8px; font-size: 16px; }
.au-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.au-table th, .au-table td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--rule); white-space: nowrap; }
.au-table td.warn { color: var(--warn); font-weight: 700; }
.table-wrap { overflow-x: auto; }

.pro-ref-h { font-weight: 800; font-size: 15px; margin: 0 0 6px !important; }
.pro-ref-steps { margin: 0 0 8px; padding-left: 20px; font-size: 14px; display: grid; gap: 2px; }
.pro-ref-n { color: var(--good-dark); }
.modal.buy .buy-card { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }

/* tutor message packs */
.tu-more { margin-left: 8px; font-weight: 700; }
.tu-buyrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.tp-packs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.buy-price { font-weight: 800; font-size: 18px; margin-top: 6px; }
.pro-packs { margin: 12px 0 0; }
/* keep the newest tutor message clear of the sticky message box when it scrolls into view */
.tu-thread > *, .tu-done { scroll-margin-bottom: 230px; }

/* Tutor tab for students without it: the video, then the ways in */
.tu-intro { max-width: 640px; margin-top: 8px; }
.tu-intro-video { border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); background: #0e111c; }
.tu-intro-video video { display: block; width: 100%; height: auto; aspect-ratio: 1024 / 680; }
.tu-intro-copy h2 { margin: 0 0 12px; font-size: 26px; }
.tu-intro-why { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 12px; }
.tu-intro-why li { display: grid; gap: 2px; }
.tu-intro-why span { color: var(--muted); font-size: 14px; }
.tu-intro-go { display: grid; gap: 8px; justify-items: start; }
.tu-intro-go .primary { font-size: 17px; padding: 13px 22px; }
.tu-intro-go p { margin: 0; }
@media (max-width: 760px) { .tu-intro { grid-template-columns: 1fr; } }

/* flag a question */
.flag-card { text-align: left; max-width: 460px; }
.flag-reasons { display: grid; gap: 8px; margin: 14px 0 10px; }
.flag-r { text-align: left; padding: 10px 14px; border-radius: var(--r); border: 2px solid var(--rule); background: var(--paper); font-weight: 600; cursor: pointer; }
.flag-r.on { border-color: var(--biro); background: var(--biro-soft); color: var(--biro-dark); }
.flag-card textarea { width: 100%; margin-bottom: 12px; }
.tu-qacts { display: inline-flex; gap: 12px; }
.flags-card .flag-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 12px 0; border-top: 1px solid var(--rule); }
.flag-row img, .flag-noimg { width: 140px; max-height: 110px; object-fit: contain; object-position: top left; border: 1px solid var(--rule); border-radius: var(--r-sm); background: #fff; display: block; }
.flag-noimg { height: 60px; display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.flag-info { display: grid; gap: 4px; }
.flag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.flag-chips em { font-style: normal; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--bad-soft); color: var(--bad-dark); }
@media (max-width: 560px) { .flags-card .flag-row { grid-template-columns: 90px minmax(0, 1fr); } .flag-row img, .flag-noimg { width: 90px; } .flags-card .flag-row button { grid-column: 1 / -1; } }

/* ---------- Study together ---------- */
#view-study { --stw: min(1240px, 100vw - 32px); width: var(--stw); margin-left: calc((100% - var(--stw)) / 2); }
.st-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.st-head h1 { margin-bottom: 2px; }
.st-room { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-room b { letter-spacing: .08em; color: var(--ink); }
.st-lobby { max-width: 620px; }
.st-lobby h2 { margin-top: 0; }
.st-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.st-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.st-tool { font: inherit; font-size: .88rem; font-weight: 700; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; }
.st-tool:hover { background: var(--hover); }
.st-tool.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.st-colours, .st-sizes { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); }
.st-col { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--paper); background: var(--c); cursor: pointer; padding: 0; }
.st-col.on { box-shadow: 0 0 0 2px var(--ink); }
.st-size { width: 26px; height: 26px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.st-size i { background: var(--ink); border-radius: 50%; display: block; }
.st-size.on { background: var(--hover); }
.st-sep { flex: 1; }
.st-qform { display: inline-flex; gap: 4px; }
.st-qform input { width: 230px; font: inherit; font-size: .88rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); }
.st-board { position: relative; aspect-ratio: 16 / 10; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 3px 0 var(--rule); }
.st-board img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: top center; pointer-events: none; user-select: none; }
.st-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
body.st-hosting .st-board canvas { cursor: crosshair; }
.st-over { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, #fff 82%, transparent); text-align: center; color: #1f2329; }
.st-over div { display: grid; gap: 4px; }
.st-side { display: grid; gap: 14px; }
.st-panel { margin: 0; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.st-ph { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.st-msgs { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 340px; min-height: 60px; }
#st-coach .st-msgs { max-height: 420px; }
.st-msgs .tu-msg { max-width: 100%; font-size: .93rem; padding: 8px 12px; }
.st-msgs .tu-msg .link { margin-top: 6px; padding: 0; }
.st-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.st-quick:empty { display: none; }
.st-quick .chip { font-size: .8rem; padding: 4px 10px; }
.st-send { display: flex; gap: 6px; }
.st-send input { flex: 1; min-width: 0; font: inherit; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--soft); color: var(--ink); }
.st-cm { font-size: .92rem; line-height: 1.45; }
.st-cm > b { display: block; font-size: .78rem; color: var(--muted); }
.st-cm.me > b { color: var(--biro); }
.st-cm.coach { background: var(--soft); border-radius: var(--r-sm); padding: 8px 10px; }
@media (max-width: 900px) {
  .st-main { grid-template-columns: 1fr; }
  .st-qform input { width: 170px; }
}
.st-friends { display: grid; gap: 6px; }
.st-fr { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.st-fr i { width: 9px; height: 9px; border-radius: 50%; background: var(--rule-strong); flex: none; }
.st-fr.on i { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.st-fr b { flex: 1; font-size: .93rem; }
.st-fr:not(.on) b { color: var(--muted); font-weight: 600; }
.st-fr button.small { padding: 5px 12px; font-size: .82rem; }
.st-codein { width: 150px; font: inherit; text-transform: uppercase; letter-spacing: .12em; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--rule); background: var(--soft); color: var(--ink); }

/* ---------- Practise (redesign) ---------- */
.pr-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.pr-head h1 { margin-bottom: 2px; }
.pr-head p { margin: 0; }
.pr-headlinks { display: flex; align-items: center; gap: 14px; }
.pr-quick { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; margin-bottom: 18px; }
.pr-q { text-align: left; display: grid; gap: 4px; align-content: start; padding: 18px 20px; border-radius: var(--r-lg); min-height: 112px; }
.pr-q b { font-family: var(--display); font-size: 1.3rem; line-height: 1.15; }
.pr-q-k { font-size: .78rem; font-weight: 800; letter-spacing: .04em; color: var(--muted); }
.pr-q-s { font-size: .92rem; color: var(--muted); line-height: 1.4; }
.pr-q.main { background: var(--biro); border-color: var(--biro-dark); box-shadow: 0 5px 0 var(--biro-dark); color: #fff; }
.pr-q.main .pr-q-k, .pr-q.main .pr-q-s { color: color-mix(in srgb, #fff 82%, var(--biro)); }
.pr-q.main b { font-size: 1.5rem; }
.pr-q.main:hover { border-color: var(--biro-dark); filter: brightness(1.05); }
.pr-topics { margin: 0 0 18px; }
.pr-tools { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.pr-tools h2 { margin: 0; }
.pr-tools input { flex: 1; min-width: 160px; margin: 0; }
.pr-links { display: flex; gap: 12px; white-space: nowrap; }
.pr-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 2px; }
.pr-key span { display: inline-flex; align-items: center; gap: 6px; }
.k { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.k.low { background: var(--bad); } .k.mid { background: var(--mid); } .k.high { background: var(--good); } .k.new { background: var(--rule-strong); }
.tp-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tp { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 14px; border-radius: var(--r); box-shadow: 0 3px 0 var(--rule); min-height: 58px; }
.tp-box { width: 22px; height: 22px; flex: none; border-radius: 7px; border: 2px solid var(--rule-strong); background: var(--paper); display: grid; place-items: center; }
.tp.on { border-color: var(--biro); background: var(--biro-soft); box-shadow: 0 3px 0 var(--biro); }
.tp.on .tp-box { background: var(--biro); border-color: var(--biro); }
.tp.on .tp-box::after { content: ''; width: 10px; height: 5px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.tp-name { flex: 1; min-width: 0; font-weight: 700; line-height: 1.25; }
.tp-name small { display: block; font-weight: 600; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.tp-you { display: flex; align-items: center; gap: 8px; flex: none; font-size: .88rem; }
.tp-you em { font-style: normal; color: var(--muted); font-size: .8rem; }
.tp-bar { width: 56px; height: 7px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.tp-bar i { display: block; height: 100%; border-radius: 99px; background: var(--rule-strong); }
.tp.low .tp-bar i { background: var(--bad); } .tp.mid .tp-bar i { background: var(--mid); } .tp.high .tp-bar i { background: var(--good); }
.tp-you b { width: 36px; text-align: right; }
.tgroup.later .tp:not(.on) { opacity: .6; }
.pr-bar { position: sticky; bottom: 12px; z-index: 6; margin-top: 18px; background: var(--paper); border: 2px solid var(--rule); border-radius: var(--r-lg); padding: 10px 12px 10px 18px; box-shadow: 0 8px 24px var(--shadow); }
.pr-bar-row { display: flex; align-items: center; gap: 14px; }
.pr-bar-l { flex: 1; min-width: 0; display: grid; }
.pr-bar-l .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-bar:not(.ready) .pr-bar-l b { color: var(--muted); }
.pr-bar .primary { padding: 12px 30px; font-size: 1.05rem; }
.pr-opts { display: grid; gap: 10px; padding: 6px 0 14px; margin-bottom: 10px; border-bottom: 2px dashed var(--rule); }
.cp-card.pulse { animation: cp-pulse 1.1s ease-out; }
@keyframes cp-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--biro) 45%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
@media (max-width: 720px) {
  .pr-quick { grid-template-columns: 1fr; }
  .pr-q { min-height: 0; }
  .tp-list { grid-template-columns: 1fr; }
  .pr-opts .opt { flex-direction: column; align-items: stretch; gap: 6px; }
  .pr-opts .seg { display: flex; } .pr-opts .seg button { flex: 1; padding: 8px 4px; }
}
@media (max-width: 640px) { .pr-bar { bottom: 74px; } }
.pr-q { justify-content: stretch; justify-items: start; }
.pr-tools h2 { text-align: left; }
@media (max-width: 720px) {
  .pr-tools h2 { width: 100%; }
  .pr-bar:not(.ready) { display: none; }
  .pr-head { align-items: flex-start; }
}

/* ---------- Progress (redesign) ---------- */
.pg-head { margin-bottom: 12px; } .pg-head h1 { margin-bottom: 2px; } .pg-head p { margin: 0; }
.pg-top { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; }
.pg-top .card { margin: 0; }
.pg-hero { display: grid; gap: 6px; align-content: start; padding: 22px 24px; }
.pg-hero p { margin: 0; }
.pg-hero .primary { justify-self: start; margin-top: 8px; }
.pg-k { font-size: .8rem; font-weight: 800; letter-spacing: .03em; color: var(--muted); margin: 0; }
.pg-big { font-family: var(--display); font-weight: 800; font-size: 3.4rem; line-height: 1; letter-spacing: -.02em; }
.pg-big.low { color: var(--bad); } .pg-big.mid { color: var(--warn); } .pg-big.high { color: var(--good); }
.pg-big.muted { font-size: 2rem; color: var(--muted); }
.pg-band { display: grid; gap: 6px; align-content: start; padding: 22px 24px; color: var(--ink); text-decoration: none; }
.pg-band:hover { text-decoration: none; border-color: var(--rule-strong); }
.pg-bandv { font-family: var(--display); font-weight: 800; font-size: 2.2rem; line-height: 1.05; }
.pg-bandv.muted { font-size: 1.6rem; color: var(--ink); }
.pg-unlock { height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.pg-unlock i { display: block; height: 100%; background: var(--biro); border-radius: 99px; }
.pg-more { color: var(--biro); font-weight: 700; font-size: .92rem; margin-top: 4px; }
.pg-ch { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.pg-ch h2 { margin: 0; }
.pg-days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; height: 120px; }
.pg-day { display: grid; grid-template-rows: 18px 1fr 18px; justify-items: center; gap: 4px; }
.pg-n { font-size: .75rem; font-weight: 700; color: var(--muted); }
.pg-col { width: 100%; max-width: 30px; background: var(--soft); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.pg-col i { display: block; width: 100%; background: var(--biro); border-radius: 8px; }
.pg-d { font-size: .75rem; color: var(--muted); font-weight: 700; }
.pg-day.today .pg-d { color: var(--biro); }
.pg-group + .pg-group { margin-top: 16px; padding-top: 14px; border-top: 2px dashed var(--rule); }
.pg-group h3 { font-size: 1rem; margin: 0 0 6px; }
.pg-row { display: grid; grid-template-columns: minmax(0, 15rem) minmax(80px, 1fr) 4.6rem auto; align-items: center; gap: 14px; padding: 7px 0; }
.pg-t { font-weight: 700; font-size: .95rem; line-height: 1.25; }
.pg-t small { font-weight: 600; color: var(--muted); }
.pg-track { position: relative; height: 12px; border-radius: 99px; background: var(--soft); }
.pg-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--rule-strong); }
.pg-row.low .pg-fill { background: var(--bad); } .pg-row.mid .pg-fill { background: var(--mid); } .pg-row.high .pg-fill { background: var(--good); }
.pg-tick { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); opacity: .55; }
.pg-tick-k { display: inline-block; width: 3px; height: 12px; border-radius: 2px; background: var(--ink); opacity: .55; }
.pg-p { display: grid; text-align: right; line-height: 1.15; }
.pg-p small { color: var(--muted); font-size: .75rem; }
.pg-p em { font-style: normal; color: var(--muted); font-size: .82rem; }
.pg-do { padding: 6px 12px; font-size: .85rem; }
.pg-row.later { opacity: .65; }
@media (max-width: 720px) {
  .pg-top { grid-template-columns: 1fr; }
  .pg-big { font-size: 2.8rem; }
  .pg-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "t p do" "bar bar do"; column-gap: 10px; row-gap: 6px; padding: 9px 0; }
  .pg-t { grid-area: t; } .pg-p { grid-area: p; } .pg-track { grid-area: bar; } .pg-do { grid-area: do; }
  .pg-days { gap: 3px; height: 100px; }
}
.pg-do { background: none; border-color: transparent; box-shadow: none; color: var(--biro); padding: 6px 8px; }
.pg-do:hover { background: var(--biro-soft); border-color: transparent; }

/* ---------- Marking (redesign) ---------- */
.mk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.mk-head h1 { margin-bottom: 2px; }
.mk-lede { margin: 0; }
.mk-chip { flex: none; border-radius: 999px; padding: 8px 16px; font-size: .92rem; white-space: nowrap; margin-top: 8px; }
.mk-chip b { color: var(--biro); font-size: 1.05rem; }
.mk-chip.out b { color: var(--bad); }
.mk-how { margin: 16px 0 14px; gap: 8px; }
.mk-how li { flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; background: transparent; border: 0; }
.mk-how li::before { flex: none; }
.mk-how li b { white-space: nowrap; }
.mk-how li span { font-size: .85rem; line-height: 1.3; }
.mk-upload { padding: 22px; margin-top: 0; }
.mk-upload h2 { font-size: 1.45rem; margin-bottom: 2px; }
.mk-find input { font-size: 1.08rem; padding: 14px 16px; }
.mk-results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mk-results > p { grid-column: 1 / -1; margin: 2px 0 0; }
.mk-hit { padding: 12px 16px; }
.mk-balance { text-align: left; padding: 20px 22px; }
.mk-balance h2 { margin-bottom: 10px; }
.mk-balance .mk-big { display: flex; align-items: baseline; gap: 10px; }
.mk-balance .mk-big b { display: inline; font-size: 2.6rem; line-height: 1; }
.mk-balance .mk-big span { display: inline; margin: 0; font-size: 1rem; }
.mk-balance .mk-tiles { justify-content: flex-start; margin: 14px 0; }
.mk-balance .mk-buy { min-width: 0; margin-top: 14px; }
@media (max-width: 720px) {
  .mk-head { flex-direction: column; gap: 6px; }
  .mk-chip { margin: 0; }
  .mk-how { grid-template-columns: 1fr; gap: 0; margin: 10px 0; }
  .mk-how li { padding: 6px 0; }
  .mk-results { grid-template-columns: 1fr; }
}
.mk-main { padding: 22px; margin-top: 0; }
.mk-main h2 { font-size: 1.45rem; margin-bottom: 2px; }
.mk-drops { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 10px; }
.mk-drop { position: relative; display: grid; gap: 4px; align-content: start; padding: 18px; border: 2px dashed var(--rule-strong); border-radius: var(--r-lg); background: var(--soft); cursor: pointer; min-height: 150px; transition: border-color .15s, background .15s; }
.mk-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mk-drop:hover, .mk-drop.over { border-color: var(--biro); background: var(--biro-soft); }
.mk-drop:focus-within { outline: 3px solid color-mix(in srgb, var(--biro) 40%, transparent); outline-offset: 2px; }
.mk-drop b { font-family: var(--display); font-size: 1.15rem; }
.mk-dn { width: 26px; height: 26px; border-radius: 50%; background: var(--biro); color: #fff; font-weight: 800; font-size: .85rem; display: grid; place-items: center; margin-bottom: 4px; }
.mk-dh { color: var(--muted); font-size: .88rem; line-height: 1.35; }
.mk-df { margin-top: auto; padding-top: 10px; font-weight: 700; color: var(--biro); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-drop.has { border-style: solid; border-color: var(--good); background: var(--good-soft); }
.mk-drop.has .mk-dn { background: var(--good); }
.mk-drop.has .mk-df { color: var(--good-dark); }
.mk-drop.has .mk-df::before { content: '✓ '; }
.small-drop { min-height: 0; margin-top: 10px; }
.mk-sep summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.mk-go { padding: 13px 28px; font-size: 1.08rem; }
.mk-main .mk-row { align-items: center; margin-top: 14px; }
.mk-priv { margin: 10px 0 0; }
@media (max-width: 720px) { .mk-drops { grid-template-columns: 1fr; } .mk-drop { min-height: 0; } }
.mk-drop, .mk-drop b { color: var(--ink); }

/* ---------- where your class is up to ---------- */
.pr-up { display: grid; text-align: left; line-height: 1.2; padding: 7px 14px; border-radius: var(--r); }
.pr-up b { font-size: .95rem; }
.pr-up.unset { background: var(--hl); border-color: var(--hl-edge); box-shadow: 0 4px 0 var(--hl-edge); }
.pr-up.unset .muted { color: var(--ink); opacity: .7; }
.up-card { max-width: 520px; width: 100%; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.up-list { overflow-y: auto; margin: 6px -4px 0; padding: 0 4px 4px; display: grid; gap: 4px; }
.up-list h3 { font-size: .9rem; margin: 12px 0 2px; color: var(--muted); }
.up-list h3:first-child { margin-top: 4px; }
.up-row { display: flex; align-items: center; gap: 12px; text-align: left; padding: 9px 12px; border-radius: var(--r); box-shadow: none; border-width: 2px; font-family: var(--font); font-weight: 700; }
.up-row i { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--rule-strong); display: grid; place-items: center; }
.up-row span { flex: 1; }
.up-row em { font-style: normal; font-size: .8rem; color: var(--muted); font-weight: 700; }
.up-row.done { background: var(--good-soft); border-color: transparent; }
.up-row.done i { background: var(--good); border-color: var(--good); }
.up-row.done i::after { content: ''; width: 9px; height: 5px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.up-row.now { background: var(--biro-soft); border-color: var(--biro); }
.up-row.now i { border-color: var(--biro); background: var(--paper); box-shadow: inset 0 0 0 4px var(--biro); }
.up-row.now em { color: var(--biro); }
.up-row:not(.done):not(.now) span { color: var(--muted); }
.up-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--rule); }
.up-acts { display: flex; gap: 10px; margin-left: auto; }

/* ---------- Admin: syllabus steps ---------- */
.steps-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.steps-top select { flex: 1; min-width: 200px; margin: 0; }
.steps-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.steps-legend .chip { font-size: .82rem; padding: 5px 10px; box-shadow: none; }
.steps-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.steps-q { border: 2px solid var(--rule); border-radius: var(--r); padding: 8px; background: var(--paper); }
.steps-qh { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.steps-qh b { flex: 1; }
.steps-qh em { font-style: normal; font-weight: 800; background: var(--biro); color: #fff; border-radius: 6px; padding: 1px 7px; margin-left: 3px; }
.steps-qh em.out { background: var(--mid); }
.steps-q img { width: 100%; border-radius: 8px; background: #fff; }
/* how far into the topic */
.up-steps { margin: 2px 0 8px 32px; display: grid; gap: 4px; }
.up-steps p { margin: 4px 0; }
.up-step { display: flex; align-items: center; gap: 10px; text-align: left; padding: 7px 10px; border-radius: var(--r-sm); box-shadow: none; font-family: var(--font); font-weight: 600; font-size: .9rem; }
.up-step i { width: 16px; height: 16px; flex: none; border-radius: 5px; border: 2px solid var(--rule-strong); }
.up-step.done { background: var(--biro-soft); border-color: transparent; }
.up-step.done i { background: var(--biro); border-color: var(--biro); }
.up-step { justify-content: flex-start; } .up-step span { flex: 1; }

/* ---------- Your data (Profile) ---------- */
.pf-data { margin-top: 22px; }
.pf-data h2 { margin-bottom: 2px; }
.pf-data-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 2px solid var(--rule); }
.pf-data-row:first-of-type { margin-top: 10px; }
.pf-data-row > div { flex: 1; display: grid; gap: 2px; }
.pf-data-row button { flex: none; min-width: 108px; }
.danger, .danger:hover { background: var(--paper); color: var(--bad); border-color: var(--bad-soft); box-shadow: 0 4px 0 var(--bad-soft); }
.danger:hover { background: var(--bad-soft); }
.modal .danger { background: var(--bad); color: #fff; border-color: var(--bad-dark); box-shadow: 0 4px 0 var(--bad-dark); }
.del-confirm { display: block; width: 100%; margin: 14px 0 0; font: inherit; font-size: 1rem; letter-spacing: .1em; text-transform: uppercase; padding: 10px 14px; border-radius: var(--r-sm); border: 2px solid var(--rule); background: var(--soft); color: var(--ink); }
@media (max-width: 560px) { .pf-data-row { flex-wrap: wrap; } .pf-data-row button { width: 100%; } }

/* ---------- annotation v2: write anywhere on the page, no text selection, full screen ---------- */
body.annotating, body.annotating * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.annotating input, body.annotating textarea { -webkit-user-select: text; user-select: text; }
.ann-canvas { pointer-events: none; -webkit-tap-highlight-color: transparent; }
.ann-live { pointer-events: auto; cursor: crosshair; touch-action: none; z-index: 6; }
.ann-on > .ann-space { margin-top: 18px; }
.ann-bar .ann-size i { display: block; border-radius: 50%; background: currentColor; }
.ann-bar .ann-size .sz-thin { width: 5px; height: 5px; } .ann-bar .ann-size .sz-med { width: 8px; height: 8px; } .ann-bar .ann-size .sz-thick { width: 12px; height: 12px; }
.ann-bar .armed { background: var(--bad); color: #fff; border-color: var(--bad); padding: 0 12px; }
.ann-sure { font: 800 .8rem var(--font); white-space: nowrap; }
.ann-bar { gap: 4px; }
/* full screen: just the question page and the tools */
body.ann-full .top, body.ann-full footer, body.ann-full .mainnav { display: none !important; }
body.ann-full main { padding-top: 12px; }
body.ann-full .ann-bar { bottom: calc(16px + env(safe-area-inset-bottom)); }
@media (max-width: 640px) { body.ann-full.annotating .ann-bar { bottom: calc(12px + env(safe-area-inset-bottom)); } }

/* ---------- annotation tool palette: a frosted floating tray ---------- */
.ann-bar { --tb-body: #f7f7f9; --tb-cone: #e3e5ea; --tb-line: rgba(30, 34, 44, .12);
  gap: 6px; padding: 0 8px 0 10px; height: 64px; border-radius: 22px; overflow: visible;
  background: color-mix(in srgb, var(--paper) 82%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--tb-line); box-shadow: 0 12px 40px rgba(20, 24, 34, .18), 0 1px 0 rgba(255, 255, 255, .6) inset; align-items: center; }
:root[data-theme="dark"] .ann-bar { --tb-body: #3a3e47; --tb-cone: #2e3139; --tb-line: rgba(255, 255, 255, .1); box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.ann-bar button { box-shadow: none; border: 0; background: none; padding: 0; min-width: 0; height: auto; color: var(--ink); }
.ann-bar button:hover { background: none; }
.ann-bar button:active:not(:disabled) { transform: none; box-shadow: none; }
/* the tools, standing in a tray; the one in use lifts up */
.ann-tray { display: flex; align-items: flex-end; gap: 2px; height: 64px; overflow: hidden; padding: 0 2px; align-self: stretch; }
.ann-tool { width: 30px; height: 64px; display: block; transform: translateY(18px); transition: transform .22s cubic-bezier(.3, 1.4, .5, 1); }
.ann-tool:hover { transform: translateY(13px); }
.ann-tool.on { transform: translateY(3px); }
.ann-tool svg { width: 30px; height: 64px; display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .12)); }
.ann-tool .tb { fill: var(--tb-body); stroke: var(--tb-line); stroke-width: 1; }
.ann-tool .tc { fill: var(--tb-cone); stroke: var(--tb-line); stroke-width: 1; }
.ann-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-left: 1px solid var(--tb-line); height: 34px; }
.ann-dot { width: 26px; height: 32px; display: grid; place-items: center; border-radius: 10px; }
.ann-dot i { display: block; border-radius: 50%; background: var(--ink); opacity: .35; }
.ann-dot.on i { opacity: 1; }
.ann-dot .sz-thin { width: 4px; height: 4px; } .ann-dot .sz-med { width: 7px; height: 7px; } .ann-dot .sz-thick { width: 11px; height: 11px; }
.ann-sw { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.ann-sw::before { content: ''; width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .15s; }
.ann-sw:hover::before { transform: scale(1.08); }
.ann-sw.on { box-shadow: 0 0 0 2px var(--c) !important; }
.ann-sw.on::before { width: 18px; height: 18px; }
.ann-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted) !important; }
.ann-ic:hover { color: var(--ink) !important; background: color-mix(in srgb, var(--ink) 7%, transparent) !important; }
.ann-ic.lit { color: var(--biro) !important; }
.ann-ic svg { width: 19px; height: 19px; }
.ann-ic.armed { width: auto; padding: 0 10px !important; background: var(--bad) !important; color: #fff !important; }
.ann-bar .ann-done { margin-left: 4px; padding: 0 16px; height: 36px; border-radius: 12px; background: var(--ink); color: var(--paper); font: 800 .92rem var(--font); }
.ann-bar .ann-done:hover { background: var(--ink); filter: brightness(1.15); }
@media (max-width: 640px) {
  .ann-bar { gap: 2px; padding: 0 6px; max-width: calc(100vw - 12px); overflow-x: auto; overflow-y: hidden; }
  .ann-sizes { display: none; }
  .ann-group { padding: 0 3px; }
  .ann-sw { width: 26px; } .ann-ic { width: 30px; }
}
.ann-bar button.on, .ann-bar button:focus { outline: none; }
.ann-bar button:focus-visible { outline: 2px solid var(--biro); outline-offset: 2px; }
:root[data-theme="dark"] .ann-sw::before { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .28); }
:root[data-theme="dark"] .ann-sw.on[data-c="#1f2329"] { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55) !important; }
@media (max-width: 640px) {
  .ann-bar { overflow: hidden; padding: 0 6px 0 4px; gap: 0; }
  .ann-tool { width: 26px; } .ann-tool svg { width: 26px; }
  .ann-sw { width: 26px; height: 26px; } .ann-sw::before { width: 19px; height: 19px; } .ann-sw.on::before { width: 15px; height: 15px; }
  .ann-ic { width: 30px; height: 32px; }
  .ann-ic[data-a="redo"], .ann-ic[data-a="full"] { display: none; }
  .ann-bar .ann-done { padding: 0 10px; font-size: .85rem; margin-left: 2px; }
}
.ann-bar .ann-sw { width: 30px; height: 30px; flex: none; }
.ann-bar .ann-tool { width: 30px; height: 64px; flex: none; }
.ann-bar .ann-dot { width: 26px; height: 32px; flex: none; }
.ann-bar .ann-ic { width: 34px; height: 34px; flex: none; }
@media (max-width: 640px) { .ann-bar .ann-sw { width: 26px; height: 26px; } .ann-bar .ann-tool { width: 26px; } .ann-bar .ann-ic { width: 30px; height: 32px; } }
.ann-tray { flex: none; }
@media (max-width: 640px) { .ann-ic[data-a="clear"] { display: none; } .ann-bar .ann-done { padding: 0 12px; } }

/* ---------- question bar: exit, where you are, tools ---------- */
.setbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 10px; }
.sb-pos { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: .92rem; }
.sb-pos b { flex: none; }
.sb-pos span { color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-tools { display: flex; align-items: center; gap: 4px; }
.setbar .sb-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 11px; border-radius: 12px; border: 0; background: none; box-shadow: none;
  color: var(--muted); font: 700 .88rem var(--font); }
.setbar .sb-btn:hover { background: var(--hover); color: var(--ink); }
.setbar .sb-btn:active:not(:disabled) { transform: none; box-shadow: none; background: var(--soft); }
.setbar .sb-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.setbar .sb-btn.lit { color: var(--warn); }
.setbar #star.lit svg { fill: #f5b301; stroke: #e0a100; }
.setbar #flag-q.lit { color: var(--bad); }
.setbar .sb-exit { color: var(--ink); padding-left: 6px; }
.setbar .sb-tutor { background: var(--biro-soft); color: var(--biro); }
.setbar .sb-tutor:hover { background: var(--biro-soft); color: var(--biro); filter: brightness(.97); }
@media (max-width: 760px) {
  .setbar .sb-l { display: none; }
  .setbar .sb-btn { width: 38px; padding: 0; justify-content: center; }
  .setbar .sb-tutor { width: auto; padding: 0 11px; }
  .sb-pos { flex-direction: column; gap: 0; align-items: flex-start; line-height: 1.2; }
  .sb-pos span { font-size: .8rem; max-width: 100%; }
  .sb-tools { gap: 0; }
}
@media (max-width: 400px) { .setbar .sb-tutor span { display: none; } .setbar .sb-tutor { width: 38px; padding: 0; justify-content: center; } }
.is-empty { display: none !important; }

/* ---------- dot points inside a topic (Practise) ---------- */
.tp-wrap { display: grid; align-content: start; }
.tp-wrap .tp { width: 100%; }
.tp-wrap.open .tp, .tp-wrap .tp.has-steps { border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; }
.tp-more { justify-self: stretch; display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: -2px; padding: 5px 10px 4px; border-radius: 0 0 var(--r) var(--r);
  border: 2px solid var(--rule); border-top: 0; box-shadow: 0 3px 0 var(--rule); font: 700 .8rem var(--font); color: var(--biro); background: var(--soft); }
.tp-more:hover { background: var(--biro-soft); border-color: var(--rule); }
.tp-more:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--rule); }
.tp-more svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.tp-wrap.open .tp-more svg { transform: rotate(180deg); }
.tp-wrap.part .tp-more { color: var(--ink); background: var(--biro-soft); }
.tp-steps { display: grid; gap: 4px; padding: 10px 2px 6px; }
.tp-steps p { margin: 0 4px 4px; }
.tp-step { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border-radius: var(--r-sm); box-shadow: none; border-width: 2px; font: 600 .88rem/1.3 var(--font); }
.tp-step i { width: 18px; height: 18px; flex: none; border-radius: 6px; border: 2px solid var(--rule-strong); display: grid; place-items: center; }
.tp-step span { flex: 1; }
.tp-step em { font-style: normal; font-size: .75rem; color: var(--muted); font-weight: 700; }
.tp-step.on { border-color: var(--biro); background: var(--biro-soft); }
.tp-step.on i { background: var(--biro); border-color: var(--biro); }
.tp-step.on i::after { content: ''; width: 8px; height: 4px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.tp-step:disabled { opacity: .55; }
.tp-steps .tp-all { justify-self: start; margin: 2px 4px 0; padding: 0; }
.pr-elsewhere { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.pr-elsewhere p { margin: 0; width: 100%; }
.pr-elsewhere button { font-size: .88rem; padding: 7px 12px; }
.tp-wrap[hidden] { display: none; }

/* ---------- Practise, calmer (Oct 2026): one list, one Start button ---------- */
#view-practise .pr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
#view-practise .pr-head h1 { margin: 0; }
#view-practise .pr-up { display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 14px; border-radius: 99px; background: var(--paper); border: 2px solid var(--rule); box-shadow: none; font-size: .9rem; }
#view-practise .pr-up b { font-size: .9rem; }
#view-practise .pr-up.unset { background: var(--paper); border-color: var(--rule); box-shadow: none; }
#view-practise .pr-up.unset b { color: var(--biro); }
#view-practise .pr-up.unset .muted { opacity: 1; color: var(--muted); }
.pr-pick { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 18px; margin-bottom: 14px; border-radius: var(--r-lg); }
.pr-pick > span { flex: 1; min-width: 0; display: grid; gap: 2px; }
.pr-pick b { font-size: 1.02rem; }
.pr-pick small { color: var(--muted); font-size: .86rem; font-weight: 600; }
.pr-pick svg, .cp-card summary svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
#view-practise .pr-topics { padding-top: 16px; }
#view-practise .pr-tools { display: flex; align-items: center; gap: 12px; margin: 0 0 4px; }
#view-practise .pr-tools input { flex: 1; margin: 0; }
#view-practise .tgroup { border-top: 1px solid var(--rule); margin-top: 10px; padding: 14px 0 0; }
#view-practise .tgroup:first-child { border-top: 0; margin-top: 4px; padding-top: 8px; }
#view-practise .tg-head { margin-bottom: 2px; }
#view-practise .tg-head h3 { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
#view-practise .tp-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; }
#view-practise .tp-wrap { grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-bottom: 1px solid var(--rule); }
#view-practise .tp { background: none; border: 0; box-shadow: none; border-radius: 10px; min-height: 50px; padding: 8px 6px; gap: 12px; }
#view-practise .tp:hover { background: var(--soft); }
#view-practise .tp.on { background: none; box-shadow: none; }
#view-practise .tp-box { width: 21px; height: 21px; border-radius: 6px; }
#view-practise .tp-name { font-weight: 650; }
#view-practise .tp-name small { font-size: .76rem; }
#view-practise .tp.on .tp-name { color: var(--biro); }
#view-practise .tp-you { gap: 6px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.tp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rule-strong); }
.tp.low .tp-dot { background: var(--bad); } .tp.mid .tp-dot { background: var(--mid); } .tp.high .tp-dot { background: var(--good); }
#view-practise .tp-more { margin: 0; padding: 6px 8px; border: 0; box-shadow: none; background: none; border-radius: 10px; color: var(--muted); font-size: .78rem; }
#view-practise .tp-more:hover { color: var(--biro); background: var(--biro-soft); }
#view-practise .tp-wrap.part .tp-more, #view-practise .tp-wrap.open .tp-more { color: var(--biro); background: none; }
#view-practise .tp-wrap.open .tp, #view-practise .tp-wrap .tp.has-steps { border-radius: 10px; }
#view-practise .tp-steps { grid-column: 1 / -1; padding: 2px 0 12px 34px; }
#view-practise .tgroup.later .tp:not(.on) { opacity: .55; }
.pr-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 0 0; }
.pr-foot .link { color: var(--muted); }
.pr-foot .link:hover { color: var(--biro); }
.cp-card { margin-top: 14px; padding: 0; }
.cp-card summary { display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; list-style: none; border-radius: var(--r-lg); }
.cp-card summary::-webkit-details-marker { display: none; }
.cp-card summary:hover { background: var(--soft); }
.cp-card summary > span { flex: 1; display: grid; gap: 2px; }
.cp-card summary b { font-size: 1.02rem; }
.cp-card summary small { color: var(--muted); font-size: .86rem; font-weight: 600; }
.cp-card[open] summary svg { transform: rotate(180deg); }
.cp-card > :not(summary) { margin-left: 18px; margin-right: 18px; }
.cp-card #cp-sub { margin-top: 0; }
.cp-card .cp-go { margin-bottom: 18px; }
@media (max-width: 720px) {
  #view-practise .tp-list { grid-template-columns: 1fr; }
  #view-practise .pr-head { align-items: center; }
}
#view-practise .pr-tools { flex-wrap: nowrap; flex-direction: row; align-items: center; }
#view-practise .pr-tools input { min-width: 0; }
@media (max-width: 720px) {
  #view-practise .tp-steps { padding-left: 0; }
  #view-practise .pr-bar-l .small { display: none; }
  #view-practise .pr-bar .primary { padding: 12px 22px; }
}
#view-practise .tp { min-height: 46px; }
#view-practise .tp-step { border: 0; background: none; padding: 7px 6px; font-weight: 600; }
#view-practise .tp-step:hover { background: var(--soft); }
#view-practise .tp-step.on { background: none; color: var(--biro); }
#view-practise .tp-steps { gap: 0; }
#view-practise .pr-bar-l .small { display: none; }
#view-practise .tp-wrap.open { grid-column: 1 / -1; }
@media (max-width: 900px) { #view-practise .tp-list { grid-template-columns: 1fr; } }
/* question switching: quick, and never shows the old question while the new one loads */
.card.question.enter, #q-online.enter { animation-duration: .2s; }
@keyframes jz-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#q-img.loading { min-height: 180px; width: 100%; border-radius: 10px; background: linear-gradient(90deg, #f2f0ea 0%, #fbfaf7 50%, #f2f0ea 100%) 0 0 / 200% 100%; animation: q-shim 1.1s linear infinite; }
@keyframes q-shim { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { #q-img.loading { animation: none; } }

/* ---------- formula sheet panel ---------- */
.sheet-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 100vw); z-index: 1040; background: var(--paper); border-left: 2px solid var(--rule); box-shadow: -12px 0 32px var(--shadow); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.sheet-panel[hidden] { display: none; }
.sheet-top { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--rule); }
.sheet-top b { flex: 1; font-size: .98rem; }
.sheet-b { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px; box-shadow: none; }
.sheet-b svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sheet-b.on { background: var(--biro-soft); color: var(--biro); border-color: var(--biro); }
.sheet-pages { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px; display: grid; gap: 12px; align-content: start; background: var(--soft); }
.sheet-pages img { width: 100%; height: auto; display: block; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px var(--shadow); }
.sheet-pages.zoom img { width: 190%; max-width: none; }
.calc-btn[data-sheet] svg, [data-sheet] svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-sheet][hidden] { display: none !important; }
/* an unfinished set waiting to be picked back up */
.pr-resume { display: flex; align-items: stretch; gap: 8px; margin-bottom: 14px; }
.pr-resume[hidden] { display: none; }
.pr-res-go { flex: 1; display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 18px; border-radius: var(--r-lg); background: var(--biro); border-color: var(--biro-dark); box-shadow: 0 4px 0 var(--biro-dark); color: #fff; }
.pr-res-go:hover { background: var(--biro); border-color: var(--biro-dark); filter: brightness(1.05); }
.pr-res-go > span { flex: 1; display: flex; align-items: baseline; gap: 10px; }
.pr-res-go b { font-size: 1.05rem; }
.pr-res-go small { font-weight: 700; opacity: .85; }
.pr-res-go svg, .pr-res-x svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pr-res-x { width: 52px; padding: 0; display: grid; place-items: center; border-radius: var(--r-lg); color: var(--muted); }
/* annotate on the tutor page: a round pen button beside the camera */
.tu-ann { display: contents; }
.tu-ann .ann-btn { flex: 0 0 auto; width: 42px; height: 42px; padding: 0; border-radius: 50%; justify-content: center; color: var(--muted); background: var(--soft); border: 0; box-shadow: none; position: relative; }
.tu-ann .ann-btn span { display: none; }
.tu-ann .ann-btn svg { width: 21px; height: 21px; }
.tu-ann .ann-btn.on { color: #fff; background: var(--biro); }
.tu-ann .ann-btn.has:not(.on)::after { position: absolute; top: 6px; right: 6px; }
/* tutor opens as a chat: starter chips under the first message */
.tu-starters { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 8px; max-width: 640px; }
.tu-start-chip { padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: .92rem; background: var(--paper); }
.tu-start-chip:hover { border-color: var(--biro); color: var(--biro); }
#tu-start, #tu-modes, #tu-modehint { display: none !important; }
/* ---------- tutor chat box over a question set ---------- */
.tu-dock { position: fixed; left: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); height: min(70vh, 640px); z-index: 1045; background: var(--paper); border: 2px solid var(--rule); border-radius: 22px; box-shadow: 0 18px 48px var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.tu-dock[hidden] { display: none; }
body.annotating .tu-dock { bottom: calc(88px + env(safe-area-inset-bottom)); height: min(62vh, 600px); }
.tu-dock-top { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--rule); }
.tu-dock-top b { flex: 1; }
.tu-dock-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tu-dock #tu-session { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tu-dock #tu-session[hidden] { display: none; }
.tu-dock #tu-q, .tu-dock .tu-ann, .tu-dock .tu-meter, .tu-dock .tu-recent { display: none !important; }
.tu-dock .tu-thread { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 12px; }
.tu-dock .tu-done { padding: 0 12px; }
.tu-dock .tu-compose { position: static; margin: 0; border-radius: 0; border: 0; border-top: 1px solid var(--rule); box-shadow: none; }
.tu-dock .tu-msg { max-width: 92%; }
@media (max-width: 640px) {
  .tu-dock { left: 0; right: 0; bottom: 0; width: 100%; height: 72vh; border-radius: 22px 22px 0 0; }
}
@media (min-width: 1440px) { body.tu-docked #view-set { padding-left: 300px; } }   /* big screens: room for both side by side */

/* ======================= 1v1 battles ======================= */
.duel-go { padding: 12px 18px; font-weight: 800; letter-spacing: .02em; }
.duel-go:not(:disabled) { background: #14161f; color: #fff; border-color: #14161f; box-shadow: 0 4px 0 #000; }
.duel-go:not(:disabled):hover { background: #1f2333; }

/* the arena: lobby and results */
#view-duel { padding-top: 12px; }
.duel-arena { position: relative; overflow: hidden; isolation: isolate; border-radius: 28px; padding: 40px 24px 32px; text-align: center; color: #fff;
  background: radial-gradient(120% 90% at 0% 0%, #2e4bff 0%, transparent 55%), radial-gradient(120% 90% at 100% 100%, #ff3d6e 0%, transparent 55%), #0d0f1a;
  box-shadow: 0 24px 60px rgba(13, 15, 26, .35); min-height: 460px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.duel-glow { position: absolute; inset: -40%; z-index: -1; background: conic-gradient(from 0deg, transparent 0 20%, rgba(255,255,255,.07) 25%, transparent 30% 70%, rgba(255,255,255,.06) 75%, transparent 80%); animation: duel-spin 14s linear infinite; }
@keyframes duel-spin { to { transform: rotate(360deg); } }
.duel-kicker { margin: 0; font-size: .82rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,.72); }
.duel-title { margin: 0; font-size: clamp(1.5rem, 4vw, 2.3rem); line-height: 1.1; max-width: 22ch; }
.duel-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; width: 100%; max-width: 640px; margin: 10px 0; }
.duel-p { display: grid; justify-items: center; gap: 6px; padding: 22px 12px; border-radius: 22px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(6px); animation: duel-in-l .6s cubic-bezier(.2,1.4,.4,1) both; }
.duel-p.them { animation-name: duel-in-r; animation-delay: .08s; }
@keyframes duel-in-l { from { opacity: 0; transform: translateX(-60px) scale(.9); } }
@keyframes duel-in-r { from { opacity: 0; transform: translateX(60px) scale(.9); } }
.dp-av { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font: 900 2rem/1 var(--display, var(--font)); color: #fff;
  background: linear-gradient(135deg, #4f6bff, #2236c9); box-shadow: 0 0 0 4px rgba(255,255,255,.12), 0 10px 30px rgba(47,75,255,.55); }
.them .dp-av { background: linear-gradient(135deg, #ff5d84, #d61e4e); box-shadow: 0 0 0 4px rgba(255,255,255,.12), 0 10px 30px rgba(255,61,110,.55); }
.dp-av.away { filter: grayscale(1); opacity: .5; }
.dp-av.wait { background: transparent; box-shadow: inset 0 0 0 3px rgba(255,255,255,.25); position: relative; }
.dp-av.wait span { position: absolute; inset: -3px; border-radius: 50%; border: 3px solid transparent; border-top-color: #fff; animation: duel-spin .9s linear infinite; }
.dp-name { font-size: 1.15rem; }
.dp-sub { font-size: .85rem; color: rgba(255,255,255,.7); font-weight: 600; min-height: 1.2em; }
.dp-score { font: 900 2.6rem/1 var(--display, var(--font)); font-variant-numeric: tabular-nums; }
.dp-score em { font-style: normal; font-size: 1.1rem; opacity: .6; margin-left: 2px; }
.dp-score.live { animation: duel-pulse 1s ease-in-out infinite; }
.duel-x { font: 900 2.2rem/1 var(--display, var(--font)); letter-spacing: -.02em; color: #ffd84d; text-shadow: 0 0 18px rgba(255,216,77,.8), 0 0 40px rgba(255,61,110,.5); animation: duel-vs 1.6s ease-in-out infinite; }
@keyframes duel-vs { 0%, 100% { transform: scale(1) rotate(-4deg); } 50% { transform: scale(1.14) rotate(4deg); } }
@keyframes duel-pulse { 50% { opacity: .35; } }
.duel-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: auto; }
.duel-actions .secondary { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); box-shadow: none; }
.duel-actions .link { color: rgba(255,255,255,.75); }
.duel-meta { width: 100%; margin: 4px 0 0; color: rgba(255,255,255,.65) !important; }
.duel-meta b { color: #fff; letter-spacing: .12em; }
.duel-fight { font-size: 1.15rem; padding: 14px 40px; background: linear-gradient(135deg, #ffcf3a, #ff7a1a); color: #1a1000; border-color: #b34d00; box-shadow: 0 5px 0 #b34d00, 0 0 30px rgba(255,170,40,.6); animation: duel-ready 1.2s ease-in-out infinite; }
@keyframes duel-ready { 50% { box-shadow: 0 5px 0 #b34d00, 0 0 50px rgba(255,170,40,.95); transform: translateY(-1px) scale(1.03); } }
.duel-arena.win { background: radial-gradient(100% 80% at 50% 0%, #ffcf3a 0%, transparent 60%), radial-gradient(120% 90% at 0% 100%, #2e4bff 0%, transparent 55%), #0d0f1a; }
.duel-arena.lose { background: radial-gradient(100% 80% at 50% 0%, #5a1426 0%, transparent 60%), #0d0f1a; }
.duel-arena.win .me .dp-av { box-shadow: 0 0 0 4px #ffd84d, 0 0 60px rgba(255,216,77,.9); animation: duel-crown 1.4s ease-in-out infinite; }
.duel-arena.lose .them .dp-av { box-shadow: 0 0 0 4px #ffd84d, 0 0 60px rgba(255,216,77,.7); }
@keyframes duel-crown { 50% { transform: translateY(-6px) scale(1.06); } }
.duel-arena.win .duel-kicker, .duel-arena.lose .duel-kicker, .duel-arena.draw .duel-kicker { font: 900 clamp(2.6rem, 9vw, 4.6rem)/1 var(--display, var(--font)); letter-spacing: -.01em; text-transform: none; color: #fff; }
.duel-arena.win .duel-kicker { color: #ffd84d; text-shadow: 0 0 30px rgba(255,216,77,.8); }
.duel-arena.lose .duel-kicker { color: #ff8aa6; }
.duel-kicker.slam { animation: duel-slam .7s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes duel-slam { 0% { opacity: 0; transform: scale(3) rotate(-6deg); filter: blur(8px); } 60% { opacity: 1; transform: scale(.92) rotate(1deg); filter: none; } 100% { transform: none; } }
.duel-arena.shake { animation: duel-shake .5s; }
@keyframes duel-shake { 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }

/* the live battle bar inside the set */
.duel-strip { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 10px 0 12px; padding: 10px 14px; border-radius: 18px; color: #fff;
  background: linear-gradient(90deg, #2236c9 0%, #151829 45%, #151829 55%, #c41c4a 100%); box-shadow: 0 8px 24px rgba(13,15,26,.25); position: relative; overflow: hidden; }
.duel-strip[hidden] { display: none; }
.ds-side { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n s" "t t"; align-items: center; gap: 4px 8px; min-width: 0; }
.ds-side.them { grid-template-columns: auto 1fr; grid-template-areas: "s n" "t t"; text-align: right; }
.ds-name { grid-area: n; font-weight: 800; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-name em { font-style: normal; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #ffd84d; margin-left: 4px; }
.ds-score { grid-area: s; font: 900 1.6rem/1 var(--display, var(--font)); font-variant-numeric: tabular-nums; }
.ds-track { grid-area: t; height: 6px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.ds-track i { display: block; height: 100%; border-radius: inherit; background: #fff; transition: width .6s cubic-bezier(.3,1.4,.5,1); }
.them .ds-track i { margin-left: auto; }
.ds-side.lead .ds-score { color: #ffd84d; text-shadow: 0 0 14px rgba(255,216,77,.8); }
.ds-side.away { opacity: .55; }
.ds-mid { font-size: .72rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; padding: 5px 9px; border-radius: 99px; background: rgba(255,255,255,.12); }
.ds-mid.up { background: #ffd84d; color: #1a1000; }
.ds-mid.down { background: rgba(255,61,110,.9); }
.duel-strip.hit { animation: ds-hit .45s; }
@keyframes ds-hit { 0% { box-shadow: 0 0 0 0 rgba(255,61,110,.9); } 30% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 100% { box-shadow: 0 0 0 18px rgba(255,61,110,0); } }
.ds-bump { animation: ds-bump .5s cubic-bezier(.2,1.8,.4,1); }
@keyframes ds-bump { 40% { transform: scale(1.6); } }

/* the start: two names slam in, VS, then 3 2 1 GO */
.duel-splash { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; background: rgba(8,9,16,.0); pointer-events: none; overflow: hidden; transition: background .3s; }
.duel-splash[hidden] { display: none; }
.duel-splash.in { background: rgba(8,9,16,.88); pointer-events: auto; }
.sp-bar { position: absolute; left: -10%; right: -10%; height: 34vh; display: flex; align-items: center; padding: 0 16%; font: 900 clamp(2.2rem, 9vw, 5.5rem)/1 var(--display, var(--font)); color: #fff; letter-spacing: -.02em; }
.sp-bar.l { top: 8vh; background: linear-gradient(90deg, #2e4bff, #1a2bb8); transform: skewY(-6deg) translateX(-120%); }
.sp-bar.r { bottom: 8vh; justify-content: flex-end; background: linear-gradient(90deg, #c41c4a, #ff3d6e); transform: skewY(-6deg) translateX(120%); }
.sp-bar span { transform: skewY(6deg); text-shadow: 0 6px 0 rgba(0,0,0,.25); }
.duel-splash.in .sp-bar { animation: sp-in .55s cubic-bezier(.2,1.2,.3,1) forwards; }
.duel-splash.in .sp-bar.r { animation-delay: .15s; }
@keyframes sp-in { to { transform: skewY(-6deg) translateX(0); } }
.sp-vs { position: relative; z-index: 2; font: 900 clamp(4rem, 18vw, 10rem)/1 var(--display, var(--font)); color: #ffd84d; opacity: 0; text-shadow: 0 0 40px rgba(255,216,77,.9), 0 8px 0 #b36b00; }
.duel-splash.in .sp-vs { animation: sp-vs .5s .55s cubic-bezier(.2,1.8,.4,1) forwards, sp-vs-out .3s 1.15s forwards; }
@keyframes sp-vs { from { opacity: 0; transform: scale(4) rotate(-12deg); } to { opacity: 1; transform: scale(1) rotate(-6deg); } }
@keyframes sp-vs-out { to { opacity: 0; transform: scale(.5) rotate(-6deg); } }
.sp-count { position: absolute; z-index: 3; font: 900 clamp(6rem, 30vw, 16rem)/1 var(--display, var(--font)); color: #fff; opacity: 0; text-shadow: 0 0 50px rgba(255,255,255,.6); }
.sp-count.hit { animation: sp-count .62s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes sp-count { 0% { opacity: 0; transform: scale(2.6); } 35% { opacity: 1; transform: scale(.95); } 100% { opacity: .0; transform: scale(.8); } }
.duel-splash.go .sp-count { color: #ffd84d; text-shadow: 0 0 60px rgba(255,216,77,1), 0 0 120px rgba(255,61,110,.8); }
.duel-splash.go { background: radial-gradient(circle, rgba(255,216,77,.35), rgba(8,9,16,.9) 60%); }
.duel-splash.go .sp-count.hit { animation-duration: .8s; }
.duel-splash.out { opacity: 0; transition: opacity .35s; }
@media (max-width: 640px) {
  .duel-arena { padding: 28px 14px 24px; border-radius: 22px; min-height: 0; }
  .dp-av { width: 58px; height: 58px; font-size: 1.6rem; }
  .duel-x { font-size: 1.6rem; }
  .dp-score { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .duel-glow, .duel-x, .duel-fight, .dp-score.live, .duel-arena.win .me .dp-av, .duel-p { animation: none !important; }
}
#view-practise .pr-head { justify-content: flex-start; }
#view-practise .pr-head h1 { margin-right: auto; }

/* ======================= 1v1: fire, embers, challenge, penalty ======================= */
.fr[data-fid] { cursor: pointer; transition: transform .15s; }
.fr[data-fid]:hover { transform: translateY(-2px); }
.fr[data-fid]:active { transform: scale(.97); }
/* CSS fire: a row of flickering flames */
.fire { position: absolute; left: 0; right: 0; bottom: -10px; height: 120px; pointer-events: none; z-index: 0; filter: blur(1.5px) contrast(1.15); mix-blend-mode: screen; }
.fire i { position: absolute; bottom: 0; left: var(--x); width: 70px; height: 110px; margin-left: -35px; transform-origin: 50% 100%;
  background: radial-gradient(ellipse 45% 60% at 50% 72%, #fff6c4 0%, #ffd23f 22%, #ff7b1c 48%, rgba(230, 40, 20, .6) 66%, transparent 74%);
  border-radius: 50% 50% 46% 46% / 64% 64% 36% 36%; animation: flick calc(.9s * var(--s)) ease-in-out var(--d) infinite alternate; opacity: .95; }
.fire i:nth-child(2n) { height: 80px; width: 54px; margin-left: -27px; }
.fire i:nth-child(3n) { height: 140px; }
@keyframes flick {
  0% { transform: scale(calc(.85 * var(--s)), calc(.8 * var(--s))) skewX(3deg); opacity: .8; }
  50% { transform: scale(calc(1 * var(--s)), calc(1.12 * var(--s))) skewX(-4deg); opacity: 1; }
  100% { transform: scale(calc(.92 * var(--s)), calc(.95 * var(--s))) skewX(2deg) translateY(-4px); opacity: .85; }
}
.embers { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.embers b { position: absolute; bottom: -10px; left: var(--x); width: 5px; height: 5px; border-radius: 50%; background: #ffcf5c; box-shadow: 0 0 8px 2px #ff8a1f;
  animation: ember var(--t) linear var(--d) infinite; opacity: 0; }
.embers b:nth-child(3n) { width: 3px; height: 3px; background: #fff3b0; }
@keyframes ember { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 80% { opacity: .8; } 100% { transform: translate(var(--w), -110vh); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fire i, .embers b { animation: none !important; } .embers { display: none; } }

/* the flaming button */
.duel-btn { position: relative; overflow: hidden; isolation: isolate; padding: 14px 34px; border-radius: 999px; border: 0; font: 900 1.15rem/1 var(--display, var(--font)); letter-spacing: .02em; color: #fff;
  background: linear-gradient(135deg, #ff7a1a, #e8213f); box-shadow: 0 5px 0 #8f0f22, 0 0 28px rgba(255, 90, 30, .55); }
.duel-btn span { position: relative; z-index: 2; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.duel-btn .fire { height: 60px; bottom: -22px; opacity: .9; }
.duel-btn .fire i { width: 34px; height: 54px; margin-left: -17px; }
.duel-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.duel-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #8f0f22, 0 0 20px rgba(255, 90, 30, .5); }
.duel-btn:disabled { filter: grayscale(.7) brightness(.85); box-shadow: 0 5px 0 #555; }
.duel-btn:disabled .fire { display: none; }
.duel-btn.wide { width: 100%; }
.duel-btn.big { font-size: 1.5rem; padding: 18px 56px; animation: duel-ready 1.1s ease-in-out infinite; }

/* a friend's card */
.fc-card { position: relative; max-width: 460px; text-align: center; padding: 26px 22px 22px; }
.fc-x { position: absolute; right: 12px; top: 10px; }
.fc-top { display: grid; justify-items: center; gap: 6px; }
.fc-top h2 { margin: 6px 0 0; }
.fc-stats { display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; margin: 0; }
.fc-stats .fr-fl svg { width: 16px; height: 18px; }
.fc-body { margin-top: 18px; display: grid; gap: 12px; justify-items: center; }
.fc-k { margin: 0; font-weight: 800; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.fc-topics { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-height: 42vh; overflow: auto; padding: 2px; }
.fc-t { padding: 8px 13px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.fc-t.on { background: #1a1d2b; color: #fff; border-color: #1a1d2b; box-shadow: 0 0 0 3px rgba(255, 110, 30, .45); }
.fc-n { display: flex; }

/* the challenge popup */
.duel-inv { z-index: 2100; }
.di-card { position: relative; overflow: hidden; isolation: isolate; max-width: 440px; text-align: center; color: #fff; padding: 30px 22px 120px; border: 0;
  background: radial-gradient(90% 70% at 50% 0%, #3a1030 0%, transparent 70%), #0d0f1a; animation: di-in .55s cubic-bezier(.2,1.5,.4,1); }
@keyframes di-in { from { opacity: 0; transform: scale(.6) rotate(-4deg); } }
.di-top { position: relative; z-index: 1; display: grid; justify-items: center; gap: 2px; }
.di-top small { font-weight: 900; letter-spacing: .3em; text-transform: uppercase; color: #ffb44d; font-size: .78rem; }
.di-vs { font: 900 5rem/1 var(--display, var(--font)); color: #ffd84d; text-shadow: 0 0 30px rgba(255, 170, 40, .9), 0 6px 0 #b34d00; animation: duel-slam .7s .1s cubic-bezier(.2,1.6,.4,1) both, duel-vs 1.6s .8s ease-in-out infinite; }
.di-card h2 { position: relative; z-index: 1; margin: 10px 0 4px; font-size: 1.4rem; }
.di-card h2 span { color: #ff8aa6; }
.di-sub { position: relative; z-index: 1; margin: 0 0 18px; color: rgba(255,255,255,.7); font-weight: 600; }
.di-actions { position: relative; z-index: 2; display: grid; gap: 10px; justify-items: center; }
.di-actions .link { color: rgba(255,255,255,.7); }
.di-card > .fire { height: 130px; }
.duel-inv.out { opacity: 0; transition: opacity .2s; }

/* lobby extras */
.duel-arena > *:not(.fire):not(.embers):not(.duel-glow) { position: relative; z-index: 1; }
.duel-arena .fire { opacity: .55; }
.duel-arena.win .fire { opacity: 1; height: 190px; }
.duel-arena.lose .fire { filter: grayscale(1) blur(3px); opacity: .35; }
.duel-arena.lose .embers b { background: #9aa0b4; box-shadow: none; }
.dp-av.wait { position: relative; }
.dp-av.wait span { position: absolute; inset: -3px; border-radius: 50%; border: 3px solid transparent; border-top-color: #ffb44d; animation: duel-spin .9s linear infinite; }
.dp-av.wait span + span { inset: 8px; border-top-color: transparent; border-bottom-color: #ff5d84; animation-duration: 1.3s; animation-direction: reverse; }
.duel-p { position: relative; }
.dp-crown { position: absolute; top: -26px; left: 50%; width: 54px; margin-left: -27px; fill: #ffd84d; filter: drop-shadow(0 0 12px rgba(255, 216, 77, .9)); animation: duel-slam .7s .3s cubic-bezier(.2,1.6,.4,1) both, duel-crown 1.4s 1s ease-in-out infinite; }
.dp-tag { font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: #1a1000; background: #ffd84d; padding: 3px 8px; border-radius: 99px; }
.duel-arena.lobby .duel-actions .secondary { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); box-shadow: none; }
.duel-arena .duel-actions .secondary { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); box-shadow: none; }

/* battle bar fire */
.ds-fire { display: inline-block; vertical-align: -2px; margin-right: 4px; }
.ds-fire svg { width: 16px; height: 20px; fill: #ffb02e; filter: drop-shadow(0 0 6px #ff7a1a); animation: flick .5s ease-in-out infinite alternate; --s: 1; }

/* the penalty */
.duel-pen { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1150; display: grid; grid-template-columns: auto auto; align-items: center; gap: 2px 12px;
  padding: 12px 20px; border-radius: 20px; color: #fff; background: linear-gradient(135deg, #c41c4a, #7a0d29); box-shadow: 0 14px 36px rgba(196, 28, 74, .5); min-width: 200px; }
.duel-pen[hidden] { display: none; }
.duel-pen b { font: 900 2rem/1 var(--display, var(--font)); font-variant-numeric: tabular-nums; }
.duel-pen span { font-weight: 900; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; }
.duel-pen i { grid-column: 1 / -1; height: 5px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.duel-pen u { display: block; height: 100%; background: #fff; }
.duel-pen.hit { animation: pen-in .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes pen-in { from { transform: translateX(-50%) scale(1.8); opacity: 0; } }
@media (max-width: 640px) { .duel-pen { bottom: calc(86px + env(safe-area-inset-bottom)); } }

/* splash extras */
.duel-splash .fire { height: 170px; bottom: -20px; opacity: 0; transition: opacity .4s .3s; }
.duel-splash.in .fire { opacity: 1; }
.duel-splash.go .fire { height: 260px; }
.sp-flash { position: relative; z-index: 3; font: 900 clamp(2rem, 8vw, 4.5rem)/1.1 var(--display, var(--font)); color: #ffd84d; text-align: center; padding: 0 20px; text-shadow: 0 0 40px rgba(255, 170, 40, .9); animation: duel-slam .6s cubic-bezier(.2,1.6,.4,1) both; }
body.quake { animation: duel-shake .45s; }
.pet-lg { --sz: 96px; }
.duel-btn:hover, .duel-btn:focus { background: linear-gradient(135deg, #ff7a1a, #e8213f); color: #fff; border: 0; }
.fc-t.on:hover { background: #1a1d2b; color: #fff; }

/* ======================= 1v1, round 3: the battle bar, results, polish ======================= */
.duel-strip { display: block; padding: 10px 14px 8px; border-radius: 20px; margin: 10px 0 14px; color: #fff; position: relative; overflow: visible;
  background: linear-gradient(100deg, #1b2fbf 0%, #12142a 38%, #12142a 62%, #b3173f 100%); box-shadow: 0 10px 30px rgba(13,15,26,.28), inset 0 1px 0 rgba(255,255,255,.12); }
.duel-strip[hidden] { display: none; }
.ds-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.ds-p { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ds-p.them { justify-content: flex-end; }
.ds-av { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font: 900 .95rem/1 var(--display, var(--font)); background: linear-gradient(135deg, #4f6bff, #2236c9); box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.them .ds-av { background: linear-gradient(135deg, #ff5d84, #d61e4e); }
.ds-p .ds-name { font-weight: 800; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ds-p .ds-name em { font-style: normal; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .6; margin-left: 4px; }
.ds-p .ds-score { font: 900 1.7rem/1 var(--display, var(--font)); font-variant-numeric: tabular-nums; grid-area: auto; transition: color .3s, text-shadow .3s; }
.duel-strip.lead .me .ds-score, .duel-strip.trail .them .ds-score { color: #ffd84d; text-shadow: 0 0 16px rgba(255,216,77,.85); }
.ds-clock { font: 800 .85rem/1 var(--font); font-variant-numeric: tabular-nums; letter-spacing: .04em; padding: 6px 10px; border-radius: 99px; background: rgba(255,255,255,.1); }
.ds-tug { position: relative; height: 10px; margin: 10px 2px 8px; border-radius: 99px; background: linear-gradient(90deg, #ff5d84, #d61e4e); box-shadow: inset 0 1px 2px rgba(0,0,0,.4); }
.ds-blue { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; border-radius: 99px 0 0 99px; background: linear-gradient(90deg, #2236c9, #6d84ff); transition: width .8s cubic-bezier(.3,1.5,.5,1); }
.ds-spark { position: absolute; top: 50%; left: 50%; width: 26px; height: 32px; margin: -20px 0 0 -13px; transition: left .8s cubic-bezier(.3,1.5,.5,1); filter: drop-shadow(0 0 8px #ff8a1f); }
.ds-spark svg { width: 100%; height: 100%; fill: #ffb02e; animation: flick .45s ease-in-out infinite alternate; --s: 1; }
.ds-pips { display: flex; justify-content: space-between; gap: 12px; }
.ds-pips span { display: flex; gap: 4px; flex-wrap: wrap; }
.ds-pips .them { justify-content: flex-end; }
.pip { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.18); display: inline-block; transition: background .3s, transform .3s; }
.pip.c { background: #3ee08a; box-shadow: 0 0 8px rgba(62,224,138,.8); transform: scale(1.15); }
.pip.p { background: #ffc53d; }
.pip.w { background: #ff4d6d; }
.pip.s { background: transparent; box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); }
.ds-feed { position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); display: grid; gap: 4px; justify-items: center; pointer-events: none; z-index: 5; }
.ds-ev { font-size: .8rem; font-weight: 800; padding: 6px 12px; border-radius: 99px; color: #fff; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.25); animation: ds-ev-in .35s cubic-bezier(.2,1.6,.4,1); transition: opacity .35s, transform .35s; }
.ds-ev.bad { background: #c41c4a; } .ds-ev.good { background: #1f9d55; } .ds-ev.mid { background: #b36b00; }
.ds-ev.out { opacity: 0; transform: translateY(-6px); }
@keyframes ds-ev-in { from { opacity: 0; transform: translateY(-10px) scale(.8); } }
.duel-strip.hit { animation: ds-hit .45s; }
.card.question.duel-hurt { animation: duel-hurt .5s; }
@keyframes duel-hurt { 0% { box-shadow: 0 0 0 0 rgba(255,61,110,.9); } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 100% { box-shadow: 0 0 0 16px rgba(255,61,110,0); } }
.duel-pen { grid-template-columns: auto 1fr; min-width: 230px; }
.duel-pen b { font-size: 2.4rem; width: 1.2ch; text-align: center; }
.duel-pen span { display: grid; gap: 2px; }
.duel-pen small { font-size: .72rem; font-weight: 700; letter-spacing: .02em; text-transform: none; opacity: .8; }
@media (max-width: 640px) {
  .ds-p .ds-name { display: none; }
  .ds-p .ds-score { font-size: 1.45rem; }
  .pip { width: 8px; height: 8px; }
}

/* results: question by question */
.duel-break { width: 100%; max-width: 640px; }
.dr-grid { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; padding: 12px; border-radius: 18px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); }
.dr-q { display: grid; justify-items: center; gap: 6px; animation: dr-in .4s calc(.5s + var(--i) * .09s) cubic-bezier(.2,1.6,.4,1) both; }
.dr-q span { font-size: .7rem; font-weight: 800; color: rgba(255,255,255,.6); }
.dr-q .pip { width: 14px; height: 14px; }
@keyframes dr-in { from { opacity: 0; transform: translateY(10px) scale(.6); } }
.dr-rec { margin: 10px 0 0; font-weight: 700; color: rgba(255,255,255,.85); }
.dr-rec b { color: #ffd84d; font-size: 1.15em; }
.dr-rec span { opacity: .65; font-weight: 600; }
.dr-meta { margin: 0; font-size: .82rem; font-weight: 700; color: rgba(255,255,255,.6); }
.dp-ready { display: inline-block; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; font-size: .72rem; color: #3ee08a; border: 2px solid #3ee08a; padding: 3px 8px; border-radius: 6px; transform: rotate(-4deg); animation: duel-slam .5s cubic-bezier(.2,1.6,.4,1) both; }
.duel-p.joined { animation: duel-join .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes duel-join { 0% { transform: scale(.8); box-shadow: 0 0 0 0 rgba(255,93,132,.8); } 60% { transform: scale(1.05); } 100% { transform: none; box-shadow: 0 0 0 24px rgba(255,93,132,0); } }
.duel-arena { gap: 16px; }
.duel-arena.race .duel-x { animation-duration: .8s; }

/* friend card: online dot, record, subject + search */
.fc-av { position: relative; }
.fc-on { position: absolute; right: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 50%; background: #2fd06e; box-shadow: 0 0 0 3px var(--paper), 0 0 12px rgba(47,208,110,.8); }
.fc-on[hidden] { display: none; }
.fc-rec { margin: 4px 0 0; font-weight: 700; }
.fc-rec b { color: var(--biro); }
.fc-rec span { color: var(--muted); font-weight: 600; }
.fc-subs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.fc-s { padding: 6px 12px; border-radius: 99px; font-size: .82rem; font-weight: 800; }
.fc-s.on, .fc-s.on:hover { background: var(--biro); color: #fff; border-color: var(--biro); }
.fc-find { width: 100%; margin: 0; }
.fc-go { display: flex; gap: 10px; align-items: center; justify-content: center; width: 100%; }
.fc-go .duel-btn { flex: 1; }
.fc-n button { min-width: 44px; }
.fc-modal.out { opacity: 0; transition: opacity .18s; }
.fc-body .duel-btn.big { animation: none; }

/* the invite: avatar and a one-minute fuse */
.di-av { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font: 900 1.8rem/1 var(--display, var(--font)); background: linear-gradient(135deg, #ff5d84, #d61e4e); box-shadow: 0 0 0 4px rgba(255,255,255,.15), 0 0 30px rgba(255,61,110,.6); margin: 8px 0 -4px; }
.di-timer { position: relative; z-index: 2; height: 4px; margin: 18px 10px 0; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; }
.di-timer i { display: block; height: 100%; background: linear-gradient(90deg, #ffd84d, #ff7a1a); animation: di-fuse 60s linear forwards; }
@keyframes di-fuse { to { width: 0; } }
.di-timer i { width: 100%; }

/* real fire: canvases (see lightFire in app.js) */
canvas.fire { display: block; width: 100%; filter: none; mix-blend-mode: screen; }
.fire i { display: none; }
.duel-arena .fire { opacity: .9; height: 150px; bottom: -6px; }
.duel-arena.win .fire { height: 230px; }
.duel-arena.lose .fire { filter: grayscale(1) brightness(.7); opacity: .4; }
.duel-btn .fire { height: 46px; bottom: -14px; opacity: .85; }
.duel-btn.big .fire { height: 60px; }
.di-card > .fire { height: 150px; bottom: -8px; }
.duel-splash .fire { height: 220px; bottom: -10px; }
.duel-splash.go .fire { height: 340px; }
.ds-spark { width: 30px; height: 44px; margin: -36px 0 0 -15px; filter: none; }
.ds-spark .fire { position: absolute; inset: 0; height: 100%; left: 0; right: 0; bottom: 0; mix-blend-mode: normal; }
/* embers: small sparks that flicker as they drift up */
.embers b { width: 3px; height: 3px; background: #ffe6a0; box-shadow: 0 0 6px 2px rgba(255, 140, 30, .85); animation: ember var(--t) linear var(--d) infinite, twinkle .3s steps(2) infinite; }
.embers b:nth-child(3n) { width: 2px; height: 2px; }
@keyframes twinkle { 50% { filter: brightness(1.8); } }
canvas.fire { filter: blur(1px) saturate(1.1); }
canvas.fire.mini { filter: blur(.8px) saturate(1.2); }
.duel-btn canvas.fire { filter: blur(1.5px) saturate(1.2); }
.duel-arena.lose canvas.fire { filter: grayscale(1) brightness(.7) blur(3px); }
.ds-spark { position: absolute; display: block; top: -34px; margin: 0 0 0 -15px; }
.ds-spark canvas.fire { position: static; width: 30px; height: 44px; }
canvas.fire, .ds-spark canvas.fire { margin: 0; padding: 0; border: 0; box-shadow: none; background: none; border-radius: 0; }

/* ======================= 1v1, round 4: pets, ranks, callouts, reactions ======================= */
.dp-av.has-pet { background: none; box-shadow: none; width: auto; height: auto; }
.duel-p .pet { --sz: 80px; }
.dp-ini { display: grid; place-items: center; width: 100%; height: 100%; }
.dp-rank { font-size: .72rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: #ffb44d; }
.duel-arena.win .me .pet, .duel-arena.lose .them .pet { animation: pet-hop .9s cubic-bezier(.3,1.6,.5,1) infinite alternate; }
@keyframes pet-hop { from { transform: translateY(0) scale(1); } to { transform: translateY(-10px) scale(1.06); } }
.duel-arena.lobby .duel-p .pet { animation: pet-idle 2.4s ease-in-out infinite; }
@keyframes pet-idle { 50% { transform: translateY(-4px) rotate(-3deg); } }
/* strip: pet faces, reactions */
.ds-av { overflow: visible; background: none; box-shadow: none; }
.ds-av .pet { --sz: 32px; }
.ds-av .dp-ini { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #4f6bff, #2236c9); box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.them .ds-av .dp-ini { background: linear-gradient(135deg, #ff5d84, #d61e4e); }
.ds-p { position: relative; }
.ds-emo { width: 30px; height: 30px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); border: 0; color: #fff; box-shadow: none; flex: none; }
.ds-emo:hover { background: rgba(255,255,255,.22); color: #fff; }
.ds-emo svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ds-emos { position: absolute; left: 0; top: calc(100% + 8px); z-index: 30; display: flex; flex-wrap: wrap; gap: 6px; width: max-content; max-width: 300px; padding: 8px; border-radius: 16px; background: #12142a; box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.ds-emos[hidden] { display: none; }
.ds-emos button { padding: 7px 12px; border-radius: 99px; font-weight: 800; font-size: .85rem; background: rgba(255,255,255,.1); color: #fff; border: 0; box-shadow: none; }
.ds-emos button:hover { background: #ff7a1a; color: #fff; }
.ds-bub { position: absolute; bottom: calc(100% + 10px); z-index: 25; padding: 8px 14px; border-radius: 16px; font-weight: 900; font-size: .95rem; white-space: nowrap; color: #12142a; background: #fff; box-shadow: 0 10px 24px rgba(0,0,0,.3); animation: bub-in .4s cubic-bezier(.2,1.8,.4,1); transition: opacity .3s, transform .3s; }
.ds-p.me .ds-bub { left: 0; } .ds-p.them .ds-bub { right: 0; }
.ds-bub::after { content: ''; position: absolute; top: 100%; border: 7px solid transparent; border-top-color: #fff; }
.ds-p.me .ds-bub::after { left: 12px; } .ds-p.them .ds-bub::after { right: 12px; }
.ds-bub.out { opacity: 0; transform: translateY(-8px); }
@keyframes bub-in { from { opacity: 0; transform: translateY(10px) scale(.5); } }
/* pips: where each of you is right now */
.pip.now { box-shadow: 0 0 0 2px #fff; animation: pip-now 1s ease-in-out infinite; }
@keyframes pip-now { 50% { box-shadow: 0 0 0 4px rgba(255,255,255,.35); } }
/* a hit lands: the bar flashes from your side */
.duel-strip.strike { animation: ds-strike .5s; }
@keyframes ds-strike { 0% { box-shadow: 0 10px 30px rgba(13,15,26,.28), 0 0 0 0 rgba(79,107,255,.9); } 100% { box-shadow: 0 10px 30px rgba(13,15,26,.28), 0 0 0 18px rgba(79,107,255,0); } }
.duel-strip.blazing { box-shadow: 0 10px 30px rgba(13,15,26,.28), 0 0 26px rgba(255,122,26,.55); }
.duel-strip.blazing .me .ds-score { color: #ffb02e; text-shadow: 0 0 18px #ff7a1a; }
/* callouts */
.duel-call { position: fixed; left: 0; right: 0; top: calc(90px + env(safe-area-inset-top)); z-index: 1180; display: grid; place-items: center; pointer-events: none; }
.duel-call[hidden] { display: none; }
.duel-call b { font: 900 clamp(2.2rem, 8vw, 4.4rem)/1 var(--display, var(--font)); letter-spacing: -.01em; color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.25), 0 0 30px rgba(79,107,255,.9); transform: scale(2.4) rotate(-6deg); opacity: 0; }
.duel-call.on b { animation: call-in .6s cubic-bezier(.2,1.6,.4,1) forwards; }
.duel-call.off b { animation: call-out .35s forwards; }
@keyframes call-out { from { opacity: 1; transform: rotate(-4deg); } to { opacity: 0; transform: translateY(-20px) rotate(-4deg); } }
@keyframes call-in { to { opacity: 1; transform: scale(1) rotate(-4deg); } }
.duel-call.fire b { color: #ffd84d; text-shadow: 0 4px 0 #b34d00, 0 0 30px rgba(255,122,26,1), 0 0 60px rgba(255,61,30,.8); }
.duel-call.blood b { color: #ff4d6d; text-shadow: 0 4px 0 #6b0a1c, 0 0 30px rgba(255,40,80,.9); }
.duel-call.gold b { color: #ffd84d; text-shadow: 0 4px 0 #8a5a00, 0 0 40px rgba(255,216,77,1); }
.duel-call.final b { color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.3), 0 0 30px rgba(255,61,110,.9); animation-name: call-in, call-beat; animation-duration: .6s, .5s; animation-delay: 0s, .6s; animation-iteration-count: 1, 2; }
@keyframes call-beat { 50% { transform: scale(1.12) rotate(-4deg); } }
/* results: head-to-head stats */
.dr-stats { display: grid; gap: 6px; margin-top: 12px; }
.dr-st { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: rgba(255,255,255,.05); animation: dr-in .4s 1s cubic-bezier(.2,1.6,.4,1) both; }
.dr-st:nth-child(2) { animation-delay: 1.12s; } .dr-st:nth-child(3) { animation-delay: 1.24s; }
.dr-st span { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.dr-st b { font: 900 1.25rem/1 var(--display, var(--font)); font-variant-numeric: tabular-nums; color: rgba(255,255,255,.85); }
.dr-st b:first-child { text-align: left; } .dr-st b:last-child { text-align: right; }
.dr-st b.best { color: #ffd84d; text-shadow: 0 0 14px rgba(255,216,77,.7); }
@media (max-width: 640px) { .duel-p .pet { --sz: 60px; } .ds-emos { max-width: 240px; } }

/* ======================= battles that count: borders, rewards, stakes ======================= */
/* borders won in 1v1s */
.bd-ember::after, .bd-inferno::after, .bd-nova::after { inset: -5px; padding: 4px; border: 0;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: ring-spin 3s linear infinite; }
.pet-sm.bd-ember::after, .pet-sm.bd-inferno::after, .pet-sm.bd-nova::after { inset: -4px; padding: 3px; }
.bd-ember::after { background: conic-gradient(#7a1206, #ff5a1f, #ffb347, #ff5a1f, #7a1206); filter: drop-shadow(0 0 5px rgba(255,90,31,.7)); }
.bd-inferno::after { padding: 5px; inset: -6px; background: conic-gradient(#ff2a00, #ffd000, #fff6c4, #ff7a00, #b50000, #ff2a00); filter: drop-shadow(0 0 10px rgba(255,80,0,.95)); animation-duration: 1.4s; }
.bd-inferno { box-shadow: 0 0 22px rgba(255,90,0,.55); animation: inferno-throb 1s ease-in-out infinite alternate; }
@keyframes inferno-throb { to { box-shadow: 0 0 34px rgba(255,140,0,.85); } }
.bd-nova::after { padding: 5px; inset: -6px; background: conic-gradient(#fff, #ffd84d, #ff4d9d, #7a5cff, #18c8ff, #fff); filter: drop-shadow(0 0 12px rgba(160,120,255,.9)); animation-duration: 2s; }
.bd-nova { box-shadow: 0 0 26px rgba(122,92,255,.6), 0 0 50px rgba(255,216,77,.35); }
.pf-tile.battle em { background: #1a1d2b; color: #ffb44d; }
.fr-rank { display: block; margin-top: 3px; font-size: .62rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: #e8590c; }
/* friend card: what you play for */
.fc-prize { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 0; }
.fc-prize span { font-size: .78rem; font-weight: 700; padding: 5px 10px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.fc-prize b { color: #e8590c; }
.fc-stakes { width: 100%; margin: 0; }
/* stakes */
.dr-stakes, .di-stakes { margin: 0; font-weight: 700; color: rgba(255,255,255,.85); }
.dr-stakes b, .di-stakes b { color: #ffd84d; }
.di-stakes { position: relative; z-index: 1; margin: -10px 0 16px; }
/* results: XP earned and the next unlock */
.duel-reward { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 16px; margin-top: 12px; padding: 14px 16px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,216,77,.14), rgba(255,122,26,.08)); border: 1px solid rgba(255,216,77,.3); text-align: left; }
.duel-reward:empty { display: none; }
.duel-reward.fresh { animation: dr-in .5s .8s cubic-bezier(.2,1.6,.4,1) both; }
.duel-reward > .dr-note { grid-column: 1 / -1; }
.rw-xp { display: grid; justify-items: center; line-height: 1; }
.rw-n { font: 900 2.2rem/1 var(--display, var(--font)); color: #ffd84d; text-shadow: 0 0 18px rgba(255,216,77,.7); font-variant-numeric: tabular-nums; }
.rw-xp span { font-size: .7rem; font-weight: 900; letter-spacing: .14em; color: rgba(255,255,255,.7); }
.rw-lvl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; font-size: .78rem; font-weight: 800; color: rgba(255,255,255,.8); }
.rw-lvl i { height: 8px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.rw-lvl u { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffb02e, #ffd84d); transition: width 1.2s cubic-bezier(.3,1.4,.5,1); }
.rw-lvl span:last-child { grid-column: 1 / -1; color: #ffb44d; letter-spacing: .06em; text-transform: uppercase; font-size: .7rem; }
.rw-unlock { grid-column: 1 / -1; margin: 4px 0 0; font-weight: 800; color: #ffd84d; }
.dr-note { margin: 0; font-size: .82rem; font-weight: 600; color: rgba(255,255,255,.65); }

/* fire is drawn by a shader now: already soft, so no blur */
canvas.fire, canvas.fire.mini, .duel-btn canvas.fire { filter: none; }
.duel-arena.lose canvas.fire { filter: grayscale(1) brightness(.7); }
canvas.fire.nogl { background: radial-gradient(60% 70% at 50% 100%, rgba(255,170,60,.85), rgba(255,80,20,.45) 45%, transparent 75%); }
/* fire sits on warm dark, never on the blue/pink player glows (screen-blended fire over those turns pink) */
.duel-arena { background: radial-gradient(80% 60% at 0% 0%, rgba(46,75,255,.85), transparent 62%), radial-gradient(80% 60% at 100% 0%, rgba(255,61,110,.7), transparent 62%), radial-gradient(110% 55% at 50% 100%, #3d1406, transparent 72%), #0d0f1a; }
.duel-arena.win { background: radial-gradient(100% 70% at 50% 0%, rgba(255,207,58,.95), transparent 60%), radial-gradient(110% 55% at 50% 100%, #451606, transparent 72%), #0d0f1a; }
.duel-arena.lose { background: radial-gradient(100% 70% at 50% 0%, #4a1222, transparent 60%), radial-gradient(110% 45% at 50% 100%, #2a0f06, transparent 72%), #0d0f1a; }
.duel-arena.win .fire { height: 200px; opacity: 1; }
.duel-arena.lose .fire, .duel-arena.lose canvas.fire { filter: saturate(.55) brightness(.6); opacity: .7; height: 120px; }

/* Marking, pared back: one card at a time, short labels, the Mark button is the thing to press */
.mk-head { align-items: center; margin-bottom: 14px; }
.mk-head h1 { margin: 0; }
.mk-chip { margin: 0; }
.mk-seg { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 14px; background: var(--soft); border-radius: 999px; }
.mk-seg button { border: 0; background: transparent; box-shadow: none; padding: 9px 18px; border-radius: 999px; font-weight: 800; color: var(--muted); min-height: 0; }
.mk-seg button:hover { background: transparent; color: var(--ink); }
.mk-seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 var(--rule), 0 4px 12px rgba(20, 24, 40, .07); }
.mk-main, .mk-upload { padding: 20px; margin-top: 0; }
.mk-drops { margin: 0 0 12px; }
.mk-drop { min-height: 168px; align-content: center; justify-items: center; text-align: center; gap: 6px; padding: 20px 14px; }
.mk-ic { width: 54px; height: 54px; border-radius: 16px; background: var(--paper); display: grid; place-items: center; color: var(--biro); box-shadow: 0 2px 0 var(--rule); margin-bottom: 4px; transition: transform .15s; }
.mk-ic svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mk-drop:hover .mk-ic { transform: translateY(-2px); }
.mk-drop .mk-df { margin: 0; padding: 0; color: var(--muted); font-weight: 600; font-size: .88rem; max-width: 100%; }
.mk-drop.has .mk-ic { color: var(--good); }
.mk-drop.has .mk-df { color: var(--good-dark); font-weight: 700; }
.mk-sep { margin: 0 0 14px; }
.mk-sep .mk-drop { min-height: 0; margin-top: 10px; padding: 14px; }
.mk-go { display: block; width: 100%; padding: 15px; font-size: 1.12rem; }
.mk-status { margin: 10px 0 0; text-align: center; }
.mk-status:empty { display: none; }
.mk-results > p { text-align: center; }
.mk-hit em { font-size: 1.3rem; color: var(--muted); }
.mk-hit:hover em { color: var(--biro); }
.mk-balance { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 0; background: none; box-shadow: none; border: 0; text-align: left; }
.mk-stats { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.mk-stat { flex: 1 1 96px; display: flex; flex-direction: column; padding: 10px 14px; border-radius: var(--r); background: var(--soft); cursor: default; }
.mk-stat b { font-family: var(--display); font-size: 1.35rem; line-height: 1.15; }
.mk-stat b em { font-style: normal; font-size: .9rem; color: var(--muted); }
.mk-stat span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.mk-stat.off { opacity: .55; }
.mk-balance .mk-buy { flex: none; margin: 0; min-width: 0; align-self: stretch; }
#own-history .sec { margin-top: 22px; }
@media (max-width: 600px) {
  .mk-head { flex-direction: row; align-items: center; }
  .mk-seg { display: flex; } .mk-seg button { flex: 1; padding: 9px 10px; }
  .mk-drop { min-height: 140px; }
  .mk-balance { flex-direction: column; align-items: stretch; }
}

/* one font everywhere (Nunito); marks keep their weight instead of a handwriting face */
.verdict, .score-mark, .tag { font-weight: 900; }
.verdict { font-size: 1.3rem; } .score-mark { font-size: 2.8rem; } .tag { font-size: .95rem; }

/* auto-mark a written answer */
.am-go { margin-bottom: 10px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.am-spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: am-spin .8s linear infinite; }
@keyframes am-spin { to { transform: rotate(360deg); } }
#sol-wrap.marked > p, #sol-wrap.marked #self-mark { display: none; }

/* ---------- organised: account menu in sections, tools as one group, profile in tabs ---------- */
.menu { min-width: 240px; padding: 8px; }
.menu-email { padding: 4px 10px 6px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sec { padding: 4px 0; border-top: 1px solid var(--rule); }
.menu-sec:not(:has(.menu-item:not([hidden]))) { display: none; }
.menu-label { margin: 4px 10px 2px; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.menu .menu-item { padding: 8px 10px; }
.menu-out { margin-top: 2px; border-top: 1px solid var(--rule) !important; border-radius: 0 0 var(--r-sm) var(--r-sm); color: var(--muted) !important; }
.menu-admin .menu-label { color: var(--muted); }
.tools { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 999px; background: var(--soft); }
.tools .calc-btn, .tools .timer-btn { border: 0 !important; box-shadow: none !important; background: transparent !important; border-radius: 999px; }
.tools .calc-btn:hover, .tools .timer-btn:hover { background: var(--paper) !important; }
.pf-tabs { display: flex; gap: 4px; padding: 4px; margin: 18px 0 14px; background: var(--soft); border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
.pf-tabs::-webkit-scrollbar { display: none; }
.pf-tabs button { flex: 1 0 auto; border: 0; background: transparent; box-shadow: none; padding: 9px 16px; border-radius: 999px; font-weight: 800; color: var(--muted); min-height: 0; white-space: nowrap; }
.pf-tabs button:hover { background: transparent; color: var(--ink); }
.pf-tabs button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 var(--rule), 0 4px 12px rgba(20, 24, 40, .07); }
.pf-panel[hidden] { display: none !important; }
.pf-panel .sec-head { margin-top: 0; }
.pf-data { margin-top: 0; }
.pf-data .pf-data-row b { font-size: 1rem; }
.pf-priv { margin: 12px 0 0; }

#view-admin > .card.adm-off { display: none; }
.adm-tabs { margin: 6px 0 16px; }
.view-as-row { display: flex !important; align-items: center; justify-content: space-between; gap: 10px; }
.view-as-row select { width: auto; margin: 0; }

/* ---------- player card: tap any face (a calm popout: banner, face on its edge, name, one line of stats) ---------- */
.pc-modal .pc-card { position: relative; width: min(380px, calc(100vw - 24px)); padding: 0; overflow: hidden; text-align: left; border-radius: 22px; }
.pc-banner { position: relative; height: 92px; background: var(--pc, var(--biro)); display: flex; justify-content: flex-end; gap: 6px; padding: 10px; }
.pc-ic { width: 32px; height: 32px; min-height: 0; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.22); box-shadow: none; color: #fff; }
.pc-ic:hover { background: rgba(0,0,0,.32); }
.pc-ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pc-head { padding: 0 20px; height: 40px; }
.pc-av { position: relative; top: -48px; width: 88px; height: 88px; border-radius: 50%; background: var(--paper); padding: 5px; display: grid; place-items: center; overflow: visible; }
.pc-av > :not(.fc-on) { width: 78px !important; height: 78px !important; font-size: 2rem; }
.pc-av img { width: 100%; height: 100%; object-fit: cover; }
.pc-av .fc-on { position: absolute; right: 4px; bottom: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--good); border: 3px solid var(--paper); }
.pc-main { padding: 6px 20px 20px; }
.pc-name { margin: 0; font-size: 1.45rem; line-height: 1.2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pc-title { font-family: var(--font); font-size: .75rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; color: var(--pc, var(--biro)); background: color-mix(in srgb, var(--pc, var(--biro)) 13%, transparent); }
.pc-line { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 0; color: var(--muted); font-size: .88rem; font-weight: 700; }
.pc-line span + span::before { content: '·'; margin: 0 7px; opacity: .6; }
.pc-rec { margin: 10px 0 0; font-size: .92rem; }
.pc-body { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
.pc-acts { display: flex; gap: 6px; }
.pc-act { flex: 1; text-align: center; padding: 9px 6px; border-radius: 12px; background: var(--soft); color: var(--ink) !important; font-weight: 800; font-size: .88rem; text-decoration: none !important; }
.pc-act:hover { background: color-mix(in srgb, var(--pc, var(--biro)) 12%, var(--soft)); }
.pc-tbtn { margin-top: 8px; width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 0; border-radius: 12px; background: transparent; box-shadow: none; min-height: 0; font-weight: 700; color: var(--muted); }
.pc-tbtn:hover { background: var(--soft); }
.pc-tbtn b { margin-left: auto; color: var(--ink); }
.pc-tbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.pc-tbtn[aria-expanded="true"] svg { transform: rotate(180deg); }
.pc-titles { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 2px 2px; max-height: 150px; overflow-y: auto; }
.pc-titles[hidden] { display: none; }
.pc-t { display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); font-weight: 700; font-size: .82rem; box-shadow: none; min-height: 0; }
.pc-t.on { background: var(--pc, var(--biro)); border-color: transparent; color: #fff; }
.pc-t.locked { color: var(--muted); background: transparent; border-style: dashed; }
.pc-t em { font-style: normal; font-weight: 600; font-size: .7rem; opacity: .75; }
.pc-go { width: 100%; }
.pc-body .fc-state { margin: 8px 0 0; text-align: center; }
.pc-body .fc-subs, .pc-body .fc-find, .pc-body .fc-topics, .pc-body .fc-stakes, .pc-body .fc-go { text-align: left; }
#duel-me, #duel-them { background-image: linear-gradient(180deg, color-mix(in srgb, var(--pc, transparent) 45%, transparent), transparent 70%); }
#duel-me .dp-av, #duel-them .dp-av, .fr.me { cursor: pointer; }
.avatar { cursor: pointer; }

.pr-key[hidden] { display: none !important; }
.subj-btn .subj-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tutor: topic picker grouped by syllabus area */
.tu-starters.picking { display: grid; gap: 12px; }
.tu-pick-back { justify-self: start; padding: 0; }
.tu-pick-g { display: grid; gap: 6px; }
.tu-pick-l { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tu-pick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tu-start-chip.sm { padding: 6px 12px; font-size: .84rem; font-weight: 600; }

/* quick questions: maths sits a touch larger than the words around it, and options stay one line */
.ol-prompt .katex, .ol-opt .katex, .ol-sol .katex { font-size: 1.1em; }
.ol-opt .ol-text { overflow-x: auto; }
.fc-go .seg.fc-k { margin-right: auto; }
.fc-go { flex-wrap: wrap; }
@media (max-width: 560px) { .fc-go #fc-send { flex: 1 1 100%; } }

/* the Margaret textbook (admins only): exercises, then a grid of question numbers */
.tb-card #tb-body, .tb-card #hr-body { display: grid; gap: 2px; padding: 0 18px 14px; }
.hr-grid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.tb-q.listed:not(.on) { border-color: var(--biro); color: var(--biro); }
.hr-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 10px; }
.hr-chip { min-height: 0; padding: 6px 10px; border-radius: 999px; font-weight: 700; font-size: .85rem; display: inline-flex; gap: 6px; align-items: center; }
.hr-chip i { font-style: normal; color: var(--muted); }
.hr-chip.on { background: var(--biro); border-color: var(--biro); color: #fff; }
.hr-chip.on i { color: rgba(255,255,255,.75); }
.hr-grid .tb-q { height: auto; min-height: 44px; display: grid; place-content: center; line-height: 1.1; padding: 4px 0; }
.hr-grid .tb-q small { display: block; font-size: .7rem; font-weight: 700; opacity: .65; }
.hr-bar { position: sticky; bottom: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 0 2px; }
.tb-ex { border-top: 1px solid var(--rule); }
.tb-ex-h { width: 100%; display: flex; justify-content: space-between; align-items: baseline; background: none; border: 0; box-shadow: none; padding: 11px 2px; min-height: 0; }
.tb-ex-h span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.tb-ex.open .tb-ex-h b { color: var(--biro); }
.tb-ch { border-top: 1px solid var(--rule); }
.tb-ch.open > .tb-ex-h b { color: var(--biro); }
.tb-ch .tb-ex { margin-left: 14px; }
.tb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; padding: 2px 0 12px; }
.tb-q { padding: 0; height: 40px; min-height: 0; font-weight: 800; border-radius: 10px; }
.tb-q.on { background: var(--biro); border-color: var(--biro); color: #fff; }
.tb-go { width: 100%; margin-bottom: 10px; }

/* answering a question: the bar with Exit, calculator and formula sheet stays on screen as you scroll */
body.focus .top { position: static; }
#view-set .setbar { position: sticky; top: 0; z-index: 15; background: var(--bg); margin: 0 -8px 10px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; }

/* phones on their side (Android and iPhone): a short screen, so one slim header row with the tabs inline, and popups that scroll */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 560px) {
  .top-in { flex-wrap: nowrap; padding-top: 4px; padding-bottom: 4px; gap: 8px; }
  .mainnav { order: 0; flex-basis: auto; flex: 1 1 auto; justify-content: center; position: static; background: none; border: 0; padding: 0; backdrop-filter: none; }
  .mainnav a { flex: 0 1 auto; flex-direction: row; font-size: .9rem; padding: 5px 9px; }
  .mainnav svg { display: none; }
  .brand { font-size: 1.2rem; }
  main { padding-bottom: 24px; } footer { padding-bottom: 24px; }
  .startbar, .pr-set .startbar { bottom: 10px; }
  #view-practise { padding-bottom: 90px; }
  .modal-card, .pc-modal .pc-card, .me-card { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .hello { font-size: 1.5rem; } h1 { font-size: 1.5rem; }
  #view-set .setbar { margin-bottom: 4px; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 800px) {   /* small phones sideways: icon tabs, so the tools and account still fit */
  .mainnav a { padding: 7px 10px; }
  .mainnav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .mainnav svg { display: block; width: 21px; height: 21px; }
  .subject .subj-btn { max-width: 104px; }
}

/* switching subject: "Welcome to <subject>" with the subject's own little animation */
.sh-pop { position: fixed; inset: 0; z-index: 2100; display: grid; place-items: center; padding: 20px; background: var(--veil);
  animation: cele-fade .2s ease-out; cursor: pointer; }
.sh-pop.out { opacity: 0; transition: opacity .25s; }
.sh-card { --c: var(--biro); --cd: var(--biro-dark); display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 4px;
  width: min(360px, 100%); padding: 10px 22px 10px 10px; border-radius: 22px; background: var(--c); color: #fff;
  box-shadow: 0 6px 0 var(--cd), 0 24px 50px -20px rgba(0,0,0,.35); animation: sh-in .5s cubic-bezier(.2,1.4,.4,1); }
.sh-pop.out .sh-card { transform: scale(.94); transition: transform .25s; }
@keyframes sh-in { from { transform: translateY(24px) scale(.8); opacity: 0; } }
.sh-art { width: 112px; height: 112px; border-radius: 16px; background: rgba(255,255,255,.12); }
.sh-art svg { width: 100%; height: 100%; overflow: visible; }
.sh-text small { display: block; font-weight: 800; font-size: .85rem; color: rgba(255,255,255,.85); animation: sh-up .4s .15s both; }
.sh-text b { display: block; font-family: var(--display); font-weight: 900; font-size: 1.75rem; line-height: 1.05; letter-spacing: -.01em; animation: sh-up .45s .25s both; }
@keyframes sh-up { from { transform: translateY(10px); opacity: 0; } }
.sh-maths .sh-card { --c: var(--biro); --cd: var(--biro-dark); }
.sh-phys .sh-card { --c: #6a4be0; --cd: #4b31b0; }
.sh-chem .sh-card { --c: #0f9e82; --cd: #0a7561; }
.sh-bio .sh-card { --c: #2f9e44; --cd: #217532; }
.sh-econ .sh-card { --c: #e08600; --cd: #b06600; }
.sh-eng .sh-card { --c: #e8590c; --cd: #b54409; }
.sh-se .sh-card { --c: #2b3038; --cd: #121418; }
/* chemistry: the flask wobbles, bubbles, then puffs over */
.sh-glass { fill: rgba(255,255,255,.16); stroke: #fff; stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.sh-liquid { fill: #8ff5d2; animation: sh-wave 1.2s linear infinite; }
@keyframes sh-wave { to { transform: translateX(-60px); } }
.sh-bub { fill: #fff; opacity: 0; animation: sh-bub 1s var(--t) ease-in infinite; }
@keyframes sh-bub { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: .9; } 100% { opacity: 0; transform: translateY(-40px); } }
.sh-flask { transform-origin: 60px 100px; animation: sh-wobble .9s ease-in-out, sh-pop 1.4s .9s cubic-bezier(.3,1.6,.5,1); }
@keyframes sh-wobble { 25% { transform: rotate(-7deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-4deg); } }
@keyframes sh-pop { 0% { transform: scale(1, 1); } 12% { transform: scale(1.12, .86); } 30% { transform: scale(.92, 1.1) translateY(-6px); } 50%, 100% { transform: none; } }
.sh-puff circle { fill: #fff; opacity: 0; transform-box: fill-box; transform-origin: center; animation: sh-puff .9s 1s ease-out forwards; }
@keyframes sh-puff { 0% { opacity: .95; transform: rotate(var(--a)) translateY(0) scale(.2); } 60% { opacity: .9; } 100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(-1 * var(--d))) scale(1.2); } }
.sh-spark path { fill: #fff6a8; opacity: 0; transform-box: fill-box; transform-origin: center; animation: sh-spark .7s 1.1s ease-out forwards; }
.sh-spark path + path { animation-delay: 1.25s; }
@keyframes sh-spark { 0% { opacity: 0; transform: scale(0) rotate(0); } 50% { opacity: 1; transform: scale(1.2) rotate(40deg); } 100% { opacity: 0; transform: scale(.6) rotate(80deg); } }
/* physics: an atom spins up */
.sh-atom { transform-origin: 60px 60px; animation: sh-grow .5s cubic-bezier(.2,1.5,.4,1); }
.sh-orbit { transform-origin: 60px 60px; animation: sh-spin 1.6s var(--t) linear infinite; }
.sh-orbit ellipse { fill: none; stroke: rgba(255,255,255,.75); stroke-width: 3.5; }
.sh-orbit circle { fill: #fff; }
.sh-nucleus { fill: #ffd36b; transform-origin: 60px 60px; animation: sh-beat .8s ease-in-out infinite; }
@keyframes sh-spin { to { transform: rotate(360deg); } }
@keyframes sh-beat { 50% { transform: scale(1.25); } }
@keyframes sh-grow { from { transform: scale(0) rotate(-90deg); } }
/* maths: a curve draws itself, symbols bounce in */
.sh-axis { fill: none; stroke: rgba(255,255,255,.45); stroke-width: 3; stroke-linecap: round; }
.sh-wave { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 160; stroke-dashoffset: 160; animation: sh-draw .9s .15s ease-out forwards; }
@keyframes sh-draw { to { stroke-dashoffset: 0; } }
.sh-sym { fill: #ffd36b; font: 900 24px var(--display); opacity: 0; transform-box: fill-box; transform-origin: center; animation: sh-bounce .6s var(--t) cubic-bezier(.2,1.8,.4,1) forwards; }
@keyframes sh-bounce { from { opacity: 0; transform: translateY(14px) scale(.3); } to { opacity: 1; transform: none; } }
/* biology: the helix twists */
.sh-rung line { stroke: rgba(255,255,255,.7); stroke-width: 3.5; stroke-linecap: round; }
.sh-rung circle { fill: #fff; }
.sh-rung circle + circle { fill: #b6f5a8; }
.sh-rung { animation: sh-twist 1.4s var(--t) ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes sh-twist { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(-1); } }
/* economics: bars grow, the trend line shoots up */
.sh-bar { fill: rgba(255,255,255,.9); transform-box: fill-box; transform-origin: bottom; animation: sh-rise .5s var(--t) cubic-bezier(.2,1.5,.4,1) both; }
@keyframes sh-rise { from { transform: scaleY(0); } }
.sh-trend, .sh-tip { fill: none; stroke: #fff3b0; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 110; stroke-dashoffset: 110; animation: sh-draw .6s .55s ease-out forwards; }
.sh-tip { stroke-dasharray: 30; stroke-dashoffset: 30; animation-delay: 1.05s; animation-duration: .25s; }
/* engineering: two gears turn together */
.sh-gear circle { fill: rgba(255,255,255,.95); stroke: rgba(255,255,255,.95); stroke-width: 9; stroke-dasharray: 6 5.6; }
.sh-gear .hole { fill: var(--c); stroke: none; }
.sh-gear.g1 { transform-origin: 46px 52px; animation: sh-spin 2.4s linear infinite; }
.sh-gear.g2 { transform-origin: 82px 84px; animation: sh-spin 1.6s linear infinite reverse; }
/* software: </> clicks together, the cursor blinks */
.sh-code { fill: #fff; font: 900 46px ui-monospace, SFMono-Regular, Menlo, monospace; opacity: 0; animation: sh-bounce .5s cubic-bezier(.2,1.8,.4,1) forwards; }
.sh-code.l { animation-delay: .1s; } .sh-code.s { fill: #8fd3ff; animation-delay: .3s; } .sh-code.r { animation-delay: .5s; }
.sh-cursor { fill: #8fd3ff; animation: sh-blink .7s .7s steps(1) infinite; opacity: 0; }
@keyframes sh-blink { 50% { opacity: 1; } }
@media (max-width: 420px) { .sh-card { grid-template-columns: 92px 1fr; } .sh-art { width: 92px; height: 92px; } .sh-text b { font-size: 1.5rem; } }
@media (prefers-reduced-motion: reduce) { .sh-pop, .sh-card, .sh-pop *, .sh-pop svg * { animation: none !important; } .sh-wave, .sh-trend, .sh-tip { stroke-dashoffset: 0; } .sh-sym, .sh-code { opacity: 1; } .sh-puff, .sh-spark, .sh-bub, .sh-cursor { display: none; } }

/* ======================= Duel mode: the whole site goes dark, red and orange =======================
   Same chunky Trialbank (thick borders, buttons that press down, cartoon flames), just a battle mood.
   Turned on by duelMode() in app.js on the 1v1 screens and inside a battle. */
:root[data-duel] {
  --bg: #1b0f0c; --paper: #29150f; --soft: #331b14; --hover: #3d2017;
  --ink: #fff2e8; --on-ink: #1b0f0c; --muted: #d0a28f;
  --rule: #4c271c; --rule-strong: #6e3726;
  --biro: #ff6a1f; --biro-dark: #b8420a; --biro-soft: #43200f;
  --marker: #ff3b3b; --hl: #5c2b0f; --hl-edge: #a8521c;
  --good-soft: #173823; --bad: #ff4646; --bad-dark: #a9232a; --bad-soft: #4a1717;
  --shadow: rgba(0,0,0,.5);
  --top-bg: color-mix(in srgb, var(--bg) 90%, transparent);
  --duel-me: #ff8a1f; --duel-me-dark: #b9520a; --duel-them: #ff3d4f; --duel-them-dark: #a8172a; --duel-gold: #ffd23f;
  color-scheme: dark;
}
:root[data-duel] body { background: radial-gradient(120% 55% at 50% 108%, rgba(255, 92, 20, .30), transparent 62%), var(--bg); background-attachment: fixed; }
:root[data-duel] body::before { content: ""; position: fixed; inset: auto 0 0 0; height: 40vh; pointer-events: none; z-index: -1;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255, 60, 30, .22), transparent 70%); animation: duel-breathe 3.2s ease-in-out infinite; }
@keyframes duel-breathe { 50% { opacity: .45; } }
:root.duel-fade body, :root.duel-fade body * { transition: background-color .6s, border-color .6s, color .6s, box-shadow .6s !important; }
/* questions stay on light paper so the scanned images read properly */
:root[data-duel] .card.question, :root[data-duel] .card.scroll { background: #fbf2e9; border-color: #fbf2e9; box-shadow: 0 4px 0 #0c0604; color: #1f2329; }
:root[data-duel] .card.question .muted, :root[data-duel] .card.scroll .muted { color: #6b707a; }
:root[data-duel] .primary, :root[data-duel] .primary:hover { color: #fff; }

/* cartoon flames (same drawing as the streak flame) */
svg.cf { display: block; overflow: visible; }
svg.cf .fl { transform-origin: 16px 37px; animation: flicker 1.1s ease-in-out infinite; }
.fire.band { position: absolute; left: 0; right: 0; bottom: -6px; height: 64px; pointer-events: none; z-index: 0; filter: none; mix-blend-mode: normal; }
.fire.band svg.cf { position: absolute; bottom: 0; left: var(--x); width: calc(44px * var(--s)); height: calc(52px * var(--s)); margin-left: calc(-22px * var(--s)); }
.fire.band svg.cf .fl { animation: cf-dance 1.4s ease-in-out var(--d) infinite; }
@keyframes cf-dance { 0%, 100% { transform: scale(1, 1) skewX(0); } 35% { transform: scale(.94, 1.12) skewX(-4deg); } 70% { transform: scale(1.05, .93) skewX(3deg); } }
svg.cf.icon { width: 20px; height: 24px; margin-right: 8px; flex: none; }
svg.cf.icon .fo { fill: #ffd23f; } svg.cf.icon .fi { fill: #fff3c4; }
.duel-btn { display: inline-flex; align-items: center; justify-content: center; }

/* embers become chunky round sparks, no glow blur */
.embers b { width: 6px; height: 6px; background: var(--duel-gold, #ffd23f); box-shadow: none; animation: ember var(--t) linear var(--d) infinite; }
.embers b:nth-child(2n) { background: #ff8a1f; width: 5px; height: 5px; }
.embers b:nth-child(3n) { background: #ff3d4f; width: 4px; height: 4px; }

/* the flaming button: a proper Trialbank press-down button */
.duel-btn, .duel-btn:hover, .duel-btn:focus { background: var(--duel-me, #ff7a1a); color: #fff; border: 2px solid var(--duel-me-dark, #b9520a); border-radius: 16px;
  box-shadow: 0 5px 0 var(--duel-me-dark, #b9520a); filter: none; }
.duel-btn:hover:not(:disabled) { filter: brightness(1.06); transform: none; }
.duel-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--duel-me-dark, #b9520a); }
.duel-btn.big { animation: duel-btn-glow 1.4s ease-in-out infinite; }
@keyframes duel-btn-glow { 50% { box-shadow: 0 5px 0 var(--duel-me-dark, #b9520a), 0 0 0 7px rgba(255, 138, 31, .22); } }
.duel-btn .fire { display: none; }

/* the arena: a big chunky card in the battle colours instead of a glossy gradient */
.duel-arena { background: var(--paper); border: 3px solid var(--rule-strong); box-shadow: 0 7px 0 #0c0604; color: var(--ink); }
.duel-arena.win { background: radial-gradient(90% 70% at 50% 0%, rgba(255, 210, 63, .22), transparent 65%), var(--paper); }
.duel-arena.lose { background: radial-gradient(90% 70% at 50% 0%, rgba(255, 61, 79, .14), transparent 65%), var(--paper); }
.duel-glow { display: none; }
.duel-kicker { color: var(--duel-gold); }
.duel-p { background: var(--soft); border: 2px solid var(--rule-strong); box-shadow: 0 4px 0 var(--rule); backdrop-filter: none; }
.dp-av { background: var(--duel-me); box-shadow: 0 4px 0 var(--duel-me-dark); }
.them .dp-av { background: var(--duel-them); box-shadow: 0 4px 0 var(--duel-them-dark); }
.dp-sub, .dr-meta, .dr-q span { color: var(--muted); }
.duel-x, .di-vs, .sp-vs { color: var(--duel-gold); text-shadow: 0 5px 0 #b34d00; }
.duel-arena.win .duel-kicker { color: var(--duel-gold); text-shadow: 0 5px 0 #b34d00; }
.duel-arena.lose .duel-kicker { color: var(--duel-them); text-shadow: 0 5px 0 #5c0d17; }
.duel-arena.win .me .dp-av, .duel-arena.lose .them .dp-av { box-shadow: 0 4px 0 #b38600, 0 0 0 5px var(--duel-gold); }
.duel-arena .duel-actions .secondary, .duel-arena.lobby .duel-actions .secondary { background: var(--soft); color: var(--ink); border: 2px solid var(--rule-strong); box-shadow: 0 4px 0 var(--rule); }
.duel-arena .duel-actions .link, .duel-meta { color: var(--muted) !important; }
.duel-meta b { color: var(--ink); }
.dr-grid { background: var(--soft); border: 2px solid var(--rule); }
.dr-rec { color: var(--ink); }
.duel-arena .fire.band { height: 70px; }
.duel-arena.win .fire.band { height: 100px; }
.duel-arena.lose .fire.band { filter: grayscale(1) brightness(.6); opacity: .5; }

/* the battle bar above each question */
.duel-strip { background: var(--paper); border: 2px solid var(--rule-strong); box-shadow: 0 4px 0 #0c0604; color: var(--ink); }
.ds-av { background: var(--duel-me); box-shadow: 0 2px 0 var(--duel-me-dark); }
.them .ds-av { background: var(--duel-them); box-shadow: 0 2px 0 var(--duel-them-dark); }
.ds-clock { background: var(--soft); border: 2px solid var(--rule); }
.ds-tug { background: var(--duel-them); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); height: 12px; }
.ds-blue { background: var(--duel-me); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.ds-spark { width: 28px; height: 34px; margin: -26px 0 0 -14px; filter: none; transform: scale(var(--heat, 1)); transform-origin: 50% 100%; transition: left .8s cubic-bezier(.3,1.5,.5,1), transform .3s; }
.ds-spark svg.cf { width: 100%; height: 100%; }
.pip { background: var(--rule-strong); }
.pip.s { box-shadow: inset 0 0 0 2px var(--muted); }
.duel-strip.lead .me .ds-score, .duel-strip.trail .them .ds-score { color: var(--duel-gold); text-shadow: none; }

/* the challenge popup, the 3-2-1 splash and the penalty, in the same colours */
.di-card { background: #29150f; border: 3px solid #6e3726; box-shadow: 0 8px 0 #0c0604; }
.di-top small { color: #ffd23f; }
.di-av { background: #ff3d4f; box-shadow: 0 4px 0 #a8172a; }
.di-card > .fire.band { height: 70px; }
.duel-splash.in { background: rgba(27, 15, 12, .94); }
.duel-splash.go { background: radial-gradient(circle, rgba(255, 138, 31, .35), rgba(27, 15, 12, .94) 60%); }
.sp-bar.l { background: #ff8a1f; box-shadow: inset 0 -10px 0 #b9520a; }
.sp-bar.r { background: #ff3d4f; box-shadow: inset 0 -10px 0 #a8172a; }
.sp-count { text-shadow: 0 8px 0 #b34d00; }
.duel-splash.go .sp-count { color: #ffd23f; text-shadow: 0 8px 0 #b34d00; }
.sp-flash { color: #ffd23f; text-shadow: 0 6px 0 #b34d00; }
.duel-splash .fire.band { height: 110px; }
.duel-splash.go .fire.band { height: 160px; }
.duel-pen { background: #ff3d4f; border: 2px solid #a8172a; box-shadow: 0 5px 0 #a8172a; }
.duel-go:not(:disabled) { background: var(--duel-me, #ff7a1a); border-color: var(--duel-me-dark, #b9520a); box-shadow: 0 4px 0 var(--duel-me-dark, #b9520a); }
.fc-t.on, .fc-t.on:hover { background: #ff7a1a; border-color: #b9520a; color: #fff; box-shadow: 0 3px 0 #b9520a; }
@media (prefers-reduced-motion: reduce) { svg.cf .fl, .fire.band svg.cf .fl, :root[data-duel] body::before, .duel-btn.big { animation: none !important; } }
.ds-spark svg.cf, .ds-spark svg.cf.mini { width: 28px; height: 34px; animation: none; fill: initial; filter: none; }
.duel-arena { padding-bottom: 84px; }
.ds-spark { top: -27px; margin: 0 0 0 -14px; }
svg.cf { margin: 0; padding: 0; border: 0; box-shadow: none; background: none; border-radius: 0; }
svg.cf.icon { margin-right: 8px; }

/* predicted band: what it's based on */
.pred-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; padding-top: 14px; border-top: 2px solid var(--rule); }
.pred-opts .seg button.on { background: var(--biro); color: #fff; }

/* no flames: a slow heat glow along the bottom, rising sparks, and a glowing knob where the tug-of-war meets */
.heat { position: absolute; left: -10%; right: -10%; bottom: -40px; height: 140px; pointer-events: none; z-index: 0;
  background: radial-gradient(50% 100% at 50% 100%, rgba(255, 106, 31, .45), rgba(255, 61, 79, .18) 55%, transparent 75%); animation: heat-pulse 2.8s ease-in-out infinite; }
@keyframes heat-pulse { 50% { opacity: .55; transform: scaleY(.9); } }
.duel-splash .heat { height: 45vh; }
.duel-splash.go .heat { height: 70vh; }
.duel-arena.lose .heat { filter: grayscale(1); opacity: .35; }
.ds-knob { position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--duel-gold, #ffd23f);
  border: 3px solid #fff3c4; box-shadow: 0 0 0 4px rgba(255, 210, 63, .25); animation: knob-pulse 1.2s ease-in-out infinite; }
@keyframes knob-pulse { 50% { box-shadow: 0 0 0 8px rgba(255, 210, 63, .12); } }
.ds-spark { width: 20px; height: 20px; top: -4px; margin: 0 0 0 -10px; }
@media (prefers-reduced-motion: reduce) { .heat, .ds-knob { animation: none; } }
.duel-arena > .heat { position: absolute !important; z-index: 0 !important; }
.duel-arena { padding-bottom: 40px; min-height: 0; }

/* English: a book whose right page turns, lines writing themselves in */
.sh-lit .sh-card { --c: #c2255c; --cd: #8f1a44; }
.sh-book { fill: rgba(255,255,255,.95); }
.sh-spine { stroke: var(--c); stroke-width: 3; fill: none; }
.sh-page { fill: #fff; stroke: var(--c); stroke-width: 2; transform-origin: 60px 60px; animation: sh-turn 1.6s .2s ease-in-out infinite; }
@keyframes sh-turn { 0%, 20% { transform: scaleX(1); } 50% { transform: scaleX(-1); } 80%, 100% { transform: scaleX(1); } }
.sh-line { stroke: var(--c); stroke-width: 3.5; stroke-linecap: round; fill: none; stroke-dasharray: 22; stroke-dashoffset: 22; animation: sh-write .5s var(--t) ease-out forwards; }
@keyframes sh-write { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .sh-page, .sh-line { animation: none; stroke-dashoffset: 0; } }

/* ---------- induction: tall squared working space, More space, model answers in the teacher's layout, the layout check ---------- */
.ann-space.ann-grid { background:
  linear-gradient(color-mix(in srgb, var(--rule) 75%, transparent) 1px, transparent 1px) 0 0 / 28px 28px,
  linear-gradient(90deg, color-mix(in srgb, var(--rule) 75%, transparent) 1px, transparent 1px) 0 0 / 28px 28px; }
.ann-more { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font: 800 .8rem var(--font); padding: 8px 16px;
  border-radius: 999px; background: var(--paper); color: var(--muted); border: 2px solid var(--rule); box-shadow: none; }
.pf { padding: 16px 18px; border: 2px solid var(--rule); border-radius: var(--r); line-height: 1.5; overflow-x: auto;
  background: var(--paper) linear-gradient(color-mix(in srgb, var(--rule) 45%, transparent) 1px, transparent 1px) 0 0 / 100% 30px; }
.pf p { margin: 6px 0; }
.pf .pf-h { margin-top: 18px; } .pf .pf-h:first-child { margin-top: 0; }
.pf .pf-h u { text-underline-offset: 3px; text-decoration-thickness: 2px; font-weight: 800; }
.pf .pf-ie { padding-left: 4px; }
.pf-cols { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 56px; margin: 6px 0; }
.pf-eq { display: grid; grid-template-columns: max-content max-content minmax(0, auto) max-content; column-gap: 8px; row-gap: 10px; align-items: center; justify-content: start; }
.pf-chain { margin: 10px 0 4px; }
.pf-lab { font-weight: 700; } .pf-e { text-align: center; } .pf-x { line-height: 1.5; }
.pf-n { color: var(--muted); padding-left: 18px; white-space: nowrap; font-size: .92rem; }
.pf-end { width: fit-content; margin: 8px 0 0 auto; }
.pf .katex { font-size: 1.08em; }
@media (max-width: 640px) { .pf { padding: 12px; } .pf-n { padding-left: 8px; } .pf-end { margin-left: 0; } .pf-x { line-height: 3.2; } }
#sol-layout { margin: 12px 0; }
#sol-layout h4, .lay h4 { margin: 0 0 8px; font: 800 .95rem var(--font); }
#sol-layout .pf { font-size: .95rem; }
.lay { border: 2px solid var(--rule); border-radius: var(--r); padding: 12px 14px; margin: 10px 0; background: var(--paper); }
.lay h4 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.lay h4 b { font-size: 1.25rem; } .lay.ok h4 b { color: var(--good); } .lay.miss h4 b { color: var(--bad); }
.lay ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lay li { display: grid; grid-template-columns: 18px 1fr; gap: 2px 8px; }
.lay li i { font-style: normal; font-weight: 900; color: var(--bad); grid-row: span 2; }
.lay li span { color: var(--muted); font-size: .9rem; }
/* dark theme: the question card stays light paper, so typed questions (quick questions, induction drills) need dark ink on it */
:root[data-theme="dark"] .card.question .ol-prompt { color: #1f2329; }


/* ---------- UX pass, Nov 2026 ---------- */
/* phones: the header always fits; the subject name shortens before anything is pushed off screen */
@media (max-width: 480px) {
  .top-in { gap: 6px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .brand { font-size: 1.25rem; flex: none; }
  .top-right { flex: 1 1 0; min-width: 0; justify-content: flex-end; gap: 5px; }
  .top-right .subject { flex: 0 1 auto; min-width: 0; }
  .top-right .subject .subj-btn { max-width: 100%; flex-shrink: 1; overflow: hidden; }
  .top-right .subject .subj-l { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .top-right .tools, .top-right .account { flex: none; }
}
/* marking yourself: one even row of marks, never a lone button on its own line */
#self-mark { display: grid; grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); gap: 8px; }
#self-mark button { min-width: 0; padding-left: 0; padding-right: 0; }
/* nothing but the question while you're in a set or an exam */
body.focus footer { display: none; }
/* solutions: tap to zoom in, tap again to zoom out */
#sol-img { cursor: zoom-in; display: block; width: 100%; }
.card.scroll.zoom { overflow-x: auto; }
.card.scroll.zoom #sol-img { width: 200%; max-width: none; cursor: zoom-out; }
/* phones: messages sit above the tab bar, not on top of it */
@media (max-width: 720px) { body:not(.focus) .toast { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ---------- navigation pass, Nov 2026 ---------- */
h1[tabindex="-1"]:focus { outline: none; }
.back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 8px -8px; padding: 6px 10px; border-radius: 999px; color: var(--muted); font-weight: 700; text-decoration: none; }
.back:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.back.feature-off { display: none; }
/* phone tab bar: five equal targets, and the tab you're on is unmistakable */
@media (max-width: 640px) {
  .mainnav a { flex: 1 1 0; min-width: 0; min-height: 52px; justify-content: center; padding: 4px 2px; border: 0; font-weight: 700; }
  .mainnav a svg { box-sizing: content-box; padding: 3px 16px; border-radius: 999px; transition: background .2s, transform .3s cubic-bezier(.3,1.8,.5,1); }
  .mainnav a.on svg { background: var(--biro-soft); }
  .mainnav a span { white-space: nowrap; }
}
@media (orientation: landscape) and (max-height: 500px) { .mainnav a svg { padding: 0; background: none !important; } }

/* practice papers made by the tutor: one row each, Start is the thing to press */
.tp-mine { margin-top: 18px; display: grid; gap: 8px; }
.tp-h { font-size: 1rem; margin: 0 0 2px; }
.tp-card { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; border-radius: var(--r); background: var(--paper); box-shadow: var(--shadow); }
.tu-thread .tp-card { align-self: stretch; }
.tp-info { display: grid; gap: 1px; flex: 1 1 180px; min-width: 0; }
.tp-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-acts { display: flex; align-items: center; gap: 8px; }
.tp-acts .secondary { min-width: 58px; }
.tp-del { color: var(--muted); padding: 4px 6px; }
.tp-card .error { flex-basis: 100%; margin: 0; }

/* speed timer (pace.js): the clock in the set bar, and its line on the results page */
.pace { font-variant-numeric: tabular-nums; font-weight: 800; font-size: .98rem; padding: 6px 12px 5px; margin-right: 4px; border-radius: 999px; background: var(--soft); color: var(--ink); }
.pace.low { background: var(--hl); color: #3d3300; }
.pace.over { background: var(--bad-soft); color: var(--bad); }
.pace.held:not(.over) { background: var(--good-soft); color: var(--good); }
.summary-pace { margin: 6px 0 12px; font-weight: 600; }

/* an official HSC paper: a single link to NESA's own copy (see nesa.js) */
.nesa-go { display: grid; place-items: center; padding: 56px 0; }
.nesa-go a { text-decoration: none; display: inline-block; padding: 12px 22px; }

/* HSC exam tiles without a cover picture: a drawn exam front page (app.js hscCover) */
.hcov { position: absolute; inset: 0; background: #fff; color: #1f2329; padding: 13% 11% 10%; display: flex; flex-direction: column; text-align: left; container-type: inline-size; }
.hcov-y { font-size: 20cqw; font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.hcov-k { font-style: normal; font-size: 5.6cqw; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #8a6d00; margin-top: 5cqw; }
.hcov-s { font-size: 9.5cqw; font-weight: 800; line-height: 1.15; margin-top: 2cqw; }
.hcov-l { display: grid; gap: 3.2cqw; margin-top: auto; }
.hcov-l.two { margin-top: 7cqw; }
.hcov-l u { display: block; height: 2.2cqw; border-radius: 2cqw; background: #e6e8ec; text-decoration: none; }
.hcov-l u:nth-child(2) { width: 82%; } .hcov-l u:nth-child(3) { width: 90%; } .hcov-l u:nth-child(4) { width: 58%; }
.hcov-l.two u:nth-child(3) { width: 44%; }

/* prep for an assessment */
#an-card .an-out:not(:empty) { margin-bottom: 18px; }
.an-in { display: grid; gap: 8px; }
.an-pick { width: 100%; padding: 18px; border-style: dashed; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-pick.on { border-style: solid; border-color: var(--biro); color: var(--biro); }
#an-text { margin: 0; }
.tp-card.an-new { animation: cp-pulse 1.1s ease-out; }
.tu-qtext { padding: 4px 2px 2px; line-height: 1.55; }
.tu-qtext ol { margin: 8px 0 0; padding-left: 1.6em; }
.tu-qtext li { margin: 2px 0; }
#an-card.an-drop { outline: 2px dashed var(--biro); outline-offset: 3px; }
