:root {
  --bg: #f4f6fb; --card: #fff; --ink: #0f172a; --muted: #5b6475; --line: #e3e7ef;
  --brand: #1d4ed8; --brand-ink: #fff; --ok: #15803d; --ok-bg: #e8f6ec; --bad: #b91c1c; --bad-bg: #fdecec; --flame: #ea580c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1020; --card: #141a2e; --ink: #e8ecf6; --muted: #9aa4b8; --line: #263052;
          --brand: #5b8cff; --brand-ink: #0b1020; --ok: #4ade80; --ok-bg: #12301f; --bad: #f87171; --bad-bg: #3a1616; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 560px; margin: 0 auto; padding: 8px 16px 48px; }
a { color: var(--brand); }
.top { max-width: 560px; margin: 0 auto; padding: 14px 16px 6px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand em { color: var(--brand); font-style: normal; }
.streak { font-weight: 700; color: var(--flame); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin: 12px 0; }
.hero h1 { font-size: 1.6rem; line-height: 1.2; margin: 4px 0 8px; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
button { font: inherit; border-radius: 12px; border: 1px solid var(--line); padding: 12px 16px; cursor: pointer; background: var(--card); color: var(--ink); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
button.big { width: 100%; padding: 16px; font-size: 1.1rem; margin-top: 8px; }
button.ghost { background: transparent; }
button:focus-visible, select:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
select { font: inherit; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); max-width: 100%; margin-top: 6px; display: block; width: 100%; }
.league { list-style: none; padding: 0; margin: 0 0 12px; }
.league li { padding: 4px 0; display: flex; justify-content: space-between; gap: 8px; }
.league li.mine { font-weight: 700; color: var(--brand); }
.league li .pts { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.topics { list-style: none; padding: 0; margin: 0 0 8px; }
.topics li { display: grid; grid-template-columns: 1fr 90px; gap: 10px; align-items: center; padding: 3px 0; font-size: .9rem; }
.meter { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0 16px; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .3s; }
.question { font-size: 1.15rem; margin: 8px 0 16px; }
.options { display: grid; gap: 10px; }
.options button { text-align: left; display: flex; gap: 12px; align-items: center; min-height: 56px; }
.options button b { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-size: .85rem; }
.options button.ok { background: var(--ok-bg); border-color: var(--ok); }
.options button.bad { background: var(--bad-bg); border-color: var(--bad); }
.options button:disabled { cursor: default; color: var(--ink); }
.explain { margin: 14px 0; padding: 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
#next { width: 100%; margin-top: 4px; }
.big-streak { font-size: 1.3rem; font-weight: 800; color: var(--flame); margin: 6px 0; }
.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.actions button { flex: 1 1 auto; white-space: nowrap; }
.actions button.primary { flex-basis: 100%; }
.sponsor { font-size: .9rem; }
.footer { text-align: center; margin-top: 24px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; background: var(--bg); padding: 4px; border-radius: 12px; }
.seg button { border: 0; padding: 8px; font-size: .9rem; background: transparent; }
.seg button[aria-pressed="true"] { background: var(--card); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
/* math */
.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .82em; line-height: 1.15; margin: 0 .1em; }
.fr > span:first-child { border-bottom: 1px solid currentColor; padding: 0 .15em; }
.rt { border-top: 1px solid currentColor; padding: 0 .1em; }
sup, sub { line-height: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.question img.fig { display: block; max-width: 100%; height: auto; margin: 12px auto; background: #fff; border-radius: 8px; }
.st { margin: 8px 0; padding-left: 1.4em; } .st li { margin: 6px 0; }
.sys { display: inline-flex; flex-direction: column; vertical-align: middle; border-left: 2px solid currentColor; border-radius: 8px 0 0 8px; padding-left: .4em; margin: 0 .2em; line-height: 1.6; }
.ri > sup { margin-right: -.3em; font-size: .7em; }
.meter.wide { margin: 10px 0 6px; height: 10px; }
#plan-card label { white-space: nowrap; display: flex; align-items: center; gap: 6px; }
#plan-card select { display: inline-block; width: auto; margin: 0; padding: 4px 8px; }

.field { display: block; margin: 14px 0; font-size: .95rem; border: 0; padding: 0; }
.field legend { font-weight: 600; margin-bottom: 4px; padding: 0; }
.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 8px; }
.subjects label { display: flex; gap: 8px; align-items: center; font-size: .92rem; }
.subjects input { width: 18px; height: 18px; accent-color: var(--accent, #1d4ed8); }
#setup .seg { margin-top: 12px; }
.subjects .soon { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: auto; }
.papers { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.papers li { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.papers button { text-align: left; flex: 1; font-size: .95rem; }
@media (max-width: 420px) { .subjects { grid-template-columns: 1fr; } }
.subjects label span { min-width: 0; }
