/* STEM-Tutor practice portal. Light by default, dark when the OS asks for it or the viewer picks it (html[data-theme]). */
:root {
  color-scheme: light;
  --bg: #f6f8fb; --surface: #ffffff; --surface-2: #f1f5fa; --line: #e1e8f0; --line-strong: #c9d5e3;
  --ink: #0e1a2b; --text: #33425a; --muted: #5f6f84; --soft: #8291a5;
  --accent: #0a6fc2; --accent-ink: #ffffff; --accent-soft: #e6f1fb; --accent-line: #9cc8ee;
  --ok: #157f3b; --ok-soft: #e5f5ea; --warn: #9a6700; --warn-soft: #fff3d1; --bad: #b42318; --bad-soft: #fdeceb;
  /* mastery: one hue, light to dark (magnitude) */
  --m0: #e6ecf3; --m1: #c7dcf1; --m2: #8dbbe6; --m3: #3d8fd6; --m4: #0b5ea8;
  --shadow: 0 1px 2px rgba(15, 35, 65, .05), 0 4px 16px rgba(15, 35, 65, .06);
  --radius: 14px;
}
/* Light by default; dark only when the viewer switches it on (html[data-theme="dark"]). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b111b; --surface: #121b29; --surface-2: #172234; --line: #233148; --line-strong: #31435f;
  --ink: #eef3fa; --text: #c6d1e0; --muted: #96a5ba; --soft: #73839a;
  --accent: #5bb4ff; --accent-ink: #06121f; --accent-soft: #13283f; --accent-line: #2c5b86;
  --ok: #5fd68a; --ok-soft: #10291b; --warn: #f2c94c; --warn-soft: #33290d; --bad: #ff8a80; --bad-soft: #3a1716;
  --m0: #1c2a3e; --m1: #2a4a6e; --m2: #2f6ea6; --m3: #4d9be0; --m4: #9fd2ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15.5px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- shell */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #009dc2, #0445bd); color: #fff; display: grid; place-items: center; font-size: .8rem; }
.brand small { font-weight: 500; color: var(--muted); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .93rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav .sep { width: 1px; background: var(--line); margin: 6px 6px; flex: none; }
.me { display: flex; align-items: center; gap: 6px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page.narrow { max-width: 820px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head p { color: var(--muted); margin: 0; }

/* ---------- building blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 16px; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .k { color: var(--muted); font-size: .82rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 1.7rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; margin-top: 2px; }
.tile .s { color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty svg.i { width: 30px; height: 30px; color: var(--soft); display: block; margin: 0 auto 8px; }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { color: var(--ink); font-weight: 600; }
.li .d { color: var(--muted); font-size: .85rem; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--accent); color: var(--accent-ink); transition: filter .15s; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet { background: transparent; color: var(--muted); border-color: transparent; padding: 7px 10px; }
.btn.quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line-strong); }
.btn.sm { padding: 5px 11px; font-size: .86rem; border-radius: 8px; }
.btn.lg { padding: 12px 22px; font-size: 1.02rem; }
.btn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; text-align: left; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip svg.i { width: 13px; height: 13px; vertical-align: -2px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: .9rem; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink); }
input[type=text], input[type=email], input[type=date], select, textarea { padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); max-width: 100%; }
textarea { width: 100%; min-height: 80px; resize: vertical; }

.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.ok i { background: var(--ok); }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.n, .table th.n { text-align: center; white-space: nowrap; }
.scroll { overflow-x: auto; }
.heat { display: inline-block; min-width: 52px; padding: 3px 6px; border-radius: 7px; font-weight: 700; font-size: .85rem; text-align: center; }
.heat small { display: block; font-weight: 500; font-size: .72rem; opacity: .85; }
.heat.hi { background: var(--ok-soft); color: var(--ok); } .heat.md { background: var(--warn-soft); color: var(--warn); } .heat.lo { background: var(--bad-soft); color: var(--bad); }
.heat.none { color: var(--soft); }

/* ---------- mastery */
.lvl { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.lvl b { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--line-strong); }
.lvl.l0 b { background: var(--m0); } .lvl.l1 b { background: var(--m1); } .lvl.l2 b { background: var(--m2); } .lvl.l3 b { background: var(--m3); } .lvl.l4 b { background: var(--m4); }
.mbar { display: flex; gap: 2px; height: 10px; border-radius: 4px; overflow: hidden; }
.mbar span { flex: 1; background: var(--m0); }
.mbar span.l1 { background: var(--m1); } .mbar span.l2 { background: var(--m2); } .mbar span.l3 { background: var(--m3); } .mbar span.l4 { background: var(--m4); }
.unit { border-top: 1px solid var(--line); padding: 14px 0; }
.unit:first-child { border-top: 0; padding-top: 0; }
.topic { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0 7px 12px; border-left: 2px solid var(--line); margin-left: 4px; }
.topic .nm { color: var(--ink); font-size: .93rem; }
.topic .st { color: var(--muted); font-size: .8rem; }

/* ---------- ring */
.ring { position: relative; width: 120px; height: 120px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .lbl b { font-size: 1.6rem; color: var(--ink); display: block; line-height: 1; }
.ring .lbl span { font-size: .78rem; color: var(--muted); }

/* ---------- builder */
.choice { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.choice button { text-align: left; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 14px; cursor: pointer; }
.choice button b { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.choice button span { display: block; color: var(--muted); font-size: .86rem; margin-top: 4px; }
.choice button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.units .u { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--surface); }
.units .uh { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.units .uh label { flex: 1; display: flex; gap: 10px; align-items: center; cursor: pointer; color: var(--ink); font-weight: 600; }
.units .tp { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px 40px; }
.units .tp label { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: .84rem; cursor: pointer; }
.units .tp label:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
.sticky-cta { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); margin: 18px -18px -18px; padding: 14px 18px; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- player */
.play { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.pbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.pbar-in { max-width: 920px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.pbar .title { flex: 1; min-width: 0; }
.pbar .title b { color: var(--ink); display: block; }
.pbar .title span { color: var(--muted); font-size: .82rem; }
.progress { height: 4px; background: var(--line); }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.timer { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); padding: 5px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; }
.timer.low { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.pmain { flex: 1; max-width: 920px; width: 100%; margin: 0 auto; padding: 22px 16px 120px; }
.qmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.qnum { font-weight: 800; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 2px 10px; }
.stem { font-size: 1.06rem; color: var(--ink); line-height: 1.65; }
.stem svg, .figure svg { max-width: 100%; height: auto; }
.figure { margin: 12px 0; }
.opts { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.opt { display: flex; align-items: stretch; gap: 0; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface); overflow: hidden; transition: border-color .12s, background .12s; }
.opt .pick { flex: 1; display: flex; gap: 12px; align-items: center; text-align: left; background: none; border: 0; padding: 12px 14px; cursor: pointer; color: var(--text); }
.opt .key { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-weight: 700; color: var(--ink); font-size: .9rem; }
.opt .strike { border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--soft); padding: 0 12px; cursor: pointer; }
.opt .strike:hover { color: var(--ink); background: var(--surface-2); }
.opt:hover { border-color: var(--accent-line); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .key { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt.out .pick { opacity: .45; text-decoration: line-through; cursor: not-allowed; }
.opt.out .strike { color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt .tag { margin-left: auto; font-size: .78rem; font-weight: 700; padding-left: 8px; white-space: nowrap; }
.opt.right .tag { color: var(--ok); } .opt.wrong .tag { color: var(--bad); }
.locked .opt .pick { cursor: default; } .locked .opt .strike { display: none; }
.feedback { margin-top: 18px; border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); }
.feedback .verdict { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; margin-bottom: 6px; }
.feedback.ok .verdict { color: var(--ok); } .feedback.bad .verdict { color: var(--bad); }
.explain ol { padding-left: 1.2em; margin: 6px 0; } .explain li { margin: 4px 0; }
.pfoot { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 10; }
.pfoot-in { max-width: 920px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.pfoot .mid { flex: 1; display: flex; justify-content: center; }
.navbtn { display: inline-flex; align-items: center; gap: 6px; background: var(--ink); color: var(--surface); border: 0; border-radius: 9px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.navgrid { position: fixed; left: 50%; transform: translateX(-50%); bottom: 64px; width: min(560px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.2); padding: 16px; z-index: 30; }
.navgrid .cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 8px; margin: 12px 0; }
.navgrid .cells button { position: relative; height: 42px; border-radius: 9px; border: 1.5px dashed var(--line-strong); background: var(--surface); font-weight: 700; color: var(--ink); cursor: pointer; }
.navgrid .cells button.ans { border-style: solid; background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.navgrid .cells button.ok { border-style: solid; background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.navgrid .cells button.bad { border-style: solid; background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.navgrid .cells button.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
.navgrid .cells button .fl { position: absolute; top: -6px; right: -6px; color: var(--bad); }
.navgrid .cells button .fl svg.i { width: 14px; height: 14px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1.5px dashed var(--line-strong); }
.legend i.ans { border-style: solid; background: var(--accent-soft); border-color: var(--accent-line); }
.kbd { display: inline-block; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: .75rem; font-family: ui-monospace, monospace; color: var(--muted); }
.tool.on { color: var(--bad); }

/* ---------- review */
.review-head { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.review-head .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; flex: 1; }
.review-head .facts div b { display: block; font-size: 1.25rem; color: var(--ink); }
.review-head .facts div span { color: var(--muted); font-size: .82rem; }
details.rq { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
details.rq > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
details.rq > summary::-webkit-details-marker { display: none; }
details.rq .mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
details.rq .mark.ok { background: var(--ok-soft); color: var(--ok); } details.rq .mark.bad { background: var(--bad-soft); color: var(--bad); } details.rq .mark.skip { background: var(--surface-2); color: var(--muted); }
details.rq .body { padding: 0 14px 14px; border-top: 1px solid var(--line); padding-top: 12px; }
details.rq[open] > summary .chev { transform: rotate(180deg); }
.chev { transition: transform .15s; color: var(--soft); }

/* ---------- chart */
.chart { position: relative; }
.chart svg { width: 100%; height: 160px; display: block; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); font-size: .8rem; padding: 5px 8px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; }

/* ---------- overlays */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-weight: 600; font-size: .92rem; display: flex; gap: 8px; align-items: center; animation: pop .2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.scrim { position: fixed; inset: 0; background: rgba(5, 12, 24, .45); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 16px; width: min(480px, 100%); padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.3); border: 1px solid var(--line); }
.modal .acts { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 10px; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.signin .card { width: min(440px, 100%); padding: 30px; text-align: center; }
.signin ul { text-align: left; color: var(--muted); padding-left: 1.1em; margin: 16px 0 22px; }
.gbtn { width: 100%; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.gbtn:hover { background: var(--surface-2); }

@media (max-width: 720px) {
  .top-in { flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  h1 { font-size: 1.35rem; }
  .brand small { display: none; }
  .pbar .hide-sm, .pfoot .hide-sm { display: none; }
  .topic { grid-template-columns: 1fr auto; }
  .topic .act { grid-column: 1 / -1; }
}

/* grid and flex children may shrink below their content (long titles, chips) instead of widening the page */
.grid > *, .tiles > *, .li > *, .row > * { min-width: 0; }
@media (max-width: 720px) {
  .page { padding: 18px 12px 56px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px; } .tile .v { font-size: 1.4rem; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .li { flex-wrap: wrap; row-gap: 8px; }
  .li .grow { flex-basis: 100%; }
  .card { padding: 14px; }
  .sticky-cta { margin: 14px -14px -14px; padding: 12px 14px; }
  .review-head { justify-content: center; }
}

/* ---------- courses and exams */
.coursesel { padding: 6px 10px; border-radius: 9px; font-weight: 600; max-width: 200px; }
.coursechip { font-size: .8rem; }
.pbar-in.wide { max-width: none; }
.exam-tabs { display: none; }
.exam-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: calc(100vh - 61px); }
.exam-wrap .paper { position: relative; border-right: 1px solid var(--line); background: var(--surface-2); }
.exam-wrap .paper iframe { width: 100%; height: 100%; border: 0; display: block; }
.paper-open { position: absolute; right: 12px; bottom: 12px; box-shadow: var(--shadow); }
.exam-wrap .paper .empty { padding-top: 120px; }
.exam-wrap .sheet { overflow-y: auto; background: var(--surface); }
.sheet-in { padding: 18px 18px 40px; }
.bubbles { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.brow { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 9px; }
.brow:nth-child(5n) { margin-bottom: 8px; }
.brow.flagged { background: var(--warn-soft); }
.brow .bn { width: 30px; text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.bub { width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer; }
.bub:hover { border-color: var(--accent); }
.bub.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bflag { margin-left: auto; border: 0; background: none; color: var(--soft); cursor: pointer; padding: 6px; border-radius: 8px; }
.bflag.on { color: var(--warn); }
.keygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin-top: 12px; }
.kcell { display: flex; align-items: center; gap: 4px; justify-content: center; padding: 6px 4px; border-radius: 8px; font-size: .85rem; border: 1px solid var(--line); }
.kcell span { color: var(--muted); font-size: .75rem; min-width: 18px; text-align: right; }
.kcell b { color: var(--ink); } .kcell i { font-style: normal; font-weight: 700; color: var(--ok); }
.kcell svg.i { width: 14px; height: 14px; }
.kcell.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.kcell.bad { background: var(--bad-soft); border-color: transparent; }
.kcell.skip { background: var(--surface-2); }
.keyedit { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; max-height: 520px; overflow-y: auto; margin-top: 10px; padding-right: 4px; }
.krow { display: flex; align-items: center; gap: 4px; }
.krow span { width: 26px; text-align: right; font-weight: 700; color: var(--ink); font-size: .85rem; margin-right: 4px; }
.krow button { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--muted); font-weight: 700; font-size: .8rem; cursor: pointer; }
.krow button.on { background: var(--ok); border-color: var(--ok); color: #fff; }
input[type=datetime-local] { padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); }
@media (max-width: 900px) {
  .exam-tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--line); }
  .exam-tabs button { flex: 1; border: 0; background: none; padding: 11px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; display: flex; gap: 6px; justify-content: center; align-items: center; }
  .exam-tabs button.on { color: var(--accent); border-color: var(--accent); }
  .exam-wrap { grid-template-columns: 1fr; height: calc(100vh - 106px); }
  .exam-wrap.tab-paper .sheet, .exam-wrap.tab-sheet .paper { display: none; }
  .coursechip { display: none; }
}
#madd > input { width: 100%; }

/* ---------- exam: one question at a time */
.exam-wrap .sheet { display: flex; flex-direction: column; overflow: hidden; }
.exam-wrap .sheet .sheet-in { flex: 1; overflow-y: auto; }
.qhead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.qhead b { color: var(--ink); font-size: 1.05rem; }
.qhead .qnum { min-width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.1rem; }
.sheet .opt .pick { padding: 14px 16px; font-size: 1.02rem; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.exam-grid { position: absolute; left: 12px; right: 12px; bottom: 70px; transform: none; width: auto; }
.exam-wrap .sheet { position: relative; }
.navgrid .cells .frqcell { grid-column: span 2; border-style: solid; background: var(--surface-2); font-size: .85rem; }
.navgrid .cells button .fl { color: var(--warn); }
@media (max-width: 480px) { .hide-xs { display: none; } }

/* ---------- exam room v3: strip, tools, review, on-screen questions */
.play.exam { height: 100vh; min-height: 0; display: flex; flex-direction: column; }
.play.exam .exam-wrap { flex: 1; min-height: 0; height: auto; }
.exam-wrap.dragging { user-select: none; }
.exam-wrap.dragging iframe { pointer-events: none; }
.divider { cursor: col-resize; background: var(--line); position: relative; }
.divider::after { content: ""; position: absolute; left: 2px; right: 2px; top: 50%; height: 40px; margin-top: -20px; border-radius: 4px; background: var(--line-strong); }
.divider:hover, .exam-wrap.dragging .divider { background: var(--accent-line); }
.exam-wrap .paper { border-right: 0; }
.tools { display: flex; gap: 2px; }
.tools .btn.on { background: var(--accent-soft); color: var(--accent); }
.qstrip { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; border-top: 1px solid var(--line); scrollbar-width: thin; }
.qs { position: relative; flex: none; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1.5px dashed var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 700; font-size: .85rem; cursor: pointer; }
.qs.ans { border-style: solid; background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.qs.flag::after { content: ""; position: absolute; top: -4px; right: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.qs.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
.qs.frq, .qs.rev { border-style: solid; background: var(--surface-2); }
.qs.rev { margin-left: 6px; }
.qrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.exam-single { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.exam-single .sheet-in { flex: 1; overflow-y: auto; width: 100%; max-width: 860px; margin: 0 auto; padding: 24px 18px 40px; }
.exam-single .sheet-foot { max-width: none; }
.exam-single .sheet-foot > * { flex: none; }
.exam .stem { font-size: calc(1.06rem * var(--qsize, 1)); }
.exam .opt .pick { font-size: calc(1rem * var(--qsize, 1)); }
.exam .figure { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.exam .figure svg { display: block; margin: 0 auto; max-height: 340px; }
.frqcard { box-shadow: none; }
/* written papers (Edexcel style): lettered parts with the marks in brackets on the right, and the mark scheme table */
.mpart { display: grid; grid-template-columns: 2.1em minmax(0, 1fr) auto; gap: 6px; align-items: start; margin: 12px 0; }
.mpart .pt p { margin: 0 0 6px; } .mpart .mk { font-weight: 700; align-self: end; white-space: nowrap; }
.mtotal { text-align: right; font-weight: 700; font-size: .85rem; margin: 10px 0 0; }
.figcap { text-align: center; font-weight: 700; font-size: .85rem; margin-top: 6px; } .figcap:empty { display: none; }
table.ms { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .85rem; }
table.ms th, table.ms td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; text-align: left; }
table.ms td.mm { white-space: nowrap; font-weight: 700; } table.ms td.mn { color: var(--muted); font-size: .8rem; } table.ms tr.msub td { padding: 2px 8px; }
.explain:has(table.ms) { overflow-x: auto; }
.toolpanel { position: fixed; top: 120px; right: 24px; width: min(420px, calc(100vw - 32px)); height: min(560px, calc(100vh - 160px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.25); z-index: 40; display: flex; flex-direction: column; overflow: hidden; resize: both; }
.toolpanel iframe { flex: 1; border: 0; width: 100%; background: #fff; }
.tp-pages { flex: 1; overflow: auto; background: #fff; -webkit-overflow-scrolling: touch; }
.tp-pages img { display: block; width: 100%; height: auto; border-bottom: 1px solid var(--line); }
.tp-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: move; user-select: none; touch-action: none; }
.tp-head .seg button { padding: 4px 10px; font-size: .8rem; }
.preview-bar { background: var(--warn-soft); color: var(--warn); text-align: center; font-weight: 600; font-size: .85rem; padding: 6px; display: flex; gap: 6px; justify-content: center; align-items: center; }
.review h3 { margin: 18px 0 4px; font-size: .95rem; }
.bigcheck { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 12px; }
.result-hero .facts { display: flex; gap: 24px; flex-wrap: wrap; }
.result-hero .facts b { display: block; font-size: 1.2rem; color: var(--ink); }
.result-hero .facts span { color: var(--muted); font-size: .82rem; }
.trend { display: flex; gap: 10px; align-items: flex-end; height: 170px; padding-top: 20px; }
.tbar { flex: 1; max-width: 80px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.tbar i { width: 70%; background: var(--m2); border-radius: 4px 4px 0 0; }
.tbar.cur i { background: var(--accent); }
.tbar .tv { font-size: .78rem; font-weight: 700; color: var(--ink); }
.tbar .tl { font-size: .72rem; color: var(--muted); max-width: 100%; }
@media (max-width: 900px) {
  .exam-wrap { grid-template-columns: 1fr !important; }
  .divider { display: none; }
  .toolpanel { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; height: 60vh; }
}

/* ---------- tutor today, marking, toasts */
.toast-act { margin-left: 10px; background: transparent; border: 1px solid rgba(255,255,255,.5); color: inherit; border-radius: 7px; padding: 3px 10px; font-weight: 700; cursor: pointer; }
.li.todo { text-decoration: none; }
.li.todo:hover .t { color: var(--accent); }
.ticon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.ticon.warn { background: var(--warn-soft); color: var(--warn); } .ticon.acc { background: var(--accent-soft); color: var(--accent); }
.ticon.ok { background: var(--ok-soft); color: var(--ok); } .ticon.bad { background: var(--bad-soft); color: var(--bad); }
.markrow { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.markrow .pts { display: flex; gap: 4px; flex-wrap: wrap; }
.markrow .pts button { width: 36px; height: 36px; border-radius: 9px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 700; cursor: pointer; }
.markrow .pts button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.nav .more { position: relative; }
.nav .more summary { list-style: none; display: flex; align-items: center; gap: 4px; padding: 7px 11px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: .93rem; cursor: pointer; white-space: nowrap; }
.nav .more summary::-webkit-details-marker { display: none; }
.nav .more summary.on, .nav .more[open] summary { background: var(--accent-soft); color: var(--accent); }
.nav .more .menu { position: fixed; margin-top: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 170px; z-index: 30; display: flex; flex-direction: column; }
.nav .more .menu a { color: var(--text); }
.nav { overflow: visible; }
@media (max-width: 720px) { .nav { overflow-x: auto; } }
.dtable { border-collapse: collapse; margin: 10px 0; font-size: .95rem; }
.dtable th, .dtable td { border: 1px solid var(--line-strong); padding: 6px 12px; text-align: center; }
.dtable th { background: var(--surface-2); color: var(--ink); font-weight: 600; text-align: left; }
.stem ol[type] { padding-left: 1.4em; } .stem ol[type] li { margin: 6px 0; }
.markrow details.guide { flex-basis: 100%; font-size: .9rem; }
.markrow details.guide summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.opt .pick svg { max-width: 160px; height: auto; }

/* ---------- notifications */
.bell { position: relative; }
.bell summary { list-style: none; position: relative; }
.bell summary::-webkit-details-marker { display: none; }
.bell .badge { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
.menu.notes { position: absolute; right: 0; top: 44px; width: min(340px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.18); padding: 6px; z-index: 40; }
.menu.notes .nhead { font-weight: 700; color: var(--ink); padding: 8px 10px; }
.menu.notes a { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 9px; color: var(--text); text-decoration: none; font-size: .9rem; }
.menu.notes a:hover { background: var(--surface-2); }
.menu.notes a.new { font-weight: 600; color: var(--ink); }
.menu.notes a.new::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: auto; margin-top: 6px; flex: none; }
a.avatar { text-decoration: none; }

/* ---------- up next, countdowns */
.upnext { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; border-left: 4px solid var(--accent); flex-wrap: wrap; }
.upnext.warn { border-left-color: var(--warn); } .upnext.bad { border-left-color: var(--bad); }
.upnext .ticon { width: 46px; height: 46px; }
.upnext h2 { margin: 2px 0 4px; font-size: 1.2rem; }
.upnext .kicker { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.countdown { margin: 10px 0 0; color: var(--accent); font-size: .9rem; display: flex; gap: 6px; align-items: center; }
.countdown.warn { color: var(--warn); }

/* ---------- test editor steps */
.steps { position: sticky; top: 58px; z-index: 5; display: flex; gap: 6px; flex-wrap: wrap; background: var(--bg); padding: 8px 0 12px; }
.steps a { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; font-size: .88rem; }
.steps a b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: .8rem; }
.steps a.ok b { background: var(--ok); color: #fff; }
.steps a b svg.i { width: 14px; height: 14px; }
.qedit textarea { min-height: 54px; font-family: ui-monospace, monospace; font-size: .85rem; }
.modal:has(.qedit) { width: min(720px, 100%); max-height: 90vh; overflow-y: auto; }

/* ---------- uploads and sections */
.uplist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.upitem { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; }
.upitem .linkish { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.workitem { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); }
.workitem .thumb { height: 150px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-weight: 700; gap: 4px; }
.secl { flex: none; align-self: center; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 4px 0 8px; display: inline-flex; gap: 4px; align-items: center; }
.secl.done { color: var(--ok); }
.qs.locked { opacity: .45; cursor: not-allowed; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th[data-dir="asc"]::after { content: " ▲"; font-size: .7em; } th[data-dir="desc"]::after { content: " ▼"; font-size: .7em; }

/* ---------- phones: bottom tab bar */
@media (max-width: 720px) {
  .top .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; gap: 0; flex-basis: auto; order: 0; }
  .top .nav a { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 8px; min-width: 56px; justify-content: center; }
  .top .nav a svg.i { width: 20px; height: 20px; }
  .top .nav .sep, .top .nav .more { display: none; }
  .page { padding-bottom: 96px; }
  .coursesel { max-width: 140px; }
  .upnext .btn { width: 100%; }
}

/* ---------- printing a student report */
@media print {
  .top, .noprint, .btn, .toasts, nav.steps { display: none !important; }
  body { background: #fff; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
  .page { padding: 0; max-width: none; }
}

/* ---------- classes */
.nextclass { border-left: 4px solid var(--accent); }
.nextclass.live { border-left-color: var(--ok); background: linear-gradient(90deg, var(--ok-soft), var(--surface) 60%); }
.nextclass.big h2 { font-size: 1.35rem; margin: 6px 0 4px; }
.nextclass .kicker, .upnext .kicker { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dotlive { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } }
.pastclass .notes { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.notes p { margin: 0 0 8px; } .notes ul { margin: 0 0 8px; padding-left: 1.2em; } .notes li { margin: 3px 0; }
.card.attention { border-color: var(--warn); }
.ledit textarea { min-height: 120px; }
.modal:has(.ledit) { width: min(640px, 100%); max-height: 92vh; overflow-y: auto; }

@media (max-width: 720px) {
  #theme, #out { display: none; }
  .top-in { flex-wrap: nowrap; }
  .brand > span:last-child { display: none; }
  .top .nav a { min-width: 46px; padding: 6px 4px; }
  .top .nav .more { display: block; }
  .top .nav .more summary { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; }
  .top .nav .more .menu { position: fixed; bottom: 66px; right: 8px; top: auto; }
}

/* ---------- class scores: categorical series colours (validated palette; dark steps for the dark surface) */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948; }
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767; }
.lchart { position: relative; }
.lchart svg { width: 100%; height: auto; display: block; overflow: visible; }
.lchart .grid { stroke: var(--line); stroke-width: 1; }
.lchart .tick { fill: var(--muted); font-size: 11px; }
.lchart .dl { font-size: 12px; }
.lchart .cross { stroke: var(--line-strong); stroke-width: 1; }
.lchart .tip { position: absolute; top: 8px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 10px; font-size: .82rem; pointer-events: none; opacity: 0; transition: opacity .1s; white-space: nowrap; z-index: 2; }
.lchart .tip b { color: var(--ink); }
.gradebook th.me, .gradebook td.me { background: var(--accent-soft); }
.gradebook tr.foot td { border-top: 2px solid var(--line-strong); }
.gradebook.edit input { width: 100%; min-width: 64px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: center; transition: box-shadow .3s, border-color .3s; }
.gradebook.edit input.gt { text-align: left; min-width: 150px; font-weight: 600; }
.gradebook.edit input.gd { text-align: left; min-width: 130px; margin-top: 4px; font-size: .8rem; color: var(--muted); }
.gradebook.edit input.gm { max-width: 80px; }
.gradebook.edit input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.gradebook.edit input.saved { animation: savedflash 1.2s; }
.gradebook.edit input.bad { border-color: var(--bad); }
@keyframes savedflash { 0% { box-shadow: 0 0 0 3px var(--ok-soft); border-color: var(--ok); } 100% { box-shadow: none; } }
.seg a.segl { padding: 6px 13px; border-radius: 8px; font-weight: 600; color: var(--muted); font-size: .9rem; text-decoration: none; }
.seg a.segl.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.gradebook td { vertical-align: middle !important; }

/* ---------- image viewer (zoomable diagrams and equation sheet pages) */
.figure, .tp-pages img { cursor: zoom-in; }
.figure { position: relative; }
.figure::after { content: "Tap to zoom"; position: absolute; top: 6px; right: 6px; font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; pointer-events: none; }
body.vw-open { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 80; background: rgba(8, 14, 24, .92); display: flex; flex-direction: column; }
.vw-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--line); }
.vw-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-bar .btn { min-width: 38px; justify-content: center; font-size: 1rem; }
.vw-pct { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); }
.vw-stage { flex: 1; overflow: auto; touch-action: pan-x pan-y; outline: none; display: flex; padding: 12px; }
.vw-content { margin: auto; flex: none; background: var(--surface); border-radius: 8px; padding: 10px; color: var(--ink); }
.vw-content svg, .vw-content img { display: block; width: 100% !important; height: auto !important; max-width: none !important; max-height: none !important; }
.vw-content img + img { margin-top: 10px; }

@media (hover: none) { .keyhint { display: none !important; } }

/* exam header on phones: drop the title and section label (the question strip shows the section), keep one line */
.only-sm { display: none; }
@media (max-width: 720px) {
  .exam .pbar .title { display: none; }
  .exam .pbar-in { gap: 6px; }
  .exam .tools { margin-left: auto; }
  .timer, .exam #submit { white-space: nowrap; }
  .timer .sec-l { display: none; }
  .pbar .only-sm { display: inline; }
}

/* syllabus topics with no questions yet */
.topic.soon .nm, label.soon { color: var(--muted); }
label.soon { cursor: default; }

/* ---------- sidebar (desktop): grouped nav, live counts, Up next / Needs you, Ctrl+K quick jump */
.side { display: none; }
@media (min-width: 1000px) {
  .app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
  :root.side-mini .app { grid-template-columns: 72px minmax(0, 1fr); }
  .side {
    --s-ink: #eef4ff; --s-text: #b9c6da; --s-muted: #7f90aa; --s-line: rgba(255,255,255,.08); --s-glass: rgba(255,255,255,.045); --s-acc: #5bb4ff;
    display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: none; padding: 14px 12px;
    color: var(--s-text); border-right: 1px solid #1b2a44;
    background: radial-gradient(120% 40% at 0% 0%, rgba(0,157,194,.20), transparent 60%), radial-gradient(90% 30% at 100% 100%, rgba(4,69,189,.28), transparent 70%), linear-gradient(180deg, #0a1322, #0c1730 60%, #0a1222);
  }
  .side::-webkit-scrollbar { display: none; }
  .side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px 6px; }
  .side .brand { color: var(--s-ink); }
  .side .brand .logo { box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 6px 18px -4px rgba(0,157,194,.7); }
  .side .brand small { color: var(--s-muted); }
  .sbtn { background: none; border: 1px solid transparent; color: var(--s-muted); border-radius: 8px; padding: 5px; cursor: pointer; display: grid; place-items: center; }
  .sbtn:hover { color: var(--s-ink); background: var(--s-glass); border-color: var(--s-line); }
  .scourse { width: 100%; background: var(--s-glass); color: var(--s-ink); border: 1px solid var(--s-line); border-radius: 10px; padding: 8px 10px; font-weight: 600; font-size: .88rem; }
  .scourse option { color: #0e1a2b; }
  .scourse.one { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
  .scourse.one .lb { overflow: hidden; text-overflow: ellipsis; }
  .sfind { display: flex; align-items: center; gap: 8px; width: 100%; background: rgba(0,0,0,.18); border: 1px solid var(--s-line); color: var(--s-muted); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: .88rem; text-align: left; }
  .sfind:hover { border-color: rgba(91,180,255,.45); color: var(--s-ink); }
  .sfind .fl { flex: 1; }
  .sfind kbd { font: 600 .72rem/1 Inter, system-ui, sans-serif; border: 1px solid var(--s-line); border-radius: 5px; padding: 3px 5px; color: var(--s-muted); }
  .snav { display: flex; flex-direction: column; gap: 2px; }
  .sg { font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--s-muted); padding: 12px 10px 4px; }
  .snav a { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--s-text); text-decoration: none; font-weight: 500; font-size: .92rem; transition: background .15s, color .15s; }
  .snav a:hover { background: var(--s-glass); color: var(--s-ink); }
  .snav a.on { color: #fff; background: linear-gradient(90deg, rgba(91,180,255,.22), rgba(91,180,255,.06)); box-shadow: inset 0 0 0 1px rgba(91,180,255,.28), 0 8px 24px -12px rgba(10,111,194,.9); }
  .snav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--s-acc); box-shadow: 0 0 12px var(--s-acc); }
  .snav a.on svg.i { color: var(--s-acc); filter: drop-shadow(0 0 6px rgba(91,180,255,.6)); }
  .snav .lb { flex: 1; }
  .sb { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: .72rem; font-weight: 800; display: grid; place-items: center; background: rgba(255,255,255,.1); color: var(--s-ink); }
  .sb.acc { background: var(--s-acc); color: #06121f; box-shadow: 0 0 10px rgba(91,180,255,.55); }
  .sb.warn { background: #f2c94c; color: #2b2000; }
  .sb.bad { background: #ff8a80; color: #2a0705; }
  .spulse { margin-top: 6px; background: var(--s-glass); border: 1px solid var(--s-line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
  .spulse:empty { display: none; }
  .ph { font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--s-muted); padding: 2px 4px 4px; display: flex; align-items: center; gap: 6px; }
  .ph::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #5fd68a; box-shadow: 0 0 8px #5fd68a; animation: spulse 2.4s ease-in-out infinite; }
  @keyframes spulse { 50% { opacity: .35; } }
  .pi { display: flex; gap: 10px; align-items: center; padding: 7px 6px; border-radius: 10px; text-decoration: none; color: var(--s-text); }
  .pi:hover { background: rgba(255,255,255,.06); }
  .pic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: rgba(255,255,255,.08); color: var(--s-ink); }
  .pic svg.i { width: 16px; height: 16px; }
  .pic.acc { background: rgba(91,180,255,.16); color: var(--s-acc); }
  .pic.warn { background: rgba(242,201,76,.15); color: #f2c94c; }
  .pic.bad { background: rgba(255,138,128,.15); color: #ff8a80; }
  .pt { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
  .pt b { color: var(--s-ink); font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pt small { color: var(--s-muted); font-size: .76rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pempty { margin: 0; padding: 6px; font-size: .84rem; color: var(--s-muted); display: flex; gap: 6px; align-items: center; }
  .pempty svg.i { color: #5fd68a; }
  .pq { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
  .pq a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--s-line); color: var(--s-text); text-decoration: none; font-size: .74rem; font-weight: 600; }
  .pq a:hover { border-color: rgba(91,180,255,.45); color: var(--s-ink); background: rgba(91,180,255,.08); }
  .pstat { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
  .pstat > div { border: 1px solid var(--s-line); border-radius: 10px; padding: 8px 10px; }
  .pstat b { color: var(--s-ink); font-size: 1.25rem; letter-spacing: -.02em; display: inline; }
  .pstat small { display: block; color: var(--s-muted); font-size: .72rem; }
  .pfire { color: var(--s-muted); } .pfire svg.i { width: 15px; height: 15px; vertical-align: -2px; margin-right: 3px; }
  .pfire.lit { color: #ff9f43; filter: drop-shadow(0 0 6px rgba(255,159,67,.7)); }
  .sme { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; text-decoration: none; border: 1px solid var(--s-line); background: rgba(0,0,0,.15); }
  .sme:hover { border-color: rgba(91,180,255,.4); }
  .sme .avatar { background: linear-gradient(135deg, #009dc2, #0445bd); color: #fff; flex: none; }
  .sme .lb { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
  .sme b { color: var(--s-ink); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sme small { color: var(--s-muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* the top bar becomes a slim glass strip; nav, brand and course live in the sidebar */
  .app .top { background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .app .top .brand, .app .top .nav, .app .top .coursesel, .app .top .coursechip, .app .top .avatar { display: none; }
  .app .top-in { max-width: none; justify-content: flex-end; min-height: 58px; padding: 10px 24px; }
  /* collapsed rail */
  :root.side-mini .side { padding: 14px 10px; align-items: center; }
  :root.side-mini .side .lb, :root.side-mini .sg, :root.side-mini .spulse, :root.side-mini .scourse:not(.one) { display: none; }
  :root.side-mini .side-top { flex-direction: column; padding: 2px 0 6px; }
  :root.side-mini #mini svg.i { transform: rotate(180deg); }
  :root.side-mini .snav a, :root.side-mini .sfind, :root.side-mini .scourse.one, :root.side-mini .sme { justify-content: center; padding: 9px; width: 46px; }
  :root.side-mini .snav a.on::before { left: -10px; }
  :root.side-mini .sb { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; font-size: .62rem; padding: 0 4px; }
  :root.side-mini .snav { gap: 4px; }
}
@media (min-width: 1000px) and (prefers-reduced-motion: reduce) { .ph::before { animation: none; } }

/* dashboard tiles: a soft accent glow in the corner */
.tile { position: relative; overflow: hidden; }
.tile::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 0%, transparent) 70%); pointer-events: none; }
.tile .k svg.i { color: var(--accent); }

/* quick jump palette */
.pal-wrap { position: fixed; inset: 0; z-index: 80; background: rgba(6,12,22,.45); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.pal { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.35), 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); overflow: hidden; }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.pal-in input { flex: 1; border: 0; outline: 0; background: none; font-size: 1rem; color: var(--ink); }
.pal kbd { font: 600 .72rem/1 Inter, system-ui, sans-serif; border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; color: var(--muted); }
.pal-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.pal-list a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.pal-list a .grow { flex: 1; }
.pal-list a small { color: var(--muted); font-size: .76rem; }
.pal-list a.on, .pal-list a:hover { background: var(--accent-soft); color: var(--accent); }
@media print { .side, .pal-wrap { display: none !important; } .app { display: block; } }
