/* Design tokens and base styles copied from legacy/voegel/index.html and legacy/start.html.
   Fonts are served by the app itself (frontend/fonts/, SIL Open Font License), never from a CDN. */

@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-latin.woff2") format("woff2");
  font-weight: 300 700; font-stretch: 75% 125%; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/nunito-latin.woff2") format("woff2");
  font-weight: 200 1000; font-display: swap; }

:root {
  --bg: #F4F7EF;
  --surface: #FFFFFF;
  --ink: #1E2B14;
  --muted: #5F6B55;
  --line: #D6E1C8;
  --accent: #4F7F1F;
  --accent-soft: #E6F0D9;
  --t1: #2F6DB5; --t2: #B5562F; --t3: #7A3FA0; --t0: #4F7F1F;
  --good: #2E8540; --good-soft: #E1F2E4;
  --bad: #C0392B; --bad-soft: #FBE5E2;
  --yolk: #F2B632; --white: #FBF6E8; --shell: #E9D9BC;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141A10; --surface: #1D2517; --ink: #E9F0E1; --muted: #A3B096; --line: #34412B;
    --accent: #8BC34A; --accent-soft: #26331C;
    --t1: #6FA8E8; --t2: #E58A63; --t3: #B98AE0; --t0: #8BC34A;
    --good: #6CCB7E; --good-soft: #1E3322; --bad: #F07B6E; --bad-soft: #3A1F1C;
    --yolk: #D9A02A; --white: #3A3A2E; --shell: #5A4E3A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141A10; --surface: #1D2517; --ink: #E9F0E1; --muted: #A3B096; --line: #34412B;
  --accent: #8BC34A; --accent-soft: #26331C;
  --t1: #6FA8E8; --t2: #E58A63; --t3: #B98AE0; --t0: #8BC34A;
  --good: #6CCB7E; --good-soft: #1E3322; --bad: #F07B6E; --bad-soft: #3A1F1C;
  --yolk: #D9A02A; --white: #3A3A2E; --shell: #5A4E3A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.45; }
.wrap { max-width: 720px; margin: 0 auto; padding: 18px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
h1 { font-family: var(--display); font-weight: 600; font-size: 1.9rem; margin: 0; text-wrap: balance; }
h1 span { color: var(--accent); }
.head .sub { color: var(--muted); font-weight: 600; }
h2 { font-family: var(--display); font-weight: 600; font-size: 1.25rem; margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 700; }
.chip small { font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--tc); background: var(--tc); color: #fff; }
.chip[aria-pressed="true"] small { color: rgba(255,255,255,.85); }

.toggle { border: 2px solid var(--line); background: var(--surface); border-radius: 10px; padding: 5px 12px; font-weight: 600; color: var(--muted); }
.toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: .75rem; font-weight: 800; color: #fff; border-radius: 6px; padding: 1px 7px; }
.page { color: var(--muted); font-size: .82rem; font-weight: 700; }
.flash { min-height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; cursor: pointer; user-select: none; }
.flash .front { font-family: var(--display); font-size: 1.55rem; font-weight: 600; line-height: 1.15; text-wrap: balance; }
.flash .hint { color: var(--muted); font-size: .9rem; }
.flash .term { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.flash .answer { background: var(--good-soft); border: 2px solid var(--good); border-radius: 12px; padding: 12px 16px; font-size: 1.15rem; font-weight: 800; text-align: left; width: 100%; }
.flash .back { background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; font-size: .98rem; text-align: left; width: 100%; }
.flash .plain { border: 2px dashed var(--line); border-radius: 12px; padding: 10px 14px; font-size: .98rem; text-align: left; width: 100%; }
.flash .plain b { color: var(--accent); }
.flash .answer span, .flash .back .lbl { display: block; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
/* Task 1.14: the English forms on a vocab card back, side by side like legacy/verben. */
.flash .forms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.flash .forms div { background: var(--accent-soft); border-radius: 10px; padding: 10px; }
.flash .forms span { display: block; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.flash .forms b { font-size: 1.3rem; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.btn { border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 800; font-size: 1rem; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.good { background: var(--good-soft); color: var(--good); border: 2px solid var(--good); }
.btn.bad { background: var(--bad-soft); color: var(--bad); border: 2px solid var(--bad); }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink); }
.btn.listen { background: var(--surface); border: 2px solid var(--yolk); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.result { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.result .score { font-family: var(--display); font-size: 3rem; font-weight: 600; color: var(--accent); line-height: 1; }
.label { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.list-miss { display: flex; flex-direction: column; gap: 6px; }
.list-miss div { display: flex; gap: 8px; align-items: baseline; background: var(--bad-soft); border: 1px solid var(--bad); border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: .95rem; }
.list-miss div .kind { flex: 0 0 auto; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); min-width: 5.5em; }

.q-text { font-family: var(--display); font-weight: 600; font-size: 1.35rem; line-height: 1.25; margin: 8px 0 4px; text-wrap: balance; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { text-align: left; border: 2px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 14px; font-weight: 700; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.ok { border-color: var(--good); background: var(--good-soft); }
.opt.no { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.num { display: flex; gap: 10px; align-items: center; }
.num input { width: 9rem; padding: 11px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); font-size: 1.2rem; font-weight: 800; }
.num input.ok { border-color: var(--good); background: var(--good-soft); }
.num input.no { border-color: var(--bad); background: var(--bad-soft); }
.num span { font-weight: 800; color: var(--muted); }
.ask input { width: 100%; min-height: 2.4rem; padding: 11px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); font-size: 1.15rem; }
.ask input:focus { border-color: var(--accent); }
.ask input::placeholder { color: var(--muted); font-weight: 400; }
.why { border-radius: 12px; padding: 12px 14px; margin-top: 12px; font-size: .98rem; }
.why.ok { background: var(--good-soft); }
.why.no { background: var(--bad-soft); }
.why b.head { display: block; margin-bottom: 2px; }
.why.ok b.head { color: var(--good); }
.why.no b.head { color: var(--bad); }
.why ol { margin: 4px 0 6px; padding-left: 1.3em; }

/* ordering (task 1.7) */
.q-sub { color: var(--muted); font-size: .95rem; margin: 0 0 12px; }
.order-done { display: flex; flex-direction: column; gap: 6px; min-height: 44px; border: 2px dashed var(--line); border-radius: 12px; padding: 8px; margin-bottom: 10px; }
.order-done p { color: var(--muted); font-size: .92rem; }
.order-pool { display: flex; flex-direction: column; gap: 6px; }
.step { display: flex; gap: 10px; align-items: center; text-align: left; border: 2px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 12px; font-weight: 700; font-size: .98rem; width: 100%; }
.step .n { flex: 0 0 auto; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: .85rem; }
.step.ok { border-color: var(--good); background: var(--good-soft); }
.step.no { border-color: var(--bad); background: var(--bad-soft); }

/* egg diagram (task 1.7) */
.egg { width: 100%; max-width: 420px; display: block; margin: 4px auto 10px; }
.egg .shell { fill: var(--shell); stroke: var(--muted); stroke-width: 2; }
.egg .white { fill: var(--white); stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.egg .air { fill: var(--surface); stroke: var(--muted); stroke-width: 1; }
.egg .yolk { fill: var(--yolk); }
.egg .disc { fill: #fff; stroke: var(--muted); stroke-width: 1; }
.egg .cord { fill: none; stroke: var(--muted); stroke-width: 2; }
.egg .lead { stroke: var(--muted); stroke-width: 1.2; }
.egg .lead.on { stroke: var(--bad); stroke-width: 2.4; }
.egg .mk circle { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.egg .mk text { font: 800 13px var(--body); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.egg .mk.on circle { fill: var(--bad); stroke: var(--bad); }
.egg .mk.on text { fill: #fff; }

/* explain (task 1.8) */
.prompt { font-family: var(--display); font-weight: 600; font-size: 1.45rem; line-height: 1.2; margin: 8px 0; text-wrap: balance; }
textarea { width: 100%; min-height: 130px; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); font-size: 1rem; resize: vertical; }
.steps4 { margin: 0 0 12px; padding-left: 1.3em; color: var(--muted); font-size: .95rem; }
.kw { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.kw label { display: inline-flex; gap: 6px; align-items: center; border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 8px; font-weight: 700; font-size: .95rem; cursor: pointer; background: var(--bg); }
.kw input { width: 18px; height: 18px; accent-color: var(--good); }
.kw label:has(input:checked) { border-color: var(--good); background: var(--good-soft); }
.model { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.model .cmp { display: block; margin-top: 8px; font-weight: 700; }

/* countdown (task 1.10) — styles from legacy/voegel/index.html, lines 55-61 */
.countdown { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 12px; padding: 12px 14px; flex-wrap: wrap; }
.countdown .days { font-family: var(--display); font-size: 2rem; font-weight: 600; color: var(--accent); min-width: 3ch; text-align: center; line-height: 1; }
.countdown .days small { display: block; font-family: var(--body); font-size: .72rem; color: var(--muted); font-weight: 700; }
.countdown p { margin: 0; }
.countdown .sub { color: var(--muted); font-size: .9rem; }
.countdown label { font-size: .85rem; }
.countdown input[type="date"] { font: inherit; }
.countdown input[type="text"] { font: inherit; border: 2px solid var(--line); border-radius: 8px; background: var(--bg); color: inherit; }

.tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 4px; background: var(--accent-soft); padding: 4px; border-radius: 12px; }.tab { border: 0; background: transparent; border-radius: 9px; padding: 9px 4px; font-weight: 800; font-size: .92rem; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tab .badge { display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: .75rem; margin-left: 3px; }

/* patterns (task 1.17) — one table per group; rows outside the chosen units are faded,
   a red dot marks mistakes */
.intro { color: var(--muted); font-size: .92rem; margin: 0 0 10px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: 0 0 14px; }
.group header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 14px; background: var(--accent-soft); }
.group header h2 { font-size: 1.05rem; }
.group header .rule { font-weight: 800; color: var(--accent); font-size: .85rem; white-space: nowrap; }
.group .tip { margin: 0; padding: 8px 14px 4px; color: var(--muted); font-size: .92rem; }
.group .tbl { overflow-x: auto; }
.group table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.group td, .group th { padding: 6px 14px; text-align: left; border-top: 1px solid var(--line); }
.group th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.group td.inf { font-weight: 800; }
.group td.native { color: var(--muted); font-size: .88rem; }
.group tr.out td { opacity: .38; }
.group tr.miss td.inf::after { content: " ●"; color: var(--bad); font-size: .7rem; }
/* task 1.18c — unit pill in the fifth column, coloured like the unit chip */
.group td.unit { white-space: nowrap; }
.group td.unit .tag { border: 2px solid var(--tc); color: var(--tc); border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* After the M1 review: parity with the legacy trainers and start page. */
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.head p { margin: 4px 0 0; }
.back { align-self: flex-start; text-decoration: none; color: var(--ink); font-weight: 800; font-size: .9rem;
  background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.back:hover { border-color: var(--accent); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.chips.dirs { margin-bottom: 2px; }
.flash.card { padding: 22px 20px; }
.flash .q-sub { color: var(--muted); }
.flash .ask { display: block; width: 100%; text-align: left; }
.flash .ask .term { display: block; margin-bottom: 4px; }

.countdown { display: block; border-left-color: var(--c, var(--accent)); }
.countdown .days { color: var(--c, var(--accent)); }
.cd-row { display: flex; align-items: center; gap: 14px; }
.cd-row .cd-text { flex: 1; }
.cd-row .linkish { font-size: .9rem; white-space: nowrap; }
.cd-edit { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.cd-saved { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.cd-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.cd-field { display: flex; flex-direction: column; gap: 3px; font-size: .8rem; font-weight: 800; color: var(--muted); }
.cd-field input, .cd-field select { font: inherit; font-size: 1rem; color: var(--ink); border: 2px solid var(--line);
  border-radius: 8px; background: var(--bg); padding: 6px 8px; }

#start .hello { color: var(--muted); font-weight: 600; margin: 4px 0 0; }
#start h1 { font-size: 2rem; }
.next { display: flex; flex-direction: column; gap: 8px; }
.ev { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-left: 6px solid var(--c); border-radius: 12px; padding: 10px 14px; color: inherit; text-decoration: none; }
.ev .days, .countdown .days { font-family: var(--display); font-size: 1.8rem; font-weight: 600; min-width: 3ch; text-align: center; line-height: 1; }
.ev .days { color: var(--c); }
.ev .days small { display: block; font-family: var(--body); font-size: .7rem; color: var(--muted); font-weight: 700; }
.ev p { margin: 0; }
.ev .sub { color: var(--muted); font-size: .9rem; }
.apps { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
a.app { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; background: var(--surface);
  border: 2px solid var(--line); border-radius: 18px; padding: 18px; transition: border-color .15s, transform .15s; }
a.app:hover { border-color: var(--c); transform: translateY(-2px); }
a.app:focus-visible { outline: 3px solid var(--c); outline-offset: 2px; }
.app .icon { width: 52px; height: 52px; border-radius: 14px; background: var(--c); display: grid; place-items: center; }
.app .icon svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.app .subject { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--c); }
.app h2 { font-size: 1.35rem; line-height: 1.15; }
.app p { margin: 0; color: var(--muted); font-size: .95rem; }
.app .miss { margin-top: auto; font-weight: 800; font-size: .9rem; color: var(--bad); }
.app .miss.none { color: var(--muted); font-weight: 700; }
.app .go { font-weight: 800; color: var(--c); }
.tip { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: .95rem; }
.tip a { color: inherit; font-weight: 800; }
.lang-switch { font-size: .9rem; }
/* M4 review: the language switch sits top right on every screen except inside a trainer. */
.top-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
@media (max-width: 520px) { .apps { grid-template-columns: 1fr; } }

/* Account screens (M2 review): real forms. */
#account h1 { font-size: 1.7rem; }
.account-form, .add-child { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 800; font-size: .85rem; color: var(--muted); }
.field input { font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--bg); border: 2px solid var(--line);
  border-radius: 10px; padding: 10px 12px; }
.field input:focus { border-color: var(--accent); outline: none; }
.form-msg { margin: 0; color: var(--bad); font-weight: 700; }
.form-msg:empty { display: none; }
.form-ok { margin: 0; color: var(--good); font-weight: 700; }
.app .shared { font-size: .8rem; font-weight: 800; color: var(--muted); }
.field select { font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--bg); border: 2px solid var(--line);
  border-radius: 10px; padding: 10px 12px; }
.admin-code-text { font-family: ui-monospace, monospace; font-size: 1.4rem; font-weight: 800; letter-spacing: .08em; margin: 0; }
.children { display: flex; flex-direction: column; gap: 8px; }
.child-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.child-row .name { font-weight: 800; font-size: 1.1rem; }
.child-row .now { color: var(--good); font-weight: 800; }
.account-foot, .parents-line { font-size: .9rem; }
.parents-line { align-self: center; margin: 0; }
#start p.intro { margin: 0; font-size: 1.05rem; }
.child-hint { font-weight: 700; padding: 12px 16px; }

/* Upload screen (task 4.9): two big buttons per choice, the file input behind its label. */
.upload-choice { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.upload-choice legend { font-weight: 800; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.btn.choice { background: var(--surface); border: 2px solid var(--line); color: var(--ink); padding: 18px 12px; font-size: 1.05rem; }
.btn.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.field:focus-within .pick { border-color: var(--accent); }
.upload-open { display: block; text-align: center; text-decoration: none; margin-top: 8px; }
.upload-state { font-weight: 700; }
.upload-state p { margin: 0 0 12px; }

/* Task 7.5: legal pages and the footer that links them on every screen. */
.legal-foot { max-width: 760px; margin: 32px auto 24px; padding: 0 16px; }
.legal-links { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; font-size: .85rem; }
.legal-links a { color: var(--muted); }
.legal-page h2 { font-size: 1.1rem; margin: 18px 0 6px; }
.legal-page p { margin: 0 0 10px; line-height: 1.5; }
.legal-draft { background: var(--bad-soft); color: var(--ink); font-weight: 700; padding: 10px 12px; border-radius: 10px; }
.legal-todo { background: var(--accent-soft); border-left: 4px solid var(--yolk); padding: 6px 10px; }

/* Task 5.7: siblings on one device. Big buttons, 44 px tap targets at least (UX rule 15). */
.who-now-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.who-now-list .btn { min-height: 64px; font-size: 1.2rem; }
.hello-child { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 0; }
.device-section { display: flex; flex-direction: column; gap: 8px; }
.device-pick { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; }
.device-pick input { width: 24px; height: 24px; }
