:root {
  --bg: #f5efe3;
  --surface: #fffdf8;
  --surface-2: #f0e9db;
  --ink: #1d2427;
  --muted: #6b6a63;
  --line: #e2d9c7;
  --accent: #0f6b5f;
  --accent-ink: #ffffff;
  --accent-soft: #d9ece7;
  --marker: #ffd86b;
  --marker-soft: #fff1c2;
  --ok: #2f8a4a;
  --bad: #c2412d;
  --warn: #b7791f;
  --a1: #c0841a;
  --a2: #b0602a;
  --b1: #4f8a6b;
  --b2: #2f6f9f;
  --c1: #8a4fa0;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(29, 36, 39, .04), 0 6px 20px -12px rgba(29, 36, 39, .25);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14191b;
    --surface: #1c2326;
    --surface-2: #232c30;
    --ink: #ece7dc;
    --muted: #9aa19e;
    --line: #2f393d;
    --accent: #3fb39f;
    --accent-ink: #0d1517;
    --accent-soft: #1d3a35;
    --marker: #e9b949;
    --marker-soft: #3b3320;
    --ok: #5cc47a;
    --bad: #f07a63;
    --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 8px 24px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14191b; --surface: #1c2326; --surface-2: #232c30; --ink: #ece7dc; --muted: #9aa19e;
  --line: #2f393d; --accent: #3fb39f; --accent-ink: #0d1517; --accent-soft: #1d3a35;
  --marker: #e9b949; --marker-soft: #3b3320; --ok: #5cc47a; --bad: #f07a63; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
body[data-view="learn"] .app { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
body[data-view="learn"] .nav { display: none; }

h1, h2, h3 { font-family: var(--serif); font-weight: 650; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 2.1rem; line-height: 1.1; }
h1.h-sm { font-size: 1.3rem; }
h2 { font-size: 1.15rem; margin-bottom: 10px; }
h3 { font-size: 1.1rem; }
.eyebrow { margin: 0 0 2px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.err { color: var(--bad); }
.ok { color: var(--ok); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 18px; }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  text-decoration: none;
}
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 10px 18px; font-weight: 600; text-decoration: none; cursor: pointer;
  min-height: 44px; transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: var(--surface-2); border-color: transparent; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.08rem; margin-top: 12px; }
.btn.small-btn { padding: 6px 14px; min-height: 38px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .6; cursor: default; }
.card > .btn:not(.big) { margin-top: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; text-decoration: none; flex: none;
}
.icon-btn.plain { background: transparent; border-color: transparent; }
.icon-btn.small { width: 32px; height: 32px; vertical-align: middle; }
.icon-btn.small svg { width: 16px; height: 16px; }
.actions-row { display: flex; gap: 8px; }
.actions-row > .btn { flex: 1; }
.actions-row.wrap { flex-wrap: wrap; }
.actions-row.wrap > .btn { flex: 0 1 auto; }

/* Start */
.streak { display: flex; align-items: center; gap: 16px; }
.streak h2 { margin-bottom: 8px; }
.flame { position: relative; width: 58px; height: 58px; display: grid; place-items: center; color: var(--line); }
.flame svg { width: 58px; height: 58px; fill: currentColor; stroke: none; }
.flame.on { color: var(--marker); }
.flame span { position: absolute; top: 24px; font-family: var(--serif); font-weight: 650; font-size: 1.25rem; color: var(--ink); }
.streak > div:last-child { min-width: 0; }
.dots { display: flex; gap: 4px; }
.dot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.dot svg { width: 16px; height: 16px; stroke-width: 2.6; }
.dot.done { background: var(--marker); color: #3a2c00; }
.dot.today:not(.done) { box-shadow: inset 0 0 0 2px var(--marker); color: var(--ink); }
.dot.future { opacity: .55; }

.today { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.num-box { background: var(--surface-2); border-radius: 14px; padding: 14px 8px; text-align: center; min-width: 0; }
.num-box strong { display: block; font-family: var(--serif); font-size: 2.6rem; line-height: 1; font-weight: 650; }
.num-box span { font-size: .85rem; color: var(--muted); }
.num-box.accent { background: var(--marker-soft); }
.plus { font-size: 1.6rem; color: var(--muted); }
.done-msg { text-align: center; color: var(--muted); margin: 14px 0 0; }

.meter { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; flex: 1; }
.meter > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
.meter.thin { height: 6px; }
.story-teaser .meter { margin: 6px 0 10px; }
.story-teaser.ready { border-color: var(--marker); background: linear-gradient(180deg, var(--marker-soft), var(--surface) 70%); }
.story-teaser p { margin: 0; }
.lvl-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; color: #fff; vertical-align: middle; letter-spacing: .03em; }
.badge.lvl-A1 { background: var(--a1); }
.badge.lvl-A2 { background: var(--a2); }
.badge.lvl-B1 { background: var(--b1); }
.badge.lvl-B2 { background: var(--b2); }
.badge.lvl-C1 { background: var(--c1); }
.chip { display: inline-block; font-size: .8rem; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink); border: 0; cursor: default; }
.chip.new { background: var(--marker-soft); }
.chip.warn { background: #f6d9c9; color: #7a2e12; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.chips.filter .chip { cursor: pointer; }
.chip.active { background: var(--accent); color: var(--accent-ink); }

/* Lernsitzung */
.session-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.flash {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 22px 20px 26px;
  box-shadow: var(--shadow); min-height: 340px; text-align: center;
}
.card-meta { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.de-word { font-family: var(--serif); font-size: 1.9rem; line-height: 1.2; margin: 18px 0 20px; }
.de-word small { font-family: var(--sans); font-size: .85rem; color: var(--muted); }
.en-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 2px; }
.en-word { font-family: var(--serif); font-size: 2.4rem; margin: 0; line-height: 1.15; }
.de-small { color: var(--muted); margin: 0 0 16px; }
.ex { font-size: 1.15rem; margin: 12px 0 6px; }
.ex-de { color: var(--muted); margin: 0 0 8px; }
.hl { font-weight: 650; background: linear-gradient(transparent 60%, var(--marker) 60%); padding: 0 2px; }
.ex-de .hl { background: none; color: var(--ink); }
.blank { display: inline-block; width: 4.5em; border-bottom: 2px solid var(--ink); margin: 0 4px; vertical-align: -3px; }
.hint { font-family: ui-monospace, Menlo, monospace; letter-spacing: .05em; color: var(--accent); margin: 14px 0 0; }
.answer {
  width: 100%; margin-top: 18px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); font-size: 1.1rem; text-align: center;
}
.typed { margin: 4px 0 8px; font-weight: 600; }
.typed.ok { color: var(--ok); }
.typed.bad { color: var(--bad); }
.note { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: .9rem; margin: 14px 0 0; text-align: left; }
.note.ff { background: #fde4dd; color: #7a2412; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note.ff { background: #47231b; color: #ffc8b8; } }
.flash-actions { margin-top: 14px; }
.flash-actions .actions-row { margin-bottom: 0; }
.known-btn { width: 100%; margin-top: 10px; font-weight: 500; color: var(--muted); }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade {
  border: 0; border-radius: 16px; padding: 12px 4px; min-height: 64px; cursor: pointer; font-weight: 650;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.grade small { font-weight: 500; font-size: .78rem; opacity: .8; }
.grade.g1 { background: #f7d6cf; color: #7a2412; }
.grade.g2 { background: #f6e3c1; color: #6b4300; }
.grade.g3 { background: #cfe8d7; color: #1b5631; }
.grade.g4 { background: #cfe1f1; color: #1c4a70; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .grade.g1 { background: #4a2620; color: #ffc8b8; }
  :root:not([data-theme="light"]) .grade.g2 { background: #4a3a1c; color: #ffdca0; }
  :root:not([data-theme="light"]) .grade.g3 { background: #1f4029; color: #b8ecc8; }
  :root:not([data-theme="light"]) .grade.g4 { background: #1d3448; color: #bcdaf4; }
}
.center-msg { text-align: center; padding-top: 12vh; }
.center-msg h1 { margin-bottom: 6px; }
.center-msg .btn { margin-top: 14px; }
.center-msg .card { text-align: left; margin-top: 20px; }
.big-check { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.big-check svg { width: 38px; height: 38px; stroke-width: 2.6; }

/* Geschichten */
.story-item h3 { margin-bottom: 2px; }
.story-item p { margin: 0 0 6px; }
.reader { padding: 22px 20px; }
.story-title { font-size: 1.7rem; margin-bottom: 12px; }
.reader-controls { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.reader-controls select { border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 9px 12px; }
.story-text { font-family: var(--serif); font-size: 1.18rem; line-height: 1.7; font-weight: 500; }
.story-text p { margin: 0 0 1em; }
.tw {
  border: 0; padding: 0 2px; margin: 0; cursor: pointer; font: inherit; font-weight: 650; color: var(--ink);
  background: linear-gradient(transparent 58%, var(--marker) 58%); border-radius: 2px;
}
.quiz { margin-bottom: 16px; }
.quiz .q { font-weight: 600; margin: 0 0 8px; }
.opt {
  display: block; width: 100%; text-align: left; padding: 10px 14px; margin-bottom: 6px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); cursor: pointer;
}
.opt.right { background: #cfe8d7; border-color: var(--ok); color: #1b5631; }
.opt.wrong { background: #f7d6cf; border-color: var(--bad); color: #7a2412; }
.cz { line-height: 2.2; }
.cz select { margin: 0 4px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: var(--bg); max-width: 11em; }
.cz select.right { border-color: var(--ok); background: #cfe8d7; color: #1b5631; }
.cz select.wrong { border-color: var(--bad); background: #f7d6cf; color: #7a2412; }
details.card summary { list-style: none; cursor: pointer; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary h2 { display: inline; }
details.card summary::after { content: "＋"; float: right; color: var(--muted); }
details[open].card summary::after { content: "－"; }
textarea { width: 100%; margin: 10px 0; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }

/* Themen */
.intro { margin: -6px 0 16px; }
.topics-teaser .chips { margin-bottom: 0; }
.topics-teaser p { margin: 6px 0 0; }
.topic-row { padding: 14px 16px; margin-bottom: 10px; opacity: .75; transition: opacity .15s; }
.topic-row.on { opacity: 1; }
.topic-head { display: flex; align-items: center; gap: 12px; }
.topic-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topic-info b { font-family: var(--serif); font-size: 1.08rem; }
.gen-box { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 6px; }
.gen-box .btn { margin-top: 6px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.link-btn { border: 0; background: none; padding: 8px 0 0; cursor: pointer; text-decoration: underline; }
.link-btn.danger { color: var(--bad); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.chip-select { border: 0; border-radius: 99px; background: var(--surface-2); padding: 4px 10px; font-size: .8rem; max-width: 50%; }

.topic-line { display: flex; align-items: baseline; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.topic-line .link-btn { padding: 0; color: var(--accent); }

/* Auswahl-Dialog */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgba(20, 25, 27, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 85vh; overflow: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
  box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, .35); animation: rise .2s ease;
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 6px 0 12px; }
.sheet-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px 14px; cursor: pointer;
}
.pick b { font-weight: 650; }
.pick-meta { font-weight: 500; color: var(--accent); }
.pick.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pick:disabled { opacity: .5; cursor: default; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 720px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; } }

.vocab-level .lvl-num { min-width: 64px; text-align: right; }
.meter.two { display: flex; }
.meter.two > div { border-radius: 0; }
.meter.two > div:first-child { border-radius: 99px 0 0 99px; }
.meter.two > .lrn { background: var(--marker); }
.legend-line { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.legend-line span { display: inline-flex; align-items: center; gap: 6px; }
.nw { white-space: nowrap; }
.vocab-level .badge, .lvl-row .badge { min-width: 32px; text-align: center; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.sw.sec { background: var(--accent); }
.sw.lrn { background: var(--marker); }
.lvl-counts { font-family: var(--sans); font-size: .85rem; font-weight: 500; color: var(--muted); white-space: nowrap; }

/* Wortschatz */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 99px; padding: 4px; margin-bottom: 12px; }
.tab { flex: 1; border: 0; background: transparent; border-radius: 99px; padding: 8px 4px; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.tab small { color: var(--muted); font-weight: 500; }
.tab.active { background: var(--surface); box-shadow: var(--shadow); }
.searchbar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.searchbar svg { color: var(--muted); width: 18px; height: 18px; }
.searchbar input { flex: 1; border: 0; background: transparent; padding: 11px 0; outline: none; }
.word-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.word-list.compact { border: 0; background: transparent; }
.wl-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.wl-item:last-child { border-bottom: 0; }
.wl-en { font-family: var(--serif); font-size: 1.2rem; }
.wl-de { color: var(--muted); }
.wl-ex { font-size: .9rem; margin-top: 2px; }
.wl-detail { grid-column: 1 / -1; cursor: default; }
.wl-detail .note { margin-top: 6px; }
.wl-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ring { width: 36px; height: 36px; }
.ring circle { fill: none; stroke-width: 4; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; }

/* Formulare */
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.field input:not([type="range"]), .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); min-height: 44px;
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .field { margin: 6px 0; }
.file-btn { cursor: pointer; }
.gen-list { margin: 12px 0; }
.gen-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.gen-item input { width: 20px; height: 20px; margin-top: 4px; accent-color: var(--accent); }

/* Statistik */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.kpi strong { display: block; font-family: var(--serif); font-size: 1.9rem; line-height: 1.1; }
.kpi span { font-size: .85rem; color: var(--muted); }
.bars { display: flex; gap: 6px; align-items: flex-end; padding-top: 18px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar-track { height: var(--h); width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: min(80%, 38px); background: var(--accent); border-radius: 6px 6px 2px 2px; position: relative; min-height: 2px; transition: height .3s; }
.bar-val { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.bar-label { font-size: .72rem; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stack-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.seg.known, .legend i.known { background: #9aa39f; }
.seg.learned, .legend i.learned { background: var(--accent); }
.seg.learning, .legend i.learning { background: var(--marker); }
.seg.new, .legend i.new { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.legend { list-style: none; padding: 0; margin: 12px 0 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.legend li b { margin-left: auto; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* Navigation */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; max-width: 130px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; font-size: .75rem; font-weight: 600; color: var(--muted); padding: 6px 4px; border-radius: 14px;
}
.nav a.active { color: var(--accent); background: var(--accent-soft); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 88px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: .95rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); z-index: 20;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body[data-view="learn"] .toast { bottom: calc(env(safe-area-inset-bottom) + 24px); }

@media (min-width: 720px) {
  .app { padding-top: 32px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.h-gap { margin-top: 14px; }
.key-box { background: var(--marker-soft); border-radius: 14px; padding: 12px; margin: 12px 0 4px; }
.key-box p { margin: 0 0 8px; }
.grades.three { grid-template-columns: 1.15fr 1fr 1fr; }
.grades.three .grade { min-height: 72px; font-size: .98rem; padding: 10px 6px; text-align: center; line-height: 1.2; }
.weak-card { border-color: #f0c9bd; }
.weak-card p { margin: 0 0 4px; }
.badge-num { background: #f7d6cf; color: #7a2412; border-radius: 99px; padding: 2px 10px; font-weight: 700; font-size: .9rem; }
.key-box summary { cursor: pointer; list-style: none; }
.key-box summary::-webkit-details-marker { display: none; }
.key-box[open] summary { margin-bottom: 8px; }
.session-top .voice-toggle { width: 40px; height: 40px; }
.voice-toggle svg { width: 20px; height: 20px; }
.voice-toggle:not(.on) { color: var(--muted); }
.listen-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 6px 0 4px; }
.btn.listen { min-height: 40px; padding: 8px 14px; font-size: .92rem; }
/* Tempowahl Langsam / Mittel / Schnell */
.speed { display: flex; gap: 2px; padding: 2px; margin: 8px 0; width: 100%; max-width: 360px; border-radius: 10px; background: rgba(120, 120, 128, 0.14); }
.speed button { flex: 1; min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.speed button.on { background: #fff; color: #111; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .speed button.on { background: #636366; color: #fff; } }
:root[data-theme="dark"] .speed button.on { background: #636366; color: #fff; }
.speed button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.listen-row + .speed { margin-top: 4px; }
.gl-speed .speed { margin: 0; max-width: none; flex: 1; }
.word-pop .speed { margin: 0; }
.reader-controls { flex-wrap: wrap; }
.ow { cursor: pointer; border-radius: 3px; }
.ow:hover { background: var(--surface-2); }
.ow.sel { background: var(--accent-soft); }
.tw.sel { outline: 2px solid var(--accent); }
.word-pop {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 25;
  width: min(528px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 14px 40px -12px rgba(0,0,0,.35); padding: 14px 14px 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start;
  animation: rise .15s ease;
}
.wp-main { flex: 1; min-width: 0; }
.wp-en { font-family: var(--serif); font-size: 1.25rem; }
.wp-de { font-size: 1.02rem; }
.wp-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wp-actions .speed { margin: 0; flex: 1; min-width: 200px; }
.wp-close { margin: -6px -6px 0 0; }
.wp-de { overflow-wrap: anywhere; }
.voice-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 10px; }
.voice-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); cursor: pointer; }
.voice-opt input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.voice-opt .vo-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.voice-opt.na { opacity: .5; cursor: default; }
.voice-opt:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* Design-Auswahl */
.design-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.design-opt { border: 2px solid var(--line); border-radius: 16px; padding: 10px; cursor: pointer; background: var(--surface-2); color: var(--ink); text-align: left; }
.design-opt.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.design-opt .sw-row { display: flex; gap: 4px; margin-bottom: 8px; }
.design-opt .sw-row i { flex: 1; height: 26px; border-radius: 6px; }
.design-opt b { display: block; }

/* Sprachen */
.top-actions { display: flex; gap: 8px; }
.lang-btn { font-size: 1.3rem; }
.lang-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lang-opt { display: flex; align-items: center; gap: 10px; border: 2px solid var(--line); border-radius: 14px; padding: 10px; background: var(--surface-2); color: var(--ink); cursor: pointer; text-align: left; }
.lang-opt.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lang-opt:disabled { opacity: .45; cursor: default; }
.lang-flag { font-size: 1.6rem; }
.lang-t { display: flex; flex-direction: column; min-width: 0; }
.rd { display: block; font-family: var(--sans); font-size: .95rem; font-weight: 500; color: var(--muted); letter-spacing: .02em; margin: 2px 0 8px; }
small.rd { font-size: .45em; margin: 4px 0 0; }
.wp-main .rd { display: inline; font-size: .9rem; margin: 0; }

/* ---------- Anmeldung ---------- */
.is-login .nav { display: none !important; }
.login { max-width: 440px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 24px) 4px 40px; font-family: "Atkinson Hyperlegible", system-ui, sans-serif; font-size: 19px; color: #14213D; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-logo { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 10px; border-radius: 22px; background: #1F5BD8; color: #fff; font-size: 2.4rem; font-weight: 700; }
.login-head h1 { margin: 0; font-size: 2rem; }
.login-head p { margin: 4px 0 0; color: #4A5670; }
.login-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: #E8EDF5; }
.login-tabs button { flex: 1; min-height: 52px; border: 0; border-radius: 12px; background: transparent; font: inherit; font-weight: 700; color: #4A5670; cursor: pointer; }
.login-tabs button.on { background: #fff; color: #14213D; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.login-intro { margin: 16px 2px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.login-form label small { font-weight: 400; color: #4A5670; }
.login-form input { width: 100%; min-height: 58px; padding: 0 16px; border: 2px solid #C9D2E1; border-radius: 14px; font: inherit; font-weight: 400; background: #fff; color: #14213D; box-sizing: border-box; }
.login-form input:focus { outline: 3px solid #F2B705; outline-offset: 1px; border-color: #1F5BD8; }
.login-pw { position: relative; display: block; }
.login-pw input { padding-right: 60px; }
.login-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border: 0; background: none; font-size: 1.3rem; cursor: pointer; }
.login-go { min-height: 64px; border: 0; border-radius: 18px; background: #1F5BD8; color: #fff; font: inherit; font-size: 1.25rem; font-weight: 700; cursor: pointer; }
.login-go:disabled { opacity: .7; }
.login-link { min-height: 48px; border: 0; background: none; color: #1F5BD8; font: inherit; text-decoration: underline; cursor: pointer; }
.login-msg { margin: 0; padding: 12px 14px; border-radius: 14px; background: #FDE2E2; color: #8A1C1C; }
.login-msg.ok { background: #E5F6EC; color: #145C33; }
.account p { margin: 6px 0; }

/* ---------- Hörmodus ---------- */
.top-actions { display: flex; gap: 8px; }
.listen-how { margin: 0 0 12px; }
.listen-now { padding: 22px 16px; border-radius: 18px; background: var(--surface-2, rgba(120,120,128,.1)); text-align: center; min-height: 170px; }
.ln-en { font-size: 2rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.ln-de { font-size: 1.15rem; color: var(--muted); margin-top: 4px; }
.ln-ex { margin-top: 12px; font-size: 1rem; }
.listen-ctrl { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 16px 0 8px; }
.listen-play { display: inline-flex; align-items: center; gap: 10px; min-height: 64px; padding: 0 28px; border: 0; border-radius: 32px; background: var(--accent); color: var(--accent-ink, #fff); font: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer; }
.listen-play svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn.big { width: 56px; height: 56px; font-size: 1.4rem; }
.listen-opts .speed.seg { margin: 4px 0 12px; }

/* ---------- Geschichten: Sätze & Dekodieren ---------- */
.dec-label { margin: 10px 0 0; }
#decMode { margin: 4px 0 6px; }
.sent { border-radius: 6px; transition: background .2s; }
.sent.cur { background: var(--marker-soft, #fff3b8); }
.sent.dec { display: block; margin: 0 0 12px; }
.sent-play { border: 0; background: none; color: var(--accent); font-size: .75em; padding: 0 4px 0 0; cursor: pointer; vertical-align: .1em; }
.sent-sub { display: block; font-size: .85em; line-height: 1.4; margin: 2px 0 0 1.2em; color: var(--muted); }
.sent-sub.wfw { font-style: italic; }

/* ---------- Üben: Nachsprechen & Diktat ---------- */
.mic-block { margin: 6px 0; }
.mic-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 2px solid var(--accent); border-radius: 24px; background: transparent; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.mic-btn.big { width: 100%; justify-content: center; min-height: 64px; font-size: 1.15rem; }
.mic-btn.rec { background: #FF3B30; border-color: #FF3B30; color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .mic-btn.rec { animation: none; } }
.mic-res.ok, .p-verdict.ok { color: var(--ok, #1E9E50); font-weight: 700; }
.mic-res.almost, .p-verdict.almost { color: #B07A00; font-weight: 700; }
.mic-res.bad, .p-verdict.bad { color: var(--bad, #D93636); font-weight: 700; }
.practice-card { display: flex; flex-direction: column; gap: 12px; }
.practice-card .listen-play { align-self: center; }
.practice-card textarea { width: 100%; box-sizing: border-box; min-height: 90px; padding: 12px; border: 2px solid var(--line); border-radius: 14px; font: inherit; font-size: 1.1rem; }
.p-diff .ok { color: var(--ok, #1E9E50); }
.p-diff .bad { color: var(--bad, #D93636); text-decoration: underline; }
.p-sol { margin: 4px 0 0; }
.center-card { text-align: center; }
.gl-speed .mic-block { flex: 1; }

/* ---------- KI-Gespräch ---------- */
.chat-scene { margin: 0 0 10px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; min-height: 40vh; padding-bottom: 8px; }
.msg { position: relative; max-width: 86%; padding: 10px 14px; border-radius: 18px; }
.msg p { margin: 0; }
.msg.ai { align-self: flex-start; background: var(--surface-2, #E8EDF5); border-bottom-left-radius: 6px; padding-right: 40px; cursor: pointer; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink, #fff); border-bottom-right-radius: 6px; }
.msg-de { margin-top: 6px !important; font-size: .9em; color: var(--muted); }
.msg-fix { margin-top: 6px !important; padding: 8px 10px; border-radius: 10px; background: #FFF3B8; color: #5a4300; font-size: .9em; }
.msg-say { position: absolute; right: 6px; top: 6px; border: 0; background: none; font-size: 1rem; cursor: pointer; }
.msg.typing p { letter-spacing: .3em; }
.chat-form { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; padding: 8px 0; background: var(--bg); }
.chat-form input { flex: 1; min-width: 0; min-height: 52px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; font: inherit; }
.chat-send { width: auto; min-height: 52px; padding: 0 16px; font-size: 1rem; }
.chat-form .ef-btn.chat-send { width: auto; flex: none; min-height: 52px; padding: 0 18px; font-size: 1rem; }
.chat-form .icon-btn.big { flex: none; }

/* Fortschritt beim Erstellen einer Geschichte */
.gen-progress{margin:14px 0 4px}
.gp-bar{height:12px;border-radius:99px;background:color-mix(in srgb,currentColor 12%,transparent);overflow:hidden}
.gp-bar i{display:block;height:100%;width:0;border-radius:inherit;background:var(--accent,#3b6cf6);transition:width .25s linear}
.gp-row{display:flex;justify-content:space-between;gap:12px;margin:8px 0 0;font-size:.95rem}
.gp-row span{font-variant-numeric:tabular-nums;opacity:.7;white-space:nowrap}
.dec-wait{display:flex;align-items:center;gap:8px}
.spin{width:14px;height:14px;border-radius:50%;border:2px solid currentColor;border-right-color:transparent;animation:spin .8s linear infinite;flex:none}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spin{animation:none}.gp-bar i{transition:none}}

/* Neues Gespräch: Ziel, Vorschläge, Auswertung */
.cv-goal { margin: 0 0 10px; }
.cv-goal-row { display: flex; justify-content: space-between; gap: 10px; font-size: .95rem; }
.cv-goal-row span:last-child { color: var(--muted); white-space: nowrap; }
.cv-bar { height: 10px; margin-top: 6px; border-radius: 99px; background: color-mix(in srgb, currentColor 12%, transparent); overflow: hidden; }
.cv-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.cv-words { margin: 0 0 8px; line-height: 2; }
.chip.used { background: #C9F2D2; color: #10582A; }
.cv-label { margin: 4px 0 6px; font-size: .85rem; color: var(--muted); }
.cv-sugg { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.cv-chip { display: flex; gap: 6px; align-items: stretch; }
.cv-use { flex: 1; text-align: left; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card, #fff); color: inherit; font: inherit; cursor: pointer; }
.cv-use small { display: block; margin-top: 2px; color: var(--muted); font-size: .85em; }
.cv-hear { flex: none; width: 48px; border: 2px solid var(--line); border-radius: 14px; background: var(--card, #fff); font-size: 1.1rem; cursor: pointer; }
.cv-say { display: flex; gap: 8px; margin: 6px 0; }
.cv-say input { flex: 1; min-width: 0; min-height: 48px; padding: 0 12px; border: 2px solid var(--line); border-radius: 14px; font: inherit; }
.linkish { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.cv-sum { text-align: center; }
.cv-stars { font-size: 2.8rem; letter-spacing: .1em; color: #D9D9D9; }
.cv-stars .on { color: #F5B800; }
.cv-points { margin: 0 0 12px; font-size: 1.2rem; }
.cv-points b { font-size: 2rem; }
.cv-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.cv-stats div { padding: 10px 6px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cv-stats b { display: block; font-size: 1.4rem; }
.cv-stats span { font-size: .85rem; line-height: 1.2; }
.cv-stats small { color: var(--muted); }
.cv-new { display: flex; flex-direction: column; gap: 8px; }
.cv-nw { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.cv-nw small { display: block; color: var(--muted); }
.cv-say[hidden] { display: none; }
a.ef-btn { text-decoration: none; display: flex; align-items: center; justify-content: center; margin-top: 10px; }

/* Einstieg */
body[data-view="onboarding"] .nav { display: none; }
.ob { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; }
.ob-title { margin: 0; font-size: 2rem; }
.ob-lead { margin: 0; color: var(--muted); }
.ob-h { margin: 10px 0 0; font-size: 1.1rem; }
.ob-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ob-lv { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.ob-lv b { font-size: 1.4rem; }
.ob-lv span { color: var(--muted); font-size: .9rem; }
.ob-lv:hover, .ob-lv:focus-visible { border-color: var(--accent); }
.ob-step { margin: 0; color: var(--muted); }
.ob-word { margin: 18px 0 0; font-size: 2.4rem; text-align: center; }
.ob-opts { display: flex; flex-direction: column; gap: 10px; }
.ob-opt { min-height: 54px; padding: 0 16px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: inherit; font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer; }
.ob-opt.ok { border-color: #1E9E55; background: #DDF6E6; color: #0C4A27; }
.ob-opt.bad { border-color: #D93B3B; background: #FBE1E1; color: #6B1414; }
.ob-skip { color: var(--muted); border-style: dashed; }
.ob-sent { margin: 16px 0 0; font-size: 1.5rem; line-height: 1.35; text-wrap: balance; }
.ob-lv.rec { border-color: var(--accent); }
