/* Deutsch Tutor — one stylesheet, no build step. docs/DESIGN.md is the spec; the numbers here are
   its numbers. Tokens live on :root and nothing in a component hardcodes a value. Dark is the
   default, light is the prefers-color-scheme override. */

:root {
  color-scheme: dark;
  --bg:        #0e1014;
  --surface:   #171a21;
  --surface-2: #1f232c;
  --line:      #2a2f3a;
  --text:      #e9ecf2;
  --text-dim:  #98a1b2;
  --accent:    #6b8cff;
  --accent-dim:#2a3558;
  --good:      #3ddc97;
  --warn:      #ffb84d;
  --bad:       #ff6b6b;
  --on-accent: #ffffff;
  /* Text-weight versions of the signal colours (4.5:1 on the surfaces they sit on), the dark ink
     that goes on a filled good/amber button, and the fill of the learner's own chat bubble. */
  --good-ink:  #3ddc97;
  --warn-ink:  #ffb84d;
  --bad-ink:   #ff8a8a;
  --accent-ink:#8ea8ff;
  --on-good:   #052e1c;
  --on-warn:   #2e1b00;
  --me-bg:     #3d5bd1;
  --warn-dim:  rgba(255, 184, 77, .16);
  --good-dim:  rgba(61, 220, 151, .16);
  --bad-dim:   rgba(255, 107, 107, .16);
  --scrim:     rgba(0, 0, 0, .5);
  --shadow:    0 12px 32px rgba(0, 0, 0, .4);

  --r-sm: 8px; --r-md: 14px; --r-lg: 20px; --r-full: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --fast: 120ms; --base: 200ms; --slow: 320ms;
  --ease: cubic-bezier(.2,.8,.2,1);
  --ease-in-out: cubic-bezier(.4,0,.2,1);

  --t-xl: 28px; --t-lg: 22px; --t-md: 17px; --t-sm: 15px; --t-xs: 13px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  /* The floating glass tab bar: its height plus the gap below it. Screens pad their bottom by
     --nav-space so the last control is never hidden behind the bar. On a phone with a home
     indicator the bar sits just above the indicator, inside the safe area, like a native floating
     tab bar; without one it keeps a 12 px margin. */
  --nav-h: 64px;
  --nav-bottom: max(12px, calc(var(--safe-b) - 12px));
  --nav-space: calc(var(--nav-h) + var(--nav-bottom) + 20px);
  --glass: rgba(40, 46, 60, .46);
  --glass-edge: rgba(255, 255, 255, .14);
  --glass-hi: rgba(255, 255, 255, .18);
  --glass-pill: rgba(255, 255, 255, .12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --col: 560px;

  /* category chips: one hue per mistake category, the same everywhere so patterns become familiar */
  --cat-gender: #f17fb0;        --cat-case: #ffb84d;         --cat-article: #ff9a62;
  --cat-word_order: #b48cff;    --cat-verb_conjugation: #6b8cff; --cat-preposition: #4fd1c5;
  --cat-plural: #a3e635;        --cat-adjective_ending: #facc15; --cat-pronoun: #818cf8;
  --cat-negation: #fb923c;      --cat-vocabulary: #3ddc97;   --cat-separable_verb: #22d3ee;
  --cat-pronunciation: #e879f9; --cat-other: #98a1b2;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg:        #f5f6f9;
    --surface:   #ffffff;
    --surface-2: #eef0f5;
    --line:      #d9dde6;
    --text:      #15181f;
    --text-dim:  #5c6577;
    --accent:    #3b5fe0;
    --accent-dim:#dde4ff;
    --good:      #16a86f;
    --warn:      #c47a00;
    --bad:       #d63f3f;
    --good-ink:  #0d7a4f;
    --warn-ink:  #8f5600;
    --bad-ink:   #b3261e;
    --accent-ink:#2f50cc;
    --me-bg:     #3b5fe0;
    --warn-dim:  rgba(196, 122, 0, .14);
    --good-dim:  rgba(22, 168, 111, .14);
    --bad-dim:   rgba(214, 63, 63, .12);
    --scrim:     rgba(20, 24, 40, .4);
    --glass: rgba(255, 255, 255, .55);
    --glass-edge: rgba(20, 24, 40, .10);
    --glass-hi: rgba(255, 255, 255, .7);
    --glass-pill: rgba(20, 24, 40, .07);
    --shadow:    0 12px 32px rgba(20, 30, 60, .18);
    --cat-case: #b86e00; --cat-adjective_ending: #a16207; --cat-plural: #4d7c0f; --cat-other: #5c6577;
  }
}

/* ---- base ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--t-md); line-height: 1.35; font-weight: 400;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; overscroll-behavior: none;
}
body.sheet-open { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: var(--t-lg); } h2 { font-size: var(--t-lg); } h3 { font-size: var(--t-md); }
p { margin: 0; }
a { color: var(--accent); }
s { text-decoration-thickness: 1.5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.muted { color: var(--text-dim); }
.small { font-size: var(--t-sm); }
.xs { font-size: var(--t-xs); }
.error { color: var(--bad); }
.ok { color: var(--good); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
[lang="de"] { line-height: 1.5; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---- shell ---------------------------------------------------------- */
/* `inset: 0` alone sizes the shell to the screen. An explicit 100dvh went stale on iOS after the
   keyboard closed and left the shell short, with the tab bar floating above a gap. */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#screens { flex: 1; min-height: 0; position: relative; }
.screen {
  position: absolute; inset: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--nav-space);
}
#app.keyboard .screen { padding-bottom: 0; }
.screen-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; max-width: var(--col); margin: 0 auto;
  padding: var(--s-3) var(--s-4) var(--s-2);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.screen-head h1 { flex: 0 0 auto; font-size: var(--t-lg); }
.screen-head .chip { flex: 1; min-width: 0; justify-content: center; }
.screen-head .chip, .chip.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 26px; }
.screen-body {
  width: 100%; max-width: var(--col); margin: 0 auto;
  /* The screen itself already clears the floating tab bar (--nav-space). */
  padding: var(--s-3) var(--s-4) var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.screen-foot {
  /* Sticks just above the floating tab bar; with the keyboard open the bar hides and it sits on the keys. */
  position: sticky; bottom: calc(var(--nav-h) + var(--nav-bottom) + 12px); z-index: 5;
  width: 100%; max-width: var(--col); margin: 0 auto;
  padding: var(--s-2) var(--s-4) var(--s-3);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}

/* Floating liquid-glass tab bar, Instagram-style: inset from the edges, content scrolls beneath a
   frosted blur, a thin light edge on top, the active tab in its own glass bubble. */
#tabs {
  position: absolute; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: var(--nav-bottom);
  width: calc(100% - 2 * var(--s-4)); max-width: 460px;
  height: var(--nav-h); padding: 5px; box-sizing: border-box;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: center;
  border-radius: var(--r-full);
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .38), inset 0 1px 0 var(--glass-hi);
  transition: transform var(--base) var(--ease), opacity var(--base) var(--ease);
}
#app.keyboard #tabs { opacity: 0; pointer-events: none; transform: translate(-50%, 120%); }
.tab {
  color: var(--text-dim); height: 100%; min-width: 0; padding: 0 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 500; line-height: 1; position: relative;
  border-radius: var(--r-full);
  transition: color var(--fast) var(--ease), background var(--base) var(--ease);
}
.tab > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--fast) var(--ease); }
.tab.active { color: var(--text); font-weight: 600; background: var(--glass-pill); box-shadow: inset 0 1px 0 var(--glass-hi); }
.tab.active svg { stroke-width: 2.1; color: var(--accent); }
.tab:active svg { transform: scale(.88); }
.tab .badge {
  position: absolute; top: 4px; left: calc(50% + 6px);
  background: var(--accent); color: var(--on-accent); border-radius: var(--r-full);
  font-size: 10px; font-weight: 600; padding: 2px 6px; min-width: 16px; text-align: center;
}

/* ---- login gate ----------------------------------------------------- */
.gate {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-5); padding-bottom: calc(var(--s-5) + var(--safe-b));
}
.gate-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: var(--s-5); }
.gate-brand { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); text-align: center; }
.gate-brand h1 { font-size: var(--t-xl); letter-spacing: -.3px; }
.gate-cat { animation: rise var(--slow) var(--ease); }
.login-users { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.login-user {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
  padding: var(--s-4) var(--s-3); border-radius: var(--r-lg);
  background: var(--surface); border: 2px solid var(--line);
  transition: border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.login-user:active { transform: scale(.97); }
.login-user[aria-pressed="true"] { border-color: var(--accent); }
.login-name { font-size: var(--t-md); font-weight: 600; }
.brand { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.brand-mark {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md);
  background: var(--accent); color: var(--on-accent); font-weight: 600; letter-spacing: .5px;
}

/* ---- controls ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 48px; padding: 10px var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: var(--t-md); text-align: center; -webkit-user-select: none; user-select: none;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease), border-color var(--fast) var(--ease), opacity var(--fast);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.outline { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 40px; padding: 6px var(--s-3); font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn.block { width: 100%; }
.btn.icon { width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: var(--r-full); }
.btn.active { border-color: var(--accent); color: var(--accent); }
.btn-row { display: flex; gap: var(--s-2); }
.btn-row > .btn { flex: 1; }
.ico { display: inline-flex; width: 20px; height: 20px; vertical-align: middle; flex: 0 0 auto; }
.ico svg { width: 100%; height: 100%; fill: currentColor; }
/* Stroke icons say fill="none"; a stylesheet fill would otherwise beat the attribute. */
.ico svg[fill="none"] { fill: none; }
.label { font-size: var(--t-xs); color: var(--text-dim); font-weight: 600; }
.input, textarea.input {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: var(--t-md); line-height: 1.4;  /* ≥16px: iOS does not zoom on focus */
  transition: border-color var(--fast) var(--ease);
}
textarea.input { resize: none; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--accent); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface);
  font-size: var(--t-sm); font-weight: 500; color: var(--text); transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.small { min-height: 32px; font-size: var(--t-xs); padding: 4px 10px; }
.chip-row { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row > * { flex: 0 0 auto; }
.chip-row.wrap { flex-wrap: wrap; overflow: visible; }
.cat {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; line-height: 1;
  letter-spacing: .3px; text-transform: lowercase; border-radius: var(--r-full); padding: 4px 8px;
  color: var(--cat-color, var(--cat-other)); background: color-mix(in srgb, var(--cat-color, var(--cat-other)) 16%, transparent);
}

/* ---- cards ---------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); }
.card.subtle { background: var(--surface-2); border-color: transparent; }
.card-title { font-size: var(--t-xs); font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.level-big { font-size: var(--t-xl); font-weight: 600; letter-spacing: -.5px; }

/* ---- feedback & states ---------------------------------------------- */
.error-line {
  display: flex; align-items: center; gap: var(--s-3); justify-content: space-between;
  padding: var(--s-3) 14px; border-radius: var(--r-md); background: var(--warn-dim); color: var(--text); font-size: var(--t-sm);
  animation: rise var(--base) var(--ease);
}
.banner {
  position: fixed; left: 50%; transform: translateX(-50%); width: calc(100% - 2 * var(--s-4)); max-width: var(--col);
  top: calc(var(--safe-t) + var(--s-2)); z-index: 40;
  padding: 8px 14px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-dim); font-size: var(--t-xs); font-weight: 500; text-align: center;
}
#toast-root {
  position: fixed; left: var(--s-3); right: var(--s-3); z-index: 60;
  bottom: calc(var(--nav-h) + var(--nav-bottom) + var(--s-3));
  display: flex; justify-content: center; pointer-events: none;
}
/* In a session the tab bar is aside and the action bar is at the bottom: toasts clear that bar. */
#app.focus ~ #toast-root, #app.keyboard ~ #toast-root { bottom: calc(92px + var(--safe-b)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--s-3); max-width: var(--col);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); box-shadow: var(--shadow); font-size: var(--t-sm); animation: rise var(--base) var(--ease);
}
.toast.err { border-color: var(--bad); }
.toast.ok { border-color: var(--good); }
.toast-action { color: var(--accent); font-weight: 600; min-height: 36px; padding: 0 var(--s-1); }
.spinner-row { display: flex; align-items: center; gap: var(--s-3); color: var(--text-dim); padding: var(--s-2) 0; font-size: var(--t-sm); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.skeleton { display: flex; flex-direction: column; gap: var(--s-3); }
/* Flat bars at the content's size that breathe; no shimmer gradient. */
.skeleton i {
  display: block; height: 14px; border-radius: var(--r-sm);
  background: var(--surface-2); animation: breathe 1.4s var(--ease-in-out) infinite;
}
.skeleton i.tall { height: 56px; border-radius: var(--r-md); }
.skeleton i.w60 { width: 60%; } .skeleton i.w80 { width: 80%; } .skeleton i.w40 { width: 40%; }
.typing { display: inline-flex; gap: 4px; padding: 6px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
.thinking-note { font-size: var(--t-xs); color: var(--text-dim); margin-top: var(--s-1); animation: rise var(--base) var(--ease); }
.empty { padding: var(--s-5) var(--s-4); text-align: center; display: flex; flex-direction: column; gap: var(--s-3); align-items: center; }
.empty p { color: var(--text-dim); max-width: 32ch; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 10px var(--bad-dim); } 50% { box-shadow: 0 0 0 18px var(--bad-dim); } }
@keyframes flip { 0% { transform: scale(.96); opacity: .4; } 100% { transform: none; opacity: 1; } }

/* ---- bottom sheet --------------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 55; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity var(--base) var(--ease);
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: var(--col); max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s-2) var(--s-4) calc(var(--s-4) + var(--safe-b));
  transform: translateY(16px); transition: transform var(--base) var(--ease); box-shadow: var(--shadow);
  touch-action: pan-y;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet.dragging { transition: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: var(--r-full); background: var(--line); margin: 6px auto 14px; }
.sheet-title { margin-bottom: var(--s-3); font-size: var(--t-lg); }
.sheet-body { display: flex; flex-direction: column; gap: var(--s-3); }

/* ---- meters --------------------------------------------------------- */
.meter { height: 8px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: var(--r-full); transition: width var(--slow) var(--ease); }
.meter.good > i { background: var(--good); }
.meter.thin { height: 4px; }

/* ---- words ---------------------------------------------------------- */
.word { border-radius: 4px; padding: 0 1px; cursor: pointer;
  /* A word is a tap target, so iOS must not offer its own long-press callout over it. */
  -webkit-touch-callout: none; }
.word:active { background: var(--accent-dim); }
.hidden-text { filter: blur(6px); -webkit-user-select: none; user-select: none; transition: filter var(--base) var(--ease); }
.hidden-text.revealed { filter: none; }
.lemma { font-size: var(--t-lg); font-weight: 600; }
.translation { font-size: var(--t-md); }
.lookup-note { color: var(--text-dim); font-size: var(--t-sm); min-height: 22px; }

/* ---- progress ------------------------------------------------------- */
.unit-pos { font-weight: 600; }
.cando { margin: 0; padding-left: 18px; font-size: var(--t-sm); color: var(--text-dim); line-height: 1.5; }
.skill-row { display: flex; align-items: center; gap: var(--s-3); min-height: 24px; }
.skill-name { width: 80px; text-transform: capitalize; font-size: var(--t-sm); }
.skill-val { width: 30px; text-align: right; font-size: var(--t-sm); font-variant-numeric: tabular-nums; color: var(--text-dim); }
.strip { display: flex; align-items: flex-end; gap: 3px; height: 56px; }
.strip .bar { flex: 1; background: var(--line); border-radius: 2px; min-height: 4px; transition: height var(--slow) var(--ease); }
.strip .bar.on { background: var(--accent); }
.mistake-row { display: flex; flex-direction: column; gap: 3px; padding: var(--s-2) 0; border-top: 1px solid var(--line); }
.mistake-row:first-of-type { border-top: 0; }
.trend { font-size: var(--t-xs); color: var(--text-dim); }
.trend.ok { color: var(--good); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.tile { background: var(--surface-2); border-radius: var(--r-md); padding: 10px 6px; text-align: center; }
.tile-n { font-size: var(--t-lg); font-weight: 600; }
.session-row { border-top: 1px solid var(--line); padding: 10px 0; text-align: left; width: 100%; color: inherit; display: flex; flex-direction: column; gap: 2px; min-height: 44px; }
.session-row:first-of-type { border-top: 0; }
.pass-card { border-color: var(--good); }
.score-row { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }

/* ===== Learning screens ==================================================================
   Learn, Talk, Review, Drill, Write, Placement and Checkpoint share one frame. A session (a
   lesson, a review, a drill, the placement) runs in focus mode: the tab bar steps aside, a close
   button and a thick progress track sit on top, and the action lives in a bar at the bottom where
   the thumb is. An answer turns that bar into a verdict panel with Katze in it. Answer tiles and
   the main action are tactile: a solid ledge under them that a press pushes down, the one
   Duolingo move. No eyebrow labels here: a heading says what a block is. */

/* ---- focus mode and the player ------------------------------------- */
#app.focus #tabs { opacity: 0; pointer-events: none; transform: translate(-50%, 120%); }
#app.focus .screen { padding-bottom: 0; }
.learn-view { display: flex; flex-direction: column; flex: 1 0 auto; }
.player { display: flex; flex-direction: column; flex: 1 0 auto; width: 100%; max-width: var(--col); margin: 0 auto; }
.player-head {
  position: sticky; top: 0; z-index: 6;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-4) var(--s-2) var(--s-2); background: var(--bg);
}
.player-head .btn.icon { color: var(--text-dim); }
.track { height: 14px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; display: flex; gap: 4px; }
.track > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--warn); transition: width var(--slow) var(--ease); }
.track.segmented { background: none; overflow: visible; }
.track.segmented > i { flex: 1; width: auto; background: var(--surface-2); transition: background-color var(--base) var(--ease); }
.track.segmented > i.right { background: var(--good); }
.track.segmented > i.wrong { background: var(--warn); }
.track.segmented > i.now { background: var(--accent-dim); box-shadow: inset 0 0 0 2px var(--accent); }
.track-count { min-width: 44px; text-align: right; font-size: var(--t-sm); font-weight: 600; color: var(--text-dim); }
.player-body { flex: 1 0 auto; display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-3) var(--s-4) var(--s-5); }
.player-foot {
  position: sticky; bottom: 0; z-index: 6;
  display: flex; align-items: center; gap: var(--s-2); min-height: 76px;
  padding: var(--s-3) var(--s-4) calc(var(--s-3) + var(--safe-b));
  background: var(--bg); border-top: 1px solid var(--line);
}
.player-foot:empty { display: none; }
#app.keyboard .player-foot { padding-bottom: var(--s-3); }
.player-foot.ok, .player-foot.no {
  flex-direction: column; align-items: stretch; gap: var(--s-3); border-top-color: transparent; color: var(--text);
  animation: rise-in var(--base) var(--ease);
}
.player-foot.ok { background: color-mix(in srgb, var(--good) 15%, var(--bg)); }
.player-foot.no { background: color-mix(in srgb, var(--warn) 15%, var(--bg)); }
.foot-hint { flex: 1; text-align: right; font-size: var(--t-sm); color: var(--text-dim); }
.foot-back { color: var(--text-dim); }
.verdict { display: flex; align-items: center; gap: var(--s-3); }
.verdict-title { font-size: 21px; font-weight: 700; line-height: 1.2; }
.ok .verdict-title { color: var(--good-ink); }
.no .verdict-title { color: var(--warn-ink); }
.verdict-detail { margin-top: 2px; font-size: var(--t-sm); line-height: 1.45; color: var(--text); }
.verdict-detail .block { display: block; }
.verdict-detail .block + .block { margin-top: 4px; }

/* ---- type for prompts ------------------------------------------------ */
.prompt-h { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; text-wrap: balance; }
.prompt-h.sm { font-size: var(--t-lg); }
.prompt-lead { font-size: var(--t-md); line-height: 1.55; color: var(--text-dim); text-wrap: pretty; }
.section-h { font-size: var(--t-md); font-weight: 700; }
.section-label { font-size: var(--t-sm); font-weight: 600; color: var(--text-dim); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-4); }
.num { font-variant-numeric: tabular-nums; }
.done-before { display: flex; align-items: center; gap: 6px; margin-bottom: var(--s-3); font-size: var(--t-sm); color: var(--good-ink); }

/* ---- tactile tiles and buttons ---------------------------------------- */
.tactile {
  --ledge: var(--line);
  border: 2px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: 0 4px 0 var(--ledge);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), border-color var(--fast) var(--ease), background-color var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.tactile:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ledge); }
.btn.tactile { border-radius: 16px; }
.btn.lg { min-height: 54px; font-size: var(--t-md); font-weight: 700; }
.btn.primary.tactile { --ledge: color-mix(in srgb, var(--accent) 55%, #000); background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.good.tactile { --ledge: color-mix(in srgb, var(--good) 50%, #000); background: var(--good); border-color: var(--good); color: var(--on-good); }
.btn.warn.tactile { --ledge: color-mix(in srgb, var(--warn) 50%, #000); background: var(--warn); border-color: var(--warn); color: var(--on-warn); }
.btn.tactile:disabled { opacity: .45; box-shadow: 0 4px 0 var(--ledge); }
.btn.grow { flex: 1; min-width: 0; }
@media (hover: hover) {
  .tactile:hover:not(:disabled) { border-color: color-mix(in srgb, var(--text-dim) 60%, var(--line)); }
  .btn.primary.tactile:hover:not(:disabled), .btn.good.tactile:hover:not(:disabled), .btn.warn.tactile:hover:not(:disabled) { filter: brightness(1.06); }
}

.options { display: flex; flex-direction: column; gap: 12px; }
.option { width: 100%; min-height: 58px; padding: 14px 18px; text-align: left; font-size: var(--t-md); line-height: 1.35; overflow-wrap: anywhere; }
.option.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); --ledge: color-mix(in srgb, var(--accent) 45%, var(--bg)); }
.option.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 16%, var(--surface)); --ledge: color-mix(in srgb, var(--good) 45%, var(--bg)); }
.option.wrong { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, var(--surface)); --ledge: color-mix(in srgb, var(--warn) 45%, var(--bg)); }
.option:disabled:not(.right):not(.wrong):not(.sel) { opacity: .5; }

/* ---- Learn: the path ----------------------------------------------- */
.learn-path { gap: var(--s-4); }
.phase-head { display: flex; flex-direction: column; gap: var(--s-2); }
.phase-title { font-size: var(--t-xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.phase-track { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; height: 10px; }
.phase-track > i { border-radius: var(--r-full); background: var(--surface-2); }
.phase-track > i.done { background: var(--good); }
.phase-track > i.now { background: var(--warn); }
.path { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: var(--s-4) 0 var(--s-2); }
.node-row { display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(var(--x, 0px)); }
.node { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.node.done { --ledge: color-mix(in srgb, var(--good) 50%, #000); background: var(--good); border-color: var(--good); color: var(--on-good); }
.node.locked { --ledge: var(--line); background: var(--surface-2); border-color: var(--line); color: var(--text-dim); }
.node.now { --ledge: color-mix(in srgb, var(--warn) 50%, #000); width: 80px; height: 80px; background: var(--warn); border-color: var(--warn); color: var(--on-warn); }
.node.checkpoint { border-radius: 24px; }
.node.checkpoint.open { --ledge: color-mix(in srgb, var(--accent) 55%, #000); background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.node-label { max-width: 200px; text-align: center; font-size: var(--t-sm); font-weight: 600; line-height: 1.3; }
.node-label.locked { color: var(--text-dim); font-weight: 500; }
.node-wrap { position: relative; width: 112px; height: 112px; display: grid; place-items: center; }
.node-ring { position: absolute; inset: 0; }
.node-cat { position: absolute; top: 50%; transform: translateY(-50%); }
.node-cat.right { left: calc(100% + 10px); }
.node-cat.left { right: calc(100% + 10px); }
.lesson-card {
  position: relative; width: 100%; margin-top: -6px;
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: 20px 18px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line);
}
.lesson-card::before {
  content: ''; position: absolute; top: -8px; left: calc(50% + var(--x, 0px) - 8px);
  width: 14px; height: 14px; transform: rotate(45deg);
  background: var(--surface); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
}
.lesson-card-title { font-size: var(--t-lg); font-weight: 700; line-height: 1.2; }
.lesson-card-intro { font-size: var(--t-sm); line-height: 1.5; color: var(--text-dim); }
.cando-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cando-list li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; font-size: var(--t-sm); line-height: 1.4; }
.cando-list .ico { color: var(--good-ink); margin-top: 2px; }
.next-phase { display: flex; align-items: center; justify-content: center; gap: 8px; padding: var(--s-3); color: var(--text-dim); font-size: var(--t-sm); font-weight: 500; }

/* ---- Learn: teaching pages ------------------------------------------ */
.lines { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.line {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 64px; padding: 12px 14px 12px 16px;
  text-align: left; color: inherit; transition: background-color var(--fast) var(--ease);
}
.line + .line { border-top: 1px solid var(--line); }
.line:active { background: var(--surface-2); }
@media (hover: hover) { .line:hover { background: var(--surface-2); } }
.line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.line-de { font-size: 20px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.line-de.sm { font-size: var(--t-md); }
.line-en { font-size: var(--t-sm); color: var(--text-dim); line-height: 1.4; }
.line-note { font-size: var(--t-xs); color: var(--text-dim); line-height: 1.4; }
.line-example { color: var(--text); font-weight: 500; }
.line .say { flex: none; width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center; color: var(--accent-ink); background: var(--accent-dim); }
.sound-letter { font-size: 26px; font-weight: 700; color: var(--accent-ink); margin-right: 10px; }
.sound-say { font-size: var(--t-sm); font-weight: 500; color: var(--text-dim); }
.g-table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow-x: auto; }
.g-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.g-table th { text-align: left; font-size: var(--t-xs); font-weight: 600; color: var(--text-dim); padding: 10px 14px 8px; }
.g-table td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.g-table td.de-cell { font-size: var(--t-md); font-weight: 600; }
.tip { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--t-sm); line-height: 1.5; }
.tip .katze { flex: none; }

/* ---- Learn: practice --------------------------------------------- */
.listen-row { display: flex; align-items: flex-end; justify-content: center; gap: var(--s-4); padding: var(--s-3) 0; }
.btn.speak-big { --ledge: color-mix(in srgb, var(--accent) 55%, #000); width: 96px; height: 96px; padding: 0; border-radius: 26px; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.speak-big.sm { width: 60px; height: 60px; min-height: 60px; border-radius: 18px; flex: none; }
.btn.speak-slow { width: 60px; height: 60px; padding: 0; border-radius: 18px; color: var(--accent-ink); }
.match-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 12px; }
.match-tile { min-height: 56px; padding: 10px 12px; font-size: var(--t-md); font-weight: 600; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.match-tile.en { font-weight: 500; }
.match-tile.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); --ledge: color-mix(in srgb, var(--accent) 45%, var(--bg)); }
.match-tile.done { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); --ledge: transparent; transform: translateY(3px); opacity: .45; }
.match-tile.hit { animation: pop 260ms var(--ease); }
.match-tile.miss { border-color: var(--warn); animation: shake .35s var(--ease); }
.build-slot {
  min-height: 120px; padding: 6px 0 10px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  /* Two ruled lines, like a page to write on. */
  background: linear-gradient(var(--line), var(--line)) 0 58px / 100% 2px no-repeat, linear-gradient(var(--line), var(--line)) 0 116px / 100% 2px no-repeat;
  transition: background-color var(--base) var(--ease);
}
.build-slot.right { background-color: color-mix(in srgb, var(--good) 8%, transparent); border-radius: var(--r-md); }
.build-slot.wrong { background-color: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: var(--r-md); }
.build-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 52px; }
.word-tile { min-height: 46px; padding: 8px 14px; border-radius: 12px; font-size: var(--t-md); font-weight: 500; }
.word-tile.used { background: var(--surface-2); border-color: var(--surface-2); color: transparent; box-shadow: none; pointer-events: none; }
.say-card { display: flex; align-items: center; gap: var(--s-3); padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.say-de { display: block; font-size: 24px; font-weight: 700; line-height: 1.25; margin-bottom: 4px; }
.heard { font-size: var(--t-sm); color: var(--text-dim); text-align: center; }
.gap { display: inline-block; min-width: 72px; height: 1.1em; margin: 0 4px; vertical-align: -0.2em; border-bottom: 3px solid var(--accent); }

/* ---- the end of a session ------------------------------------------ */
.finish { display: flex; flex-direction: column; align-items: center; gap: var(--s-4); padding-top: var(--s-5); text-align: center; }
.finish-cat { display: grid; place-items: center; }
.finish-cat .katze svg { animation: hop 900ms var(--ease) 1; }
.finish-h { font-size: var(--t-xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; text-wrap: balance; }
.finish-sub { max-width: 34ch; font-size: var(--t-md); line-height: 1.5; color: var(--text-dim); text-wrap: pretty; }
.finish-actions { width: 100%; display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }
.level-mark { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--warn-ink); }
.stat-strip { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.stat-strip > div { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 6px; }
.stat-strip > div + div { border-left: 1px solid var(--line); }
.stat-n { font-size: var(--t-lg); font-weight: 700; }
.stat-l { font-size: var(--t-xs); color: var(--text-dim); }
.center-row { justify-content: center; }

/* ---- Katze speaks, facts, intros ------------------------------------ */
.says { display: flex; align-items: flex-end; gap: 10px; }
.says .katze { flex: none; }
.says-bubble { position: relative; min-width: 0; padding: 12px 14px; border-radius: 20px 20px 20px 6px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.says-line { font-size: var(--t-md); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.says-sub { font-size: var(--t-sm); line-height: 1.45; color: var(--text-dim); }
.intro { display: flex; flex-direction: column; gap: var(--s-4); padding-top: var(--s-2); }
.facts { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.facts li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; font-size: var(--t-sm); line-height: 1.45; }
.facts li + li { border-top: 1px solid var(--line); }
.facts .ico { color: var(--text-dim); margin-top: 1px; }
.wait-line { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: var(--t-sm); }
.heard-card { padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.heard-card p { font-size: var(--t-md); line-height: 1.5; }
.pill.kind { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); }
.type-instead > summary { list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: var(--t-sm); font-weight: 600; }
.type-instead > summary::-webkit-details-marker { display: none; }
.type-instead[open] > summary { color: var(--text); }

/* ---- Talk --------------------------------------------------------- */
.talk-head { gap: var(--s-2); }
.scenario-btn {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px 0 14px; display: flex; align-items: center; gap: 4px;
  border-radius: var(--r-full); background: var(--surface-2); color: var(--text); font-size: var(--t-sm); font-weight: 600;
}
.scenario-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.scenario-btn .ico { color: var(--text-dim); }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-full); background: var(--surface-2); flex: none; }
.seg-btn { min-width: 40px; height: 34px; padding: 0 8px; display: grid; place-items: center; border-radius: var(--r-full); color: var(--text-dim); font-size: var(--t-xs); font-weight: 700; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.seg-btn.active { background: var(--surface); color: var(--accent-ink); box-shadow: 0 0 0 1px var(--line); }
.end-btn { flex: none; color: var(--text-dim); padding: 6px 8px; }
.chat {
  flex: 1; width: 100%; max-width: var(--col); margin: 0 auto;
  display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-3) var(--s-4) var(--s-4);
}
.talk-start { display: flex; flex-direction: column; gap: var(--s-4); padding-top: var(--s-2); }
.talk-unit { display: flex; flex-direction: column; gap: 4px; }
.talk-unit-title { font-size: var(--t-lg); font-weight: 700; }
.choice-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.choice { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; width: 100%; padding: 14px 16px; text-align: left; color: inherit; transition: background-color var(--fast) var(--ease); }
.choice + .choice { border-top: 1px solid var(--line); }
@media (hover: hover) { .choice:hover { background: var(--surface-2); } }
.choice-mark { width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.choice[aria-checked="true"] .choice-mark { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.choice[aria-checked="true"] { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.choice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice-title { font-size: var(--t-md); font-weight: 600; }
.choice-sub { font-size: var(--t-sm); color: var(--text-dim); line-height: 1.4; }

.msg { display: flex; gap: 8px; max-width: 88%; animation: rise-in var(--base) var(--ease); }
.msg.tutor { align-self: flex-start; align-items: flex-start; }
.msg.user { align-self: flex-end; flex-direction: column; align-items: flex-end; gap: var(--s-2); max-width: 85%; }
.msg-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; margin-top: 2px; }
.msg-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bubble { position: relative; padding: 12px 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.msg.tutor .bubble { border-bottom-left-radius: 6px; }
.msg.user .bubble { background: var(--me-bg); border-color: var(--me-bg); color: #fff; border-bottom-right-radius: 6px; }
.msg.pending .bubble { opacity: .7; }
.bubble-text { font-size: var(--t-md); line-height: 1.5; overflow-wrap: anywhere; }
/* What the German means. Quiet and clearly secondary — the German stays the loudest thing in the
   bubble — but always legible, because at A1 this is the line that makes the reply usable at all. */
.bubble-meaning { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: var(--t-sm); line-height: 1.45; color: var(--text-dim); }
.bubble-foot { display: flex; align-items: center; gap: 4px; margin: 10px -4px -4px; flex-wrap: wrap; }
.bubble-play { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-dim); color: var(--accent-ink); flex: none; }
.bubble-tool { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 10px; border-radius: var(--r-full); color: var(--text-dim); font-size: var(--t-xs); font-weight: 600; }
.bubble-tool.active, .bubble-tool[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-dim); }
@media (hover: hover) { .bubble-tool:hover, .bubble-play:hover { filter: brightness(1.12); } }
.msg.playing .bubble-play { background: var(--accent); color: var(--on-accent); }
.audio-line { position: absolute; left: 16px; right: 16px; bottom: 3px; height: 2px; border-radius: 1px; background: color-mix(in srgb, var(--accent) 25%, transparent); overflow: hidden; opacity: 0; transition: opacity var(--fast); }
.audio-line > i { display: block; height: 100%; width: 0; background: var(--accent); }
.msg.playing .audio-line { opacity: 1; }
.transcript-label {
  display: inline-flex; align-items: center; gap: 4px; min-height: 28px; margin: -4px 0 2px;
  font-size: var(--t-xs); font-weight: 600; color: color-mix(in srgb, #fff 78%, transparent);
}
.vocab-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.vocab-label { font-size: var(--t-xs); font-weight: 600; color: var(--warn-ink); }
.msg-extras { display: flex; flex-direction: column; gap: var(--s-2); width: 100%; align-items: flex-end; }
.msg-extras:empty { display: none; }
.corr { width: 100%; background: var(--surface); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: var(--r-md); overflow: hidden; }
.corr-toggle { width: 100%; display: flex; align-items: center; gap: var(--s-2); min-height: 44px; padding: 0 var(--s-3); color: var(--warn-ink); font-size: var(--t-sm); font-weight: 600; text-align: left; }
.corr-toggle .chev { margin-left: auto; display: inline-flex; transition: transform var(--base) var(--ease); }
.corr-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.corr-toggle .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.corr-panel { height: 0; overflow: hidden; transition: height var(--base) var(--ease); }
.corr-list { list-style: none; margin: 0; padding: var(--s-2) var(--s-3) var(--s-3); display: flex; flex-direction: column; gap: var(--s-3); border-top: 1px solid var(--line); }
.corr-pair { font-size: var(--t-md); line-height: 1.5; }
.corr-pair s { color: var(--text-dim); }
.corr-pair b { font-weight: 700; color: var(--text); }
.corr-expl { margin-top: 2px; display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; color: var(--text-dim); font-size: var(--t-sm); }
.praise { font-size: var(--t-sm); font-weight: 600; color: var(--good-ink); }
.help-card { width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.help-german { font-size: var(--t-md); line-height: 1.5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.done-card { align-self: stretch; display: flex; flex-direction: column; gap: var(--s-3); padding: 14px 16px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--good) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--good) 35%, var(--line)); }
.talk-summary { display: flex; flex-direction: column; gap: var(--s-4); padding-top: var(--s-3); }
.summary-card { display: flex; flex-direction: column; gap: var(--s-2); padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); line-height: 1.5; }
.talk-foot { display: flex; flex-direction: column; gap: var(--s-2); }
.composer { display: flex; gap: var(--s-2); align-items: flex-end; }
.composer-input { flex: 1; min-height: 48px; max-height: 120px; border-radius: 24px; padding: 12px 16px; }
.send-btn { width: 48px; height: 48px; min-height: 48px; }
.msg.queued .bubble { border: 1px dashed var(--warn); background: transparent; color: var(--text); }
.msg.queued .btn-row { margin-top: var(--s-2); }

/* ---- the mic --------------------------------------------------------- */
.mic-wrap { display: flex; flex-direction: column; gap: 6px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.mic-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--s-3); }
.mic-side { display: flex; align-items: center; }
.mic-side:last-child { justify-content: flex-end; }
.mic-btn { -webkit-touch-callout: none;
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  touch-action: none; -webkit-user-select: none; user-select: none;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 55%, #000);
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.mic-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.mic-btn.on { background: var(--bad); box-shadow: 0 0 0 0 var(--bad-dim); animation: pulse 1.6s var(--ease-in-out) infinite; }
.mic-btn:disabled { opacity: .45; }
.mic-alt, .mic-cancel { width: 48px; height: 48px; min-height: 48px; border-radius: 50%; background: var(--surface-2); border: 0; color: var(--text); }
.mic-label { min-height: 18px; text-align: center; font-size: var(--t-xs); font-weight: 500; color: var(--text-dim); }
.mic-label.warn { color: var(--bad-ink); font-weight: 700; }
.mic-status { display: flex; align-items: center; justify-content: center; gap: 10px; height: 32px; animation: rise-in var(--fast) var(--ease); }
.mic-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: blink 1.2s infinite; }
.mic-timer { min-width: 40px; font-size: var(--t-md); font-weight: 700; }
.mic-wave { display: flex; align-items: center; gap: 3px; height: 28px; }
.mic-wave i { width: 3px; height: 100%; border-radius: 2px; background: var(--bad); transform: scaleY(.14); transition: transform 90ms linear; }
.mic-status.cancel .mic-wave i, .mic-status.cancel .mic-dot { background: var(--text-dim); }
/* Holding the mic is a gesture, not a text interaction. Pointer capture keeps the events on the
   button, but a drag still lands over the chat bubbles, and on iOS that starts a selection and the
   "Copy / Look Up" callout — which is what makes hold-to-talk feel broken. Clamped for the whole
   document, because the thumb travels outside the button by design (slide away to cancel). */
html.recording, html.recording * {
  -webkit-user-select: none !important; user-select: none !important;
  -webkit-touch-callout: none !important;
}
html.recording { cursor: default; }
.speak-card .mic-wrap, .stack-lg > .mic-wrap { margin-top: var(--s-2); }

/* ---- Review ---------------------------------------------------------- */
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.dir-btn { min-height: 36px; padding: 0 12px; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-dim); font-size: var(--t-xs); font-weight: 700; }
.deck { position: relative; padding-bottom: 16px; }
.deck::before, .deck::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 8px; height: 24px;
  border-radius: 0 0 22px 22px; background: var(--surface-2); border: 1px solid var(--line); border-top: 0;
}
.deck::after { left: 30px; right: 30px; bottom: 0; opacity: .6; }
.flashcard {
  position: relative; z-index: 1; width: 100%; min-height: 300px; padding: 40px 20px 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-4);
  border-radius: 24px; background: var(--surface); border: 1px solid var(--line); color: inherit; text-align: center;
}
.flashcard.flip { animation: flip 180ms var(--ease); }
.fc-front { font-size: 34px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; overflow-wrap: anywhere; text-wrap: balance; }
.fc-back { width: 100%; padding-top: var(--s-4); border-top: 1px solid var(--line); animation: rise-in var(--base) var(--ease); }
.fc-answer { font-size: var(--t-lg); font-weight: 600; }
.fc-example { margin-top: 6px; font-size: var(--t-sm); color: var(--text-dim); }
.fc-hint { position: absolute; left: 0; right: 0; bottom: 18px; font-size: var(--t-xs); color: var(--text-dim); }
.fc-say { position: absolute; z-index: 2; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--accent-ink); background: var(--accent-dim); }
.rate-grid { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.rate { min-height: 62px; padding: 8px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  --tone: var(--accent); border-color: color-mix(in srgb, var(--tone) 45%, var(--line)); background: color-mix(in srgb, var(--tone) 12%, var(--surface));
  --ledge: color-mix(in srgb, var(--tone) 35%, var(--bg)); }
.rate b { font-size: var(--t-sm); font-weight: 700; color: var(--tone-ink, var(--text)); }
.rate small { font-size: 12px; color: var(--text-dim); }
.rate.again { --tone: var(--bad); --tone-ink: var(--bad-ink); }
.rate.hard { --tone: var(--warn); --tone-ink: var(--warn-ink); }
.rate.good { --tone: var(--good); --tone-ink: var(--good-ink); }
.rate.easy { --tone: var(--accent); --tone-ink: var(--accent-ink); }
.back-link { align-self: flex-start; gap: 4px; padding-left: 4px; }
.search { position: relative; display: block; }
.search > .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.search-input { padding-left: 42px; }
.deck-list { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.deck-list:has(> .skeleton), .deck-list:has(> .error-line) { border: 0; background: none; }
.deck-row { display: flex; align-items: center; gap: var(--s-2); padding: 4px 4px 4px 16px; min-height: 60px; }
.deck-row + .deck-row { border-top: 1px solid var(--line); }
.deck-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; color: inherit; min-height: 44px; justify-content: center; }
.deck-word { font-size: var(--t-md); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-sub { font-size: var(--t-sm); color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-due { flex: none; font-size: var(--t-xs); color: var(--text-dim); }
.deck-empty { padding: var(--s-4); text-align: center; }

/* ---- Drill ---------------------------------------------------------- */
.drill-sentence { font-size: 24px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.answer-input { min-height: 56px; font-size: 20px; border-radius: 16px; padding: 14px 16px; }

/* ---- Write ---------------------------------------------------------- */
.task-card { display: flex; flex-direction: column; gap: var(--s-3); padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.task-text { font-size: 19px; font-weight: 500; line-height: 1.45; text-wrap: pretty; }
.task-to { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); color: var(--text-dim); }
.task-to b { color: var(--text); font-weight: 600; }
.need-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.need { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 4px 10px; border-radius: var(--r-full); border: 1px solid var(--line); font-size: var(--t-sm); font-weight: 500; transition: background-color var(--base) var(--ease), color var(--base) var(--ease), border-color var(--base) var(--ease); }
.need .ico { display: none; }
.need.met { background: var(--good-dim); border-color: transparent; color: var(--good-ink); }
.need.met .ico { display: inline-flex; }
.write-area { min-height: 220px; padding: 16px; border-radius: var(--r-lg); font-size: 18px; line-height: 1.6; }
.word-meter { display: flex; flex-direction: column; gap: 6px; }
.wm-track { position: relative; height: 8px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.wm-band { position: absolute; top: 0; bottom: 0; background: var(--good-dim); }
.wm-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: var(--text-dim); transition: width var(--base) var(--ease), background-color var(--base) var(--ease); }
.word-meter[data-state="in"] .wm-fill { background: var(--good); }
.word-meter[data-state="over"] .wm-fill { background: var(--warn); }
.wm-label { font-size: var(--t-xs); color: var(--text-dim); }
.word-meter[data-state="in"] .wm-label { color: var(--good-ink); }
.result-head { display: flex; flex-direction: column; gap: var(--s-3); }
.score-pips { display: inline-flex; align-items: center; gap: 6px; }
.score-pips i { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.score-pips i.on { background: var(--warn); border-color: var(--warn); }
.score-pips .muted { margin-left: 4px; }
.score-pips.sm i { width: 8px; height: 8px; }
.fb-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); width: 100%; text-align: left; }
.fb-row { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding: 14px 16px; font-size: var(--t-sm); line-height: 1.5; }
.fb-row + .fb-row { border-top: 1px solid var(--line); }
.fb-row.good .ico { color: var(--good-ink); margin-top: 1px; }
.fb-row.next .ico { color: var(--accent-ink); margin-top: 1px; }
.text-card { display: flex; flex-direction: column; gap: var(--s-3); padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.write-text { font-size: var(--t-md); line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
mark { border-radius: 3px; padding: 0 1px; color: inherit; background: transparent; }
mark.wrong { text-decoration: underline; text-decoration-color: var(--warn); text-decoration-thickness: 2px; text-underline-offset: 4px; cursor: pointer; }
mark.wrong.open { background: var(--warn-dim); }
mark.better { background: var(--good-dim); }
.inline-expl { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); font-size: var(--t-sm); animation: rise-in var(--base) var(--ease); }
.recent { border-top: 1px solid var(--line); margin-top: var(--s-2); }
.recent > summary { list-style: none; cursor: pointer; min-height: 52px; display: flex; align-items: center; justify-content: space-between; color: var(--text-dim); font-size: var(--t-sm); font-weight: 600; }
.recent > summary::-webkit-details-marker { display: none; }
.recent[open] > summary .ico { transform: rotate(180deg); }
.recent > summary .ico { transition: transform var(--base) var(--ease); }
.recent .stack { gap: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.recent-row { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 12px 16px; text-align: left; color: inherit; }
.recent-row + .recent-row { border-top: 1px solid var(--line); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- Checkpoint ------------------------------------------------------- */
.cp-part { display: flex; flex-direction: column; gap: var(--s-3); padding: 18px 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.cp-part-head { display: flex; align-items: center; gap: 10px; }
.cp-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-dim); color: var(--accent-ink); font-size: var(--t-sm); font-weight: 700; }
.cp-prompt { font-size: var(--t-md); line-height: 1.5; }
.recorded { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--good-dim); color: var(--good-ink); font-size: var(--t-sm); font-weight: 600; }
.scores { display: flex; flex-direction: column; gap: var(--s-4); }
.score { display: flex; flex-direction: column; gap: 6px; }
.score-bar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; height: 10px; }
.score-bar i { border-radius: var(--r-full); background: var(--surface-2); }
.score-bar i.on { background: var(--good); }

@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 50% { transform: translateY(3px) scale(1.04); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Narrow phones (320 px): the head row and the path give back a little width. */
@media (max-width: 359px) {
  .seg-btn { min-width: 34px; padding: 0 6px; }
  .end-btn { padding: 6px 4px; }
  .talk-head h1 { font-size: var(--t-md); }
  .node-cat { display: none; }
  .rate small { font-size: 11px; }
  .prompt-h { font-size: var(--t-lg); }
  .fc-front { font-size: 28px; }
}


/* ---- Katze, rings, game layer ------------------------------------------------------------- */
.katze { display: inline-flex; line-height: 0; }
.katze svg { display: block; }
.katze-cheering svg, .katze-proud svg { animation: hop 900ms var(--ease) 1; }
@keyframes hop { 0%, 100% { transform: none; } 35% { transform: translateY(-6px) rotate(-3deg); } 65% { transform: translateY(0) rotate(2deg); } }
.ring-arc { transition: stroke-dashoffset 900ms var(--ease); }
.ring-wrap { position: relative; flex: 0 0 auto; }
.ring-inner { position: absolute; inset: 12%; border-radius: var(--r-full); background: var(--surface-2); display: grid; place-items: center; }
.pill { padding: 6px 10px; border-radius: var(--r-full); background: var(--surface-2); font-size: var(--t-xs); font-weight: 600; white-space: nowrap; }
.pill.xp { color: var(--warn); }
.dot { width: 10px; height: 10px; border-radius: var(--r-full); display: inline-block; flex: 0 0 auto; }
.ok { color: var(--good); }

/* ---- home ------------------------------------------------------------------------------- */
.home { gap: var(--s-4); padding-top: var(--s-4); }
.home-head { display: flex; align-items: center; gap: var(--s-3); }
.home-greet { font-size: var(--t-lg); font-weight: 600; line-height: 1.2; }
.avatar-btn { width: 52px; height: 52px; border-radius: var(--r-full); background: var(--surface-2); display: grid; place-items: center; flex: 0 0 auto; }
.rings-card { display: flex; align-items: center; gap: var(--s-4); border-radius: var(--r-lg); }
.plan { display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left; transition: transform var(--fast) var(--ease); }
.plan:active, .hub:active, .race:active { transform: scale(.985); }
.plan > .grow, .hub > .grow { display: flex; flex-direction: column; gap: 2px; }
.plan-icon, .hub-icon { width: 42px; height: 42px; border-radius: var(--r-md); display: grid; place-items: center; flex: 0 0 auto; }
.plan-icon .ico { width: 22px; height: 22px; }
.plan-title, .hub-title { font-size: var(--t-md); font-weight: 600; }
.race { display: flex; flex-direction: column; gap: var(--s-2); width: 100%; text-align: left; }
.race-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 60px; align-items: center; gap: var(--s-2); }
.race-name { font-size: var(--t-sm); font-weight: 600; }
.race-xp { text-align: right; }
.race .meter { height: 10px; }

/* ---- practice --------------------------------------------------------------------------- */
.hub { display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px 16px; border-radius: var(--r-lg); }
.hub-icon { width: 54px; height: 54px; border-radius: 16px; }
.hub-icon svg { width: 28px; height: 28px; }
.hub-title { font-size: var(--t-md); }
.count { min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--r-full); background: var(--good); color: var(--bg); display: grid; place-items: center; font-size: var(--t-xs); font-weight: 600; }

/* ---- you -------------------------------------------------------------------------------- */
.you-head { display: flex; align-items: center; gap: 14px; }
.you-name { font-size: var(--t-lg); font-weight: 600; line-height: 1.15; }
.h2h { border-radius: var(--r-lg); }
.h2h-grid { display: grid; grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr); align-items: center; gap: 6px; }
.h2h-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.h2h-xp { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.h2h-stats { border-top: 1px solid var(--line); padding-top: var(--s-3); gap: var(--s-2); }
.h2h-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px minmax(0, 1fr); align-items: center; font-size: var(--t-sm); font-weight: 600; }
.h2h-l { text-align: right; } .h2h-m { text-align: center; font-weight: 400; }
.badge-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: var(--r-md); background: var(--surface); border: 1px dashed var(--line); text-align: center; color: var(--text-dim); min-height: 84px; }
.badge.on { background: var(--surface-2); border: 1px solid transparent; color: var(--text); }
.avatar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.avatar-pick { aspect-ratio: 1; border-radius: 18px; background: var(--surface); border: 2px solid var(--line); display: grid; place-items: center; }
.avatar-pick.active { border-color: var(--accent); }
.you-progress { display: contents; }

/* ---- milestone moment ------------------------------------------------------------------- */
.moment {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 40px 28px calc(28px + var(--safe-b)); text-align: center;
  opacity: 0; transform: scale(.98); transition: opacity var(--base) var(--ease), transform var(--base) var(--ease);
}
.moment.open { opacity: 1; transform: none; }
.moment-halo { position: absolute; inset: -75px; pointer-events: none; }
.moment-halo i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--accent-dim); animation: halo 2.4s var(--ease) infinite; }
.moment-halo i:nth-child(2) { animation-delay: .5s; } .moment-halo i:nth-child(3) { animation-delay: 1s; }
@keyframes halo { 0% { transform: scale(.55); opacity: .9; } 100% { transform: scale(1.1); opacity: 0; } }
.moment-cat { position: relative; display: grid; place-items: center; width: 170px; height: 170px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 8px var(--warn-dim); }
.moment-text { display: flex; flex-direction: column; gap: 6px; position: relative; }
.eyebrow { font-size: var(--t-xs); font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--warn); }
.moment-h { font-size: 40px; font-weight: 600; letter-spacing: -.8px; line-height: 1.05; }
.moment-sub { font-size: var(--t-md); color: var(--text-dim); max-width: 300px; margin: 0 auto; }
.moment .btn { max-width: 340px; position: relative; }

/* Narrow phones (320 px): smaller rings and greeting so the legend and the XP pill still fit. */
@media (max-width: 359px) {
  .rings-card { gap: var(--s-3); padding: var(--s-3); }
  .rings-card > svg { width: 104px; height: 104px; flex: 0 0 auto; }
  .home-greet { font-size: var(--t-md); }
  .home-head .pill { display: none; }
}
