:root {
  --ink: #1e1e1e;
  --muted: #5f6368;
  --line: #d4d7dd;
  --bg: #ffffff;
  --panel: #f6f7fb;
  --blue: #324dc7;
  --blue-soft: #e8ecfb;
  --green: #1d7a45;
  --green-soft: #e3f4ea;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --amber: #b26a00;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; height: auto; }
.loading { text-align: center; margin-top: 30vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--red); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #fff; border: 1px solid var(--red); padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.15); z-index: 50; }

/* buttons */
.btn { border: 1px solid transparent; border-radius: 999px; padding: 8px 20px; font-weight: 600; background: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #2a41aa; }
.btn.primary:disabled { opacity: .6; }
.btn.outline { border-color: var(--blue); color: var(--blue); background: #fff; }
.btn.ghost { border-color: var(--line); background: #fff; padding: 6px 14px; font-size: 14px; }
.btn.link { color: var(--blue); padding: 0; border: 0; text-decoration: underline; font-weight: 600; }
.btn.small { padding: 5px 14px; font-size: 14px; }

/* gate */
.gate { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.gate h1 { margin: 16px 0 4px; }
.gate form { display: grid; gap: 12px; margin-top: 16px; }
.gate label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.gate input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.gate .switch { margin-top: 18px; color: var(--muted); }

/* home */
.home-head { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.home-head .who { margin-left: auto; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.back-home { color: var(--muted); text-decoration: none; font-size: 14px; }
.home { max-width: 980px; margin: 0 auto; padding: 24px 24px 64px; }
.home h1 { font-size: 32px; margin: 8px 0 0; letter-spacing: -.01em; }
.hello { font-size: 18px; margin: 4px 0 0; }
.lede { color: var(--muted); max-width: 620px; }
.home h3 { margin: 28px 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 20px; background: #fff; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 21px; }
.meter { height: 8px; background: #eceef3; border-radius: 99px; overflow: hidden; margin: 14px 0; }
.meter span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 16px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-size: 22px; font-weight: 700; }
.new-session { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding-top: 14px; border-top: 1px solid var(--line); }
.new-session label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.new-session input, .new-session select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; background: #fff; }
.new-session input { width: 90px; }
.sessions { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sessions li { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sessions li:first-child { border-top: 0; }
.sessions .when { color: var(--muted); font-size: 14px; }
.sessions .score { margin-left: auto; font-weight: 600; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--blue-soft); color: var(--blue); }
.tag.math { background: #fff2dc; color: var(--amber); }

/* planned sessions */
.plan-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 16px 20px; margin-bottom: 12px; }
.plan-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.plan-form input, .plan-form select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 15px; background: #fff; }
.plan-form input[name="count"] { width: 90px; }
.plan-form .grow { flex: 1 1 180px; }
.plans .plan { flex-wrap: nowrap; }
.plan-check input { width: 18px; height: 18px; accent-color: var(--blue); }
.plan-when { min-width: 170px; }
.plan-when span { color: var(--muted); font-size: 14px; }
.plan-when em { font-style: normal; font-size: 12px; font-weight: 700; margin-left: 8px; padding: 1px 8px; border-radius: 99px; }
.plan-when .rel { background: var(--blue-soft); color: var(--blue); }
.plan-when .missed { background: #fff2dc; color: var(--amber); }
.plan-what { flex: 1; display: grid; font-size: 15px; }
.plan-note { color: var(--muted); font-size: 13px; }
.plan.done .plan-when b, .plan.done .plan-what { text-decoration: line-through; color: var(--muted); }
.small-x { font-size: 20px; color: var(--muted); }
@media (max-width: 760px) { .plans .plan { flex-wrap: wrap; } .plan-when { min-width: 0; } }

/* sync pill */
.sync { font-size: 13px; color: var(--muted); }
.sync.saved::before { content: "✓ "; color: var(--green); }
.sync.offline, .sync.locked, .sync.retrying { color: var(--amber); }

/* test layout */
.test { min-height: 100vh; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: #fff; }
.bar .bar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.bar.top .bar-left { display: flex; flex-direction: column; line-height: 1.25; }
.bar.top .bar-left .muted { font-size: 13px; }
.bar.top { position: sticky; top: 0; z-index: 10; }
.bar.bottom { position: sticky; bottom: 0; z-index: 10; }
.stripe { height: 3px; background: repeating-linear-gradient(90deg, #324dc7 0 14px, transparent 14px 18px, #e2a300 18px 32px, transparent 32px 36px, #1d7a45 36px 50px, transparent 50px 54px, #c2185b 54px 68px, transparent 68px 72px); opacity: .85; }
.test-body { flex: 1; display: flex; background: #fff; }
.pane { padding: 28px 32px 40px; }
.pane.question { width: 100%; max-width: 1000px; margin: 0 auto; }
.stem { margin: 8px 0 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.stem-img, .rationale-img { display: block; }

.q-head { display: flex; align-items: center; gap: 12px; background: var(--panel); border-bottom: 2px dashed var(--line); padding: 0 12px 0 0; margin-bottom: 18px; }
.q-num { background: #1e1e1e; color: #fff; font-weight: 700; padding: 6px 12px; min-width: 36px; text-align: center; }
.mark { border: 0; background: none; display: flex; align-items: center; gap: 6px; font-size: 14px; padding: 6px 0; }
.mark svg { width: 13px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 1.6; }
.mark.on svg { fill: #c2185b; stroke: #c2185b; }
.q-meta { font-size: 12px; color: var(--muted); margin-left: auto; text-align: right; }
.abc { border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 12px; font-weight: 700; padding: 2px 6px; }
.abc.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* choices */
.choices { display: grid; gap: 12px; }
.choice-row { display: flex; gap: 8px; align-items: center; }
.choice { flex: 1; display: flex; align-items: center; gap: 14px; text-align: left; background: #fff; border: 1.5px solid #b9bdc6; border-radius: var(--radius); padding: 10px 14px; position: relative; min-height: 52px; }
.choice:hover:not(:disabled) { border-color: var(--blue); }
.choice .letter { flex: 0 0 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.choice .choice-img { flex: 1; min-width: 0; }
.choice.chosen { border-color: var(--blue); box-shadow: 0 0 0 1.5px var(--blue); }
.choice.chosen .letter { background: var(--blue); border-color: var(--blue); color: #fff; }
.choice.struck .choice-img { opacity: .35; }
.choice.struck::after { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; border-top: 2px solid var(--ink); }
.choice:disabled { cursor: default; }
.choice.right { border-color: var(--green); box-shadow: 0 0 0 1.5px var(--green); background: var(--green-soft); }
.choice.right .letter { background: var(--green); border-color: var(--green); color: #fff; }
.choice.wrong { border-color: var(--red); box-shadow: 0 0 0 1.5px var(--red); background: var(--red-soft); }
.choice.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
.choice .verdict { position: absolute; top: -10px; right: 14px; font-size: 11px; font-weight: 700; white-space: nowrap; color: #fff; padding: 1px 10px; border-radius: 99px; }
.choice.right .verdict { background: var(--green); }
.choice.wrong .verdict { background: var(--red); }
.choice img { mix-blend-mode: multiply; }
.strike { border: 1px solid var(--line); background: #fff; border-radius: 50%; width: 34px; height: 34px; font-size: 12px; font-weight: 700; padding: 0; }

/* student-produced response */
.spr { display: grid; gap: 6px; max-width: 320px; }
.spr label { font-weight: 600; }
.spr-input { font-size: 22px; padding: 10px 12px; border: 1.5px solid #b9bdc6; border-radius: 8px; width: 180px; }
.spr-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 1.5px var(--blue); }
.spr-input.right { border-color: var(--green); background: var(--green-soft); }
.spr-input.wrong { border-color: var(--red); background: var(--red-soft); }
.preview, .hint, .key { margin: 0; font-size: 14px; }
.hint { color: var(--muted); }

/* feedback */
.pane .btn.outline { margin-top: 18px; }
.feedback { margin-top: 18px; padding: 12px 16px; border-radius: var(--radius); }
.feedback.right { background: var(--green-soft); color: var(--green); }
.feedback.wrong { background: var(--red-soft); color: var(--red); }
.feedback.skipped { background: var(--panel); }
.feedback b { color: var(--ink); }
.rationale { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.errata { background: #fff2dc; color: #6b4300; border-radius: 8px; padding: 8px 12px; font-size: 14px; margin: 0 0 10px; }
.rationale summary { font-weight: 700; cursor: pointer; margin-bottom: 8px; }

/* bottom nav + popovers */
.nav-toggle { position: absolute; left: 50%; transform: translateX(-50%); background: #1e1e1e; color: #fff; border: 0; border-radius: 8px; padding: 6px 16px; font-weight: 600; }
.bar.bottom { position: sticky; }
.popover { position: fixed; z-index: 30; background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: 16px 20px 20px; }
.nav-pop { bottom: 72px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); }
.progress-pop { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
.pop-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.x { border: 0; background: none; font-size: 24px; line-height: 1; }
.legend { display: flex; gap: 16px; font-size: 13px; margin-bottom: 12px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; border-radius: 3px; }
.legend i.cur { border: 2px solid var(--ink); }
.legend i.unanswered { border: 1.5px dashed #888; }
.legend i.marked { background: #c2185b; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px; }
.cell { height: 38px; border-radius: 6px; font-weight: 700; position: relative; }
.cell.answered { background: var(--blue); color: #fff; border: 0; }
.cell.unanswered { background: #fff; border: 1.5px dashed #888; color: var(--blue); }
.cell.right { background: var(--green); }
.cell.wrong { background: var(--red); }
.cell.current { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.cell.marked::after { content: ""; position: absolute; top: -4px; right: -4px; width: 10px; height: 12px; background: #c2185b; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.big-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 16px; }
.big-stats div { background: var(--panel); border-radius: 10px; padding: 10px 12px; display: grid; }
.big-stats b { font-size: 24px; }
.big-stats span { font-size: 13px; color: var(--muted); }
.finish-check h4 { margin: 14px 0 2px; font-size: 15px; }
.finish-check .small { margin: 0 0 8px; }
.pop-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* results */
.results h1 .pct { color: var(--muted); font-weight: 600; font-size: 22px; margin-left: 8px; }
.domains { display: grid; gap: 8px; margin: 18px 0 24px; max-width: 620px; }
.domain { display: grid; grid-template-columns: 1fr 160px 50px; gap: 12px; align-items: center; font-size: 14px; }
.domain .meter { margin: 0; }
.result-list { list-style: none; padding: 0; margin: 0 0 24px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.result-list li { border-top: 1px solid var(--line); }
.result-list li:first-child { border-top: 0; }
.result-list button { width: 100%; display: grid; grid-template-columns: 32px 1fr 80px 100px 24px; gap: 10px; align-items: center; text-align: left; padding: 10px 16px; border: 0; background: #fff; }
.result-list button:hover { background: var(--panel); }
.result-list .n { font-weight: 700; color: var(--muted); }
.result-list .sk { font-size: 14px; }
.result-list .ya, .result-list .ka { font-size: 13px; color: var(--muted); }
.result-list .ic { font-weight: 800; text-align: center; }
.result-list .right .ic { color: var(--green); }
.result-list .wrong .ic { color: var(--red); }

@media (max-width: 760px) {
  .test-body { flex-direction: column; }
  .pane { padding: 18px 16px 28px; }
  .bar { padding: 8px 16px; }
  .bar.top .bar-left .muted, .bar.bottom .bar-left { display: none; }
  .nav-toggle { position: static; transform: none; }
  .home-head, .home { padding-left: 16px; padding-right: 16px; }
  .result-list button { grid-template-columns: 28px 1fr 24px; }
  .result-list .ya, .result-list .ka { display: none; }
  .domain { grid-template-columns: 1fr 90px 40px; }
}
