:root {
  --bg: #fbfaf7; --card: #ffffff; --fg: #1f2328; --muted: #5d636c; --line: #e2e0d9;
  --m: #1d4ed8; --f: #d42020; --n: #15803d; --pl: #7c3aed; --exc: #a16207; --ok: #15803d;
  --fi-vowel: #0e7490; --fi-strong: #c2410c; --fi-cons: #be185d; /* Finnish stem families, mirrored in grammar/style.css */
  --serif: Georgia, 'Times New Roman', serif; --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15171b; --card: #1d2025; --fg: #e7e6e1; --muted: #a0a5ad; --line: #2f333a;
    --m: #7eaaff; --f: #ff7d7d; --n: #5fd18a; --pl: #bc9fff; --exc: #e2b552; --ok: #5fd18a;
    --fi-vowel: #22d3ee; --fi-strong: #fb923c; --fi-cons: #f472b6; }
}
* { box-sizing: border-box; }
html { overflow-x: hidden; }
html, body { margin: 0; background: var(--bg); color: var(--fg); max-width: 100vw;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; display: flex; flex-direction: column; }
header { border-bottom: 1px solid var(--line); padding: 10px 16px; }
nav { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; max-width: 640px; margin: 0 auto; }
a { color: inherit; } /* one colour for every link, visited or not (pages are revisited constantly); same as grammar/style.css */
nav a { color: var(--muted); text-decoration: none; }
nav a[aria-current] { color: var(--fg); font-weight: 600; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-settings { font-size: 20px; line-height: 1; }
.nav-rewards { color: var(--exc); font-size: 13px; font-weight: 600; white-space: nowrap; border-radius: 6px; padding: 1px 6px; }
.nav-rewards.bump { animation: bump 2.5s ease-out; }
@keyframes bump { 0% { transform: scale(1.35); background: var(--exc); color: #fff; } 20% { transform: scale(1.1); background: var(--exc); color: #fff; } 100% { transform: none; background: transparent; } }
/* active-time bar next to the star (ticket 008): the open quarter of an hour fills the bar, one dot per possible
   active bonus of the day (filled when paid); muted while the quarter's accuracy is under the threshold ("low") and
   once the day's bonuses are all paid ("done"); "award" drains the full bar when a quarter was just paid */
.nav-active { display: inline-flex; align-items: center; gap: 5px; }
.nav-active-bar { width: 44px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.nav-active-fill { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--exc); transition: width .6s ease-out; }
.nav-active.low .nav-active-fill, .nav-active.done .nav-active-fill { background: var(--muted); }
.nav-active.award .nav-active-fill { animation: drain 1s ease-in; }
@keyframes drain { 0%, 60% { width: 100%; background: var(--exc); } 100% { width: 0; } }
.nav-active-dots { display: inline-flex; gap: 3px; }
.nav-active-dots i { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--exc); }
.nav-active-dots i.paid { background: var(--exc); }
.lang-switcher { display: flex; justify-content: center; gap: 4px; }
.lang-switcher button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px;
  padding: 2px 8px; cursor: pointer; font: inherit; }
.lang-switcher button.active { color: var(--fg); border-color: var(--fg); }
main { flex: 1; display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 640px; min-width: 0;
  margin: 0 auto; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; color: var(--muted); font-size: 14px; }
.controls label { display: inline-flex; align-items: center; gap: 4px; }
.controls .auto { margin-left: 8px; }
.stats { margin-left: auto; }
.card { position: relative; flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 14px; min-width: 0; max-width: 100%; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 240px; }
/* per-word score for the current mode, top-right of the card after the reveal: correct / asked and the Leitner box as a bar */
.score { position: absolute; top: 10px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1; }
.score-num { color: var(--muted); }
.score-bar { display: flex; align-items: center; gap: 2px; }
.score-bar i { display: block; width: 9px; height: 5px; border-radius: 2px; background: var(--line); }
.score-bar i.on { background: currentColor; }
.score-bar .done { font-size: 11px; font-weight: 700; margin-left: 3px; }
.message { color: var(--muted); font-size: 15px; min-height: 56px; display: flex; align-items: center; justify-content: center; text-align: center; }
/* answer feedback: the ring and tick / cross draw themselves, the disc fills, then a bounce (right) or a shake (wrong) */
.result { display: inline-flex; width: 52px; height: 52px; border-radius: 50%; position: relative; }
.result.ok { color: var(--ok); animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both, bounce .45s .55s ease-out; }
.result.wrong { color: var(--f); animation: pop .3s ease-out both, shake .45s .5s ease-in-out; }
.result svg { width: 100%; height: 100%; overflow: visible; }
.result .ring { fill: currentColor; fill-opacity: 0; stroke: currentColor; stroke-width: 3.5;
  stroke-dasharray: 145; stroke-dashoffset: 145; transform: rotate(-90deg); transform-box: fill-box; transform-origin: center;
  animation: draw .35s ease-out forwards, fill .2s .35s ease-out forwards; }
.result .mk { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .25s .4s ease-out forwards; }
.result .mk2 { animation-delay: .52s; }
/* a ring of colour spreading out from the badge */
.result::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid currentColor; opacity: 0;
  animation: burst .6s .45s ease-out; }
.card.flash-ok { animation: flash-ok .9s ease-out; } .card.flash-wrong { animation: flash-wrong .9s ease-out; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fill { to { fill-opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.18); } 70% { transform: scale(.95); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes burst { from { transform: scale(1); opacity: .6; } to { transform: scale(1.9); opacity: 0; } }
@keyframes flash-ok { 0%, 40% { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 35%, transparent); } }
@keyframes flash-wrong { 0%, 40% { border-color: var(--f); box-shadow: 0 0 0 3px color-mix(in srgb, var(--f) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) {
  .result, .result::after, .card.flash-ok, .card.flash-wrong { animation: none; }
  .result .ring, .result .mk { animation: none; stroke-dashoffset: 0; fill-opacity: 1; }
  .nav-active-fill, .nav-active.award .nav-active-fill { animation: none; transition: none; }
}
.word { font-size: clamp(30px, 8.5vw, 52px); font-weight: 500; text-align: center; line-height: 1.15; transition: color .2s;
  max-width: 100%; overflow-wrap: anywhere; }
.word .hl { font-weight: 800; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.word.g-m, .g-m { color: var(--m); } .word.g-f, .g-f { color: var(--f); } .word.g-n, .g-n { color: var(--n); }
.word .article { font-weight: 400; margin-right: .25em; }
.card.mono .g-m, .card.mono .g-f, .card.mono .g-n { color: inherit; }
.card.mono .chip.g-m, .card.mono .chip.g-f, .card.mono .chip.g-n { color: var(--muted); }
.card.mono .chip.g-m .chip-key, .card.mono .chip.g-f .chip-key, .card.mono .chip.g-n .chip-key { background: var(--muted); }
.detail { text-align: center; display: flex; flex-direction: column; gap: 10px; width: 100%; align-items: center; }
.plural { color: var(--pl); font-size: 16px; display: flex; align-items: center; gap: 6px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 2px 6px; border-radius: 5px;
  border: 1px solid currentColor; line-height: 1.2; opacity: .85; }
.translation { font-family: var(--serif); font-size: 22px; display: flex; flex-direction: column; gap: 4px; align-items: center;
  padding-top: 10px; border-top: 1px dashed var(--line); width: 100%; }
.tr-line { display: inline-flex; align-items: center; gap: 8px; }
.tr-line.en { color: var(--muted); font-size: 16px; }
.translation .conf { color: var(--exc); font-size: 14px; font-family: system-ui, sans-serif; }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--line); width: 100%; }
.chip { display: inline-flex; align-items: center; border-radius: 999px; border: 1.5px solid currentColor; overflow: hidden; font-size: 14px; }
.chip-key { font-family: var(--mono); font-weight: 700; padding: 4px 10px; background: currentColor; }
.chip-key, .chip-name { line-height: 1.3; }
.chip .chip-key { color: var(--card); background: currentColor; }
.chip.g-m .chip-key { background: var(--m); } .chip.g-f .chip-key { background: var(--f); } .chip.g-n .chip-key { background: var(--n); }
.chip.exc { color: var(--exc); } .chip.exc .chip-key { background: var(--exc); }
.chip-name { padding: 4px 10px 4px 8px; font-variant: small-caps; letter-spacing: .02em; }
.hidden { display: none !important; }
.modes { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.modes select { flex: 1; min-width: 0; font: inherit; font-size: 15px; font-weight: 600; padding: 8px 10px; border-radius: 10px;
  background: var(--card); color: var(--fg); border: 1px solid var(--line); }
@media (max-height: 720px) { .card { min-height: 170px; } main { gap: 10px; } }

/* Finnish genitive drill: colour = stem family (vowel / strong-grade / consonant stem) */
.fi-vowel { color: var(--fi-vowel); } .fi-strong { color: var(--fi-strong); } .fi-cons { color: var(--fi-cons); } .fi-none { color: var(--exc); }
.word .question-gen { font-family: var(--serif); font-size: clamp(26px, 7vw, 46px); display: inline-flex; flex-wrap: wrap;
  justify-content: center; align-items: baseline; column-gap: .2em; max-width: 100%; }
.word .question-gen .target { white-space: nowrap; }
.word .question-gen .gap { color: var(--muted); font-weight: 400; letter-spacing: .05em; }
.word .arrow { color: var(--muted); font-weight: 300; margin: 0 .25em; }
.word .lemma { color: var(--fg); font-weight: 400; }
.subword { color: var(--muted); font-size: 16px; text-align: center; min-height: 1.3em; }
.subword:empty { display: none; }
.subword .article { margin-right: .25em; }
.chip.fi-vowel .chip-key { background: var(--fi-vowel); } .chip.fi-strong .chip-key { background: var(--fi-strong); }
.chip.fi-cons .chip-key { background: var(--fi-cons); } .chip.fi-none .chip-key { background: var(--exc); }
.chip.grad { color: var(--muted); } .chip.grad .chip-key { background: var(--muted); }
a.chip { text-decoration: none; }
.hint .gentle { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
.word .question-fi { font-family: var(--serif); font-size: .9em; display: inline-flex; align-items: center; gap: 12px; }
/* preposition drill: a short sentence with the article slot; cases use the symbols of the grammar pages */
.word .question-praep { font-family: var(--serif); font-size: clamp(22px, 5.5vw, 36px); font-weight: 400; color: var(--fg); }
.word .question-praep .gap { color: var(--muted); letter-spacing: .05em; }
.word .question-praep .hl { font-weight: 800; }
.subword .cue { font-weight: 700; color: var(--fg); border: 1.5px solid currentColor; border-radius: 6px; padding: 0 6px; margin-right: 4px; }
.subword em { font-style: normal; font-weight: 600; color: var(--fg); }
.case-akk, .case-dat { color: var(--fg); } .chip.case-akk .chip-key, .chip.case-dat .chip-key { background: var(--fg); }
.word .question-fi .badge { font-family: system-ui, sans-serif; font-size: 12px; }
.answers { display: grid; gap: 10px; min-width: 0; }
.answers.cols-3 { grid-template-columns: repeat(3, 1fr); }
.answers.cols-2 { grid-template-columns: repeat(2, 1fr); }
.answer.choice { font-size: 19px; font-weight: 500; color: var(--fg); border-color: var(--line); padding: 14px 10px; min-width: 0;
  display: flex; align-items: center; gap: 10px; text-align: left; }
.answer.choice .fi { font-family: var(--serif); font-size: clamp(16px, 5vw, 21px); overflow-wrap: anywhere; min-width: 0; }
.answer.choice .num { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.answer.choice.is-right { color: var(--ok); border-color: currentColor; opacity: 1; font-weight: 700; }
.answer.choice.chosen-wrong { color: var(--f); border-color: currentColor; opacity: 1; }
.answer { font: inherit; font-size: 26px; font-weight: 600; padding: 18px 0; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 2px solid currentColor; }
.answer:disabled { opacity: .45; cursor: default; }
.answer.chosen-wrong { background: color-mix(in srgb, currentColor 15%, var(--card)); }
.next-row { min-height: 52px; }
.next { width: 100%; font: inherit; font-size: 18px; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--fg); color: var(--bg); border: none; }
.signin { justify-content: center; }
.signin-card { flex: 0; gap: 16px; padding: 28px 20px; }
.signin-card h1 { margin: 0; }
.signin-card .muted { color: var(--muted); margin: 0; text-align: center; }
.signin-status { margin: 0; min-height: 1.2em; color: var(--exc); text-align: center; font-size: 14px; }
.signin-card .next { width: auto; padding: 12px 24px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin: 0; }
.link { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
.flag-btn { font-size: 14px; padding: 12px 16px; min-height: 44px; margin-top: 4px; }

/* stats.html (progress; the all-users part for platform admins) */
.stats-page h1 { font-size: 22px; margin: 0; }
.stats-page h2 { font-size: 18px; margin: 16px 0 0; }
.admin { display: flex; flex-direction: column; gap: 10px; }
.stats-page .muted { color: var(--muted); margin: 0; font-size: 14px; }
.user-card { flex: 0; align-items: stretch; gap: 10px; min-height: 0; padding: 16px; }
.backup.stale { color: var(--exc); font-weight: 600; }
.user-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.user-head .name { font-weight: 600; }
.user-head .email, .user-head .last { color: var(--muted); font-size: 13px; }
.user-head .last { margin-left: auto; }
.mode-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mode-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 2px 6px 4px 0; border-bottom: 1px solid var(--line); }
.mode-table td { padding: 4px 6px 4px 0; }
.mode-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.mode-table .known { color: var(--ok); } .mode-table .learning { color: var(--exc); }
.user-foot { display: flex; align-items: center; gap: 12px; }
.user-foot .link { padding: 0; }
.user-foot .note { color: var(--muted); font-size: 13px; }
.points-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 14px; }
.points-box .num { font-weight: 700; }
.points-box input { background: var(--card, transparent); color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font: inherit; }
.points-box input[type=number] { width: 5em; }
.points-box input[type=text] { flex: 1 1 8em; min-width: 0; }
.ledger-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.ledger-table td { padding: 2px 6px 2px 0; border-top: 1px solid var(--line); }
.ledger-table .num { text-align: right; }

/* settings.html */
.settings-page h1 { font-size: 22px; margin: 0; }
.settings-page .muted { margin: 0; font-size: 14px; }
.settings-page .modes label { flex: 0 0 auto; }
.account { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 14px; }
.account .link { padding: 0; }

/* path.html (learning path) */
.path-page h1 { font-size: 22px; margin: 0; }
.path-page .muted { color: var(--muted); margin: 0; font-size: 14px; }
.path-level h2 { font-size: 18px; margin: 8px 0 2px; }
.level-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.level-tab { font: inherit; font-size: 15px; font-weight: 600; padding: 6px 16px; border-radius: 999px; cursor: pointer;
  color: var(--fg); background: var(--card); border: 1.5px solid var(--line); }
.level-tab.on { color: var(--card); background: var(--fg); border-color: var(--fg); }
.path-level .hint { text-align: left; margin-bottom: 6px; }
.topics { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.topic { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0;
  display: flex; flex-direction: column; gap: 6px; }
.topic.no-drill { border-style: dashed; }
.topic-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.topic-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.topic-kind { color: var(--muted); font-size: 12px; margin-left: auto; }
.topic-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.topic-missing { color: var(--exc); }
.topic-points { color: var(--exc); font-weight: 600; white-space: nowrap; }
.share-bar { flex: 1 1 80px; min-width: 80px; max-width: 160px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.share-bar i { display: block; height: 100%; background: var(--ok); }
.share-num { font-variant-numeric: tabular-nums; }
.topic-page { margin-left: auto; color: var(--muted); }
.topic-practise { font-weight: 600; }
/* the check (js/check.js): verdict per topic, summary of the level */
.topic-check { border-top: 1px solid var(--line); padding-top: 6px; }
.check-solid { color: var(--ok); font-weight: 600; }
.check-holes { color: var(--exc); font-weight: 600; }
.check-skipped { font-weight: 600; }
.check-hole { color: var(--exc); overflow-wrap: anywhere; }
.check-progress { font-variant-numeric: tabular-nums; }
.topic-check-go { margin-left: auto; font-weight: 600; }
.check-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 14px; margin-bottom: 8px; }
.check-count { color: var(--muted); }
.check-level { font-weight: 600; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--fg); color: var(--fg);
  text-decoration: none; white-space: nowrap; }
.check-first { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }

/* index.html in topic mode (?topic=<id>): controls that would change the item set are hidden */
.topic-bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; font-size: 15px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.topic-bar strong { overflow-wrap: anywhere; }
.topic-links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
body.topic-mode [data-topic-hide] { display: none !important; }
.check-pos { color: var(--muted); font-size: 13px; white-space: nowrap; }
.check-done { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 0; }
.check-done strong { color: var(--fg); font-size: 17px; }
.check-done > a { font-weight: 600; }
.check-list { list-style: none; margin: 0; padding: 0; align-self: stretch; display: flex; flex-direction: column; gap: 4px;
  text-align: left; overflow-wrap: anywhere; }

/* first-login nickname prompt (auth.js) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center;
  justify-content: center; padding: 16px; z-index: 100; }
.modal-card { background: var(--card, #fff); color: inherit; border-radius: 14px; padding: 24px 20px; width: 100%;
  max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.modal-card h2 { margin: 0; font-size: 20px; }
.modal-card .muted { color: var(--muted); margin: 0; font-size: 14px; }
.modal-card input { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line, var(--border, #ccc));
  background: transparent; color: inherit; }
.modal-error { min-height: 1.2em; font-size: 13px; color: var(--f, var(--danger, #c0392b)); }
