/* Deutschweg — warm and calm: gold, peach, beige, light brown. Large, legible, few things per screen. */

@font-face {
  font-family: "Atkinson Next";
  src: url("/fonts/atkinson-next-latin.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
  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 Next";
  src: url("/fonts/atkinson-next-latin-ext.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, 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;
}

:root {
  --bg: oklch(95.6% 0.022 76);
  --glow-peach: oklch(89% 0.07 52 / 0.7);
  --glow-gold: oklch(90% 0.085 85 / 0.75);
  --glow-brown: oklch(84% 0.045 62 / 0.45);
  --surface: oklch(98.7% 0.012 80);
  --glass: oklch(98.9% 0.012 80 / 0.74);
  --sunken: oklch(92.8% 0.024 74);
  --ink: oklch(27% 0.035 50);
  --ink-2: oklch(45% 0.04 55);
  --line: oklch(85% 0.032 72);
  --line-gold: oklch(80% 0.07 78);
  --gold: oklch(79% 0.125 82);
  --gold-deep: oklch(69% 0.13 70);
  --accent: oklch(47% 0.1 58);
  --accent-ink: oklch(25% 0.045 50);
  --accent-soft: oklch(92% 0.05 80);
  --right: oklch(50% 0.1 140);
  --right-soft: oklch(93% 0.04 125);
  --warn: oklch(52% 0.14 38);
  --warn-soft: oklch(93.5% 0.045 52);
  --der: oklch(47% 0.11 245);
  --die: oklch(51% 0.15 15);
  --das: oklch(48% 0.1 150);
  --focus: oklch(60% 0.14 65);
  --subs-bg: oklch(12% 0.03 50 / 0.30);
  --subs-ink: oklch(100% 0 0);
  --on-strong: oklch(98% 0.01 80);
  --radius: 20px;
  --shadow: 0 1px 2px oklch(35% 0.05 55 / 0.06), 0 12px 32px oklch(40% 0.06 60 / 0.10);
  --shadow-lift: 0 2px 4px oklch(35% 0.05 55 / 0.08), 0 18px 44px oklch(40% 0.07 60 / 0.16);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(16% 0.04 310);
    --glow-peach: oklch(34% 0.10 315 / 0.42);
    --glow-gold: oklch(48% 0.11 78 / 0.32);
    --glow-brown: oklch(29% 0.07 288 / 0.48);
    --surface: oklch(21% 0.045 307);
    --glass: oklch(23% 0.05 305 / 0.76);
    --sunken: oklch(13.5% 0.035 310);
    --ink: oklch(95% 0.018 82);
    --ink-2: oklch(80% 0.035 78);
    --line: oklch(34% 0.055 300);
    --line-gold: oklch(57% 0.10 76);
    --gold: oklch(80% 0.12 82);
    --gold-deep: oklch(71% 0.13 72);
    --accent: oklch(83% 0.11 80);
    --accent-ink: oklch(22% 0.035 50);
    --accent-soft: oklch(29% 0.07 310);
    --subs-bg: oklch(4% 0.02 50 / 0.30);
    --subs-ink: oklch(98% 0.01 85);
    --on-strong: oklch(22% 0.035 50);
    --right: oklch(80% 0.1 135);
    --right-soft: oklch(30% 0.045 135);
    --warn: oklch(78% 0.12 52);
    --warn-soft: oklch(31% 0.05 45);
    --der: oklch(78% 0.09 245);
    --die: oklch(79% 0.1 15);
    --das: oklch(80% 0.09 150);
    --focus: oklch(80% 0.12 80);
    --shadow: 0 1px 2px oklch(0% 0 0 / 0.3), 0 12px 32px oklch(0% 0 0 / 0.3);
    --shadow-lift: 0 2px 4px oklch(0% 0 0 / 0.35), 0 18px 44px oklch(0% 0 0 / 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: oklch(16% 0.04 310);
  --glow-peach: oklch(34% 0.10 315 / 0.42);
  --glow-gold: oklch(48% 0.11 78 / 0.32);
  --glow-brown: oklch(29% 0.07 288 / 0.48);
  --surface: oklch(21% 0.045 307);
  --glass: oklch(23% 0.05 305 / 0.76);
  --sunken: oklch(13.5% 0.035 310);
  --ink: oklch(95% 0.018 82);
  --ink-2: oklch(80% 0.035 78);
  --line: oklch(34% 0.055 300);
  --line-gold: oklch(57% 0.10 76);
  --gold: oklch(80% 0.12 82);
  --gold-deep: oklch(71% 0.13 72);
  --accent: oklch(83% 0.11 80);
  --accent-ink: oklch(22% 0.035 50);
  --accent-soft: oklch(29% 0.07 310);
  --subs-bg: oklch(4% 0.02 50 / 0.30);
  --subs-ink: oklch(98% 0.01 85);
  --on-strong: oklch(22% 0.035 50);
  --right: oklch(80% 0.1 135);
  --right-soft: oklch(30% 0.045 135);
  --warn: oklch(78% 0.12 52);
  --warn-soft: oklch(31% 0.05 45);
  --der: oklch(78% 0.09 245);
  --die: oklch(79% 0.1 15);
  --das: oklch(80% 0.09 150);
  --focus: oklch(80% 0.12 80);
  --shadow: 0 1px 2px oklch(0% 0 0 / 0.3), 0 12px 32px oklch(0% 0 0 / 0.3);
  --shadow-lift: 0 2px 4px oklch(0% 0 0 / 0.35), 0 18px 44px oklch(0% 0 0 / 0.4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 112.5%;
  -webkit-text-size-adjust: 100%;
  /* Ambient light: soft peach, gold and light-brown glows on warm beige. */
  background:
    radial-gradient(60rem 40rem at 8% -10%, var(--glow-peach), transparent 70%),
    radial-gradient(55rem 38rem at 100% 0%, var(--glow-gold), transparent 70%),
    radial-gradient(70rem 50rem at 50% 115%, var(--glow-brown), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100%;
}
body {
  margin: 0;
  background: transparent;
  color: var(--ink);
  font-family: "Atkinson Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  min-height: 100dvh;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; font-weight: 750; letter-spacing: -0.012em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.3rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 0.9rem; }
.noscript { padding: 2rem; }
.label { display: block; font-weight: 650; margin: 0 0 6px; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 4px 1rem; flex-wrap: wrap;
  padding: 14px max(18px, env(safe-area-inset-left)) 14px max(18px, env(safe-area-inset-right));
  border-bottom: 1px solid color-mix(in oklch, var(--line-gold) 45%, transparent);
  background: color-mix(in oklch, var(--bg) 70%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; font-size: 1.18rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 10px; }
.brand::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--gold), var(--gold-deep));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--gold) 25%, transparent);
}
.topnav { display: flex; gap: 1.2rem; align-items: center; }
@media (max-width: 420px) { .topnav { gap: 0.9rem; } .topnav a, .topnav .linklike { font-size: 0.9rem; } }
.topnav a, .linklike {
  color: var(--ink-2); text-decoration: none; font: inherit; font-size: 0.95rem;
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
}
.topnav a:hover, .linklike:hover { color: var(--ink); text-decoration: underline; }
.notification-center { position: relative; display: inline-flex; }
.notification-bell {
  position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px;
  padding: 0; border: 1px solid var(--line); border-radius: 13px; color: var(--ink-2);
  background: color-mix(in oklch, var(--surface) 82%, transparent); cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.1s ease;
}
.notification-bell:hover, .notification-bell[aria-expanded="true"] { color: var(--gold-deep); border-color: var(--line-gold); background: var(--accent-soft); }
.notification-bell:active { transform: translateY(1px) scale(0.98); }
.notification-bell-icon { width: 22px; height: 22px; }
.notification-badge {
  position: absolute; top: -6px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px;
  border: 2px solid var(--bg); border-radius: 10px; background: var(--gold-deep); color: var(--accent-ink);
  font-size: 0.7rem; font-weight: 850; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums;
}
.notification-panel {
  position: absolute; top: calc(100% + 11px); right: -88px; width: min(25rem, calc(100vw - 24px));
  max-height: min(34rem, calc(100dvh - 90px)); overflow: hidden; z-index: 30;
  border: 1px solid var(--line-gold); border-radius: 18px; background: var(--surface);
  box-shadow: 0 22px 60px color-mix(in oklch, var(--ink) 24%, transparent);
}
.notification-panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 17px 18px 13px; border-bottom: 1px solid var(--line); }
.notification-panel > header strong { font-size: 1.04rem; }
.notification-panel > header span { color: var(--ink-2); font-size: 0.82rem; white-space: nowrap; }
.notification-list { max-height: min(28rem, calc(100dvh - 155px)); overflow-y: auto; padding: 6px; }
.notification-item {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; width: 100%;
  padding: 12px 13px 13px 17px; border: 0; border-radius: 12px; background: transparent;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: background 0.18s ease, transform 0.1s ease;
}
.notification-item:hover { background: var(--accent-soft); }
.notification-item:active { transform: scale(0.99); }
.notification-item.unread::before { content: ""; position: absolute; left: 6px; top: 18px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold-deep); }
.notification-item strong { font-size: 0.94rem; line-height: 1.25; }
.notification-kind { width: max-content; color: var(--gold-deep); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; }
.notification-kind.exam_fail, .notification-kind.ai_error, .notification-kind.bug { color: var(--warn); }
.notification-message { color: var(--ink-2); font-size: 0.86rem; line-height: 1.35; overflow-wrap: anywhere; }
.notification-meta { color: var(--ink-2); font-size: 0.73rem; margin-top: 2px; }
.notification-empty { margin: 0; padding: 26px 18px; color: var(--ink-2); text-align: center; }
@media (max-width: 620px) {
  .notification-panel { position: fixed; top: 66px; left: 12px; right: 12px; width: auto; }
}
.viewing-banner { background: var(--warn-soft); color: var(--ink); text-align: center; padding: 8px 16px; font-size: 0.9rem; }

main { padding: 30px 16px 150px; outline: none; }
.wrap { max-width: 44rem; margin: 0 auto; }
.wrap-wide { max-width: 72rem; margin: 0 auto; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 56px; padding: 0 1.6em;
  border-radius: 16px; border: 1px solid color-mix(in oklch, var(--gold-deep) 70%, black 5%);
  font: inherit; font-size: 1.08rem; font-weight: 750;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: var(--accent-ink);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.45), 0 6px 16px oklch(55% 0.1 65 / 0.22);
  cursor: pointer; text-decoration: none;
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { filter: brightness(1.04) saturate(1.05); box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.5), 0 8px 22px oklch(55% 0.1 65 / 0.3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }
.btn.secondary {
  background: var(--glass); color: var(--ink); border-color: var(--line-gold);
  box-shadow: none; backdrop-filter: blur(8px);
}
.btn.secondary:hover { background: var(--surface); border-color: var(--gold-deep); filter: none; }
.btn.quiet { background: transparent; color: var(--accent); border-color: transparent; box-shadow: none; padding: 0 0.8em; }
.btn.quiet:hover { background: var(--accent-soft); filter: none; }
.btn.small { min-height: 44px; font-size: 0.95rem; padding: 0 1em; border-radius: 13px; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 1.4rem; align-items: center; }
.actions.end { justify-content: flex-end; }
.actions.split { justify-content: space-between; }
.actions + h2 { margin-top: 2.2rem; }
.ico { display: inline-flex; width: 1.25em; height: 1.25em; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ---- Panels ---- */
.panel {
  background: var(--glass);
  border: 1px solid color-mix(in oklch, var(--line-gold) 55%, transparent);
  border-radius: var(--radius);
  padding: clamp(22px, 3.5vw, 34px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
}
.panel + .panel { margin-top: 20px; }
.panel.accent { border-color: var(--line-gold); box-shadow: var(--shadow-lift); position: relative; overflow: hidden; }
.panel.accent::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-deep), color-mix(in oklch, var(--gold) 40%, oklch(80% 0.07 45)));
}

/* Quick taps on buttons and tiles never zoom the page on a phone (double-tap zoom). */
button, a, .option, .tile, .mic, label.check { touch-action: manipulation; }

/* ---- Forms ---- */
label { display: block; font-weight: 650; margin: 0 0 6px; }
.field { margin-bottom: 18px; }
.field .hint { font-weight: 400; color: var(--ink-2); font-size: 0.9rem; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
  width: 100%; font: inherit; font-size: 1.05rem; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 13px;
  padding: 12px 14px; min-height: 52px;
}
textarea { min-height: 220px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold-deep); outline: none; box-shadow: 0 0 0 4px color-mix(in oklch, var(--gold) 25%, transparent); }
input[type="range"] { width: 100%; accent-color: var(--gold-deep); }
.error { color: var(--warn); font-weight: 650; margin: 0.6em 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; cursor: pointer; margin-bottom: 8px; }
.check input { width: 22px; height: 22px; accent-color: var(--gold-deep); flex: none; }

/* ---- Login ---- */
.login { max-width: 27rem; margin: 5vh auto 0; text-align: left; }
.login h1 { margin-bottom: 0.3em; }
.login-portrait { width: 112px; height: 112px; border-radius: 50%; overflow: hidden; margin: 6px 0 18px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--gold), var(--shadow); }
.login-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; transform: scale(1.35); transform-origin: 52% 40%; }
.login-role {
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 2px 0 18px; padding: 5px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--sunken);
}
.login-role button {
  min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent;
  color: var(--ink-2); font: inherit; font-weight: 720; cursor: pointer;
}
.login-role button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.login-role button:hover { color: var(--ink); }
.lang-switch { display: flex; gap: 6px; justify-content: flex-end; margin: -8px -8px 4px 0; }
.lang-switch button {
  font: inherit; font-size: 0.9rem; padding: 6px 12px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
}
.lang-switch button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---- Home ---- */
.hello h1 { margin-bottom: 0.2em; }
.hello p { color: var(--ink-2); font-size: 1.05rem; }
.next-step h2 { margin-bottom: 0.3em; }
.next-step .meta { color: var(--ink-2); margin-bottom: 1rem; }
.path { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.path-title { font-size: 1.1rem; color: var(--ink-2); font-weight: 650; margin: 2.4rem 0 0.6rem; }
.path li {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center;
  padding: 14px 4px; border-bottom: 1px solid color-mix(in oklch, var(--line-gold) 45%, transparent);
}
.path li:last-child { border-bottom: 0; }
.path .dot {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 0.95rem; border: 2px solid var(--line); color: var(--ink-2);
}
.path .passed .dot { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); border-color: var(--gold-deep); color: var(--accent-ink); }
.path .open .dot { border-color: var(--gold-deep); color: var(--accent); }
.path .locked { color: var(--ink-2); }
.path .skipped .dot { border-style: dashed; }
.path .skipped .name { font-weight: 500; color: var(--ink-2); }
.path .dot .ico { width: 18px; height: 18px; }
.path .name { font-weight: 650; }
.path .locked .name { font-weight: 400; }
.path .score { color: var(--ink-2); font-size: 0.95rem; }
.week { margin-top: 2rem; color: var(--ink-2); }
.bar { height: 10px; background: var(--sunken); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-deep)); border-radius: 99px; }

/* ---- Classroom ---- */
.room { display: grid; gap: 24px; max-width: 74rem; margin: 0 auto; }
@media (min-width: 900px) {
  .room { grid-template-columns: 320px 1fr; align-items: start; gap: 40px; }
  .teacher-col { position: sticky; top: 86px; }
}
.teacher-col { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
@media (max-width: 899px) {
  .teacher-col { flex-direction: row; align-items: flex-start; }
  .teacher-col .teacher-wrap { width: 200px; flex: none; }
}
@media (max-width: 599px) {
  .teacher-col .teacher-wrap { width: 132px; }
  .bubble { font-size: 0.98rem; }
}
.teacher-wrap { width: 100%; }

/* The portrait: the teacher's picture, animated by face.js. */
.portrait {
  position: relative; aspect-ratio: 782 / 792; border-radius: 24px; overflow: hidden;
  background: var(--sunken);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--gold) 55%, transparent), var(--shadow-lift);
  transition: box-shadow 0.4s ease;
}
.portrait::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px oklch(100% 0 0 / 0.18), inset 0 -40px 60px -30px oklch(30% 0.05 50 / 0.25);
}
.portrait-face, .portrait-face img, .portrait-face canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.portrait-face canvas { opacity: 0; transition: opacity 0.3s ease; }
.portrait-face canvas.on { opacity: 1; }
.portrait[data-state="listening"] { box-shadow: 0 0 0 3px var(--gold), 0 0 0 9px color-mix(in oklch, var(--gold) 22%, transparent), var(--shadow-lift); animation: listenGlow 1.8s ease-in-out infinite; }
.portrait[data-state="happy"] { box-shadow: 0 0 0 2px color-mix(in oklch, var(--right) 60%, var(--gold)), var(--shadow-lift); }
.portrait[data-state="thinking"] { box-shadow: 0 0 0 2px color-mix(in oklch, var(--gold) 70%, transparent), var(--shadow-lift); }
@keyframes listenGlow { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 0 14px color-mix(in oklch, var(--gold) 10%, transparent), var(--shadow-lift); } }

.bubble {
  position: relative; background: var(--glass); border: 1px solid color-mix(in oklch, var(--line-gold) 55%, transparent);
  border-radius: 18px; padding: 14px 16px; font-size: 1.05rem; width: 100%; box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.bubble:empty { display: none; }
.bubble .who { display: block; font-size: 0.82rem; color: var(--accent); font-weight: 750; margin-bottom: 2px; letter-spacing: 0.01em; }
.bubble .help { display: block; color: var(--ink-2); font-size: 0.95rem; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.teacher-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
@media (max-width: 899px) { .teacher-controls { justify-content: flex-start; gap: 4px; } .teacher-controls .btn { padding: 0 0.5em; } }
.teacher-side { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 0; width: 100%; }

.stage { min-width: 0; }
.stage h1 { font-size: clamp(1.5rem, 3.4vw, 2.05rem); }
.stage-context-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 10px; }
.course-context {
  width: fit-content; margin: 0; padding: 7px 13px; border: 1px solid var(--line-gold);
  border-radius: 999px; background: var(--surface); color: var(--accent); font-size: 0.9rem; font-weight: 800;
  line-height: 1.2; box-shadow: 0 4px 14px oklch(30% 0.04 55 / 0.08);
}
.rail { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.rail button {
  font: inherit; font-size: 0.9rem; padding: 7px 13px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--glass); color: var(--ink-2); cursor: pointer;
}
.rail button.done { border-color: var(--line-gold); color: var(--accent); }
.rail button.done::before { content: "✓ "; }
.rail button.current { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.step-count { color: var(--ink-2); font-size: 0.95rem; margin-bottom: 8px; }

/* ---- Subtitles: fixed at the bottom, one whole sentence at a time ---- */
.subtitles {
  position: fixed; left: 50%; bottom: max(6px, env(safe-area-inset-bottom)); transform: translate(-50%, 6px);
  width: max-content; max-width: min(68rem, calc(100% - 32px));
  background: var(--subs-bg); color: var(--subs-ink);
  padding: 9px 18px; border: 1px solid oklch(100% 0 0 / 0.18); border-radius: 14px; font-size: clamp(1rem, 1.7vw, 1.22rem); line-height: 1.3; text-align: center;
  box-shadow: 0 5px 18px oklch(10% 0.03 50 / 0.12); backdrop-filter: none; -webkit-backdrop-filter: none;
  font-weight: 750;
  text-shadow: 0 1px 2px oklch(0% 0 0 / 0.95), 0 2px 8px oklch(0% 0 0 / 0.7);
  opacity: 0; pointer-events: none; z-index: 40; transition: opacity 0.2s ease, transform 0.2s ease;
  box-sizing: border-box;
}
.subtitles.on { opacity: 1; transform: translate(-50%, 0); }
:root[data-theme="dark"] .subtitles {
  text-shadow: 0 1px 2px #000, 0 2px 8px oklch(0% 0 0 / 0.95);
}

/* ---- Word card ---- */
.word-card { text-align: center; padding: 38px 20px; }
.word-card .vocab-photo {
  width: min(100%, 31rem);
  aspect-ratio: 3 / 2;
  margin: 0 auto 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background-repeat: no-repeat;
  background-size: 300% 200%;
  box-shadow: 0 8px 24px oklch(35% 0.05 55 / 0.12);
}
.word-card .word { font-size: clamp(2rem, 6vw, 2.9rem); font-weight: 800; letter-spacing: -0.01em; margin-bottom: 4px; }
.word-card .forms { color: var(--ink-2); font-size: 1.05rem; }
.word-card .help-t { font-size: 1.15rem; margin-top: 14px; color: var(--accent); font-weight: 650; }
.word-card .example { margin-top: 18px; font-size: 1.15rem; }
.word-card .lbl { color: var(--ink-2); font-weight: 500; font-size: 0.9em; margin-right: 0.4em; }
.art-der { color: var(--der); } .art-die { color: var(--die); } .art-das { color: var(--das); }

/* ---- Exercises ---- */
.q { font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 650; line-height: 1.4; margin: 0 0 20px; }
.q .gap-input {
  display: inline-block; width: 8.5em; min-height: 0; padding: 4px 10px; font-size: inherit;
  border-width: 0 0 3px; border-color: var(--gold-deep); border-radius: 8px 8px 0 0; background: var(--sunken); text-align: center; box-shadow: none;
}
.q .hint-t { display: block; font-size: 1rem; font-weight: 400; color: var(--ink-2); margin-top: 8px; }
/* Translations of questions, tasks and explanations: a small button, then a calm line in the help language. */
.tr-wrap { margin: -4px 0 12px; }
.tr-wrap .tr-toggle { font-size: 0.9rem; padding: 6px 0; min-height: 32px; }
.tr-line { color: var(--ink-2); font-size: 1rem; line-height: 1.45; margin-top: 4px; }
.tr-line > div + div { margin-top: 2px; }
.tr-line > div { white-space: pre-line; } /* translated answer options come on their own lines */
.feedback .tr-line, .review-list .tr-line { font-size: 0.95rem; }
.word-card .example .tr-wrap { margin: 6px 0 0; }
.options { display: grid; gap: 12px; }
.option {
  text-align: left; font: inherit; font-size: 1.15rem; padding: 16px 18px; min-height: 62px;
  border-radius: 16px; border: 1.5px solid var(--line); background: var(--glass); color: var(--ink); cursor: pointer;
  display: flex; align-items: center; gap: 14px; transition: border-color 0.15s, background-color 0.15s;
}
.option:hover { border-color: var(--line-gold); background: var(--surface); }
.option .key {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--sunken); color: var(--ink-2); font-size: 0.9rem; font-weight: 700;
}
.option[aria-pressed="true"] { border-color: var(--gold-deep); background: var(--accent-soft); }
.option[aria-pressed="true"] .key { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: var(--accent-ink); }
.option.is-right { border-color: var(--right); background: var(--right-soft); }
.option.is-wrong { border-color: var(--warn); background: var(--warn-soft); }
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-row .option { justify-content: center; }
.order-line {
  min-height: 66px; border: 1.5px dashed var(--line-gold); border-radius: 16px; padding: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; background: var(--glass);
}
.order-line:empty::before { content: attr(data-empty); color: var(--ink-2); font-size: 0.95rem; padding: 0 6px; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile {
  font: inherit; font-size: 1.15rem; padding: 10px 16px; border-radius: 13px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
}
.tile.used { visibility: hidden; }
.passage {
  background: var(--glass); border: 1px solid color-mix(in oklch, var(--line-gold) 50%, transparent); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 20px; white-space: pre-line; font-size: 1.08rem; line-height: 1.7;
  max-height: 46vh; overflow: auto;
}
.passage.long { max-height: none; font-size: 1.12rem; }
.audio-btn { margin-bottom: 20px; }
.umlauts { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.umlauts button {
  font: inherit; font-size: 1.05rem; min-width: 44px; min-height: 44px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--glass); color: var(--ink); cursor: pointer;
}
.feedback { margin-top: 20px; border-radius: 16px; padding: 16px 18px; font-size: 1.05rem; }
.feedback.right { background: var(--right-soft); }
.feedback.wrong { background: var(--warn-soft); }
.feedback strong { display: block; font-size: 1.15rem; margin-bottom: 4px; }

/* ---- Grammar ---- */
.rule-list { padding-left: 1.2em; }
.rule-list li { margin-bottom: 0.6em; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; margin: 18px 0; font-size: 1.02rem; border: 1px solid var(--line-gold); border-radius: 14px; overflow: hidden; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 11px 13px; text-align: left; background: var(--glass); }
table.grid tr:last-child > * { border-bottom: 0; }
table.grid tr > *:last-child { border-right: 0; }
table.grid th { background: var(--accent-soft); font-weight: 700; }
.table-scroll { overflow-x: auto; }
details.help-box { margin: 14px 0; border: 1px solid color-mix(in oklch, var(--line-gold) 50%, transparent); border-radius: 14px; padding: 12px 16px; background: var(--glass); }
details.help-box summary { cursor: pointer; font-weight: 650; }
details.help-box ul { margin: 10px 0 0; padding-left: 1.2em; }
.example-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.example-row:last-child { border-bottom: 0; }
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 13px; border: 1px solid var(--line-gold);
  background: var(--glass); color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.icon-btn svg { width: 20px; height: 20px; }

/* ---- Speaking ---- */
.say-target { font-size: clamp(1.4rem, 3.4vw, 1.85rem); font-weight: 700; margin: 8px 0 18px; line-height: 1.4; }
.words { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 700; margin: 10px 0 16px; }
.words .w-ok { color: var(--right); }
.words .w-miss { color: var(--warn); text-decoration: underline wavy; text-underline-offset: 6px; }
.mic {
  display: inline-flex; align-items: center; gap: 12px; min-height: 64px; padding: 0 30px; border-radius: 99px;
  font: inherit; font-size: 1.15rem; font-weight: 750; cursor: pointer;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.45), 0 8px 20px oklch(55% 0.1 65 / 0.25);
}
.mic .ico { width: 1.4em; height: 1.4em; }
.mic.recording { background: linear-gradient(180deg, oklch(66% 0.15 40), var(--warn)); border-color: var(--warn); color: var(--on-strong); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--warn) 45%, transparent); } 50% { box-shadow: 0 0 0 12px transparent; } }
.heard { margin-top: 16px; color: var(--ink-2); font-size: 1.05rem; }
.heard b { color: var(--ink); }
.errors { list-style: none; padding: 0; margin: 12px 0 0; }
.errors li { padding: 10px 0; border-top: 1px solid var(--line); }
.errors .wr { text-decoration: line-through; color: var(--warn); }
.errors .rt { color: var(--right); font-weight: 700; }
.errors .rule-help { color: var(--ink-2); font-size: 0.95rem; }
.corrected { font-size: 1.3rem; font-weight: 700; margin: 12px 0; }

/* ---- Writing ---- */
.points { padding-left: 1.2em; }
.points li { margin-bottom: 0.4em; }
.points .tr { display: block; color: var(--ink-2); font-size: 0.92rem; }
.wordcount { color: var(--ink-2); font-size: 0.95rem; margin-top: 6px; }
.model { white-space: pre-line; }

/* ---- Results ---- */
.big-score { font-size: clamp(3rem, 10vw, 4.6rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1; margin: 8px 0 6px; }
.big-score.ok { color: var(--right); }
.big-score.no { color: var(--warn); }
.review-list { list-style: none; padding: 0; margin: 1.4rem 0 0; }
.review-list li { padding: 14px 0; border-top: 1px solid var(--line); }
.review-list .rq { font-weight: 650; }
.review-list .ra { margin-top: 4px; }
.mark-ok { color: var(--right); font-weight: 750; }
.mark-no { color: var(--warn); font-weight: 750; }
.skill-row { display: grid; grid-template-columns: 8rem 1fr 3.2rem; gap: 12px; align-items: center; margin: 10px 0; }
.skill-row .bar { margin: 0; }
.level-badge {
  display: inline-block; font-size: 2.6rem; font-weight: 800; padding: 8px 24px; border-radius: 18px;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: var(--accent-ink); margin: 6px 0 12px;
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.45), var(--shadow);
}

/* ---- Costs ---- */
.cost-list { list-style: none; padding: 0; margin: 0; }
.cost-list li { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.cost-list li:last-child { border-bottom: 0; }
.cost-list .price { font-weight: 700; white-space: nowrap; }
.cost-list .what { font-weight: 650; }
.cost-list .detail { color: var(--ink-2); font-size: 0.95rem; }
@media (max-width: 520px) { .cost-list li { grid-template-columns: 1fr; gap: 4px; } }
.free-list { padding-left: 1.2em; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 10px; } }

/* ---- Dialog + toast ---- */
dialog.confirm {
  border: 1px solid var(--line-gold); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  padding: 28px; max-width: 30rem; width: calc(100% - 32px); box-shadow: var(--shadow-lift);
}
dialog.confirm::backdrop { background: oklch(25% 0.03 50 / 0.45); backdrop-filter: blur(2px); }
.learner-footer {
  position: sticky; bottom: 0; z-index: 35; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end; gap: 12px; padding: 7px max(12px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid color-mix(in oklch, var(--line-gold) 45%, transparent);
  background: color-mix(in oklch, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.learner-footer::after { content: ""; width: 1px; }
.feedback-dock { display: flex; gap: 7px; flex-wrap: wrap; }
.feedback-dock button {
  min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink-2); font: inherit; font-size: 0.8rem; font-weight: 650; cursor: pointer;
}
.feedback-dock button:hover { color: var(--ink); border-color: var(--line-gold); }
dialog.report-dialog {
  width: min(36rem, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  border: 1px solid var(--line-gold); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  padding: 26px; box-shadow: var(--shadow-lift);
}
dialog.report-dialog::backdrop { background: oklch(16% 0.04 310 / 0.58); backdrop-filter: blur(3px); }
dialog.report-dialog textarea { min-height: 150px; }
.feedback-preview { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 12px; margin-top: 10px; color: var(--ink-2); font-size: 0.9rem; }
.feedback-preview img { width: 96px; max-height: 72px; object-fit: cover; border: 1px solid var(--line); border-radius: 10px; }
.admin-feedback-list { display: grid; gap: 12px; }
.admin-feedback-item { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.admin-feedback-item p { white-space: pre-wrap; margin: 8px 0; }
.admin-feedback-meta { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--ink-2); font-size: 0.88rem; }
.feedback-screenshot { display: block; max-width: 100%; max-height: 70dvh; margin: 12px auto; border-radius: 12px; border: 1px solid var(--line); }
.toast {
  position: fixed; left: 50%; top: 84px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 14px; font-size: 0.98rem;
  max-width: calc(100% - 32px); box-shadow: var(--shadow-lift);
}

@media (prefers-reduced-motion: reduce) {
  .btn, .portrait, .subtitles { transition: none !important; }
  .mic.recording, .portrait[data-state="listening"] { animation: none; }
}

/* ---- Admin ---- */
.admin main { padding-top: 20px; }
.admin .tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.admin .tabs button {
  font: inherit; font-size: 1rem; padding: 10px 14px; border: 0; background: none; color: var(--ink-2); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.admin .tabs button.on { color: var(--ink); border-bottom-color: var(--gold-deep); font-weight: 700; }
.admin table.data { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.admin table.data th, .admin table.data td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin table.data th { color: var(--ink-2); font-weight: 650; background: var(--bg); position: sticky; top: 0; }
.admin table.data tr.click { cursor: pointer; }
.admin table.data tr.click:hover td { background: var(--glass); }
.admin .form-grid { display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.admin .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin .row-actions button { font: inherit; font-size: 0.85rem; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.admin .row-actions button:hover { border-color: var(--gold-deep); }
.admin .pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 0.85rem; background: var(--sunken); }
.admin .pill.passed { background: var(--right-soft); color: var(--right); }
.admin .pill.open { background: var(--accent-soft); }
.admin section + section { margin-top: 34px; }
.admin pre { white-space: pre-wrap; background: var(--sunken); padding: 12px; border-radius: 10px; font-size: 0.85rem; max-height: 420px; overflow: auto; }
.admin .scroll-x { overflow-x: auto; }
.admin-fold {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in oklch, var(--surface) 82%, transparent);
  overflow: clip;
}
.admin-fold > summary,
.admin-settings-group > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 24px;
  padding: 17px 20px;
  transition: background 180ms ease, color 180ms ease;
}
.admin-fold > summary::-webkit-details-marker,
.admin-settings-group > summary::-webkit-details-marker { display: none; }
.admin-fold > summary::after,
.admin-settings-group > summary::after {
  content: "+";
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--sunken);
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 700;
}
.admin-fold[open] > summary::after,
.admin-settings-group[open] > summary::after { content: "−"; }
.admin-fold > summary:hover,
.admin-settings-group > summary:hover { background: var(--accent-soft); }
.admin-fold > summary:focus-visible,
.admin-settings-group > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.admin-fold-title { font-weight: 750; font-size: 1.08rem; letter-spacing: -0.01em; }
.admin-fold-meta { color: var(--ink-2); font-size: 0.9rem; grid-column: 1; }
.admin-fold-body { padding: 6px 20px 22px; border-top: 1px solid var(--line); }
.admin-fold.danger > summary { color: var(--warn); }
.admin-settings { padding: 0; box-shadow: none; border: 0; background: transparent; }
.admin-settings .settings-intro { margin: 12px 2px 16px; max-width: 62ch; }
.admin-settings-group {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.admin-settings-group:last-of-type { border-bottom: 1px solid var(--line); }
.admin-settings-group > summary { padding: 15px 16px; }
.admin-settings-body { padding: 4px 16px 20px; }
.admin-settings-body .form-grid { margin-top: 0; }
.admin-settings .actions { padding: 4px 2px 0; }
.admin .check-stack { display: grid; gap: 10px; margin: 10px 0 4px; }
.admin .group-note { color: var(--ink-2); max-width: 70ch; margin: 8px 0 14px; }
@media (max-width: 620px) {
  .admin-fold > summary, .admin-settings-group > summary { padding: 14px; gap: 6px 12px; }
  .admin-fold-body, .admin-settings-body { padding-left: 14px; padding-right: 14px; }
  .admin-fold-meta { font-size: 0.84rem; }
}

.bubble .tr-toggle { display: block; margin-top: 6px; font-size: 0.85rem; padding: 2px 0; }
.bubble .said { display: block; }

/* ---- Switches: theme (top bar) and sound (under the teacher) ---- */
.theme-toggle {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-gold); background: var(--glass); color: var(--ink);
}
.theme-toggle .ico { width: 20px; height: 20px; }
.lang-switch .theme-toggle { width: 36px; height: 36px; border-radius: 99px; }
.sound-toggle {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 0.95rem; font-weight: 700;
  padding: 7px 14px; border-radius: 99px; cursor: pointer;
  border: 1.5px solid var(--gold-deep); background: var(--accent-soft); color: var(--ink);
}
.sound-toggle.off { background: transparent; border-color: var(--line); color: var(--ink-2); }
.sound-toggle .ico { width: 18px; height: 18px; }
.motion-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 12px;
  border-radius: 999px; border: 1.5px solid var(--line); background: transparent; color: var(--ink-2);
  font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
}
.switch-track { position: relative; width: 34px; height: 20px; flex: none; border-radius: 999px; background: var(--line); transition: background-color 0.2s ease; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 4px oklch(20% 0.03 50 / 0.35); transition: transform 0.2s ease; }
.motion-toggle[aria-pressed="true"] { border-color: var(--gold-deep); color: var(--ink); background: var(--accent-soft); }
.motion-toggle[aria-pressed="true"] .switch-track { background: var(--gold-deep); }
.motion-toggle[aria-pressed="true"] .switch-knob { transform: translateX(14px); }
:root[data-teacher-motion="off"] .portrait-face canvas { opacity: 0 !important; }
:root[data-teacher-motion="off"] .portrait { animation: none !important; transition: none !important; }

.two-col { display: grid; gap: 22px; }
@media (min-width: 1100px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }
.review-box { margin-top: 1.4rem; }
.review-box[open] .review-list { max-height: 50vh; overflow: auto; }

/* ---- One screen classroom ----
   The subtitle is a real final grid row. It therefore cannot cover the exercise,
   regardless of zoom, viewport width, translated text length or header height. */
:root { --topbar-h: 69px; }
body.in-room {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body.in-room .topbar { position: relative; top: auto; }
body.in-room main {
  height: auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
body.in-room main::-webkit-scrollbar { display: none; }
body.in-room .subtitles {
  position: static;
  left: auto;
  bottom: auto;
  justify-self: center;
  transform: translateY(6px);
  margin: 5px 16px max(6px, env(safe-area-inset-bottom));
}
body.in-room .subtitles.on { transform: none; }
body.in-room.teacher-hidden .teacher-col { display: none; }
body.in-room.teacher-hidden .room { max-width: none; width: 100%; }
@media (min-width: 900px) and (min-height: 560px) {
  body.in-room main { height: auto; overflow: hidden; padding: 10px 24px 0; }
  body.in-room .room {
    height: 100%;
    grid-template-columns: clamp(240px, 24vw, 320px) 1fr; gap: 30px; align-items: stretch;
  }
  body.in-room.teacher-hidden .room { grid-template-columns: minmax(0, 1fr); }
  body.in-room .teacher-col { position: static; height: 100%; min-height: 0; flex-direction: column; gap: 10px; }
  body.in-room .teacher-wrap { flex: none; width: 100%; max-width: min(100%, 42vh); margin: 0 auto; }
  body.in-room .teacher-side { flex: 1 1 auto; min-height: 0; }
  body.in-room .bubble { flex: 1 1 auto; min-height: 0; overflow: auto; font-size: 1rem; }
  body.in-room .stage {
    display: flex; flex-direction: column; min-height: 0; height: 100%; padding: 14px 20px 10px;
    border: 1px solid color-mix(in oklch, var(--line-gold) 55%, transparent); border-radius: var(--radius);
    background: var(--glass); box-shadow: var(--shadow); overflow: hidden;
  }
  body.in-room .stage-top { flex: none; }
  body.in-room .stage-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding-right: 0; display: flex; flex-direction: column; scrollbar-width: none; }
  body.in-room .stage-body::-webkit-scrollbar { display: none; }
  body.in-room .stage-body > .actions:last-child {
    position: sticky; bottom: 0; margin-top: auto; padding: 10px 0 6px;
    background: linear-gradient(to bottom, color-mix(in oklch, var(--bg) 0%, transparent), var(--bg) 14px);
  }
  body.in-room .stage-body .feedback, body.in-room .stage-body .words { scroll-margin-bottom: 96px; }
  body.in-room .rail { margin-bottom: 12px; }
  body.in-room .rail button { padding: 5px 11px; font-size: 0.85rem; }
  body.in-room .stage h1 { font-size: clamp(1.35rem, 2.4vw, 1.75rem); margin-bottom: 0.45em; }
  body.in-room .q { font-size: clamp(1.15rem, 2vw, 1.35rem); margin-bottom: 14px; }
  body.in-room .option { min-height: 52px; padding: 11px 16px; font-size: 1.05rem; }
  body.in-room .options { gap: 9px; }
  body.in-room .stage-body:has(> .word-card) { overflow: hidden; }
  body.in-room .word-card { padding: 12px 18px; flex: 1 1 auto; min-height: 0; overflow: hidden; }
  body.in-room .word-card .vocab-photo { width: auto; max-width: min(100%, 42rem); height: min(35dvh, 22rem); aspect-ratio: 3 / 2; margin-bottom: 10px; }
  body.in-room.teacher-hidden .word-card .vocab-photo { height: min(39dvh, 26rem); }
  body.in-room .word-card .word { font-size: clamp(1.8rem, 3.6vw, 2.4rem); }
  body.in-room .word-card .example, body.in-room .word-card .help-t { margin-top: 8px; font-size: 1.05rem; }
  body.in-room .actions { margin-top: 1rem; }
  body.in-room .feedback { margin-top: 12px; padding: 12px 16px; }
  body.in-room .words { margin: 6px 0 8px; font-size: clamp(1.15rem, 2.2vw, 1.4rem); }
  body.in-room .heard { margin-top: 8px; }
  body.in-room .say-target { margin: 4px 0 12px; font-size: clamp(1.3rem, 2.6vw, 1.6rem); }
  body.in-room .mic { min-height: 54px; padding: 0 24px; }
  body.in-room .passage { max-height: none; }
  body.in-room .points li { margin-bottom: 0.2em; }
  body.in-room .points .tr { font-size: 0.85rem; }
  body.in-room textarea { min-height: 150px; }
  body.in-room .panel { padding: 20px 24px; }
}

@media (max-width: 599px) {
  .subtitles { max-width: calc(100% - 24px); padding: 8px 12px; font-size: 0.98rem; line-height: 1.25; }
}

/* Placement: choose where the test begins */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 12px 0 8px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 16px 18px; border-radius: 16px;
  border: 1.5px solid var(--line-gold); background: var(--glass); color: var(--ink); font: inherit; cursor: pointer; min-height: 96px; }
.choice b { font-size: 1.15rem; }
.choice span { color: var(--ink-2); font-size: 0.98rem; line-height: 1.35; }
.choice:hover, .choice:focus-visible { border-color: var(--gold-deep); outline: none; box-shadow: 0 0 0 3px color-mix(in oklch, var(--gold) 35%, transparent); }
.start-decision > .meta { max-width: 62ch; }
.start-options { display: grid; gap: 14px; margin-top: 22px; }
@media (min-width: 760px) { .start-options { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .start-options.three { grid-template-columns: 1fr 1fr 1fr; } }
.level-tests .actions { flex-wrap: wrap; }
.start-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.start-option h3 { margin: 0 0 8px; font-size: 1.25rem; }
.start-option .meta { flex: 1; }
.start-option .actions { width: 100%; }
.placement-scope { margin: 20px 0 4px; box-shadow: none; }
.level-route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.level-route span:nth-child(odd) {
  min-width: 68px;
  padding: 9px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  text-align: center;
  font-weight: 800;
}

/* ---- Rewards ------------------------------------------------------------------------------ */
.reward-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 14px 0; color: var(--ink); text-decoration: none; box-shadow: none; }
.reward-strip:hover { border-color: var(--line-gold); }
.reward-counts { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.02em; }
.reward-icon { font-size: 2rem; line-height: 1; }
.reward-pop {
  position: fixed; right: 16px; bottom: 16px; z-index: 60; width: min(380px, calc(100% - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-gold); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-lift); animation: reward-in 0.35s ease-out;
}
.reward-line { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.reward-line > div { display: flex; flex-direction: column; }
.reward-pop .actions { margin-top: 10px; }
.reward-close { margin-left: auto; }
@keyframes reward-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.reward-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 18px 0; }
.reward-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.reward-tile b { font-size: 1.6rem; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 12px 0 24px; }
.badge-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border: 1px dashed var(--line); border-radius: 16px; background: var(--sunken); color: var(--ink-2); }
.badge-card .reward-icon { filter: grayscale(1); opacity: 0.45; }
.badge-card.earned { border-style: solid; border-color: var(--line-gold); background: var(--surface); color: var(--ink); }
.badge-card.earned .reward-icon { filter: none; opacity: 1; }
.reward-path li { flex-wrap: wrap; }
.class-rewards { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-left: auto; align-items: center; }
.reward-chip { font: inherit; color: var(--ink); }
.reward-chip.missing { filter: grayscale(1); opacity: 0.5; cursor: default; text-decoration: none; }
.share-card { width: 100%; max-width: 320px; border-radius: 16px; border: 1px solid var(--line); display: block; margin: 8px auto 14px; }
.share-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.share-buttons .btn { text-decoration: none; }

/* ---- ⚡ Blitz ------------------------------------------------------------------------------- */
.fire-chip { margin-left: auto; padding: 4px 12px; border-radius: 999px; background: var(--gold); color: var(--accent-ink); font-weight: 700; }
.stage.on-fire { box-shadow: 0 0 0 2px var(--gold), var(--shadow); }
.stage.blitz-flash::after {
  content: "⚡"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 9rem; pointer-events: none;
  animation: blitz 0.9s ease-out forwards;
}
.stage { position: relative; }
@keyframes blitz { 0% { opacity: 0; transform: scale(0.6); } 25% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0; transform: scale(1.3); } }

/* ---- Leaving the test ----------------------------------------------------------------------- */
.away-note { margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  .reward-pop { animation: none; }
  .stage.blitz-flash::after { animation: none; opacity: 0; }
}
.bubble .tr-say { display: inline-block; margin-top: 4px; padding: 2px 6px; font-size: 1.1rem; text-decoration: none; }

/* ---- Layout fixes from the persona tests (12 Oct 2026) ---------------------------------------
   The classroom grid names its rows: the hidden admin banner used to take a row away, so the
   classroom got an unlimited row (taller than the screen) and the subtitles a zero-height row. */
body.in-room > .topbar { grid-row: 1; }
body.in-room > #viewing { grid-row: 2; }
body.in-room > main { grid-row: 3; }
body.in-room > .learner-footer { grid-row: 4; position: static; min-width: 0; }
body.in-room .learner-footer { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
body.in-room .learner-footer .subtitles { grid-column: 2; }
/* Subtitles wrap inside the screen and keep a fixed strip, so the room does not jump when they come and go. */
.subtitles { width: auto; max-width: min(68rem, calc(100vw - 32px)); white-space: normal; overflow-wrap: anywhere; }
body.in-room .subtitles { box-sizing: border-box; min-height: calc(2 * 1.3em + 18px); display: flex; align-items: center; justify-content: center; }
body.in-room .subtitles:not(.on) { visibility: hidden; }
/* Nothing in the classroom may push the page wider than the screen. */
.room, .stage, .stage-body, .teacher-col, .teacher-side, .bubble { min-width: 0; }
.bubble, .stage-body { overflow-wrap: anywhere; }
.table-scroll { max-width: 100%; }
.table-scroll table.grid { min-width: max-content; }
/* Phone: the menu wraps instead of running off the screen; a long speech bubble scrolls instead of filling the screen. */
.topnav { flex-wrap: wrap; justify-content: flex-end; row-gap: 2px; }
@media (max-width: 899px) {
  body.in-room .bubble { max-height: 28vh; overflow-y: auto; }
  body.in-room .room { max-width: 100%; }
}
@media (min-width: 900px) and (min-height: 560px) {
  /* the classroom fills exactly the space between the top bar and the subtitle strip */
  body.in-room main > .view { height: 100%; min-height: 0; }
}
/* Phone: the translation button stays reachable at the bottom of a long, scrolling speech bubble. */
@media (max-width: 899px) {
  body.in-room .bubble .tr-toggle { position: sticky; bottom: -1px; background: var(--surface); padding: 6px 0 2px; margin-top: 4px; }
  body.in-room .bubble { max-height: 22vh; }
}
/* Phone classroom: the lesson must start on the first screen. */
@media (max-width: 599px) {
  .topbar { padding-top: 8px; padding-bottom: 8px; }
  .topnav { gap: 0.25rem 0.75rem; }
  .topnav a, .topnav .linklike { font-size: 0.86rem; padding: 4px 2px; }
  .theme-toggle { width: 36px; height: 36px; }
  body.in-room .rail { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; padding-bottom: 2px; }
  body.in-room .rail::-webkit-scrollbar { display: none; }
  body.in-room .rail button { flex: none; }
  body.in-room .bubble { max-height: 18vh; }
}
@media (max-width: 899px) {
  /* no permanently reserved subtitle strip on small screens: it appears below the lesson only while she speaks */
  body.in-room .subtitles { min-height: 0; }
  body.in-room .subtitles:not(.on) { display: none; }
  body.in-room .learner-footer { grid-template-columns: 1fr; }
  body.in-room .learner-footer .subtitles { grid-column: 1; grid-row: 1; }
  body.in-room .feedback-dock { grid-column: 1; grid-row: 2; justify-content: flex-end; }
}

/* ---- Phones (Oct 2026): the lesson gets the screen ----
   Measured on a 375×667 iPhone: menu, teacher, her buttons and the class row used to fill ~70 % of the
   screen, so the sentence to repeat and the microphone sat below it. Now: a slim top bar, the teacher
   as a small strip (picture · speech bubble · two icon buttons), the next/check buttons always in
   reach at the bottom, and no second copy of her sentence in a subtitle strip. */
@media (max-width: 599px), (max-height: 500px) and (max-width: 1000px) {
  body.in-room .topbar { padding-top: 2px; padding-bottom: 2px; flex-wrap: nowrap; }
  body.in-room .topnav > a, body.in-room #logout { display: none; } /* not needed in a lesson; the name goes home */
  body.in-room .brand { min-height: 44px; display: inline-flex; align-items: center; font-size: 1.05rem; }
  body.in-room main { padding: 8px 12px 0; }
  body.in-room .room { gap: 8px; }
  body.in-room .teacher-col { flex-direction: row; align-items: flex-start; gap: 8px; }
  body.in-room .teacher-col .teacher-wrap { width: 76px; flex: none; }
  body.in-room .portrait { border-radius: 16px; }
  body.in-room .teacher-side { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: row; align-items: flex-start; gap: 6px; }
  body.in-room .bubble { flex: 1 1 auto; width: auto; min-width: 0; max-height: 6.2em; overflow-y: auto; padding: 8px 10px; font-size: 0.95rem; line-height: 1.35; border-radius: 14px; }
  body.in-room .bubble .who { display: none; }
  body.in-room .bubble .tr-toggle { position: static; background: none; padding: 0; margin-top: 0; }
  body.in-room .teacher-controls { flex-direction: column; flex-wrap: nowrap; gap: 6px; flex: none; }
  body.in-room .teacher-controls .btn, body.in-room .teacher-controls .sound-toggle { width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 12px; }
  body.in-room .teacher-controls .lbl-t, body.in-room .motion-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body.in-room .stage-context-row { margin-bottom: 6px; gap: 8px; justify-content: space-between; }
  body.in-room .motion-toggle { min-height: 44px; min-width: 44px; padding: 0 10px; justify-content: center; }
  body.in-room .course-context { font-size: 0.85rem; }
  body.in-room .rail { margin-bottom: 8px; gap: 6px; }
  body.in-room .rail button { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }
  body.in-room .stage h1 { font-size: 1.35rem; margin-bottom: 0.4em; }
  body.in-room .q { font-size: 1.2rem; margin-bottom: 12px; }
  body.in-room .say-target { font-size: 1.3rem; }
  /* her sentence is already in the speech bubble; the strip only returns when the teacher is switched off */
  body.in-room:not(.teacher-hidden) .subtitles { display: none; }
  /* next / check stay at the bottom edge, in thumb reach */
  body.in-room .stage-body > .actions:last-child:not(.no-stick) {
    position: sticky; bottom: 0; z-index: 3; margin-top: 12px; padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, color-mix(in oklch, var(--bg) 0%, transparent), var(--bg) 14px);
    flex-wrap: nowrap;
  }
  body.in-room .stage-body > .actions:last-child:not(.no-stick) .btn { min-width: 0; padding-inline: 14px; }
}
/* Phone on its side: teacher in a narrow column on the left, the lesson on the right. */
@media (max-height: 500px) and (max-width: 1000px) and (orientation: landscape) {
  body.in-room .room { grid-template-columns: 132px minmax(0, 1fr); gap: 14px; align-items: start; }
  body.in-room .teacher-col { flex-direction: column; position: sticky; top: 0; }
  body.in-room .teacher-col .teacher-wrap { width: 96px; }
  body.in-room .teacher-side { flex-direction: column; width: 100%; }
  body.in-room .bubble { max-height: 7.5em; width: 100%; }
  body.in-room .teacher-controls { flex-direction: row; }
}
/* Fingers need about 44 px: menu links, theme switch, language buttons, the class list, translations. */
@media (pointer: coarse), (max-width: 899px) {
  .topnav a, .topnav .linklike { min-height: 44px; display: inline-flex; align-items: center; }
  .theme-toggle, .lang-switch .theme-toggle { width: 44px; height: 44px; }
  .lang-switch button { min-height: 44px; }
  .path a.name { display: inline-flex; align-items: center; min-height: 44px; }
  .tr-wrap .tr-toggle, .bubble .tr-toggle { min-height: 44px; }
  .motion-toggle { min-height: 44px; }
  input[type="range"] { height: 44px; }
  .linklike { min-height: 44px; }
  .brand { min-height: 44px; display: inline-flex; align-items: center; }
  .reward-chip { min-width: 44px; justify-content: center; }
}
/* Phone: short messages appear near the thumb, above the next/check buttons, not over the task text. */
@media (max-width: 599px) {
  .toast { top: auto; bottom: calc(88px + env(safe-area-inset-bottom)); }
}
/* Tablet upright: a smaller picture, so the lesson starts higher. */
@media (min-width: 600px) and (max-width: 899px) {
  body.in-room .teacher-col .teacher-wrap { width: 150px; }
  body.in-room .room { gap: 14px; }
}
/* Phone: the share card with its picture fits one screen (picture shrinks with the screen height). */
@media (max-width: 599px) {
  dialog.confirm { padding: 20px; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .share-card { width: auto; max-width: 100%; max-height: 34dvh; }
  .share-buttons { gap: 8px; }
}
/* Feedback scrolled into view stops above the sticky next/check buttons. */
.feedback, .words, .heard { scroll-margin-bottom: 104px; }
/* Admin on a phone: tables become cards (labels from the column names, see admin.js labelCells). */
@media (max-width: 599px) {
  .scroll-x:has(> table.data) { overflow: visible; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr { border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; background: var(--surface); }
  table.data td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; text-align: right; }
  table.data td::before { content: attr(data-label); color: var(--ink-2); font-weight: 600; text-align: left; flex: none; max-width: 45%; }
  table.data td:not([data-label])::before, table.data td[data-label=""]::before { content: none; }
}
/* Translation of an answer option, under the German option text. */
.option .opt-text { display: flex; flex-direction: column; gap: 2px; }
.option .opt-tr { color: var(--ink-2); font-size: 0.9rem; font-weight: 400; }

/* Admin: one drop-down card per learner. */
.learner-list { display: flex; flex-direction: column; gap: 10px; }
.learner-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.learner-card > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding: 14px 16px; min-height: 44px; }
.learner-card > summary::-webkit-details-marker { display: none; }
.learner-card > summary::before { content: '▸'; color: var(--accent); }
.learner-card[open] > summary::before { content: '▾'; }
.learner-card[open] > summary { border-bottom: 1px solid var(--line); }
.learner-card .lc-name { font-size: 1.05rem; }
.learner-card .lc-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.95rem; color: var(--ink-2); }
.learner-card .learner-detail { padding: 12px 16px 16px; }

/* ---- Learning timer at the top right, and the history behind it ---- */
.learn-timer {
  display: inline-flex; align-items: center; gap: 0.5em; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-gold); border-radius: 99px;
  color: var(--ink); text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.learn-timer:hover { background: var(--accent-soft); }
.lt-clock { font-weight: 750; font-size: 1.1rem; }
.lt-since { color: var(--ink-2); font-size: 0.95rem; }
.learn-timer.paused .lt-clock { color: var(--ink-2); }
.lt-sum { margin-bottom: 1rem; font-size: 1.1rem; }
.lt-sum dd { font-weight: 700; }
.lt-how { margin-top: 14px; }
.lt-day { margin-top: 1.6rem; }
.lt-day h2, .lt-day li { display: flex; justify-content: space-between; gap: 16px; }
.lt-day h2 { font-size: 1.1rem; margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--line-gold); }
.lt-day ul { list-style: none; margin: 0; padding: 0; }
.lt-day li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.lt-day li:last-child { border-bottom: 0; }
.lt-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Under 860 px the menu does not fit beside the name and the timer: name and timer stay on the top row. */
@media (max-width: 859px) {
  .learn-timer { order: 1; margin-left: auto; }
  .topnav { order: 2; width: 100%; }
}
@media (max-width: 599px) {
  .learn-timer { flex-direction: column; justify-content: center; gap: 0; padding: 0 12px; border-radius: 14px; line-height: 1.15; }
  .lt-clock { font-size: 1rem; }
  .lt-since { font-size: 0.8rem; }
}
@media (max-width: 599px), (max-height: 500px) and (max-width: 1000px) {
  body.in-room .topnav { order: 1; width: auto; margin-left: auto; }
  body.in-room .learn-timer { order: 2; margin-left: 0; }
}
@media (max-width: 359px) {
  body.in-room .topbar { padding-left: 10px; padding-right: 10px; gap: 4px 8px; }
  body.in-room .brand::before { display: none; }
}
