/* Kielisparraaja: mobile-first, light and dark, WCAG 2.1 AA colour pairs (checked in tests/test_frontend.py).
   Fonts are self-hosted (CSP 'self'): Atkinson Hyperlegible Next for text, Bricolage Grotesque for headings. Both SIL OFL 1.1. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */

:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --bg-glow: #ebe6fb;
  --surface: #ffffff;
  --sunken: #f1ede5;
  --text: #1c1a2e;
  --muted: #595670;
  --line: #e4ded3;
  --field: #807b93;
  --primary: #4b3bd1;
  --on-primary: #ffffff;
  --primary-ink: #4434c4;
  --primary-soft: #ece9ff;
  --win: #11704e;
  --win-soft: #dcf4e8;
  --on-win-soft: #0c5139;
  --nudge: #8a4b06;
  --nudge-soft: #fff0d4;
  --gold: #f5b82e;
  --on-gold: #3b2600;
  --coral: #ff7a5c;
  --danger: #b42318;
  --focus: #1f6feb;
  --shadow: 0 1px 2px rgb(28 26 46 / 0.06), 0 6px 24px -8px rgb(28 26 46 / 0.12);
  --shadow-lift: 0 2px 4px rgb(28 26 46 / 0.08), 0 14px 32px -10px rgb(75 59 209 / 0.35);
  --scrim: rgb(20 18 36 / 0.45);

  --font-text: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --tap: 48px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #13121f;
    --bg-glow: #221e45;
    --surface: #1c1b2d;
    --sunken: #151424;
    --text: #f2f0fa;
    --muted: #b0adc6;
    --line: #2e2c45;
    --field: #7e7a9c;
    --primary: #a99dff;
    --on-primary: #15122e;
    --primary-ink: #b8aeff;
    --primary-soft: #2a2654;
    --win: #63d6a6;
    --win-soft: #143528;
    --on-win-soft: #a6f0cf;
    --nudge: #ffc670;
    --nudge-soft: #3a2b12;
    --gold: #ffc94d;
    --on-gold: #2e1d00;
    --coral: #ff9478;
    --danger: #ff8f84;
    --focus: #7cb3ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 28px -10px rgb(0 0 0 / 0.5);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / 0.3), 0 14px 32px -10px rgb(169 157 255 / 0.35);
    --scrim: rgb(5 4 12 / 0.65);
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, var(--bg-glow), transparent 70%) no-repeat,
    var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 750; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 22px 0 10px; }
h4 { font-size: 1rem; font-weight: 700; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--primary-ink); text-underline-offset: 3px; }
strong { font-weight: 700; }

.display { font-size: clamp(1.9rem, 7.5vw, 2.6rem); font-weight: 780; letter-spacing: -0.03em; line-height: 1.05; }
.display-sm { font-size: 1.6rem; font-weight: 760; letter-spacing: -0.02em; margin-bottom: 14px; }
.lead { font-size: 1.125rem; color: var(--text); }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 0.95rem; margin: 6px 0 12px; }
.eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary-ink); margin: 0 0 8px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
h1:focus { outline: none; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 700;
}
.skip:focus { top: 12px; }

.icon { width: 1.3em; height: 1.3em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon .fill { fill: currentColor; stroke: none; }

/* ---------- shell ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 6px;
  color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 760; font-size: 1.15rem; letter-spacing: -0.02em;
}
.mark { width: 34px; height: 34px; }
.mark-bubble { fill: var(--primary); }
.mark-spark { fill: var(--gold); }
.icon-btn.help-btn { gap: 6px; padding: 0 16px 0 12px; width: auto; font-weight: 700; color: var(--primary-ink); background: var(--surface); box-shadow: var(--shadow); }
@media (max-width: 359px) { .help-label { display: none; } .icon-btn.help-btn { padding: 0; width: var(--tap); } }

.container {
  max-width: 36rem; margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.container:focus { outline: none; }
.container.enter > * { animation: rise 320ms var(--ease) both; }
.container.enter > *:nth-child(2) { animation-delay: 40ms; }
.container.enter > *:nth-child(3) { animation-delay: 80ms; }
.container.enter > *:nth-child(n+4) { animation-delay: 120ms; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { margin: 12px 0 20px; }
.page-head h1 { margin-bottom: 4px; }
.page-head.with-avatar { display: flex; align-items: center; gap: 14px; }

.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); margin: 0 0 4px -6px; padding: 0 10px 0 4px;
  font-weight: 700; text-decoration: none; color: var(--primary-ink); border-radius: 999px;
}
.back:hover { background: var(--primary-soft); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}
.card.quiet { background: transparent; box-shadow: none; }
.card.note { background: var(--primary-soft); border-color: transparent; }
.card.feature {
  background: linear-gradient(135deg, var(--primary-soft), var(--surface) 75%);
  border-color: transparent;
}
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.title-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary-ink);
}
.title-icon .icon { width: 20px; height: 20px; }
.card.note .title-icon { background: var(--surface); }
.card > :last-child { margin-bottom: 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 10px 20px; margin: 0;
  font: inherit; font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none;
  border-radius: 999px; border: 2px solid transparent; cursor: pointer;
  background: var(--primary-soft); color: var(--primary-ink);
  transition: transform 140ms var(--ease), box-shadow 200ms var(--ease), background-color 200ms var(--ease);
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-lift); }
.btn.secondary { background: var(--primary-soft); color: var(--primary-ink); }
.btn.ghost { background: transparent; color: var(--primary-ink); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn.block { display: flex; width: 100%; }
.btn.grow { flex: 1 1 auto; }
.btn.lg { min-height: 56px; font-size: 1.125rem; }
.btn.xl { min-height: 64px; font-size: 1.25rem; border-radius: var(--r-lg); margin: 4px 0 20px; }
.btn.sm { min-height: 44px; padding: 8px 14px; font-size: 0.95rem; }
.btn .icon-arrow { order: 2; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.55; cursor: progress; transform: none; }
.btn:disabled:not([aria-busy]) { cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: 999px;
  background: transparent; color: var(--text); cursor: pointer; font: inherit;
}
.icon-btn:hover { background: var(--primary-soft); }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-stack { display: grid; gap: 10px; margin-top: 14px; }

/* ---------- forms ---------- */

.field { margin: 0 0 16px; }
.label { display: block; font-weight: 700; margin: 0 0 8px; }

input[type="text"], input[type="email"], input[type="number"], input[type="time"], select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px;
  font: inherit; font-size: max(1rem, 16px); color: var(--text);
  background: var(--surface); border: 2px solid var(--field); border-radius: var(--r-sm);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 25%, transparent); }
textarea { min-height: 96px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }

.form-msg { min-height: 0; margin: 10px 0 0; font-weight: 600; }
.form-msg:empty { display: none; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--win); }

/* Large checkbox row: the native input stays focusable and clickable on top of the drawn box. */
.check { position: relative; display: flex; align-items: flex-start; gap: 14px; min-height: var(--tap); padding: 10px 0; cursor: pointer; }
.check input { position: absolute; left: 0; top: 10px; width: 30px; height: 30px; margin: 0; opacity: 0; cursor: pointer; }
.check-box {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  border: 2px solid var(--field); background: var(--surface); color: transparent;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.check-box .icon { width: 20px; height: 20px; stroke-width: 3; transform: scale(0.4); transition: transform 220ms var(--ease-pop); }
.check input:checked + .check-box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.check input:checked + .check-box .icon { transform: scale(1); }
.check input:focus-visible + .check-box { outline: 3px solid var(--focus); outline-offset: 3px; }
.check-text { padding-top: 2px; }

/* Radio cards */
.choices { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 10px; }
.levels .choice-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.levels .choice-body { flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; text-align: start; }
.levels .choice-label { flex: 0 0 2.5rem; }
.levels .choice-sub { font-size: 0.9rem; line-height: 1.35; min-width: 0; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice-body {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; padding: 10px 8px; border-radius: var(--r-md); text-align: center;
  border: 2px solid var(--field); background: var(--surface);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease);
}
.choice-label { font-weight: 700; }
.choice-sub { font-size: 0.8rem; color: var(--muted); }
.levels .choice-label { font-family: var(--font-display); font-size: 1.2rem; }
.choice input:checked + .choice-body { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }
.choice input:checked + .choice-body .choice-sub { color: var(--primary-ink); }
.choice input:focus-visible + .choice-body { outline: 3px solid var(--focus); outline-offset: 3px; }
.choice input:active + .choice-body { transform: scale(0.97); }

details.more { margin: 4px 0 8px; }
details > summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary-ink); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ""; width: 8px; height: 8px; margin-left: 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform 200ms var(--ease); }
details[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }

.two-col { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 420px) { .two-col { grid-template-columns: 2fr 1fr; } }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { flex: 1 1 8rem; width: auto; min-width: 0; }
.inline-form.wide input { flex-basis: 12rem; }
.subform { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }

/* ---------- sign-in hero ---------- */

.hero { position: relative; padding: 28px 0 8px; }
.hero .display { max-width: 12ch; }
.bubbles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.bubble {
  position: relative; display: inline-block; padding: 6px 14px; border-radius: 16px 16px 16px 4px;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  animation: bob 5s ease-in-out infinite;
}
.bubble.b0 { background: var(--primary); color: var(--on-primary); }
.bubble.b1 { animation-delay: -1.2s; }
.bubble.b2 { background: var(--gold); color: var(--on-gold); animation-delay: -2.4s; }
.bubble.b3 { animation-delay: -3.1s; border-radius: 16px 16px 4px 16px; }
.bubble.b4 { background: var(--win-soft); color: var(--on-win-soft); animation-delay: -0.6s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.sent { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: var(--r-md); background: var(--win-soft); color: var(--on-win-soft); }
.sent p { margin: 0; font-weight: 600; }
.sent-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--win); color: var(--surface); }
.row-text { display: flex; gap: 10px; align-items: flex-start; }
.row-text .icon { margin-top: 2px; color: var(--primary-ink); }

.code-input { font-family: var(--font-mono); font-size: 1.6rem !important; letter-spacing: 0.25em; text-align: center; text-transform: uppercase; min-height: 64px !important; }
.code-display { margin-top: 16px; padding: 16px; border-radius: var(--r-md); background: var(--sunken); text-align: center; border: 2px dashed var(--field); }
.code-display .help { display: block; margin: 0 0 4px; }
.code { display: block; font: 800 2.4rem/1.1 var(--font-mono); letter-spacing: 0.18em; color: var(--text); }

/* ---------- people, avatars, chips, badges ---------- */

.avatar {
  display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px;
  background: var(--primary); color: var(--on-primary); font-family: var(--font-display); font-weight: 800; font-size: 1.2rem;
}
.avatar.sm { width: 30px; height: 30px; border-radius: 10px; font-size: 0.95rem; }
.avatar.lg { width: 60px; height: 60px; border-radius: 20px; font-size: 1.7rem; }

.people { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 8px; }
.person {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--sunken); color: var(--text); text-decoration: none; transition: background-color 160ms var(--ease);
}
.person:hover { background: var(--primary-soft); }
.person-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; flex: 1; min-width: 0; }
.person-name { font-weight: 700; font-size: 1.1rem; }
.chev { color: var(--muted); }

.badge { display: inline-block; font-size: 0.85rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); }
.badge.win { background: var(--win-soft); color: var(--on-win-soft); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; }
.chips li { padding: 6px 14px; border-radius: 999px; background: var(--sunken); border: 1px solid var(--line); font-weight: 600; font-size: 0.95rem; }
.chips:empty { display: none; }

.greeting { margin: 16px 0 18px; }
.greeting h1 { margin-bottom: 10px; }
.coach-chip { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-weight: 600; margin: 0; }

/* ---------- progress ---------- */

.level-row { display: flex; align-items: center; gap: 18px; margin-bottom: 12px; }
.level-text { flex: 1; min-width: 0; }
.level-text p { margin: 6px 0 0; }
.big-number { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 8px !important; }
.ring-wrap { position: relative; width: 88px; height: 88px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--sunken); stroke-width: 9; }
.ring-fill { fill: none; stroke: var(--primary); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 900ms var(--ease); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ring-label small { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.ring-label strong { font-family: var(--font-display); font-size: 1.8rem; }
.stat { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.stat .icon { color: var(--win); }

.bar-track { position: relative; display: block; height: 10px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.bar-track.thick { height: 14px; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--primary); transform-origin: left; animation: grow 700ms var(--ease) both; }
.bar-fill.alt { background: var(--win); }
.bar-fill.gold { background: var(--gold); }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 6.2em 1fr auto; gap: 10px; align-items: center; font-size: 0.95rem; }
.bar-label { color: var(--muted); white-space: nowrap; }
.bar-value { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- admin: aggregate tables ---------- */

.container.wide { max-width: 64rem; }
.admin-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.admin-head > div:first-child { flex: 1 1 18rem; }
.admin-head .field { margin: 0; min-width: 9rem; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
@media (min-width: 48rem) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.kpi-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-label { font-weight: 600; line-height: 1.3; }
.kpi-sub { color: var(--muted); font-size: 0.9rem; }
.table-wrap { overflow-x: auto; margin: 0 0 8px; border-radius: var(--r-sm); }
.table-wrap:focus-visible { outline-offset: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
table.data thead th { color: var(--muted); font-size: 0.85rem; font-weight: 700; background: var(--sunken); }
table.data tbody th { font-weight: 600; }
table.data .num { text-align: right; }
table.data .mono, table.data th.mono { font-family: var(--font-mono); font-size: 0.88rem; }
table.data td.flag { color: var(--nudge); font-weight: 700; }
table.data td.cov-gap { background: var(--nudge-soft); color: var(--nudge); font-weight: 700; }
table.data tr.unmet th { color: var(--nudge); }
table.data .bar-cell { min-width: 9rem; }
table.data .bar-cell .bar-track { margin-top: 4px; height: 6px; }

.rewards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.reward { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--r-md); background: var(--sunken); }
.reward.reached { background: var(--win-soft); }
.reward-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--surface); color: var(--primary-ink); }
.reward.reached .reward-icon { background: var(--gold); color: var(--on-gold); }
.reward-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.reward-label { font-weight: 700; }
.reward-progress { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.reward .inline-form input { flex: 0 1 7rem; }

.windows { display: grid; gap: 8px; margin-bottom: 8px; }
.window-row { display: flex; align-items: center; gap: 8px; }
.window-times { display: flex; align-items: center; gap: 8px; flex: 1; }
.window-times input { flex: 1; min-width: 0; }
.dash { color: var(--muted); font-weight: 700; }

/* ---------- onboarding ---------- */

.dots { list-style: none; display: flex; gap: 6px; margin: 0 0 16px; padding: 0; }
.dots li { width: 28px; height: 6px; border-radius: 999px; background: var(--line); transition: background-color 300ms var(--ease), width 300ms var(--ease); }
.dots li.on { background: var(--primary); width: 40px; }
.wizard-step > .card { animation: rise 300ms var(--ease) both; }
.wizard-nav { display: flex; gap: 10px; margin-top: 8px; }
.ai-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--surface); color: var(--primary-ink); margin-bottom: 14px; }
.ai-mark .icon { width: 28px; height: 28px; }

/* Placement (optional, on the level step): an offer, then one suggested starting level. */
.placement-offer[hidden] { display: none; }
.placement-offer { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.placement-offer .row-text .icon { color: var(--primary-ink); }
.suggestion { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 10px 14px; border-radius: var(--r-md); background: var(--win-soft); color: var(--on-win-soft); font-weight: 700; animation: rise 280ms var(--ease) both; }
.suggestion[hidden] { display: none; }
.level-badge { display: inline-grid; place-items: center; min-width: 96px; height: 96px; padding: 0 18px; margin: 4px 0 8px; border-radius: 28px; background: var(--primary); color: var(--on-primary); font: 800 2.6rem/1 var(--font-display); letter-spacing: -0.02em; animation: pop 500ms 200ms var(--ease-pop) both; }

/* ---------- practice ---------- */

.practice-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.pips-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pips-label { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.pips { list-style: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; margin: 0; padding: 0; max-width: 12rem; }
.pips li { width: 14px; height: 6px; border-radius: 999px; background: var(--line); }
.pips li.done { background: var(--win); }
.pips li.now { background: var(--primary); width: 22px; }

.task { background: var(--surface); border-radius: var(--r-lg); padding: 22px 20px; margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.instructions { color: var(--muted); font-weight: 600; }
.prompt { font-size: 1.4rem; line-height: 1.35; font-weight: 700; margin: 4px 0 18px; overflow-wrap: anywhere; }
.passage { white-space: pre-wrap; background: var(--sunken); border-radius: var(--r-md); padding: 16px; margin-bottom: 16px; font-size: 1.1rem; line-height: 1.8; }
.gap { display: inline-block; min-width: 2.4em; padding: 0 6px; margin: 0 1px; border-bottom: 3px solid var(--field); text-align: center; font-size: 0.85em; font-weight: 700; color: var(--muted); line-height: 1.5; }
.gap.current { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); border-radius: 6px 6px 0 0; }
.gap.filled { color: var(--on-win-soft); background: var(--win-soft); border-color: var(--win); border-radius: 6px 6px 0 0; font-size: 1em; }

.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 10px 16px 10px 10px;
  font: inherit; font-size: 1.15rem; font-weight: 600; text-align: left; color: var(--text); cursor: pointer;
  background: var(--surface); border: 2px solid var(--field); border-radius: var(--r-md);
  transition: transform 140ms var(--ease), border-color 200ms var(--ease), background-color 200ms var(--ease), opacity 200ms var(--ease);
  touch-action: manipulation;
}
.option:hover { border-color: var(--primary); }
.option:active { transform: scale(0.98); }
.option-key { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--primary-soft); color: var(--primary-ink); font-family: var(--font-display); font-weight: 800; }
.option-text { overflow-wrap: anywhere; }
.option.tried, .option.tried:hover { border-style: dashed; border-color: var(--field); background: var(--sunken); cursor: default; }
.option.tried .option-key { background: transparent; border: 2px dashed var(--field); color: var(--muted); }
.option.correct { border-color: var(--win); background: var(--win-soft); color: var(--on-win-soft); animation: glow 1.6s var(--ease) infinite alternate; }
.option.correct .option-key { background: var(--win); color: var(--surface); }
.option[aria-busy="true"] { opacity: 0.7; }
@keyframes glow { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--win) 0%, transparent); } to { box-shadow: 0 0 0 6px color-mix(in srgb, var(--win) 22%, transparent); } }

.answer-form { display: grid; gap: 10px; }
.answer-input { min-height: 60px !important; font-size: 1.25rem !important; font-weight: 600; }
.answer-form .btn { min-height: 56px; width: 100%; font-size: 1.1rem; }
@media (min-width: 480px) { .answer-form { grid-template-columns: 1fr auto; } .answer-form .btn { width: auto; min-height: 60px; } }

.feedback:empty { display: none; }
.nudge { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--nudge-soft); color: var(--nudge); font-weight: 700; animation: rise 280ms var(--ease) both; }

.ladder li { display: flex; gap: 12px; align-items: flex-start; }
.ladder strong { display: block; }
.rescue-text { display: block; font-size: 0.95rem; margin-bottom: 6px; }
.ladder { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.ladder:empty { display: none; }
.ladder li { padding: 12px 14px; border-radius: var(--r-md); background: var(--nudge-soft); color: var(--text); animation: rise 280ms var(--ease) both; }
.ladder li strong { color: var(--nudge); }
.ladder li.rescue { background: var(--win-soft); color: var(--on-win-soft); }
.ladder li.rescue strong { color: var(--on-win-soft); }
.hint-text { display: block; overflow-wrap: anywhere; }
.rung { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--surface); color: var(--nudge); }
.ladder li.rescue .rung { color: var(--win); }
.task-tools { display: flex; gap: 10px; margin-top: 16px; }
.task-tools:empty { display: none; }

.ask summary { min-height: 52px; font-size: 1.05rem; }
.ask form { display: grid; gap: 10px; }
.ask form .btn { justify-self: start; }
.bubble-reply { margin: 14px 0 0; padding: 14px 16px; border-radius: 18px 18px 18px 6px; background: var(--primary-soft); color: var(--text); }

/* Guided writing: rubric up front, starters as tappable chips, a live word count that only ever counts up. */
.tools-label { margin: 0 0 6px; font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.rubric { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--r-md); background: var(--primary-soft); color: var(--text); }
.rubric .tools-label { color: var(--text); }
.rubric ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rubric li { display: flex; gap: 10px; align-items: flex-start; overflow-wrap: anywhere; }
.rubric li .icon { flex: none; color: var(--primary-ink); }
.writing-form { display: grid; gap: 10px; }
/* On-screen letters for Russian. grid-column: 1 / -1 keeps them below the answer field on wide screens. */
.keypad-panel { grid-column: 1 / -1; }
.keypad-panel summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--primary-ink); }
.keypad { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.key {
  min-height: 44px; padding: 0; border-radius: 10px; border: 1px solid var(--field); background: var(--surface);
  color: var(--text); font: inherit; font-size: 1.15rem; font-weight: 600; touch-action: manipulation; cursor: pointer;
}
.key:active { background: var(--primary-soft); }
.key.wide { grid-column: span 3; }
.writing-form .starters + .tools-label { margin-top: 4px; }
.starters { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.starter {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--field);
  font: inherit; font-size: 0.95rem; font-weight: 600; color: var(--text); background: var(--surface);
  cursor: pointer; touch-action: manipulation; text-align: left;
}
.starter:hover { border-color: var(--primary); }
.starter:active { transform: scale(0.97); }
.starter.word { background: var(--sunken); border-style: dashed; }
textarea.writing-input { min-height: 180px; font-size: 1.15rem; line-height: 1.5; margin-top: 6px; }
.word-count { margin: 0; font-size: 0.95rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.word-count.reached { color: var(--win); }
.example { margin-top: 10px; display: grid; gap: 10px; justify-items: start; }
.example-text { margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; justify-self: stretch; }
.writing-feedback h3 { margin: 18px 0 8px; font-size: 1rem; }
.got-across { margin: 0; font-size: 1.2rem; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.strengths { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.strengths li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); background: var(--win-soft); color: var(--on-win-soft); overflow-wrap: anywhere; }
.strengths li .icon { flex: none; }
.next-step { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-md); background: var(--nudge-soft); color: var(--text); overflow-wrap: anywhere; }
.next-step .icon { flex: none; color: var(--nudge); }
.own-text { margin: 8px 0 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--sunken); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.writing-feedback .example-text { margin-top: 8px; background: var(--sunken); }

/* Wins: warm, quick, never loud. */
.win-card {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 14px;
  border-radius: var(--r-lg); background: var(--win-soft); color: var(--on-win-soft);
  animation: pop 420ms var(--ease-pop) both;
}
.win-text { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.win-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.win-text strong { font-family: var(--font-display); font-size: 1.15rem; }
.win-answer { font-size: 0.95rem; overflow-wrap: anywhere; }
.win-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--gold); color: var(--on-gold); animation: spin-in 600ms var(--ease-pop) both; }
.win-icon .icon { fill: currentColor; }
.xp-pill { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--gold); color: var(--on-gold); font-family: var(--font-display); font-weight: 800; font-variant-numeric: tabular-nums; }
.xp-pill.lg { font-size: 1.4rem; padding: 8px 20px; }
@keyframes pop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes spin-in { from { transform: rotate(-120deg) scale(0.4); } to { transform: none; } }

.celebrate { position: relative; text-align: center; padding: 28px 0 8px; }
.celebrate .display { margin: 18px 0 8px; }
.trophy {
  display: inline-grid; place-items: center; width: 112px; height: 112px; border-radius: 36px;
  background: var(--gold); color: var(--on-gold); box-shadow: 0 18px 40px -16px color-mix(in srgb, var(--gold) 80%, transparent);
  animation: spin-in 700ms var(--ease-pop) both;
}
.trophy .icon { width: 64px; height: 64px; fill: currentColor; stroke-width: 1.5; }
.xp-line { margin: 12px 0; }
.level-up { display: inline-block; padding: 8px 18px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; animation: pop 500ms 300ms var(--ease-pop) both; }

.burst { position: absolute; left: 50%; top: 40%; width: 0; height: 0; pointer-events: none; z-index: 2; }
.celebrate .burst { top: 70px; }
.piece { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; opacity: 0; animation: fly 1100ms var(--delay, 0ms) var(--ease) forwards; }
.piece.dot { border-radius: 50%; }
.piece.bar { width: 6px; height: 14px; border-radius: 3px; }
.piece.star { clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); width: 14px; height: 14px; }
.piece.c1 { background: var(--gold); }
.piece.c2 { background: var(--primary); }
.piece.c3 { background: var(--win); }
.piece.c4 { background: var(--coral); }
@keyframes fly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(0.6); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); }
}

/* ---------- device help ---------- */

.steps { list-style: none; counter-reset: step; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.steps li { counter-increment: step; position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px 12px 48px; border-radius: var(--r-md); background: var(--sunken); min-height: 52px; }
.steps li::before {
  content: counter(step); position: absolute; left: 12px; top: 12px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 0.9rem;
}
.step-icon { order: 2; margin-left: auto; color: var(--primary-ink); padding-top: 1px; }
.callout { padding: 12px 14px; border-radius: var(--r-md); background: var(--nudge-soft); color: var(--text); border-left: 4px solid var(--nudge); }
.state { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.state.ok { color: var(--win); }
.state.soft { color: var(--nudge); }
.notify-panel > .btn, .install-panel > .btn { margin-bottom: 8px; }
.install-card .btn.ghost { margin-top: 4px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 16px; border-radius: 999px; background: var(--sunken); border: 1px solid var(--line); }
.tab { min-height: 44px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; transition: background-color 200ms var(--ease), color 200ms var(--ease); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.guide h3 { display: flex; align-items: center; gap: 8px; }
.guide h3:first-child { margin-top: 0; }
.panel.this-device { padding: 16px; border-radius: var(--r-lg); background: var(--primary-soft); margin-bottom: 8px; }
.panel.this-device h3 { margin-top: 0; }
.panel.this-device .steps li { background: var(--surface); }
.section-title { margin-top: 24px; }

/* ---------- dialog / sheet ---------- */

.dialog {
  width: min(34rem, calc(100% - 32px)); max-height: min(90dvh, 52rem); padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.5);
  overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; animation: pop 260ms var(--ease) both; }
.dialog::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog-inner { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 12px 8px 20px; }
.dialog-body { padding: 4px 20px 20px; overflow-y: auto; overscroll-behavior: contain; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
@media (max-width: 599px) {
  .dialog.sheet { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 26px 26px 0 0; }
  .dialog.sheet[open] { animation: sheet-up 320ms var(--ease) both; }
  .dialog.sheet .dialog-head::before { content: ""; position: absolute; left: 50%; top: 7px; width: 40px; height: 5px; margin-left: -20px; border-radius: 999px; background: var(--line); }
  .dialog.sheet .dialog-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
@keyframes sheet-up { from { transform: translateY(40%); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* ---------- toast, loading ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: var(--r-md);
  background: var(--text); color: var(--bg); font-weight: 700; box-shadow: var(--shadow);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  transition: transform 260ms var(--ease), opacity 260ms var(--ease);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 64px 0; text-align: center; color: var(--muted); }
.loading h1 { font-size: 1.25rem; color: var(--text); }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- motion and input preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .burst { display: none; }
  .spinner { animation: none; border-top-color: var(--primary); }
}

@media (forced-colors: active) {
  .btn, .option, .choice-body, .check-box, .card { border: 2px solid CanvasText; }
  .choice input:checked + .choice-body, .option.correct { outline: 3px solid Highlight; }
}

@media (min-width: 600px) {
  .container { padding-top: 16px; }
  h1 { font-size: 2rem; }
  .card { padding: 24px; }
  .task { padding: 28px; }
}
