/* Kotoba – Washi-Papier, Tusche und Torii-Rot */
:root {
  --bg: #f6f1e9;
  --surface: #fffdf9;
  --surface-2: #efe8dc;
  --text: #1f1c19;
  --muted: #7a7168;
  --line: #e3dace;
  --accent: #c8423a;
  --accent-soft: #f6dcd7;
  --indigo: #2f4a7a;
  --indigo-soft: #dde4f1;
  --ok: #4f8a3a;
  --ok-soft: #e0eed6;
  --warn: #b7791f;
  --warn-soft: #f6ead2;
  --bad: #c8423a;
  --bad-soft: #f6dcd7;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 18px;
  --jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  --jp-serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  --jp-hand: "Klee", "Klee One", "Hiragino Maru Gothic ProN", var(--jp);
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, var(--jp), sans-serif;
  --hm0: #e9e1d4; --hm1: #f0c3bb; --hm2: #e0897e; --hm3: #cf5a4e; --hm4: #a8322b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16151a; --surface: #211f26; --surface-2: #2b2931; --text: #ece7df; --muted: #9c958c; --line: #34313a;
    --accent: #e0645a; --accent-soft: #43272a; --indigo: #8fa8d8; --indigo-soft: #263049;
    --ok: #86c06c; --ok-soft: #233421; --warn: #e0a84a; --warn-soft: #3a2f1c; --bad: #e86a5f; --bad-soft: #43272a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --hm0: #2b2931; --hm1: #5a2f2f; --hm2: #8a3c37; --hm3: #c24f45; --hm4: #ec7a6e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16151a; --surface: #211f26; --surface-2: #2b2931; --text: #ece7df; --muted: #9c958c; --line: #34313a;
  --accent: #e0645a; --accent-soft: #43272a; --indigo: #8fa8d8; --indigo-soft: #263049;
  --ok: #86c06c; --ok-soft: #233421; --warn: #e0a84a; --warn-soft: #3a2f1c; --bad: #e86a5f; --bad-soft: #43272a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --hm0: #2b2931; --hm1: #5a2f2f; --hm2: #8a3c37; --hm3: #c24f45; --hm4: #ec7a6e;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--ui);
  min-height: 100dvh; padding-bottom: calc(72px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
body.focus { padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--indigo); text-decoration: none; }
b { font-weight: 650; }
h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.4rem; }
p { margin: .5em 0; }
code { font-size: .8em; word-break: break-all; }
.jp { font-family: var(--jp); }
.f-sans { font-family: var(--jp); }
.f-serif { font-family: var(--jp-serif); }
.f-hand { font-family: var(--jp-hand); }
.muted { color: var(--muted); }
.center { text-align: center; }
.small-note { font-size: .85rem; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile & Navigation ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 8px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
header.top h1 { font-size: 1.05rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .logo { font-family: var(--jp-serif); color: var(--accent); font-weight: 700; font-size: 1.05rem; }
header.top .back, header.top .gear {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  color: var(--text); font-size: 1.6rem; line-height: 1;
}
header.top .gear { font-size: 1.3rem; justify-self: end; }
header.top.session { grid-template-columns: 44px 1fr auto; }
header.top.session .back { font-size: 1.15rem; }
header.top .back:active, header.top .gear:active { background: var(--surface-2); }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
nav.tabs a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; color: var(--muted); font-size: .7rem; border-radius: 12px; }
nav.tabs a .ti { font-size: 1.35rem; line-height: 1.3; }
nav.tabs a.active { color: var(--accent); }
body.focus nav.tabs { display: none; }

/* ---------- Layout ---------- */
main.page { max-width: 720px; margin: 0 auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.card-title { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.sub-title { font-weight: 650; font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
.foot { text-align: center; font-size: .85rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer;
  text-align: center; transition: transform .08s, filter .15s; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 11px; }
.btn.big { min-height: 54px; font-size: 1.05rem; width: 100%; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.danger { color: var(--bad); background: transparent; border-color: var(--bad-soft); margin-top: 12px; }
.btn small { font-weight: 400; opacity: .75; font-size: .8em; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row-btns > .btn { flex: 1 1 auto; }
.row-btns.col { flex-direction: column; }
.speak { border: 0; background: var(--surface-2); border-radius: 50%; width: 34px; height: 34px; font-size: .95rem; cursor: pointer; flex: none; display: inline-grid; place-items: center; vertical-align: middle; }
.speak:active { transform: scale(.92); }
.speak.big { width: 52px; height: 52px; font-size: 1.4rem; margin: 10px auto 0; display: grid; }

/* ---------- Segment-Schalter ---------- */
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg a { flex: 1; text-align: center; padding: 8px 6px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .95rem; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.small a { padding: 6px 4px; font-size: .85rem; }

/* ---------- Fortschritt ---------- */
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.badge { font-size: .72rem; padding: 2px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 600; margin-left: 4px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Start ---------- */
.hero { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 0; }
.hello { font-size: 1.9rem; font-weight: 700; }
.streak { display: flex; flex-direction: column; align-items: center; background: var(--surface); border-radius: 16px; padding: 6px 14px; box-shadow: var(--shadow); line-height: 1.1; }
.streak span { font-size: 1.3rem; }
.streak b { font-size: 1.3rem; }
.streak small { color: var(--muted); font-size: .7rem; }
.streak.zero span { filter: grayscale(1); opacity: .5; }
.due-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.due-grid.two { grid-template-columns: repeat(2, 1fr); }
.due { display: flex; flex-direction: column; align-items: center; background: var(--surface-2); border-radius: 14px; padding: 10px 4px; color: var(--text); line-height: 1.2; }
.due b { font-size: 1.7rem; }
.due span { font-size: .75rem; color: var(--muted); }
.due em { font-style: normal; font-size: .78rem; color: var(--indigo); font-weight: 600; margin-top: 2px; }
.due small { font-size: .78rem; font-weight: 650; margin-top: 4px; }
.done { text-align: center; padding: 12px; background: var(--ok-soft); color: var(--ok); border-radius: 14px; font-weight: 600; }
.kana-prog { display: grid; gap: 10px; }
.kp { display: flex; gap: 12px; align-items: center; color: var(--text); }
.kp > span { font-size: 1.8rem; width: 52px; height: 52px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); border-radius: 14px; flex: none; }
.kp > div { flex: 1; }
.kp small { color: var(--muted); font-size: .8rem; }
.weak { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.weak span { font-size: 1.4rem; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--bad-soft); color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-bottom: 14px; }
.stats b { display: block; font-size: 1.6rem; }
.stats small { color: var(--muted); }
.heatmap { display: flex; gap: 3px; justify-content: center; }
.hm-col { display: flex; flex-direction: column; gap: 3px; }
.heatmap i { width: 14px; height: 14px; border-radius: 3px; background: var(--hm0); display: block; }
.heatmap i.l1 { background: var(--hm1); } .heatmap i.l2 { background: var(--hm2); } .heatmap i.l3 { background: var(--hm3); } .heatmap i.l4 { background: var(--hm4); }
.heatmap i.empty { background: transparent; }

/* ---------- Kana-Übersicht ---------- */
.intro-text { margin: 0 4px; font-size: .9rem; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; }
details.intro { background: var(--indigo-soft); border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; }
details.intro summary { cursor: pointer; font-weight: 600; color: var(--indigo); }
.intro-body { padding-top: 6px; }
.big-inline { font-family: var(--jp); font-size: 1.6rem; color: var(--accent); vertical-align: middle; }
ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
ul.rows li:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); }
.row-kana { font-size: 1.35rem; letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-label { font-size: .85rem; color: var(--muted); }
.row-act { display: flex; gap: 6px; flex: none; }
.confuse { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.confuse li { display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.pair { font-size: 1.6rem; flex: none; width: 72px; text-align: center; background: var(--surface-2); border-radius: 12px; padding: 2px 0; }

/* ---------- Kana lernen ---------- */
.learn .dots { display: flex; gap: 6px; justify-content: center; }
.learn .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.learn .dots i.on { background: var(--accent); }
.slide { min-height: 56vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.kana-big { font-size: min(42vw, 190px); line-height: 1.1; color: var(--text); }
.kana-romaji { font-size: 2rem; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.mnemonic { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--warn-soft); border-radius: 16px; padding: 12px 14px; max-width: 520px; }
.mnemonic .emoji { font-size: 2.2rem; flex: none; }
.mnemonic p { margin: 0; }
.mnemonic b { color: var(--accent); }
.mnemonic.small { margin-top: 10px; font-size: .92rem; }
.mnemonic.small .emoji { font-size: 1.6rem; }
.fonts { display: flex; gap: 16px; margin-top: 8px; }
.fonts span { display: flex; flex-direction: column; align-items: center; }
.fonts b { font-size: 1.8rem; font-weight: 400; }
.fonts small { font-size: .7rem; color: var(--muted); }
.learn-nav { display: flex; gap: 10px; }
.learn-nav .btn { flex: 1; min-height: 52px; }
.intro-slide { text-align: left; max-width: 520px; font-size: 1.05rem; }
.end-slide { display: flex; flex-direction: column; gap: 10px; align-items: center; width: 100%; max-width: 420px; }
.big-emoji { font-size: 3rem; }
.recap { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; font-size: 2rem; margin: 6px 0; }
.recap span { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.recap small { font-size: .8rem; color: var(--muted); font-family: var(--ui); }

/* ---------- Kana-Test ---------- */
.quiz .q { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 16px; transition: background .2s; min-height: 50vh; justify-content: center; }
.q.right { background: var(--ok-soft); }
.q.wrong { background: var(--bad-soft); }
.q-prompt { font-size: min(36vw, 160px); line-height: 1.1; }
.ro-prompt { font-family: var(--ui); font-size: .55em; font-weight: 700; }
.q-feedback { min-height: 1.5em; text-align: center; width: 100%; display: flex; flex-direction: column; align-items: center; }
.solution { font-size: 1.3rem; }
.solution b { color: var(--bad); }
.answer {
  width: 100%; max-width: 320px; text-align: center; font-size: 1.6rem; padding: 12px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--surface); outline: none;
}
.answer:focus { border-color: var(--indigo); }
.q.right .answer { border-color: var(--ok); }
.q.wrong .answer { border-color: var(--bad); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 420px; }
.choice { position: relative; min-height: 64px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); font-size: 1.4rem; font-weight: 650; cursor: pointer; }
.choice.jp { font-size: 2rem; font-weight: 400; }
.choice small { position: absolute; top: 4px; left: 8px; font-size: .7rem; color: var(--muted); font-family: var(--ui); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.score { font-size: .9rem; font-weight: 650; white-space: nowrap; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 24px 16px; }
.result .row-btns { width: 100%; max-width: 380px; }
.pct { font-size: 3.6rem; font-weight: 800; line-height: 1; }
.missed { list-style: none; padding: 0; margin: 0; width: 100%; text-align: left; display: grid; gap: 8px; }
.missed li { display: grid; grid-template-columns: 48px 52px 1fr; grid-template-rows: auto auto; gap: 0 10px; align-items: center; background: var(--surface-2); padding: 8px 12px; border-radius: 12px; }
.missed b { font-size: 1.8rem; font-weight: 400; grid-row: span 2; }
.missed .r { font-weight: 700; color: var(--accent); grid-row: span 2; }
.missed .m { font-size: .85rem; }
.missed .st { font-size: .75rem; color: var(--muted); }
.celebrate .pct { animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* Eigener Test */
.pick-group { margin-bottom: 12px; }
.pick-all { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.pick-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.pick { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 12px; border: 2px solid var(--line); cursor: pointer; }
.pick input { display: none; }
.pick span { font-size: 1.15rem; }
.pick small { font-size: .7rem; color: var(--muted); }
.pick.on { border-color: var(--accent); background: var(--accent-soft); }
.sticky-bottom { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }

/* ---------- Schalter ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span { width: 46px; height: 28px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: 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 .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch small { font-size: .8rem; color: var(--muted); }

/* ---------- Vokabeln ---------- */
.cats, .sits { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cat, .sit { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.cat-main, .sit-main { flex: 1; display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 0; }
.cat-emoji, .sit-emoji { font-size: 1.8rem; width: 48px; height: 48px; display: grid; place-items: center; background: var(--surface-2); border-radius: 14px; flex: none; }
.sit.active .sit-emoji { background: var(--ok-soft); }
.cat-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cat-info small { color: var(--muted); font-size: .8rem; }
.cat .switch small, .sit .switch small { display: none; }
.search { width: 100%; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; outline: none; }
.search:focus { border-color: var(--indigo); }
.cat-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.words { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.word { display: grid; grid-template-columns: minmax(84px, auto) 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); position: relative; }
.w-jp { display: flex; flex-direction: column; }
.w-jp .w { font-size: 1.45rem; line-height: 1.2; }
.w-jp .k { font-size: .85rem; color: var(--muted); }
.w-de { font-size: .95rem; min-width: 0; }
.w-de .ro, .ro { font-size: .82rem; color: var(--indigo); }
.note { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.w-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.st { font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.st-new { background: var(--indigo-soft); color: var(--indigo); }
.st-learning { background: var(--bad-soft); color: var(--bad); }
.st-young { background: var(--warn-soft); color: var(--warn); }
.st-mature { background: var(--ok-soft); color: var(--ok); }
.del { position: absolute; top: -6px; right: -6px; border: 0; background: var(--surface-2); border-radius: 50%; width: 28px; height: 28px; font-size: .8rem; cursor: pointer; }
.kanji-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 2px; }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.kt { aspect-ratio: 1; font-size: 1.6rem; border-radius: 12px; border: 2px solid transparent; cursor: pointer; }
.kt.st-new { background: var(--surface); color: var(--text); }
.kt.sel { border-color: var(--accent); }
#kdetail { margin-top: 10px; }
.kanji-w { font-size: 2.4rem !important; }
.readings { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .9rem; margin-top: 2px; }
.readings small { font-size: .65rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.readings i { color: var(--indigo); font-style: normal; font-size: .82rem; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.form input, .set-row input:not([type=checkbox]):not([type=range]), .set-row select, .inline-form input {
  padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; font-weight: 400; outline: none; min-width: 0;
}
.form input:focus { border-color: var(--indigo); }
.preview { font-size: .85rem; min-height: 1.2em; margin-top: -6px; }

/* ---------- Phrasen ---------- */
.tip { background: var(--indigo-soft); color: var(--text); border-radius: 14px; padding: 12px 14px; font-size: .92rem; }
.hide-toggle { margin: 0 2px; }
.hide-toggle small { font-size: .85rem; }
.phrases { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.phrase { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); border-left: 4px solid var(--accent); }
.phrase.heard { border-left-color: var(--indigo); }
.who { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: flex; justify-content: space-between; }
.who .st { text-transform: none; letter-spacing: 0; }
.p-jp { font-size: 1.3rem; line-height: 1.4; margin-top: 4px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.p-kana { font-size: .9rem; color: var(--muted); }
.p-de { font-weight: 600; margin-top: 4px; }
.phrases.hiding .phrase { cursor: pointer; }
.phrases.hiding .phrase:not(.shown) .cover { filter: blur(7px); opacity: .6; user-select: none; }
.cover { transition: filter .2s, opacity .2s; }

/* ---------- Wiederholung ---------- */
.review { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.rcard { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 18px 16px 24px; cursor: pointer; min-height: 50vh; }
.rcard.revealed { min-height: 0; }
.rcard.revealed .front { flex: 0 0 auto; padding: 8px 0 4px; }
.kind { align-self: stretch; display: flex; justify-content: center; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; position: relative; }
.new-tag { color: var(--indigo); }
.undo { position: absolute; right: 0; border: 0; background: var(--surface-2); border-radius: 10px; width: 34px; height: 30px; font-size: 1rem; cursor: pointer; color: var(--text); }
.front { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; width: 100%; }
.f-label { font-size: .85rem; color: var(--muted); }
.f-main { font-size: clamp(2.4rem, 13vw, 4.2rem); line-height: 1.25; word-break: keep-all; overflow-wrap: anywhere; }
.f-main.long { font-size: clamp(1.6rem, 8vw, 2.6rem); }
.f-main.de { font-family: var(--ui); font-size: clamp(1.5rem, 7vw, 2.2rem); font-weight: 650; }
.kanji-front { font-size: clamp(4.5rem, 30vw, 8rem); }
.hint { font-size: 1.3rem; color: var(--muted); }
.rback { width: 100%; border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.b-jp { font-size: clamp(1.8rem, 9vw, 2.8rem); display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.b-kana { font-size: 1.3rem; color: var(--muted); display: flex; gap: 10px; align-items: center; justify-content: center; }
.b-ro { color: var(--indigo); font-size: 1.05rem; }
.b-de { font-size: 1.5rem; font-weight: 650; }
.readings.big { flex-direction: column; align-items: center; font-size: 1.15rem; }
.example { background: var(--surface-2); border-radius: 14px; padding: 10px 14px; font-size: .95rem; }
.example .jp { font-size: 1.2rem; }
.example i { color: var(--indigo); font-style: normal; }
.answer-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.answer-bar > * { max-width: 688px; margin: 0 auto; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grades.two { grid-template-columns: 1fr 1fr; }
.grades.three { grid-template-columns: repeat(3, 1fr); }
.quiz-entry { display: flex; align-items: center; gap: 12px; color: var(--text); padding: 12px 14px; }
.quiz-entry .chev { font-size: 1.6rem; color: var(--muted); }
.grade { min-height: 58px; border-radius: 14px; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; color: #fff; }
.grade small { font-size: .75rem; opacity: .85; }
.grade:active { transform: scale(.96); }
.grade.again { background: #c8423a; }
.grade.hard { background: #b7791f; }
.grade.good { background: #4f8a3a; }
.grade.easy { background: #2f4a7a; }
.counts { display: flex; gap: 8px; font-weight: 700; font-size: .9rem; }
.c-new { color: var(--indigo); } .c-learn { color: var(--bad); } .c-rev { color: var(--ok); }

/* ---------- Einstellungen ---------- */
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-title + .set-row { border-top: 0; }
.set-row > span:first-child { display: flex; flex-direction: column; }
.set-row small { color: var(--muted); font-size: .78rem; }
.set-row input[type=number] { width: 84px; text-align: right; }
.set-row input:not([type]), .set-row select { max-width: 55%; }
.set-row input[type=range] { width: 50%; accent-color: var(--accent); }
.steps { padding-left: 1.3em; margin: 8px 0 12px; }
.steps li { margin: 4px 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.sync-state { font-weight: 600; }
.kbd { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-size: .85em; }

/* ---------- Lesen ---------- */
.next-story { display: block; color: var(--text); }
.ns-main { display: flex; gap: 12px; align-items: center; }
.ns-main b { display: block; font-size: 1.15rem; line-height: 1.25; }
.ns-main small { color: var(--muted); font-size: .88rem; }
.ns-meta { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.ns-meta .badge { margin-left: 0; }
.ns-meta .chev { margin-left: auto; font-size: 1.6rem; color: var(--muted); line-height: 1; }
.s-emoji { font-size: 2rem; width: 56px; height: 56px; display: grid; place-items: center; background: var(--surface-2); border-radius: 16px; flex: none; }
.s-emoji.big { font-size: 2.4rem; width: 64px; height: 64px; }
.topics { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.topic { padding: 7px 12px; border-radius: 99px; background: var(--surface-2); color: var(--text); font-size: .9rem; font-weight: 600; border: 1px solid var(--line); }
.topic:active { transform: scale(.96); }
.topic-form input { flex: 1; }
.hm-wrap { margin-top: 14px; }
.lib-title { margin: 6px 4px -4px; }
.stories .cat.read .cat-emoji { background: var(--ok-soft); }
.read-mark { color: var(--ok); font-weight: 800; font-size: 1.1rem; }
.legacy-note { margin: 0 4px; }
.legacy-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.legacy-links .jp { font-size: 1.1rem; }

.story { padding: 18px 18px 8px; }
.s-head { display: flex; gap: 14px; align-items: center; }
.s-head h2 { font-size: 1.35rem; margin-top: 2px; }
.s-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0 4px; }
.s-meta .badge { margin-left: 0; }
.s-body { font-size: 1.08rem; line-height: 2.05; }
.s-body p { margin: 0 0 1em; }
.vw {
  font: inherit; color: inherit; background: none; border: 0; padding: 0 2px; margin: 0 1px; cursor: pointer;
  border-radius: 6px; line-height: inherit; display: inline; text-align: inherit;
}
.vw .jp { color: var(--accent); font-weight: 600; }
.vw.lv-ruby .jp { color: var(--indigo); }
.vw.lv-plain .jp { color: var(--text); border-bottom: 2px dotted var(--line); }
.vw:active, .vw:hover { background: var(--accent-soft); }
.vw .ve { margin-right: 2px; }
.vw .gl { display: inline-block; font-size: .72rem; line-height: 1.3; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 0 5px; margin-left: 3px; vertical-align: .15em; }
.vw.target .jp { background: var(--warn-soft); border-radius: 4px; padding: 0 2px; }
ruby rt { font-size: .55em; color: var(--muted); font-weight: 400; }
.blank { display: inline-block; min-width: 2.4em; text-align: center; border-bottom: 2px solid var(--accent); color: var(--accent); font-weight: 700; }
.tip.grammar { margin: 4px 0 14px; line-height: 1.6; }
.jp-block { display: grid; gap: 8px; margin: 0 0 1em; }
.jpl { background: var(--surface-2); border-left: 4px solid var(--indigo); border-radius: 12px; padding: 8px 10px 8px 12px; cursor: pointer; }
.jpl-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.jpl-jp { font-size: 1.3rem; line-height: 2.1; }
.jpl-de { font-size: .92rem; line-height: 1.5; padding-bottom: 4px; animation: fade .2s ease; }
.jpl-de i { display: block; color: var(--indigo); font-style: normal; font-size: .85rem; }
.sword { cursor: pointer; }
.sword .w-jp .w { font-size: 1.25rem; white-space: nowrap; }
.legend { text-align: center; line-height: 2; }

/* Wort-Blatt */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 85dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; position: relative; }
.sheet-x { position: absolute; top: 10px; right: 10px; border: 0; background: var(--surface-2); border-radius: 50%; width: 34px; height: 34px; cursor: pointer; color: var(--text); }
.sh-e { font-size: 2.4rem; line-height: 1; }
.sh-w { font-size: 3rem; line-height: 1.5; }
.sh-de { font-size: 1.35rem; font-weight: 700; }
.big-ro { font-size: 1rem; }
.sh-st { margin: 4px 0; }
.sheet .tip { text-align: left; width: 100%; }
.sheet .sub-title { align-self: flex-start; }
.sheet .ctx { width: 100%; text-align: left; }
@media (min-width: 760px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }

/* Quiz */
.qz { display: flex; flex-direction: column; gap: 10px; }
.qz-top { display: flex; align-items: center; gap: 10px; }
.qz-top .bar { flex: 1; margin: 0; }
.qz-left { font-weight: 700; font-size: .85rem; color: var(--muted); min-width: 2ch; text-align: right; }
.qz-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 22px 16px; }
.q-jp { font-size: clamp(2.6rem, 14vw, 4.2rem); line-height: 1.5; }
.q-de { font-size: 1.6rem; font-weight: 700; }
.q-fact { font-size: 1.2rem; font-weight: 650; line-height: 1.4; max-width: 520px; }
.q-hint { width: 100%; }
.speak.huge { width: 84px; height: 84px; font-size: 2.2rem; margin: 6px auto; }
.opts { display: grid; gap: 8px; width: 100%; max-width: 520px; }
.opt { position: relative; min-height: 52px; padding: 10px 14px 10px 34px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-size: 1.02rem; font-weight: 600; cursor: pointer; text-align: left; display: flex; align-items: center; gap: 10px; }
.opt > small:first-child { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .72rem; color: var(--muted); font-weight: 700; }
.opt .jp { font-size: 1.35rem; font-weight: 500; }
.opt small.jp { font-size: .85rem; color: var(--muted); }
.opt:disabled { cursor: default; color: var(--text); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q-fb { width: 100%; max-width: 520px; display: grid; gap: 10px; }
.q-fb:empty { display: none; }
.fb-head { font-weight: 700; font-size: 1.05rem; }
.wc { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.wc-e { font-size: 2rem; }
.wc-main { flex: 1; min-width: 0; }
.wc-jp { font-size: 1.5rem; line-height: 1.3; }
.wc-k { font-size: 1rem; color: var(--muted); }
.wc-de { font-weight: 650; }
.ctx { text-align: left; border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 8px 12px; font-size: .95rem; line-height: 1.9; margin-top: 4px; }
.ctx-src.jp { font-size: 1.1rem; }
.ctx-de { font-size: .88rem; line-height: 1.4; }
.ctx-from { font-size: .75rem; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.ctx .vw .jp { color: var(--text); }
.ctx .vw.target .jp { color: var(--accent); }
.wchips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.wchip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: .95rem; }
.wchip small { color: var(--muted); }
.gen { min-height: 40vh; justify-content: center; }
.spin { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg) scale(1.1); } }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 14px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Desktop ---------- */
@media (min-width: 760px) {
  main.page { padding-top: 22px; }
  .cats { grid-template-columns: 1fr 1fr; }
  .sits { grid-template-columns: 1fr 1fr; }
  .heatmap i { width: 16px; height: 16px; }
}
@media (hover: hover) {
  .btn:hover { filter: brightness(1.05); }
  .cat:hover, .sit:hover { box-shadow: 0 2px 4px rgba(60, 40, 20, .08), 0 8px 24px rgba(60, 40, 20, .1); }
}
