@font-face { font-family: 'Public Sans'; font-weight: 400; font-display: swap; src: url(fonts/public-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Public Sans'; font-weight: 500; font-display: swap; src: url(fonts/public-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Public Sans'; font-weight: 600; font-display: swap; src: url(fonts/public-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Public Sans'; font-weight: 700; font-display: swap; src: url(fonts/public-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 200 900; font-display: swap; src: url(fonts/source-serif-4-latin-wght-normal.woff2) format('woff2'); }

:root {
  --green: #1E4D2B; --green-deep: #163A20; --gold: #C8C372; --gold-soft: #EEECD3;
  --page: #F6F6F1; --card: #FFFFFF; --ink: #18221B; --muted: #55605A; --line: #D9DCD2; --line-strong: #A9B0A4; --track: #E4E7DE;
  --right: #1E6B3A; --right-bg: #E3F0E6; --wrong: #9B2C1F; --wrong-bg: #F7E4E0;
  --serif: 'Source Serif 4', Georgia, serif; --sans: 'Public Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
body { min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--serif); color: var(--green); margin: 0; line-height: 1.12; }
a { color: var(--green); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
header.top { background: var(--green); color: #fff; }
header.top .bar { max-width: 1180px; margin: 0 auto; padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
header.top .brand { font-family: var(--serif); font-size: 26px; font-weight: 700; color: #fff; text-decoration: none; }
header.top .tag { font-size: 14px; color: #DCE6DD; }
header.top .spacer { flex: 1; }
.switch { display: flex; background: var(--green-deep); padding: 4px; gap: 4px; }
.switch button { background: transparent; color: #fff; border: 0; padding: 9px 14px; font-weight: 600; font-size: 14px; cursor: pointer; min-height: 40px; }
.switch button[aria-pressed="true"] { background: var(--gold); color: var(--ink); font-weight: 700; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 20px 48px; display: flex; flex-direction: column; gap: 28px; }
footer { max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 20px 28px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px 20px; border-top: 1px solid var(--line); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 11px 20px; border: 2px solid var(--green); background: transparent; color: var(--green); font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; border-radius: 0; }
.btn.primary { background: var(--green); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.quiet { border-color: var(--line-strong); color: var(--ink); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--green); font-weight: 600; text-decoration: underline; cursor: pointer; }

.card { background: var(--card); box-shadow: 0 1px 0 var(--line); padding: 24px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.badge { display: inline-block; align-self: flex-start; background: var(--gold); color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 5px 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* home */
.hero { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
.hero .main { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.hero .main h1 { font-size: 38px; }
.hero .main p { margin: 0; font-size: 17px; color: #3B463E; max-width: 580px; }
.hero .side { flex: 1 1 260px; min-width: 0; background: var(--green); color: #fff; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.hero .side h2 { color: #fff; font-family: var(--sans); font-size: 16px; }
.hero .side p { margin: 0; color: #E4ECE5; font-size: 15px; }
.section-title { font-size: 26px; }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.unit { background: var(--card); box-shadow: 0 1px 0 var(--line); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); text-decoration: none; border: 0; text-align: left; cursor: pointer; font: inherit; }
.unit:hover { box-shadow: 0 0 0 2px var(--green); }
.unit .meta { font-size: 13px; font-weight: 600; color: var(--muted); }
.unit .name { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.2; }
.unit.locked { background: #ECEDE6; box-shadow: none; cursor: default; color: var(--muted); }
.unit.locked:hover { box-shadow: none; }
.meter { height: 6px; background: var(--track); }
.meter > span { display: block; height: 6px; background: var(--green); }
.modes { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { background: var(--card); border: 1px solid #C9CEC2; color: var(--ink); padding: 12px 18px; font-weight: 600; font-size: 15px; cursor: pointer; min-height: 46px; }
.chip:hover { border-color: var(--green); }
.chip .soon { font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 6px; }
.chip:disabled { cursor: default; color: var(--muted); }
.chip:disabled:hover { border-color: #C9CEC2; }

/* course picker */
.pick { max-width: 640px; margin: 24px auto; display: flex; flex-direction: column; gap: 18px; }
.pick h1 { font-size: 40px; }
.pick .courses { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.pick .course { background: var(--card); border: 2px solid var(--line); padding: 22px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.pick .course:hover, .pick .course:focus-visible { border-color: var(--green); }
.pick .course b { font-family: var(--serif); font-size: 26px; color: var(--green); }

/* setup */
.setup { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .setup { grid-template-columns: 1fr; } }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--green); margin-bottom: 6px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid #C9CEC2; background: var(--card); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--green); box-shadow: inset 4px 0 0 var(--green); }
.choice input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--green); flex: none; }
.choice .t { font-weight: 600; }
.choice .d { font-size: 14px; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { border: 1px solid #C9CEC2; background: var(--card); padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; min-height: 42px; display: inline-flex; align-items: center; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--green); color: #fff; border-color: var(--green); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 2px; }

/* play */
.play { max-width: 720px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.playbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.progress { display: flex; gap: 3px; }
.progress span { flex: 1; height: 5px; background: var(--track); }
.progress span.done { background: var(--green); }
.progress span.miss { background: var(--wrong); }
.progress span.now { background: var(--gold); }
.kind { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stem { font-family: var(--serif); font-size: 25px; font-weight: 600; line-height: 1.28; margin: 0; white-space: pre-wrap; }
.blank { display: inline-block; min-width: 80px; border-bottom: 2px solid var(--green); }
.fact { background: var(--card); border-left: 0; box-shadow: 0 1px 0 var(--line); padding: 18px 20px; font-family: var(--serif); font-size: 19px; line-height: 1.45; white-space: pre-wrap; }
.part { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.part .stem { font-size: 21px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; gap: 14px; align-items: baseline; text-align: left; background: var(--card); border: 1px solid var(--line-strong); padding: 14px 16px; min-height: 54px; font-size: 17px; cursor: pointer; width: 100%; }
.opt .k { font-weight: 700; color: var(--green); font-size: 14px; flex: none; width: 16px; }
.opt[aria-pressed="true"] { border: 2px solid var(--green); padding: 13px 15px; background: #EEF3EE; }
.opt:disabled { cursor: default; }
.opt.right { border: 2px solid var(--right); background: var(--right-bg); padding: 13px 15px; }
.opt.wrong { border: 2px solid var(--wrong); background: var(--wrong-bg); padding: 13px 15px; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf .opt { justify-content: center; font-weight: 700; font-size: 18px; min-height: 70px; align-items: center; }
input.answer { width: 100%; border: 2px solid var(--line-strong); background: #fff; padding: 14px 16px; font-size: 18px; min-height: 54px; border-radius: 0; }
input.answer:focus { border-color: var(--green); }
input.answer.right { border-color: var(--right); background: var(--right-bg); }
input.answer.wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.match { display: flex; flex-direction: column; gap: 10px; }
.match .m { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line-strong); padding: 10px 12px; }
.match .m.right { border: 2px solid var(--right); background: var(--right-bg); }
.match .m.wrong { border: 2px solid var(--wrong); background: var(--wrong-bg); }
.match .term { font-weight: 600; }
.match select { width: 100%; min-height: 46px; border: 1px solid var(--line-strong); background: #fff; padding: 8px; border-radius: 0; }
@media (max-width: 560px) { .match .m { grid-template-columns: 1fr; } }
.order { display: flex; flex-direction: column; gap: 8px; }
.order .o { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line-strong); padding: 8px 10px 8px 14px; min-height: 56px; }
.order .o .n { font-weight: 700; color: var(--green); }
.order .o.right { border: 2px solid var(--right); background: var(--right-bg); }
.order .o.wrong { border: 2px solid var(--wrong); background: var(--wrong-bg); }
.order .mv { display: flex; gap: 6px; }
.order .mv button { min-width: 44px; min-height: 44px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; font-weight: 700; }
.order .mv button:disabled { opacity: .35; cursor: default; }
.feedback { padding: 14px 16px; font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.feedback.right { background: var(--right-bg); color: var(--right); }
.feedback.wrong { background: var(--wrong-bg); color: var(--wrong); }
.feedback .ans { color: var(--ink); font-weight: 500; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; padding-top: 6px; border-top: 1px solid var(--line); }
.actions .btn { min-width: 160px; }
@media (max-width: 560px) { .actions .btn { flex: 1; } .stem { font-size: 22px; } }

/* results */
.score { font-family: var(--serif); font-size: 64px; font-weight: 700; color: var(--green); line-height: 1; }
.missed { display: flex; flex-direction: column; gap: 10px; }
.missed .item { background: var(--card); box-shadow: 0 1px 0 var(--line); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.missed .item .a { font-size: 14px; color: var(--right); font-weight: 600; }

/* flashcards */
.flash { background: var(--card); box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line); min-height: 280px; padding: 28px 24px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.flash .side { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.flash .front { font-family: var(--serif); font-size: 24px; font-weight: 600; white-space: pre-wrap; }
.flash .back { font-size: 20px; padding-top: 14px; border-top: 2px solid var(--gold); white-space: pre-wrap; }
.rate { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rate .btn { padding: 11px 8px; }

.empty { text-align: center; padding: 48px 20px; }
.notice { background: var(--gold-soft); padding: 12px 16px; font-size: 15px; }
.error { color: var(--wrong); font-weight: 600; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* privacy page */
.prose { max-width: 720px; }
.prose h1 { font-size: 36px; margin-bottom: 8px; }
.prose h2 { font-size: 22px; margin: 24px 0 6px; }
.prose p, .prose li { font-size: 17px; }
