/* Deutsch B1 — "Schulheft" design system
   Learner writes in royal-blue ink, the teacher corrects in red, ticks in green.
   Squared paper (Karopapier) for exercises, DIN-style condensed type for headings. */

:root {
  --bg: #F5F7FA;
  --page: #FFFFFF;
  --graphite: #1E2430;
  --graphite-2: #4B5463;
  --graphite-3: #5F6877;
  --line: #DCE3EC;
  --line-strong: #C3CDDA;
  --grid: #E7EDF5;

  --ink: #2341A8;
  --ink-deep: #182F7E;
  --ink-tint: #E9EEFB;
  --red: #D0263A;
  --red-deep: #9E1728;
  --red-tint: #FCEBEC;
  --green: #1B8048;
  --green-deep: #115C33;
  --green-tint: #E3F3E9;
  --marker: #FFE45C;
  --marker-soft: #FFF4AE;

  --der: #1F63B5;
  --die: #B8233F;
  --das: #17774C;
  --verb: #8A4B00;
  --konn: #0B6875;

  --font-display: "DIN Alternate", "DIN Next LT Pro", "DIN 2014", Bahnschrift, "D-DIN", "Roboto Condensed", "sans-serif-condensed", "Arial Narrow", "Liberation Sans Narrow", system-ui, sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;

  --t-xs: 0.8125rem;
  --t-sm: 0.9375rem;
  --t-md: 1rem;
  --t-lg: 1.25rem;
  --t-xl: 1.5625rem;
  --t-2xl: 1.953rem;
  --t-3xl: 2.441rem;

  --nav-h: 64px;
  --radius: 12px;
  --gutter: 16px;
  --paper-grid: linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 20px 20px,
                linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 20px 20px,
                var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--graphite);
  font: 400 var(--t-md)/1.5 var(--font-ui);
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--ink-deep); outline-offset: 2px; }
h1:focus, h2:focus, main:focus { outline: none; }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--graphite); color: #fff; padding: 10px 14px; border-radius: 8px; text-decoration: none; font-weight: 700; }
.skip-link:focus { top: 12px; }

/* ---------- Highlighter (used for <u> emphasis in grammar content) ---------- */
u, mark {
  text-decoration: none;
  color: inherit;
  background: linear-gradient(transparent 52%, var(--marker) 52%, var(--marker) 92%, transparent 92%);
  padding: 0 1px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 0; border-radius: var(--radius);
  font: 700 var(--t-md)/1.1 var(--font-ui);
  text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease;
}
.btn .icon { width: 20px; height: 20px; }
.btn-lg { min-height: 54px; font-size: 1.0625rem; padding: 0 26px; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 4px 0 var(--ink-deep); }
.btn-primary:hover { background: #2A4BBB; }
.btn-secondary { background: var(--page); color: var(--graphite); border: 2px solid var(--line-strong); box-shadow: 0 3px 0 var(--line-strong); }
.btn-secondary:hover { background: #FAFBFD; }
.btn-ok { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-deep); }
.btn-bad { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-deep); }
.btn-danger-outline { background: var(--page); color: var(--red-deep); border: 2px solid #E8B3BA; box-shadow: 0 3px 0 #E8B3BA; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.btn:disabled { background: #E3E8EF; color: #6A7381; box-shadow: 0 4px 0 #CCD4DF; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  background: var(--page); color: var(--graphite);
  border: 2px solid var(--line); border-radius: 50%;
}
.icon-btn:hover { border-color: var(--line-strong); }
.star-btn[aria-pressed="true"] { color: #8A6A00; border-color: #E6C200; background: var(--marker-soft); }
.star-btn[aria-pressed="true"] .icon { fill: var(--marker); }
.link-btn, .text-link { background: none; border: 0; padding: 8px 0; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }

.field {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--page); border: 2px solid var(--line-strong); border-radius: 10px;
  font-size: var(--t-md); color: var(--graphite);
}
.field:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--ink-tint); }
.field[aria-invalid="true"] { border-color: var(--red); border-style: dashed; }
.field[aria-invalid="false"] { border-color: var(--green); }

/* ---------- Shell & navigation ---------- */
.shell { min-height: 100vh; }
main { padding: 20px var(--gutter) calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; gap: 20px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--page); border-top: 1px solid var(--line);
}
.nav-brand, .nav-present { display: none; }
.nav-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--graphite-3); text-decoration: none; font-size: 0.75rem; font-weight: 600;
}
.nav-link .icon { width: 44px; height: 28px; padding: 3px 11px; border-radius: 999px; }
.nav-link[aria-current="page"] { color: var(--ink); }
.nav-link[aria-current="page"] .icon { background: var(--ink-tint); stroke-width: 2.3; }

.b1 {
  display: inline-block; font-family: var(--font-display); font-weight: 700;
  background: var(--marker); color: var(--graphite);
  padding: 0 .22em; border-radius: 3px; line-height: 1.05;
}

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh; z-index: 5;
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 24px 16px; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav-brand { display: block; font: 700 1.75rem/1 var(--font-display); color: var(--graphite); text-decoration: none; padding: 4px 12px 28px; letter-spacing: -0.01em; }
  .nav-link { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: var(--t-sm); }
  .nav-link .icon { width: 22px; height: 22px; padding: 0; background: none !important; }
  .nav-link:hover { background: var(--bg); color: var(--graphite); }
  .nav-link[aria-current="page"] { background: var(--ink-tint); color: var(--ink-deep); }
  .nav-present {
    display: flex; align-items: center; gap: 12px; margin-top: auto;
    padding: 10px; border: 2px solid var(--line); border-radius: 10px; background: var(--page);
    font-weight: 700; font-size: 0.875rem; text-align: left;
  }
  .nav-present:hover { border-color: var(--line-strong); }
  main { padding: 48px 40px 64px; margin: 0; max-width: 760px; }
  .btn-present-home { display: none !important; }
  .kbd-hint { display: block !important; }
}

/* ---------- Headings ---------- */
.screen-head h1, .topic-head h1 {
  font: 700 var(--t-3xl)/1.05 var(--font-display);
  letter-spacing: -0.01em;
  overflow-wrap: break-word; hyphens: auto;
}
.screen-head p { color: var(--graphite-2); margin-top: 6px; max-width: 60ch; }
.back-link { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; color: var(--ink); font-weight: 700; text-decoration: none; padding: 6px 8px 6px 0; }
.back-link .icon { width: 20px; height: 20px; }
.block { display: flex; flex-direction: column; gap: 8px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.block-head h2 { font: 700 var(--t-xl)/1.1 var(--font-display); }
.block-note { color: var(--graphite-3); font-size: var(--t-sm); }

/* ---------- Home ---------- */
.home-head { display: grid; gap: 8px; }
.wordmark { font: 700 3.25rem/0.95 var(--font-display); letter-spacing: -0.02em; }
.wordmark .b1 { font-size: .8em; vertical-align: .08em; }
.lede { color: var(--graphite-2); font-size: 1.0625rem; max-width: 46ch; }
.btn-present-home { justify-self: start; margin-top: 6px; min-height: 42px; font-size: var(--t-sm); }

/* The exercise-book page (hero) */
.heft {
  position: relative;
  background: var(--paper-grid);
  border: 2px solid var(--line-strong);
  border-radius: 6px 16px 16px 6px;
  padding: 22px 20px 24px 46px;
  box-shadow: 0 1px 0 var(--line-strong), 0 10px 24px -18px rgba(30, 36, 48, .45);
}
.heft::before { /* the red margin line of a German Heft */
  content: ""; position: absolute; top: 0; bottom: 0; left: 30px; width: 2px; background: #EBA1AA;
}
.heft-label { color: var(--graphite-3); font-size: var(--t-sm); font-weight: 600; }
.heft-title { font: 700 var(--t-2xl)/1.05 var(--font-display); margin-top: 4px; }
.heft-sub { color: var(--graphite-2); margin-top: 4px; }
.heft-sentence { font-size: 1.375rem; font-weight: 600; margin: 22px 0 24px; line-height: 1.5; }
.heft .btn { width: 100%; }
@media (min-width: 560px) { .heft .btn { width: auto; } }

/* Ruled index (lessons, topics, stories) */
.toc { list-style: none; padding: 0; border-top: 2px solid var(--graphite); }
.toc > li { border-bottom: 1px solid var(--line-strong); }
.toc-row {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 4px 12px;
  width: 100%; padding: 14px 6px 14px 0; min-height: 64px;
  background: none; border: 0; text-align: left; text-decoration: none; color: inherit;
}
.toc-row:hover { background: var(--page); }
.toc-num { font: 700 1.5rem/1 var(--font-display); color: var(--ink); text-align: right; padding-right: 4px; }
.toc-text { min-width: 0; }
.toc-title { display: block; font: 700 1.1875rem/1.2 var(--font-display); }
.toc-sub { display: block; color: var(--graphite-2); font-size: var(--t-sm); margin-top: 2px; }
.toc-status { display: flex; align-items: center; gap: 8px; color: var(--graphite-3); font-size: var(--t-sm); font-weight: 600; white-space: nowrap; }
.toc-status .icon { width: 20px; height: 20px; }
.toc-status.is-good { color: var(--green); }
.toc-status .meter { width: 44px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.toc-status .meter span { display: block; height: 100%; background: var(--ink); }
.toc-status.is-good .meter span { background: var(--green); }
.chev { color: var(--graphite-3); width: 20px; height: 20px; }

#reset-progress { align-self: flex-start; font-size: var(--t-sm); color: var(--graphite-3); }

/* ---------- Vocabulary ---------- */
.vocab-tools { display: flex; flex-direction: column; gap: 12px; }
.segmented { display: inline-flex; align-self: flex-start; padding: 4px; gap: 4px; background: #E6EBF2; border-radius: 12px; }
.segmented button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; color: var(--graphite-2); }
.segmented button .icon { width: 18px; height: 18px; }
.segmented button[aria-pressed="true"] { background: var(--page); color: var(--graphite); box-shadow: 0 1px 2px rgba(30,36,48,.15); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-filter {
  flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--page); border: 1.5px solid var(--line-strong);
  font-weight: 600; font-size: var(--t-sm); color: var(--graphite-2); white-space: nowrap;
}
.chip-filter .n { color: var(--graphite-3); font-weight: 500; margin-left: 4px; }
.chip-filter[aria-pressed="true"] { background: var(--graphite); border-color: var(--graphite); color: #fff; }
.chip-filter[aria-pressed="true"] .n { color: #C9D0DB; }

.flash { display: block; width: 100%; height: 300px; padding: 0; border: 0; background: none; perspective: 1400px; text-align: left; touch-action: pan-y; }
.flash-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3,.7,.2,1); }
.flash.is-flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: 20px; border-radius: 16px;
  background: var(--page); border: 2px solid var(--line-strong); border-bottom-width: 5px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.flash-back { transform: rotateY(180deg); background: var(--paper-grid); border-color: var(--ink); justify-content: center; gap: 14px; }
.flash-tag { align-self: flex-start; }
.flash-word { margin: auto 0 0; font: 700 2.25rem/1.1 var(--font-display); overflow-wrap: break-word; hyphens: auto; }
.flash-word.is-long { font-size: 1.85rem; }
.flash-word.is-xlong { font-size: 1.5rem; }
.flash-word .art { font-weight: 700; }
.flash-plural { color: var(--graphite-2); margin: 6px 0 auto; }
.flash-hint { color: var(--graphite-3); font-size: var(--t-xs); }
.flash-meaning { font: 700 var(--t-xl)/1.2 var(--font-display); color: var(--ink-deep); }
.flash-ex { font-size: 1.0625rem; font-weight: 600; border-left: 3px solid var(--marker); padding-left: 12px; }
.flash-ex-sq { color: var(--graphite-2); font-size: var(--t-sm); padding-left: 15px; }
.flash-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.flash-count { flex: 1; text-align: center; font: 700 1.125rem/1 var(--font-display); color: var(--graphite-2); }
.kbd-hint { display: none; color: var(--graphite-3); font-size: var(--t-xs); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font: 700 var(--t-xs)/1.4 var(--font-ui); border: 1.5px solid currentColor; }
.tag-der { color: var(--der); background: #EAF1FB; }
.tag-die { color: var(--die); background: #FBEAEE; }
.tag-das { color: var(--das); background: #E6F4EC; }
.tag-verb { color: var(--verb); background: #FBF0E1; }
.tag-konn { color: var(--konn); background: #E2F2F4; }
.art-der { color: var(--der); } .art-die { color: var(--die); } .art-das { color: var(--das); }

.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--graphite-3); pointer-events: none; }
.search .field { padding-left: 46px; }
.list-count { color: var(--graphite-3); font-size: var(--t-sm); }
.word-list { list-style: none; padding: 0; border-top: 2px solid var(--graphite); }
.word-list li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line-strong); }
.word-main { min-width: 0; }
.word-de { font-weight: 700; font-size: 1.0625rem; }
.word-sq { color: var(--graphite-2); font-size: var(--t-sm); }
.word-pl { color: var(--graphite-3); font-size: var(--t-xs); }
.word-list .icon-btn { width: 40px; height: 40px; }
.empty { padding: 32px 0; color: var(--graphite-2); }

/* ---------- Grammar topic content ---------- */
.topic { display: flex; flex-direction: column; gap: 18px; }
.topic-num { color: var(--graphite-3); font-size: var(--t-sm); font-weight: 600; margin-bottom: 2px; }
.topic-sq { color: var(--graphite-2); font-size: 1.0625rem; margin-top: 6px; }
.topic-body { display: flex; flex-direction: column; gap: 14px; }
.topic-body p { max-width: 64ch; line-height: 1.65; }
.topic-body strong { font-weight: 700; }
.topic-sub { font: 700 var(--t-xl)/1.15 var(--font-display); margin-top: 18px; }
.rule-formula {
  border: 2px solid var(--ink); border-radius: 10px; background: var(--page);
  padding: 12px 16px; color: var(--ink-deep); font-weight: 700; line-height: 1.5;
}
.rule-ex-list { display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.rule-ex-item { padding: 11px 0 11px 14px; border-bottom: 1px solid var(--line-strong); position: relative; line-height: 1.55; }
.rule-ex-item::before { content: ""; position: absolute; left: 0; top: 19px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.conj-wrap { overflow-x: auto; border: 2px solid var(--line-strong); border-radius: 12px; background: var(--page); }
.conj-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.conj-table th, .conj-table td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.conj-table tr:last-child th, .conj-table tr:last-child td { border-bottom: 0; }
.conj-table thead th { font: 700 var(--t-md)/1.2 var(--font-display); background: #F0F3F8; color: var(--graphite); }
.conj-table tbody th { color: var(--graphite-3); font-weight: 600; }
.conj-table td { font-weight: 700; color: var(--ink-deep); }
@media (max-width: 400px) { .conj-table th, .conj-table td { padding: 8px 6px; } }

.verb-list { display: flex; flex-direction: column; padding-left: 2.2em; border-top: 1px solid var(--line-strong); }
.verb-list li { padding: 10px 0; border-bottom: 1px solid var(--line-strong); }
.verb-list li::marker { font: 700 var(--t-md) var(--font-display); color: var(--ink); }
.verb-forms { font-weight: 600; }
.verb-forms strong { color: var(--ink-deep); background: var(--marker-soft); padding: 0 3px; border-radius: 3px; }
.verb-ex { margin-top: 3px; }
.verb-sq { color: var(--graphite-2); font-size: var(--t-sm); margin-top: 2px; }

.pair-list { list-style: none; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.pair-list li { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line-strong); }
.pair-prefix { justify-self: start; font: 700 var(--t-sm)/1.3 var(--font-display); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 6px; padding: 1px 8px; }
.pair-main::before, .pair-sub::before { display: inline-block; min-width: 84px; color: var(--graphite-3); font-size: var(--t-xs); font-weight: 600; }
.pair-main::before { content: "Hauptsatz"; }
.pair-sub::before { content: "Nebensatz"; }

/* hatte drill inside topic 11 */
.drill { display: flex; flex-direction: column; gap: 0; background: var(--paper-grid); border: 2px solid var(--line-strong); border-radius: 12px; padding: 8px 14px 14px; }
.drill-row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.drill-row label { font: 700 1.125rem/1 var(--font-display); color: var(--graphite); }
.drill-input { min-height: 44px; color: var(--ink); font-weight: 700; }
.drill-ex { grid-column: 2; color: var(--graphite-3); font-size: var(--t-sm); }
.drill-fb { grid-column: 1 / -1; font-size: var(--t-sm); font-weight: 700; }
.drill-fb:empty { display: none; }
.drill .btn-row { margin-top: 14px; }
.drill .btn { min-height: 44px; }
.feedback:empty { display: none; }
.fb-ok { color: var(--green-deep); background: var(--green-tint); border-left: 4px solid var(--green); padding: 8px 12px; border-radius: 6px; }
.fb-bad { color: var(--red-deep); background: var(--red-tint); border-left: 4px dashed var(--red); padding: 8px 12px; border-radius: 6px; }
.drill-fb.fb-ok, .drill-fb.fb-bad { padding: 4px 10px; }
.feedback { margin-top: 12px; font-weight: 600; }

.practice { border: 2px solid var(--ink); border-radius: 14px; padding: 18px; background: var(--page); display: flex; flex-direction: column; gap: 12px; }
.practice h2 { font: 700 var(--t-xl)/1.1 var(--font-display); }
.practice-list { display: flex; flex-direction: column; gap: 10px; }
.practice-list .btn { justify-content: space-between; width: 100%; }
.topic-pager { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line-strong); padding-top: 14px; }
.pager-link { color: var(--ink); font-weight: 600; text-decoration: none; max-width: 48%; }
.pager-link small { display: block; color: var(--graphite-3); font-weight: 500; }
.pager-next { text-align: right; margin-left: auto; }

/* ---------- Stories ---------- */
#story-listen { align-self: flex-start; }
.story-text { background: var(--paper-grid); border: 2px solid var(--line-strong); border-radius: 12px; padding: 18px 16px; font-size: 1.25rem; line-height: 2.1; }
.word { display: inline; padding: 2px 1px; margin: 0; border: 0; border-radius: 4px; background: none; font: inherit; line-height: inherit; color: inherit; text-align: left; }
.word:hover { background: var(--marker-soft); }
.word[aria-pressed="true"] { background: var(--marker); }
.inspector {
  position: sticky; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  background: var(--graphite); color: #fff; border-radius: 14px; padding: 14px 16px; min-height: 64px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 12px 28px -12px rgba(30,36,48,.6);
}
@media (min-width: 900px) { .inspector { bottom: 20px; } }
.inspector-empty { color: #C9D0DB; font-size: var(--t-sm); }
.inspector-word { font: 700 var(--t-xl)/1.1 var(--font-display); }
.inspector-sq { color: #DCE3EC; font-size: var(--t-sm); margin-top: 2px; }
.inspector .icon-btn { margin-left: auto; background: transparent; color: #fff; border-color: #5F6877; }

/* ---------- Lesson player ---------- */
body.lesson-open { overflow: hidden; }
.lesson { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--paper-grid); }
.lesson-top { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 760px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) var(--gutter) 12px; }
.lesson-top .icon-btn { border-color: transparent; background: transparent; color: var(--graphite-2); }
.progress { flex: 1; height: 14px; background: #DEE4EC; border-radius: 999px; overflow: hidden; }
.progress-fill { display: block; height: 100%; width: 0; background: var(--ink); border-radius: inherit; transition: width .45s cubic-bezier(.3,.7,.2,1); }
.lesson-count { font: 700 var(--t-md)/1 var(--font-display); color: var(--graphite-2); min-width: 3.2em; text-align: right; }
.lesson-stage { flex: 1; overflow-y: auto; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px var(--gutter) 28px; display: flex; flex-direction: column; gap: 18px; }
.q-title { font: 700 var(--t-2xl)/1.1 var(--font-display); }
.q-source { align-self: flex-start; font-size: 1.125rem; font-weight: 600; background: var(--page); border: 2px solid var(--line-strong); border-radius: 4px 14px 14px 14px; padding: 10px 14px; max-width: 46ch; }
.q-sentence { font-size: 1.5rem; font-weight: 600; line-height: 1.7; }
@media (min-width: 700px) { .q-sentence { font-size: 1.875rem; } .q-title { font-size: var(--t-3xl); } }
.q-word { display: flex; align-items: center; gap: 12px; }
.q-word-text { font: 700 2.25rem/1.1 var(--font-display); }
.verb-hint { display: inline-flex; align-self: flex-start; align-items: baseline; gap: 8px; padding: 4px 12px; border-radius: 999px; background: var(--marker-soft); font-size: var(--t-sm); }
.verb-hint b { font: 700 1.125rem/1.3 var(--font-display); }
.hint { color: var(--graphite-3); font-size: var(--t-sm); }

/* the blank: what the learner writes, in royal-blue ink */
.blank {
  display: inline-block; min-width: 4.5ch; padding: 0 6px; text-align: center;
  border-bottom: 3px solid var(--ink); color: var(--ink); font-weight: 700; line-height: 1.25;
}
.blank.is-empty { border-bottom: 3px dashed var(--graphite-3); color: transparent; }
.blank.is-ok, .blank.is-bad { border-bottom-color: transparent; }
.mine { position: relative; color: var(--ink); }
.strike::after {
  content: ""; position: absolute; left: -3px; right: -3px; top: 52%; height: 3px; border-radius: 2px;
  background: var(--red); transform: rotate(-5deg) scaleX(0); transform-origin: left center;
  animation: strike .32s ease-out forwards;
}
.fix { color: var(--red); font-style: italic; margin-left: .35em; display: inline-block; animation: write .35s .28s ease-out both; }
.tick { display: inline-block; width: .95em; height: .95em; margin-left: .2em; vertical-align: -.05em; fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .4s ease-out forwards; }
@keyframes strike { to { transform: rotate(-5deg) scaleX(1); } }
@keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

.blank-input {
  display: inline-block; width: 8.5ch; min-width: 6ch; max-width: 100%;
  padding: 0 6px; border: 0; border-bottom: 3px solid var(--ink); border-radius: 0;
  background: var(--marker-soft); color: var(--ink); font-weight: 700; text-align: center; line-height: 1.3;
}
.blank-input:focus { outline: none; background: var(--marker); }
.umlauts { display: flex; gap: 8px; }
.umlauts button { width: 48px; height: 44px; border-radius: 10px; border: 2px solid var(--line-strong); background: var(--page); font-weight: 700; font-size: 1.125rem; box-shadow: 0 3px 0 var(--line-strong); }
.umlauts button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line-strong); }

/* scroll wheel picker */
.wheel-wrap { display: flex; align-items: center; gap: 10px; max-width: 440px; }
.wheel-frame { position: relative; flex: 1; --row: 54px; }
.wheel {
  height: calc(var(--row) * 3); overflow-y: auto; overscroll-behavior: contain;
  scroll-snap-type: y mandatory; padding-block: var(--row);
  scrollbar-width: none; background: var(--page);
  border: 2px solid var(--line-strong); border-radius: 14px;
  -webkit-mask-image: linear-gradient(transparent, #000 34%, #000 66%, transparent);
  mask-image: linear-gradient(transparent, #000 34%, #000 66%, transparent);
}
.wheel::-webkit-scrollbar { display: none; }
.wheel:focus-visible { outline: none; }
.wheel:focus-visible + .wheel-band { box-shadow: 0 0 0 3px var(--ink-deep); }
.wheel-item {
  height: var(--row); display: flex; align-items: center; justify-content: center;
  scroll-snap-align: center; font-size: 1.375rem; font-weight: 600; color: var(--graphite-3);
  cursor: pointer; user-select: none; -webkit-user-select: none; transition: color .15s, transform .15s;
}
.wheel-item.is-center { color: var(--ink); font-weight: 800; transform: scale(1.06); }
.wheel-band {
  position: absolute; left: 6px; right: 6px; top: 50%; height: var(--row); transform: translateY(-50%);
  border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); border-radius: 8px;
  background: rgba(35, 65, 168, .05); pointer-events: none;
}
.wheel-steps { display: flex; flex-direction: column; gap: 8px; }
.wheel.is-locked { pointer-events: none; }

/* multiple choice */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 10px 16px;
  background: var(--page); border: 2px solid var(--line-strong); border-bottom-width: 4px; border-radius: 12px;
  font-size: 1.0625rem; font-weight: 600; text-align: left; line-height: 1.35;
}
.option:hover:not(:disabled) { border-color: #9FB0C8; }
.option .key { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border: 2px solid var(--line-strong); border-radius: 7px; font: 700 var(--t-sm)/1 var(--font-display); color: var(--graphite-3); }
.option .mark { margin-left: auto; width: 22px; height: 22px; }
.option[aria-pressed="true"] { border-color: var(--ink); background: var(--ink-tint); color: var(--ink-deep); }
.option[aria-pressed="true"] .key { border-color: var(--ink); color: var(--ink); }
.option:disabled { cursor: default; }
.option.is-correct { border-color: var(--green); background: var(--green-tint); color: var(--green-deep); }
.option.is-correct .key { border-color: var(--green); color: var(--green); }
.option.is-wrong { border-color: var(--red); border-style: dashed; background: var(--red-tint); color: var(--red-deep); }
.option.is-wrong .key { border-color: var(--red); color: var(--red); }

/* word bank */
.answer-lines {
  min-height: 112px; padding: 4px 0 8px;
  display: flex; flex-wrap: wrap; align-content: flex-start; align-items: center; gap: 8px 6px;
  background: repeating-linear-gradient(to bottom, transparent 0 51px, var(--line-strong) 51px 53px);
}
.answer-lines .lead { font-size: 1.125rem; font-weight: 600; color: var(--graphite-2); padding: 0 4px; }
.answer-lines.is-ok { background: repeating-linear-gradient(to bottom, transparent 0 51px, var(--green) 51px 53px); }
.answer-lines.is-bad { background: repeating-linear-gradient(to bottom, transparent 0 51px, var(--red) 51px 53px); }
.bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 8px 0; }
.chip {
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  background: var(--page); border: 2px solid var(--line-strong); box-shadow: 0 3px 0 var(--line-strong);
  font-size: 1.125rem; font-weight: 600; color: var(--graphite);
}
.chip:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--line-strong); }
.answer-lines .chip { color: var(--ink); animation: pop .16s ease-out; }
.chip.is-used { color: transparent; background: #E6EBF2; border-color: #E6EBF2; box-shadow: none; }
@keyframes pop { from { transform: scale(.85); } to { transform: scale(1); } }

/* match pairs */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match .option { min-height: 56px; justify-content: center; text-align: center; padding: 8px 10px; font-size: var(--t-md); }
.match .option.is-matched { opacity: .45; border-color: var(--green); background: var(--green-tint); color: var(--green-deep); }
.match .option.is-miss { border-color: var(--red); border-style: dashed; background: var(--red-tint); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* footer + verdict */
.lesson-foot { border-top: 2px solid var(--line); background: var(--page); padding: 16px var(--gutter) max(16px, env(safe-area-inset-bottom)); transition: background-color .2s; }
.lesson-foot[data-state="ok"] { background: var(--green-tint); border-top-color: #A8D9BC; }
.lesson-foot[data-state="bad"] { background: var(--red-tint); border-top-color: #F0B5BC; }
.foot-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.foot-inner .btn { width: 100%; }
.verdict:empty { display: none; }
.verdict { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: start; }
.verdict-icon { grid-row: span 3; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--page); }
.verdict-icon .icon { width: 26px; height: 26px; stroke-width: 3; }
.verdict-title { font: 700 var(--t-xl)/1.15 var(--font-display); }
.verdict-detail { grid-column: 2; font-size: var(--t-sm); line-height: 1.5; }
.verdict-detail strong { font-size: var(--t-md); }
.verdict .icon-btn { grid-column: 3; grid-row: 1 / span 2; }
.lesson-foot[data-state="ok"] .verdict { color: var(--green-deep); }
.lesson-foot[data-state="ok"] .verdict-icon { color: var(--green); }
.lesson-foot[data-state="bad"] .verdict { color: var(--red-deep); }
.lesson-foot[data-state="bad"] .verdict-icon { color: var(--red); }
@media (min-width: 700px) {
  .foot-inner { flex-direction: row; align-items: center; justify-content: space-between; }
  .foot-inner .btn { width: auto; min-width: 200px; margin-left: auto; }
  .verdict { flex: 1; }
}

/* result */
.result { display: flex; flex-direction: column; gap: 18px; padding-top: 12px; }
.result h2 { font: 700 var(--t-3xl)/1.05 var(--font-display); }
.result-score { font-size: 1.125rem; color: var(--graphite-2); }
.result-figures { display: flex; gap: 28px; flex-wrap: wrap; border-top: 2px solid var(--graphite); border-bottom: 1px solid var(--line-strong); padding: 14px 0; }
.result-figures div { display: flex; flex-direction: column-reverse; }
.result-figures dt { color: var(--graphite-3); font-size: var(--t-sm); }
.result-figures dd { font: 700 var(--t-3xl)/1 var(--font-display); color: var(--ink); }
.result h3 { font: 700 var(--t-lg)/1.2 var(--font-display); }
.review { list-style: none; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.review li { padding: 10px 0; border-bottom: 1px solid var(--line-strong); }
.review .r-de { font-weight: 600; }
.review .r-de b { color: var(--red); }
.review .r-why { color: var(--graphite-2); font-size: var(--t-sm); }
.result .btn-row .btn { flex: 1 1 200px; }

/* ---------- Dialog sheets ---------- */
dialog.sheet {
  width: 100%; max-width: 100%; margin: auto 0 0; padding: 0; border: 0;
  border-radius: 20px 20px 0 0; background: var(--page); color: var(--graphite);
  max-height: 92dvh;
}
dialog.sheet::backdrop { background: rgba(20, 24, 33, .5); }
dialog.sheet form { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 26px 20px max(22px, env(safe-area-inset-bottom)); }
dialog.sheet h2 { font: 700 var(--t-2xl)/1.1 var(--font-display); padding-right: 48px; }
dialog.sheet p { color: var(--graphite-2); }
.sheet-kicker { font-weight: 600; font-size: var(--t-sm); }
.sheet-meta { font-size: var(--t-sm); }
.sheet-close { position: absolute; right: 14px; top: 14px; }
.sheet-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.sheet-actions .btn { width: 100%; }
.text-link { align-self: center; }
dialog.sheet[open] { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) {
  dialog.sheet { max-width: 460px; margin: auto; border-radius: 18px; }
}

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60; background: var(--graphite); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: var(--t-sm); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Presenter (projector: white page, heavy type, maximum contrast) ---------- */
dialog.presenter {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0;
  padding: clamp(14px, 3vw, 48px); background: #fff; color: #10131A;
  display: none; flex-direction: column; gap: clamp(10px, 2vh, 28px);
}
dialog.presenter[open] { display: flex; }
dialog.presenter::backdrop { background: #000; }
.pres-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pres-select { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: clamp(.95rem, 1.8vw, 1.3rem); }
.pres-select select { min-height: 44px; padding: 0 12px; border: 2px solid #10131A; border-radius: 10px; background: #fff; font-weight: 700; font-size: inherit; max-width: 60vw; }
.pres-count { margin-left: auto; font: 700 clamp(1.1rem, 2.4vw, 1.9rem)/1 var(--font-display); }
.pres-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: clamp(12px, 3vh, 34px); min-height: 0; overflow-y: auto; }
.pres-kind { font: 700 clamp(1.1rem, 2.6vw, 2rem)/1.1 var(--font-display); color: var(--ink); }
.pres-kind:empty, .pres-source:empty, .pres-feedback:empty { display: none; }
.pres-source { font-size: clamp(1.1rem, 2.8vw, 2.1rem); font-weight: 600; color: #3A4250; }
.pres-question { font-size: clamp(1.75rem, 5.4vw, 4.4rem); font-weight: 800; line-height: 1.2; }
.pres-question .gap { display: inline-block; min-width: 3.2em; border-bottom: .09em solid #10131A; }
.pres-options { display: flex; flex-wrap: wrap; gap: clamp(8px, 1.4vw, 18px); }
.pres-opt { flex: 1 1 40%; min-height: 64px; padding: clamp(10px, 1.8vh, 22px); background: #fff; color: #10131A; border: 4px solid #10131A; border-radius: 14px; font-size: clamp(1.25rem, 3.4vw, 2.7rem); font-weight: 800; text-align: center; }
.pres-opt.is-long { flex-basis: 100%; text-align: left; font-size: clamp(1.1rem, 2.6vw, 2.1rem); }
.pres-opt.is-correct { background: #0F6B39; border-color: #0F6B39; color: #fff; }
.pres-opt.is-wrong { background: #fff; border-color: var(--red); border-style: dashed; color: var(--red-deep); }
.pres-chip { padding: 6px 18px; border: 3px solid #10131A; border-radius: 12px; font-size: clamp(1.25rem, 3.4vw, 2.6rem); font-weight: 700; }
.pres-feedback { font: 700 clamp(1.2rem, 3vw, 2.2rem)/1.2 var(--font-display); }
.pres-feedback.is-ok { color: #0F6B39; }
.pres-feedback.is-bad { color: var(--red-deep); }
.pres-answer { border: 5px solid var(--ink); border-radius: 16px; padding: clamp(12px, 2vh, 26px); font-size: clamp(1.4rem, 4.2vw, 3.3rem); font-weight: 800; color: var(--ink-deep); background: var(--ink-tint); }
.pres-answer .why { display: block; font-size: clamp(1rem, 2.2vw, 1.7rem); font-weight: 600; color: #10131A; margin-top: 8px; }
.pres-bottom { display: flex; gap: clamp(8px, 1.5vw, 20px); }
.pres-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 58px; padding: 10px 14px; background: #fff; color: #10131A; border: 3px solid #10131A; border-radius: 14px; font-size: clamp(1rem, 2.4vw, 1.75rem); font-weight: 800; }
.pres-btn .icon { width: 1.1em; height: 1.1em; stroke-width: 2.6; }
.pres-show { background: #10131A; color: #fff; }
.pres-show:disabled { background: #fff; color: #10131A; border-style: dashed; cursor: default; }
.pres-close { flex: 0 0 auto; min-height: 44px; font-size: clamp(.95rem, 1.8vw, 1.25rem); }
.pres-help { text-align: center; color: #3A4250; font-size: clamp(.85rem, 1.5vw, 1.1rem); }
dialog.presenter :focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }

/* ---------- Small screens ---------- */
@media (max-width: 360px) {
  :root { --gutter: 12px; }
  .wordmark { font-size: 2.75rem; }
  .q-sentence { font-size: 1.3rem; }
  .q-title { font-size: var(--t-xl); }
  .flash-word { font-size: 1.9rem; }
  .heft { padding-left: 38px; }
  .heft::before { left: 24px; }
  .match .option { font-size: var(--t-sm); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
}
