:root {
  --primary: #4F46E5; --primary-soft: #EEF2FF; --good: #10B981; --good-soft: #ECFDF5;
  --bad: #F43F5E; --bad-text: #BE123C; --warn: #F59E0B; --warn-soft: #FFFBEB; --good-strong: #047857; --field: #7C8AA0; --focus: #4F46E5;
  --bg: #FAFAF9; --surface: #FFFFFF; --ink: #1E293B; --muted: #5B6B82; --border: #E7E5E4;
  --r-card: 16px; --r-ctl: 12px;
}
* { box-sizing: border-box; }
html { color-scheme: light; accent-color: #4F46E5; scrollbar-color: #CBD5E1 transparent; -webkit-tap-highlight-color: rgba(79, 70, 229, .12); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
p { margin: 0 0 8px; }
a { color: var(--primary); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.good { background: var(--good-soft); color: #047857; }
.chip.warn { background: var(--warn-soft); color: #B45309; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

.btn {
  display: block; width: 100%; padding: 13px 16px; border-radius: var(--r-ctl); border: 1px solid var(--field);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none;
  min-height: 44px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.good { background: var(--good-strong); border-color: var(--good-strong); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { width: auto; display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; font-size: 14px; }
.btns { display: flex; gap: 8px; margin-top: 8px; }
.btns .btn { flex: 1; }

input, textarea, select {
  width: 100%; padding: 12px; border: 1px solid var(--field); border-radius: var(--r-ctl);
  font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 200px; line-height: 1.5; }
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
.pin { position: relative; }
.pin button { position: absolute; right: 2px; top: 2px; height: 44px; min-width: 56px; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; padding: 0 12px; cursor: pointer; }

.task { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.task .tick { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--field); flex: none; display: grid; place-items: center; color: #fff; }
.task .tick .ic { width: 16px; height: 16px; }
.task.done .tick { background: var(--good-strong); border-color: var(--good-strong); }
.task.done .t { color: var(--muted); }
.task .t { font-weight: 600; }
.task .s { font-size: 13px; color: var(--muted); }
.task .go { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }

.bar { height: 8px; background: #EEF0F3; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.bar.good > i { background: var(--good); }
.rd { margin-bottom: 14px; }
.rd:last-child { margin-bottom: 0; }
.rd .row { margin-bottom: 4px; }

.prompt { font-size: 17px; font-weight: 600; line-height: 1.45; }
.big-timer { font-size: 44px; font-weight: 700; text-align: center; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 8px 0; }
.big-timer.rec { color: var(--bad); }
.counter { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }

.fb-band { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.fb-band .b { font-size: 30px; font-weight: 800; color: var(--primary); }
.praise { background: var(--good-soft); border-radius: 12px; padding: 12px; color: #065F46; margin: 10px 0; }
.gap { background: var(--primary-soft); border-radius: 12px; padding: 12px; margin: 10px 0; }
.scores > div { display: grid; grid-template-columns: 96px 1fr 24px; gap: 8px; align-items: center; font-size: 14px; margin: 4px 0; }
.note { border-top: 1px solid var(--border); padding: 12px 0; }
.note:first-child { border-top: 0; }
.note .w { color: var(--bad-text); text-decoration: line-through; text-decoration-thickness: 1px; }
.note .b { color: #047857; font-weight: 600; }
.note .y { font-size: 14px; color: var(--muted); margin-top: 2px; }
.cat { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: #F1F5F9; color: var(--muted); margin-bottom: 4px; }
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.model { white-space: pre-wrap; background: #F8FAFC; border-radius: 12px; padding: 12px; margin-top: 8px; }
.flash { text-align: center; padding: 28px 8px; }
.flash .front { font-size: 26px; font-weight: 700; margin-bottom: 12px; }
.err { color: var(--bad-text); font-size: 14px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips button { border: 1px solid var(--field); background: #fff; border-radius: 99px; padding: 8px 14px; min-height: 44px; font: inherit; font-size: 14px; cursor: pointer; }
.chips button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.hist { padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.hist:first-child { border-top: 0; }
.spark { display: block; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.nav[hidden] { display: none; }
.nav a { flex: 1; text-align: center; padding: 14px 4px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.nav a.on { color: var(--primary); box-shadow: inset 0 2px 0 var(--primary); }

/* ---- mock test ---- */
.exam-bar { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-bottom: 1px solid var(--border); margin: -16px -16px 12px; padding: 12px 16px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary); }
.rules { margin: 0; padding-left: 20px; }
.rules li { margin: 6px 0; }
.passage { white-space: pre-wrap; line-height: 1.6; }
.gapn { background: var(--primary-soft); color: var(--primary); border-radius: 6px; padding: 0 5px; }
.q .qt { font-weight: 600; margin-bottom: 6px; }
.opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; min-height: 44px; border: 1px solid #CBD5E1; border-radius: var(--r-ctl); margin: 6px 0; font-weight: 400; font-size: 16px; cursor: pointer; }
.opt input { width: 20px; height: 20px; margin: 0; flex: none; }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 10px 8px; min-height: 44px; border: 1px solid var(--field); background: #fff; border-radius: var(--r-ctl); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl td, .tbl th { padding: 6px 4px; border-top: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl tr:first-child td, .tbl tr:first-child th { border-top: 0; }
.card.disabled { opacity: .5; pointer-events: none; }
textarea[hidden] { display: none; }

#live { margin-bottom: 10px; }

/* ---- score display ---- */
.score-hero { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 8px; }
.score-hero b { font-size: 44px; font-weight: 800; letter-spacing: -0.02em; color: var(--primary); line-height: 1; }
.score-hero span { color: var(--muted); font-size: 15px; font-weight: 600; }
.sbar { position: relative; height: 10px; background: #EEF0F3; border-radius: 99px; margin: 8px 0 4px; }
.sbar .rng { position: absolute; top: 0; height: 100%; background: #A5B4FC; border-radius: 99px; }
.sbar.above .rng { background: #6EE7B7; }
.sbar .dot { position: absolute; top: -3px; width: 4px; height: 16px; margin-left: -2px; background: var(--primary); border-radius: 2px; }
.sbar.above .dot { background: var(--good-strong); }
.sbar .c1 { position: absolute; top: -5px; width: 2px; height: 20px; margin-left: -1px; background: var(--good-strong); }
.sbar.off { opacity: .4; }
.zone { font-size: 14px; margin: 6px 0 0; }
.zone.above { color: #047857; } .zone.edge { color: #B45309; } .zone.below { color: var(--muted); }

/* ---- study guide + target-dependent blocks ---- */
body[data-target="B2"] .only-c1 { display: none; }
body[data-target="C1"] .only-b2 { display: none; }
.strat p, .strat ul, .strat ol { margin: 8px 0; }
.strat ul, .strat ol { padding-left: 20px; }
.strat li { margin: 5px 0; }
.strat table { margin: 8px 0; }

/* ---- accessibility floor ---- */
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 1px; }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
::selection { background: #C7D2FE; color: var(--ink); }
input, textarea { caret-color: var(--focus); }
::placeholder { color: #64748B; opacity: 1; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; top: 8px; left: 8px; z-index: 20; background: var(--surface); color: var(--primary); padding: 12px 16px; border-radius: var(--r-ctl); font-weight: 600; }
#app:focus { outline: none; }
.gap .muted { color: #475569; }

/* headings and back links used as page titles */
.ttl { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: 0; color: var(--ink); }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 10px 0 0; margin-left: -4px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.go .ic { width: 16px; height: 16px; }

/* disclosure rows: full-height target with a drawn chevron */
summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ''; width: 8px; height: 8px; margin-right: 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); flex: none; }
details[open] > summary::after { transform: rotate(-135deg); }

/* Home: countdown, primary next action, compact score, link list */
.count { text-align: right; line-height: 1.1; }
.count b { display: block; font-size: 24px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.count span { font-size: 13px; color: var(--muted); font-weight: 600; }
.count.warn b { color: #B45309; }
.next { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; padding: 16px; margin-bottom: 8px; }
.next small { display: block; font-weight: 500; opacity: .9; font-size: 13px; }
.next .ic { width: 22px; height: 22px; }
.done-card { display: flex; gap: 12px; align-items: center; }
.done-card .tick { width: 32px; height: 32px; border-radius: 50%; background: var(--good-strong); color: #fff; display: grid; place-items: center; flex: none; }
.sum > summary { padding: 4px 0; }
.sum-l { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sum-l b { font-size: 26px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.sum-l span { color: var(--muted); font-size: 14px; font-weight: 600; }
.sum > div { margin-top: 10px; }
.legend { margin: 10px 0 0; }
.links { padding: 4px 16px; }
.links a { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; color: var(--ink); text-decoration: none; border-top: 1px solid var(--border); }
.links a:first-child { border-top: 0; }
.links .ic:first-child { color: var(--primary); }
.links b { display: block; font-size: 16px; }
.links small { display: block; color: var(--muted); font-size: 13px; }
.links .go { margin-left: auto; color: var(--muted); }

/* login */
.login { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 8vh 0 12px; }
.login img { width: 56px; height: 56px; border-radius: 14px; }
.login h1 { margin-top: 8px; }

/* exam chrome: remaining time, progress, warnings */
.exam-bar h1.ttl { font-size: 16px; }
.exam-bar .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.clock.warn { color: #B45309; }
.clock.crit { color: #B45309; font-weight: 800; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.grp > summary { color: var(--primary); font-weight: 600; }
.grp { margin: 12px 0; }
details.grp.card { padding: 2px 16px; }
details.grp.card[open] { padding-bottom: 14px; }

/* in-app confirmation (replaces the native confirm) */
dialog.dlg { border: 0; border-radius: var(--r-card); padding: 20px; width: min(92vw, 420px); box-shadow: 0 8px 32px rgba(15, 23, 42, .18); color: var(--ink); }
dialog.dlg::backdrop { background: rgba(15, 23, 42, .4); }
dialog.dlg p { font-size: 16px; margin: 0 0 16px; }

/* history rows behave like buttons */
.hist { display: block; }
.hist:focus-visible { outline-offset: -2px; border-radius: 8px; }

/* study guide tables never widen the page */
.strat table { display: block; max-width: 100%; overflow-x: auto; }

/* desktop: keep the bottom nav as wide as the content column */
@media (min-width: 760px) {
  .nav { left: 50%; right: auto; transform: translateX(-50%); width: 720px; border: 1px solid var(--border); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
