/* Lernwörter: ruhige Heft-Optik. Helle Neutraltöne, eine Akzentfarbe (Tafelgrün), harte Kanten. */
:root {
  --paper: #F4F2EC;
  --surface: #FFFFFF;
  --ink: #16171A;
  --ink-2: #4B4E55;
  --ink-3: #74777E;
  --rule: #D8D4CA;
  --rule-strong: #16171A;
  --accent: #1D5A4A;
  --accent-ink: #FFFFFF;
  --accent-tint: #E4ECE8;
  --wrong: #B3261E;
  --wrong-tint: #F6E5E3;
  --focus: #1D5A4A;

  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --margin: 56px;          /* Heftrand */
  --tap: 56px;             /* Mindesthöhe für Buttons */
  --border: 2px;
}

* { box-sizing: border-box; border-radius: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 19px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---- Kopfzeile ---- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4);
  padding: calc(env(safe-area-inset-top) + 10px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: var(--border) solid var(--ink);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -0.01em; min-height: 48px; }
.brand-mark { width: 22px; height: 22px; background:
  linear-gradient(var(--ink), var(--ink)) 0 100% / 100% 3px no-repeat,
  linear-gradient(var(--accent), var(--accent)) 6px 0 / 3px 100% no-repeat; }
.who {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 0 14px;
  background: transparent; border: var(--border) solid var(--ink); cursor: pointer;
  font-weight: 700;
}
.who svg { width: 20px; height: 20px; }
.who:active { background: var(--ink); color: var(--paper); }

/* ---- Seite mit Heftrand ---- */
.view { outline: none; }
.page {
  position: relative;
  max-width: 820px;
  margin: 0 auto;
  padding: var(--s6) 20px var(--s8) calc(var(--margin) + 20px);
}
.page::before {               /* senkrechter Heftrand */
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--margin);
  width: 2px; background: var(--accent); opacity: .55;
}
@media (max-width: 560px) {
  :root { --margin: 0px; }
  body { font-size: 18px; }
  .page { padding: var(--s5) 16px var(--s7); }
  .page::before { display: none; }
}

.enter > * { animation: rise .42s cubic-bezier(.2,.7,.2,1) both; }
.enter > *:nth-child(2) { animation-delay: .05s; }
.enter > *:nth-child(3) { animation-delay: .1s; }
.enter > *:nth-child(4) { animation-delay: .15s; }
.enter > *:nth-child(5) { animation-delay: .2s; }
.enter > *:nth-child(n+6) { animation-delay: .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- Typo ---- */
.eyebrow { font-size: 15px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 var(--s2); }
h1 { font-size: clamp(34px, 6vw, 52px); line-height: 1.05; letter-spacing: -0.025em; font-weight: 800; margin: 0 0 var(--s4); }
h2 { font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -0.01em; margin: var(--s7) 0 var(--s4); }
p { margin: 0 0 var(--s4); max-width: 34em; }
.lead { font-size: 21px; color: var(--ink-2); }
.small { font-size: 16px; color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: var(--tap); padding: 0 26px;
  border: var(--border) solid var(--ink); background: var(--surface);
  font-weight: 700; font-size: 19px; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn svg { width: 24px; height: 24px; flex: none; }
.btn:active { transform: translateY(2px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-main {
  width: 100%; min-height: 68px; font-size: 21px;
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.22);
}
.btn-main:active { box-shadow: none; }
.btn-ghost { background: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s3); }
.btn-row .btn { flex: 1 1 0; min-width: 0; }
.stack { display: grid; gap: var(--s3); }
.actions { margin-top: var(--s6); display: grid; gap: var(--s3); }
.link-btn { background: none; border: 0; padding: 0; min-height: 48px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; font-weight: 700; color: var(--ink-2); }

/* ---- Wer übt? ---- */
.pick { display: grid; gap: var(--s4); grid-template-columns: 1fr 1fr; margin-top: var(--s6); }
.pick button {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  min-height: 200px; padding: var(--s5);
  background: var(--surface); border: var(--border) solid var(--ink); cursor: pointer; text-align: left;
  transition: background .15s ease, color .15s ease;
}
.pick .initial { font-size: 88px; line-height: .8; font-weight: 800; letter-spacing: -0.04em; }
.pick .name { font-size: 26px; font-weight: 800; }
.pick button:hover, .pick button:active { background: var(--ink); color: var(--paper); }
@media (max-width: 420px) { .pick { grid-template-columns: 1fr; } .pick button { min-height: 140px; } }

/* ---- Fortschritts-Lineal ---- */
.ruler { margin: var(--s5) 0 var(--s2); }
.ruler-track {
  position: relative; height: 28px; background: var(--surface);
  border: var(--border) solid var(--ink); overflow: hidden;
}
.ruler-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width .8s cubic-bezier(.2,.7,.2,1); }
.ruler-fill.uebt { background: repeating-linear-gradient(135deg, var(--accent) 0 2px, transparent 2px 7px); opacity: .55; }
.ruler-ticks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(22,23,26,.35) calc(10% - 1px) 10%); pointer-events: none; }
.ruler-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); font-size: 16px; color: var(--ink-2); margin-top: var(--s2); }
.key { display: inline-flex; align-items: center; gap: 8px; }
.key i { width: 14px; height: 14px; border: 2px solid var(--ink); display: inline-block; }
.key .k-sicher { background: var(--accent); border-color: var(--accent); }
.key .k-uebt { background: repeating-linear-gradient(135deg, var(--accent) 0 2px, transparent 2px 5px); }
.big-count { font-size: clamp(48px, 9vw, 72px); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }

/* ---- Menü-Liste (Heftzeilen) ---- */
.menu { list-style: none; margin: var(--s6) 0 0; padding: 0; border-top: var(--border) solid var(--ink); }
.menu li { border-bottom: 1px solid var(--rule); }
.menu a, .menu button {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: var(--s4);
  width: 100%; min-height: 72px; padding: var(--s3) 0;
  background: none; border: 0; text-decoration: none; text-align: left; cursor: pointer;
}
.menu svg { width: 28px; height: 28px; }
.menu .t { font-weight: 700; font-size: 20px; display: block; }
.menu .d { font-size: 16px; color: var(--ink-2); display: block; }
.menu .go { width: 22px; height: 22px; color: var(--ink-3); }
.menu a:active, .menu button:active { background: var(--accent-tint); }

/* ---- Auswahl 10 / 20 ---- */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: var(--border) solid var(--ink); margin: var(--s4) 0; }
.seg button { min-height: 96px; background: var(--surface); border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.seg button + button { border-left: var(--border) solid var(--ink); }
.seg .n { font-size: 40px; font-weight: 800; line-height: 1; }
.seg .l { font-size: 16px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button[aria-pressed="true"] .l { color: var(--paper); opacity: .8; }

/* ---- Schritte (nummeriert im Heftrand) ---- */
.steps { list-style: none; padding: 0; margin: var(--s5) 0; counter-reset: st; }
.steps li { position: relative; padding: var(--s2) 0 var(--s3); border-bottom: 1px solid var(--rule); counter-increment: st; }
.steps li::before {
  content: counter(st); position: absolute; left: calc(-1 * var(--margin) - 4px); width: var(--margin); text-align: center;
  font-weight: 800; font-size: 22px; color: var(--accent); top: 6px;
}
@media (max-width: 560px) { .steps li { padding-left: 36px; } .steps li::before { left: 0; width: 24px; text-align: left; } }

/* ---- Üben ---- */
.counter { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s4); }
.counter .of { font-weight: 800; font-size: 20px; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.dots i { width: 14px; height: 6px; background: var(--rule); display: block; }
.dots i.ok { background: var(--accent); }
.dots i.no { background: var(--wrong); }
.dots i.now { background: var(--ink); }

.speak { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: var(--s3); margin: var(--s4) 0 var(--s6); }
.speak .btn { padding: 0 12px; min-height: 64px; flex-direction: column; gap: 2px; font-size: 16px; }
.speak .btn:first-child { font-size: 18px; flex-direction: row; gap: 10px; }
.speak .btn svg { width: 26px; height: 26px; }
@media (max-width: 420px) { .speak { grid-template-columns: 1fr 1fr; } .speak .btn:first-child { grid-column: 1 / -1; } }

.line { position: relative; padding-top: 18px; margin-bottom: var(--s5); }
.line::before { content: ""; position: absolute; left: 0; right: 0; top: 34px; border-top: 2px dotted var(--rule); }
.write {
  position: relative; display: block; width: 100%;
  font-family: var(--mono); font-size: clamp(36px, 8vw, 56px); line-height: 1.2; letter-spacing: .04em;
  padding: 6px 4px 8px; background: transparent;
  border: 0; border-bottom: 4px solid var(--ink);
  outline: none; caret-color: var(--accent);
}
.write:focus { border-bottom-color: var(--accent); }
.write::placeholder { color: var(--rule); }

.feedback { border: var(--border) solid var(--ink); background: var(--surface); padding: var(--s5); margin-bottom: var(--s5); }
.feedback.ok { border-color: var(--accent); box-shadow: inset 8px 0 0 var(--accent); }
.feedback.no { border-color: var(--wrong); box-shadow: inset 8px 0 0 var(--wrong); }
.feedback .verdict { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 26px; margin-bottom: var(--s2); }
.feedback .verdict svg { width: 32px; height: 32px; }
.feedback.ok .verdict { color: var(--accent); }
.feedback.no .verdict { color: var(--wrong); }
.cmp { display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s4); align-items: baseline; margin-top: var(--s3); }
.cmp .lbl { font-size: 15px; color: var(--ink-2); font-weight: 700; }
.letters { font-family: var(--mono); font-size: clamp(28px, 6vw, 40px); letter-spacing: .06em; line-height: 1.3; word-break: break-all; }
.letters .bad { color: var(--wrong); text-decoration: line-through; text-decoration-thickness: 3px; }
.letters .gap { color: var(--wrong); }
.letters .fix { color: var(--accent); font-weight: 600; box-shadow: inset 0 -5px 0 var(--accent-tint), 0 4px 0 var(--accent); }
.feedback .hint { margin: var(--s3) 0 0; font-size: 17px; color: var(--ink-2); }

/* ---- Ergebnis ---- */
.score { display: flex; align-items: flex-end; gap: var(--s4); margin: var(--s5) 0 var(--s3); }
.score .big { font-size: clamp(88px, 20vw, 150px); font-weight: 800; line-height: .82; letter-spacing: -0.05em; }
.score .of { font-size: 26px; font-weight: 700; color: var(--ink-2); padding-bottom: 8px; }
.wordlist { list-style: none; margin: 0; padding: 0; border-top: var(--border) solid var(--ink); }
.wordlist li { display: grid; grid-template-columns: 1fr auto; gap: var(--s3); align-items: baseline; padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
.wordlist .w { font-family: var(--mono); font-size: 24px; letter-spacing: .03em; }
.wordlist .was { font-size: 16px; color: var(--ink-2); }
.wordlist .was s { color: var(--wrong); text-decoration-thickness: 2px; font-family: var(--mono); }
.tag { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border: 1.5px solid currentColor; white-space: nowrap; }
.tag.papier { color: var(--ink); }
.tag.tablet { color: var(--accent); }
.tag.schwer { color: var(--wrong); }

/* ---- Prüfen (Erwachsene) ---- */
.adult { border: var(--border) dashed var(--ink-2); padding: var(--s3) var(--s4); font-size: 16px; color: var(--ink-2); margin-bottom: var(--s5); }
.photo { display: block; width: 100%; max-height: 320px; object-fit: contain; background: var(--surface); border: var(--border) solid var(--ink); margin-bottom: var(--s4); }
.check { list-style: none; margin: 0; padding: 0; border-top: var(--border) solid var(--ink); }
.check li { display: grid; grid-template-columns: 34px 1fr 128px; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
.check .nr { font-weight: 800; color: var(--ink-3); text-align: right; }
.check .target { font-family: var(--mono); font-size: 22px; }
.check input {
  width: 100%; margin-top: 4px; font-family: var(--mono); font-size: 18px; padding: 6px 8px; min-height: 44px;
  border: 1.5px solid var(--rule); background: var(--paper);
}
.check input:focus { border-color: var(--ink); outline: none; }
.toggle { min-height: 64px; border: var(--border) solid var(--ink); background: var(--surface); font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 17px; }
.toggle svg { width: 22px; height: 22px; }
.toggle.ok { background: var(--accent); color: #fff; border-color: var(--accent); }
.toggle.no { background: var(--wrong); color: #fff; border-color: var(--wrong); }
.toggle.unset { border-style: dashed; color: var(--ink-2); }
@media (max-width: 420px) { .check li { grid-template-columns: 26px 1fr 104px; } }

/* ---- Statistik ---- */
.hist { list-style: none; margin: 0; padding: 0; border-top: var(--border) solid var(--ink); }
.hist li { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s4); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
.hist .when { font-weight: 700; }
.hist .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.hist .res { font-weight: 800; font-size: 22px; text-align: right; }
.hist .mini { display: block; height: 6px; width: 120px; background: var(--rule); margin-top: 6px; position: relative; }
.hist .mini b { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.empty { padding: var(--s5); border: var(--border) dashed var(--rule); color: var(--ink-2); }
.backup { margin-top: var(--s7); padding-top: var(--s5); border-top: var(--border) solid var(--ink); }

/* ---- Dialog, Lade-Anzeige, Hinweis ---- */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(22,23,26,.45); display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--paper); border: var(--border) solid var(--ink); padding: var(--s5); max-width: 460px; width: 100%; }
.dialog h3 { margin: 0 0 var(--s3); font-size: 24px; }
.loading { display: flex; align-items: center; gap: var(--s4); padding: var(--s6) 0; font-weight: 700; font-size: 21px; }
.loading .bars { display: inline-flex; gap: 5px; }
.loading .bars i { width: 6px; height: 26px; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.loading .bars i:nth-child(2) { animation-delay: .15s; }
.loading .bars i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translate(-50%, 140%);
  background: var(--ink); color: var(--paper); padding: 14px 20px; font-weight: 700; max-width: calc(100% - 32px);
  transition: transform .25s ease, visibility .25s; z-index: 30; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.error { border: var(--border) solid var(--wrong); background: var(--wrong-tint); padding: var(--s4); margin: var(--s4) 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 56px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin-bottom: var(--s5); cursor: pointer; }
.switch input { width: 28px; height: 28px; accent-color: var(--accent); }
