/* Washi & Zinnober: Papiergrund, Tusche, Zinnoberrot (朱) wie Torii und Hanko */
:root {
  --bg: #f7f1e5;
  --surface: #fffcf5;
  --text: #26211c;
  --muted: #776b5d;
  --border: #e4d9c5;
  --accent: #c23b2b;
  --accent-soft: #f7e2da;
  --good: #2f8f5b;
  --good-soft: #e3f4ea;
  --fav: #c98a00;
  --bad: #c8382e;
  --bad-soft: #fbe4e1;
  --saved: #c98a12;
  --l0: #f1ece5; --l1: #f7d9c4; --l2: #f4e3a1; --l3: #cfe8b5; --l4: #9fd6a8;
  --b1: #f7d9c4; --b2: #f4e3a1; --b3: #cfe8b5; --b4: #9fd6a8; --b5: #8cc7d9;
  --shadow: 0 2px 10px rgba(60, 40, 20, .08);
  --radius: 12px;
  --page: #ece2cd; --on-page: #26211c; --on-page-muted: #6c5f4f;
  --loom: #efe4cc; --warp: rgba(120, 92, 60, .38); --fringe: #b59a72;
  --jp: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  /* Washi: feine Fasern und Körnung */
  --washi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='a'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .18 0 0 0 .09 0'/%3E%3C/filter%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .35' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .5 -.18'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)'/%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  /* Tusche: dunkler Grund, Zinnober etwas heller */
  :root {
    --bg: #1c1916; --surface: #25211d; --text: #efe7da; --muted: #a89c8c; --border: #3a332b;
    --accent: #e0604c; --accent-soft: #3f241e; --good: #5cc48a; --good-soft: #1f3a2b;
    --fav: #f0c040;
    --bad: #e0604c; --bad-soft: #43231f; --saved: #e3b04b;
    --l0: #302b25; --l1: #4a3326; --l2: #4a4222; --l3: #32472a; --l4: #285338;
    --b1: #4a3326; --b2: #4a4222; --b3: #32472a; --b4: #285338; --b5: #234a57;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    --page: #141210; --on-page: #efe7da; --on-page-muted: #a89c8c;
    --loom: #2b2620; --warp: rgba(220, 200, 170, .22); --fringe: #6f5c45;
    /* auf dunklem Grund nur eine zarte Körnung mit wenigen hellen Fasern */
    --washi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='a'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .95 0 0 0 0 .9 0 0 0 0 .8 0 0 0 .05 0'/%3E%3C/filter%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .35' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .95 0 0 0 0 .85 0 0 0 .14 -.08'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23a)'/%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--washi), var(--page); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--accent); }
.hidden { display: none !important; }
.center { text-align: center; justify-content: center; }
.jp { font-family: var(--jp); }
kbd { font-size: .7rem; opacity: .7; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; font-family: system-ui; }

/* ---------- Kopfzeile & Navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
.brand-jp { font-family: var(--jp); color: var(--accent); margin-right: 4px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: none; padding: 8px 14px; border-radius: 999px;
  color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.tabs .ti { font-family: var(--jp); font-size: .95rem; }
.tabs button:hover { color: var(--text); background: var(--bg); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { max-width: 860px; margin: 0 auto; padding: 32px 16px 80px; }
.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }

h1 { font-family: var(--jp); margin: 0 0 8px; font-size: 2rem; }
h1 small { font-family: system-ui, sans-serif; font-size: 1rem; font-weight: 400; }
h2 { margin: 0 0 16px; }
h2 small, h3 small { font-weight: 400; color: var(--muted); font-size: .8em; }
h3 { margin: 0 0 12px; font-size: 1.05rem; }
.lead { margin: 0 0 24px; }
.hint { color: var(--muted); font-size: .9rem; }
/* Text direkt auf dem dunkelroten Hintergrund */
.view > h1, .view > .hint, .toolbar .hint, .kana-group h3, .on-page { color: var(--on-page) !important; }
.view > h1 small, .lead { color: var(--on-page-muted) !important; }

/* ---------- Bausteine ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin: 0 0 16px; }
.panel.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.row.wrap { flex-wrap: wrap; }
button.primary { background: var(--accent); color: #fff; border: 0; padding: 10px 20px; border-radius: 10px; font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.primary.big { padding: 13px 26px; font-size: 1.05rem; }
.secondary { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 10px; text-decoration: none; display: inline-block; font-size: .95rem; cursor: pointer; }
.secondary:hover:not(:disabled) { border-color: var(--accent); }
.secondary.danger { color: var(--bad); }
.secondary.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 4px; font-size: .9rem; }
.icon-btn { border: 0; background: none; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); font-size: 1.1rem; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.tag { display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 2px 8px; margin-right: 6px; }
.tag.good { color: var(--good); background: var(--good-soft); }
.kicker { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 600; }
.level-badge { display: inline-block; vertical-align: middle; font-size: .68rem; font-weight: 700; letter-spacing: .04em; line-height: 1; padding: 4px 7px; border-radius: 6px; background: var(--l0); color: var(--muted); font-family: inherit; }
.level-badge.lv-n5 { background: var(--good-soft); color: var(--good); }
.level-badge.lv-n4 { background: #e3eefb; color: #2f6db5; }
.level-badge.lv-n3 { background: #fdf0dc; color: #b06d12; }
.level-badge.lv-n2, .level-badge.lv-n1 { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) { .level-badge.lv-n4 { background: #223a55; color: #8ab8ee; } .level-badge.lv-n3 { background: #4a3a1c; color: #e8b864; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .9rem; }
.chip small { color: var(--muted); }
.chip.toggle { cursor: pointer; }
.chip.toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.progress { height: 6px; background: var(--l0); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 20px; }
.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; color: var(--muted); }
.segmented button.active { background: var(--accent); color: #fff; }
.segmented.small button { padding: 5px 10px; font-size: .88rem; }
.field { margin-bottom: 20px; }
.field > label { display: block; font-weight: 600; margin-bottom: 8px; font-size: .9rem; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; }
.empty { text-align: center; }

/* Wortbausteine im Text */
rt { font-size: .5em; color: var(--muted); }
.no-furi .transcript rt, .no-furi .peek rt { visibility: hidden; }
.tok { border-radius: 6px; padding: 0 1px; margin: 0 1px; transition: background .15s, color .15s; }
[data-k].tok { cursor: pointer; }
[data-k].tok:hover, .tok:focus-visible { background: var(--l2); outline: none; }
.tok.st-saved { text-decoration: underline dotted var(--saved); text-decoration-thickness: 2px; text-underline-offset: 7px; }
.tok.st-active { text-decoration: underline solid var(--good); text-decoration-thickness: 2px; text-underline-offset: 7px; }
.tok.target { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tok.speaking { background: var(--accent); color: #fff; }
.tok.speaking rt { color: #fff; }

/* ---------- Heute ---------- */
.story-hero { display: flex; gap: 20px; align-items: stretch; }
/* ---------- Wandteppich (Bild der Geschichte, gewebt bis zum Anteil bekannter Wörter) ---------- */
.tapestry { --w: 96px; position: relative; flex: none; width: var(--w); aspect-ratio: 3 / 4; padding-top: 5px; margin-bottom: 7px; align-self: flex-start; }
.tapestry.small { --w: 78px; }
.tapestry.large { --w: 132px; }
/* Holzstab oben und Fransen unten */
.tapestry::before { content: ""; position: absolute; z-index: 4; top: 0; left: -5px; right: -5px; height: 6px; border-radius: 3px; background: linear-gradient(#8a5d3b, #4d2f1b); box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.tapestry::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: -7px; height: 7px; background: repeating-linear-gradient(90deg, var(--fringe) 0 1.4px, transparent 1.4px 3.6px); }
.tp-cloth { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--loom); box-shadow: 0 3px 8px rgba(40, 25, 10, .25), inset 0 0 0 1px rgba(0, 0, 0, .08); }
.tp-cloth img, .tp-pattern { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
/* noch nicht gewebt: blasse Vorzeichnung, darüber die leeren Kettfäden */
.tp-ghost { position: absolute; inset: 0; opacity: .2; filter: grayscale(1) sepia(.4); }
.tp-cloth::before { content: ""; position: absolute; inset: 0; z-index: 2; clip-path: inset(0 0 var(--fill) 0);
  background: repeating-linear-gradient(90deg, var(--warp) 0 1px, transparent 1px 3px); }
/* gewebter Teil mit Fadenstruktur */
.tp-woven { position: absolute; inset: 0; clip-path: inset(calc(100% - var(--fill)) 0 0 0); transition: clip-path .9s ease; }
.tp-woven::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .16) 0 1px, rgba(255, 255, 255, .07) 1px 2px, transparent 2px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .1) 0 1px, transparent 1px 3px); }
.tp-woven::after { content: ""; position: absolute; inset: 0; z-index: 1; opacity: .85; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='2' height='2' fill='%23fff' fill-opacity='.22'/%3E%3Crect x='2' y='2' width='2' height='2' fill='%23fff' fill-opacity='.22'/%3E%3Cpath d='M0 1h2M2 3h2' stroke='%23000' stroke-opacity='.28' stroke-width='.5'/%3E%3Cpath d='M3 0v2M1 2v2' stroke='%23000' stroke-opacity='.28' stroke-width='.5'/%3E%3C/svg%3E"); }
/* Webkante: hier wird gerade gewebt */
.tp-cloth::after { content: ""; position: absolute; z-index: 3; left: 0; right: 0; bottom: var(--fill); height: 2px; background: var(--accent); box-shadow: 0 0 5px var(--accent); transition: bottom .9s ease; }
.tapestry.done .tp-cloth::after, .tapestry.done .tp-cloth::before { display: none; }
.tp-seal { position: absolute; z-index: 5; right: -6px; bottom: -4px; width: 22px; height: 22px; display: grid; place-items: center; font-size: .78rem; color: #fff; background: var(--accent); border-radius: 4px; transform: rotate(-6deg); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.tapestry.large .tp-seal { width: 28px; height: 28px; font-size: 1rem; }
/* Muster für Geschichten ohne Bild: 青海波 (Wellen) */
.tp-pattern { --c1: hsl(var(--hue) 45% 32%); --c2: hsl(var(--hue) 35% 88%); display: grid; place-items: center;
  background-color: var(--c1);
  background-image:
    radial-gradient(circle at 100% 150%, var(--c1) 24%, var(--c2) 24% 28%, var(--c1) 28% 36%, var(--c2) 36% 40%, transparent 40%),
    radial-gradient(circle at 0 150%, var(--c1) 24%, var(--c2) 24% 28%, var(--c1) 28% 36%, var(--c2) 36% 40%, transparent 40%),
    radial-gradient(circle at 50% 100%, var(--c2) 10%, var(--c1) 10% 23%, var(--c2) 23% 30%, var(--c1) 30% 43%, var(--c2) 43% 50%, var(--c1) 50% 63%, var(--c2) 63% 71%, transparent 71%),
    radial-gradient(circle at 100% 50%, var(--c2) 5%, var(--c1) 5% 15%, var(--c2) 15% 20%, var(--c1) 20% 29%, var(--c2) 29% 34%, var(--c1) 34% 44%, var(--c2) 44% 49%, transparent 49%),
    radial-gradient(circle at 0 50%, var(--c2) 5%, var(--c1) 5% 15%, var(--c2) 15% 20%, var(--c1) 20% 29%, var(--c2) 29% 34%, var(--c1) 34% 44%, var(--c2) 44% 49%, transparent 49%);
  background-size: 28px 14px; }
.tp-pattern span { font-size: calc(var(--w) * .42); color: #fff; background: var(--c1); border-radius: 50%; width: 1.5em; height: 1.5em; display: grid; place-items: center; box-shadow: 0 0 0 3px var(--c2); }
.story-hero-body { flex: 1; min-width: 0; }
.story-hero h2 { margin: 4px 0 8px; font-size: 1.5rem; }
.today-next { text-align: center; }
.today-next .hint { margin: 0; }

/* ---------- Bibliothek ---------- */
.library { display: grid; gap: 12px; }
.story-card {
  display: flex; gap: 16px; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: border-color .15s;
}
.story-card:hover { border-color: var(--accent); }
.story-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.story-card b { font-size: 1.1rem; }
.story-card b small { font-weight: 400; color: var(--muted); }
.story-card .desc { font-size: .92rem; }
.story-card .meta, .meta { font-size: .8rem; color: var(--muted); }
.coverage { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; margin-top: 2px; }
.coverage-bar { width: 80px; height: 6px; border-radius: 3px; background: var(--l0); overflow: hidden; flex: none; }
.coverage-bar span { display: block; height: 100%; background: currentColor; }
.coverage.high { color: var(--good); } .coverage.mid { color: var(--saved); } .coverage.low { color: var(--accent); }

/* ---------- Player ---------- */
.player { padding: 20px 24px 0; }
.pl-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.audio-badge { font-size: .78rem; color: var(--saved); border: 1px dashed var(--saved); border-radius: 999px; padding: 3px 10px; }
.audio-badge.rec { color: var(--good); border: 1px solid var(--good); }
.pl-title { margin: 14px 0 10px; font-size: 1.5rem; }
.scene-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.scene-tabs button { flex: none; border: 1px solid var(--border); background: var(--bg); border-radius: 999px; padding: 5px 12px; font-family: var(--jp); font-size: .88rem; color: var(--muted); }
.scene-tabs button b { font-family: system-ui; margin-right: 2px; }
.scene-tabs button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.voice-hint { background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin: 12px 0 0; }
.scene-title { font-family: var(--jp); color: var(--muted); font-weight: 500; margin: 20px 0 8px; }
.sents { list-style: none; padding: 0; margin: 0; }
.sent { display: flex; gap: 6px; align-items: flex-start; padding: 6px 10px 6px 2px; border-radius: 12px; transition: background .25s; }
.sent.current { background: var(--accent-soft); }
.say { flex: none; border: 0; background: none; color: var(--muted); font-size: .8rem; width: 30px; height: 30px; margin-top: 12px; border-radius: 50%; }
.say:hover { color: var(--accent); background: var(--bg); }
.sent-body { min-width: 0; }
.sent-tools { flex: none; display: flex; flex-direction: column; align-items: center; }
.sent-tools .fav-btn { width: 30px; height: 30px; padding: 0; border: 0; background: none; }
/* Favoriten-Stern: leer und dezent, markiert golden */
.fav-btn { font: inherit; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; cursor: pointer; line-height: 1.2; }
.fav-btn:hover { color: var(--fav); border-color: var(--fav); }
.fav-btn.on { color: var(--fav); border-color: var(--fav); }
.sent-tools .fav-btn, .sh-list .fav-btn { font-size: 1.05rem; }
.transcript .jp, .peek .jp { font-size: 1.65rem; line-height: 2.35; margin: 0; }
.transcript .ro, .transcript .de, .peek .ro, .peek .de { display: none; margin: 0 0 6px; }
.ro { color: var(--muted); font-size: .92rem; }
.de { font-style: italic; }
.show-ro .ro, .show-de .de { display: block !important; }
.scene-nav { display: flex; justify-content: space-between; gap: 8px; margin: 20px 0 8px; }
.end-card { display: flex; flex-direction: column; gap: 8px; text-align: center; background: var(--good-soft); border-radius: 12px; padding: 18px; margin: 12px 0; }
.end-card b { font-family: var(--jp); font-size: 1.2rem; }
.legend { margin: 8px 0 16px; }
.legend .tok { cursor: default; }
.listen-card { text-align: center; padding: 36px 8px 28px; }
.listen-icon { font-size: 3rem; }
.listen-meta { color: var(--muted); }
.listen-meta:first-of-type { font-family: var(--jp); color: var(--text); font-size: 1.05rem; margin-top: 8px; }
.peek { background: var(--bg); border-radius: 12px; padding: 12px 16px; margin: 16px auto 0; max-width: 560px; }
.peek .ro, .peek .de { display: none; }
.listen-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.pl-bar {
  position: sticky; bottom: 0; z-index: 5; margin: 8px -24px 0; padding: 10px 24px 14px;
  background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}
.pl-progress { height: 4px; background: var(--l0); border-radius: 2px; overflow: hidden; margin-bottom: 10px; }
#pl-progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.pl-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-controls > button {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; padding: 0;
}
.pl-controls > button:hover { border-color: var(--accent); }
.pl-controls > button.play { width: 52px; height: 52px; background: var(--accent); color: #fff; border: 0; font-size: 1.25rem; }
.pl-pos { color: var(--muted); font-size: .85rem; min-width: 56px; }
.pl-controls .segmented { margin-left: auto; }
.pl-options { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 10px; font-size: .92rem; }
.pl-options label { display: flex; align-items: center; gap: 5px; }

/* ---------- Wortdetails (Bottom-Sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 50; width: min(560px, 100%);
  max-height: 85vh; overflow-y: auto; transform: translate(-50%, 105%); transition: transform .25s ease;
  background: var(--surface); color: var(--text); border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); padding: 10px 22px calc(22px + env(safe-area-inset-bottom));
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 10px; }
.sheet-close { position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 1.6rem; color: var(--muted); }
.ws-tags { min-height: 20px; }
.ws-word { font-size: 2.6rem; line-height: 1.5; margin-top: 4px; }
.ws-reading { color: var(--muted); }
.ws-meaning { font-size: 1.25rem; font-weight: 600; margin: 8px 0; }
.ws-info { background: var(--bg); border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-size: .92rem; }
.ws-example { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 14px 0; }
.ws-example .jp { font-size: 1.2rem; line-height: 2.1; margin: 0; }
.ws-example .de, .flash-ex .de, .check-ex .de { margin: 2px 0 0; color: var(--muted); }
.ws-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.ws-actions .primary { flex: 1; }
.ws-actions .primary:disabled { background: var(--good-soft); color: var(--good); opacity: 1; }

/* ---------- Wortschatz-Check ---------- */
.check { max-width: 640px; margin: 0 auto; }
.check-intro { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; }
.check-top { display: flex; justify-content: space-between; align-items: center; }
.check-word { font-size: 3.2rem; text-align: center; line-height: 1.6; margin: 20px 0 4px; }
.check-ex { text-align: center; margin: 16px 0; }
.check-ex .jp { font-size: 1.2rem; line-height: 2.1; margin: 0; }
.check-answer { text-align: center; font-size: 1.4rem; font-weight: 600; margin: 8px 0 4px; }
.check-answer small { display: block; font-size: .9rem; font-weight: 400; color: var(--muted); }
button.rate { border: 2px solid var(--border); background: var(--surface); border-radius: 12px; padding: 11px 20px; font-weight: 600; }
button.rate.bad { color: var(--bad); } button.rate.bad:hover { background: var(--bad-soft); border-color: var(--bad); }
button.rate.good { color: var(--good); } button.rate.good:hover { background: var(--good-soft); border-color: var(--good); }

/* ---------- Merkliste ---------- */
.saved-head p { margin: 0; }
.saved-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.saved-item { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 12px 14px 16px; box-shadow: var(--shadow); }
.saved-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.saved-check { padding-top: 10px; }
.saved-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.saved-body { flex: 1; min-width: 0; }
.saved-word { font-size: 1.6rem; line-height: 1.8; }
.saved-de { font-weight: 600; margin-left: 6px; }
.rank { font-size: .72rem; font-weight: 400; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 1px 6px; margin-left: 8px; vertical-align: middle; white-space: nowrap; }
.rank.top { color: var(--good); background: var(--good-soft); }
.saved-ex { font-size: 1.05rem; line-height: 2; }
.saved-ex-de { font-size: .88rem; color: var(--muted); font-style: italic; }
.saved-tools { display: flex; flex-direction: column; }
.saved-sort { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.saved-group { margin-bottom: 18px; }
.saved-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 6px 2px 8px; }
.saved-group-head h3 { margin: 0; font-size: 1.05rem; }
.saved-group-head small { font-weight: 400; color: var(--muted); }

/* ---------- Lernkartei ---------- */
.deck-head { text-align: center; }
.deck-head p { margin: 0 0 12px; }
.deck-head .secondary { margin-top: 10px; }
.boxes4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.box4 { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border-top: 6px solid var(--b1); display: flex; flex-direction: column; gap: 2px; }
.box4-2 { border-top-color: var(--b2); } .box4-3 { border-top-color: var(--b3); } .box4-4 { border-top-color: var(--b4); } .box4-5 { border-top-color: var(--b5); }
.boxes4.boxes5 { grid-template-columns: repeat(5, 1fr); }
.ok-line { color: var(--good); font-weight: 600; margin: 0 0 8px; }
.gate-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.story-hero.locked .tapestry { filter: grayscale(.7); opacity: .7; }
.box4-head { display: flex; flex-direction: column; }
.box4-head span { font-size: .82rem; color: var(--muted); }
.box4-count { font-size: 2rem; font-weight: 700; line-height: 1.2; margin-top: 6px; }
.box4-due { font-size: .82rem; color: var(--accent); font-weight: 600; }
.box4-help { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.box4-words { font-size: .95rem; margin-top: 8px; line-height: 1.7; word-break: keep-all; }
/* Fächer der Wort-Lernkartei sind antippbar und klappen ihre Wortliste auf */
button.box4 { font: inherit; color: inherit; text-align: left; cursor: pointer; transition: transform .1s, box-shadow .1s; }
button.box4:hover { transform: translateY(-1px); }
button.box4.open { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.box-list { margin-top: 12px; border-top: 6px solid var(--b1); }
.box-list-2 { border-top-color: var(--b2); } .box-list-3 { border-top-color: var(--b3); } .box-list-4 { border-top-color: var(--b4); } .box-list-5 { border-top-color: var(--b5); }
.box-list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.box-list-head h3 { margin: 0 0 8px; }
.count { font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.box-words { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.box-word { width: 100%; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "w de" "w meta"; column-gap: 12px; align-items: center; text-align: left; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; cursor: pointer; }
.box-word:hover { border-color: var(--accent); }
.box-word > .jp { grid-area: w; font-size: 1.3rem; line-height: 1.7; }
.box-word-de { grid-area: de; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box-word-meta { grid-area: meta; font-size: .76rem; color: var(--muted); }
.box-word-meta .lapses { color: var(--accent); font-weight: 600; }
.session-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; max-width: 640px; margin-left: auto; margin-right: auto; }
.flash { max-width: 640px; margin: 0 auto; text-align: center; }
/* Fach-Markierung klein oben links, als eigene Zeile, damit sie auf schmalen Bildschirmen nichts überdeckt */
.box-tag { display: block; width: fit-content; margin: -8px auto 12px 0; color: var(--text); font-size: .62rem; padding: 1px 7px; }
.box-tag.box4-1 { background: var(--b1); } .box-tag.box4-2 { background: var(--b2); }
.box-tag.box4-3 { background: var(--b3); } .box-tag.box4-4 { background: var(--b4); } .box-tag.box4-5 { background: var(--b5); }
.flash-word { font-size: 3.4rem; line-height: 1.6; }
.flash-reading { color: var(--muted); }
.flash-meaning { font-size: 1.5rem; font-weight: 600; margin: 6px 0; }
.flash-ex { background: var(--bg); border-radius: 12px; padding: 10px 16px; margin: 16px 0 4px; }
.flash-ex .jp { font-size: 1.2rem; line-height: 2.1; margin: 0; }
/* vor dem Aufdecken sind die Wörter im Satz nicht antippbar */
.flash:not(.revealed) .flash-ex .tok { cursor: default; }
.flash:not(.revealed) .flash-ex .tok:hover { background: none; }
.rate-row { margin-top: 20px; }

/* ---------- Kanji (Heisig) ---------- */
.today-kanji { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer; color: var(--text); font: inherit; }
.today-kanji:hover { border-color: var(--accent); }
.today-kanji > .jp { font-size: 2rem; color: var(--accent); }
.today-kanji > span:nth-child(2) { flex: 1; }
.kanji-progress-row { display: flex; justify-content: space-between; align-items: baseline; }
.boxes4.compact { margin-bottom: 16px; }
.boxes4.compact .box4-count { font-size: 1.5rem; }
.block-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 6px; margin-bottom: 10px; }
.block-tabs button { flex: none; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 4px 10px; font-size: .8rem; color: var(--muted); }
.block-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.kcell { border: 1px solid transparent; border-radius: 8px; padding: 4px 0 2px; display: flex; flex-direction: column; align-items: center; background: var(--l0); line-height: 1.1; }
.kcell span { font-size: 1.35rem; }
.kcell small { font-size: .62rem; color: var(--muted); }
.kcell:hover { border-color: var(--accent); }
.kcell.st-locked span { opacity: .3; }
.st-box1 { background: var(--b1); } .st-box2 { background: var(--b2); } .st-box3 { background: var(--b3); } .st-box4 { background: var(--b4); } .st-box5 { background: var(--b5); }
.st-learned { background: var(--b4); }
.legend-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 12px 0 0; }
.kdot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--l0); margin-left: 8px; }
.frame-no { color: var(--muted); font-size: .9rem; text-align: center; }
.kanji-learn { max-width: 640px; margin-left: auto; margin-right: auto; }
.kanji-stage { width: 200px; height: 200px; margin: 8px auto; position: relative; }
.kanji-svg { width: 100%; height: 100%; background: var(--bg); border-radius: 14px; }
.kanji-svg .grid { stroke: var(--border); stroke-width: .6; stroke-dasharray: 2 2; fill: none; }
.kanji-svg .ghost path { fill: none; stroke: var(--border); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.kanji-svg .ink path { fill: none; stroke: var(--text); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.kanji-svg .nums text { font-size: 7px; fill: var(--accent); font-family: system-ui, sans-serif; }
@keyframes kanji-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@keyframes kanji-current { from, 80% { stroke: var(--accent); } to { stroke: var(--text); } }
@keyframes kanji-num { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .kanji-svg .ink path, .kanji-svg .nums text { animation: none !important; } }
.kanji-fallback { font-size: 150px; line-height: 200px; text-align: center; color: var(--border); }
.kanji-stage .hint { position: absolute; bottom: -24px; left: 0; right: 0; text-align: center; }
/* Zeichenfläche in der Kanji-Abfrage (js/kanji-draw.js) */
.draw-pad { width: 260px; height: 260px; max-width: 100%; margin: 12px auto 4px; }
.draw-canvas { display: block; width: 100%; height: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; touch-action: none; cursor: crosshair; }
.draw-tools { margin-top: 4px; }
.draw-compare { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.draw-compare figure { margin: 0; text-align: center; }
.draw-compare .kanji-stage { width: 150px; height: 150px; margin: 4px auto; }
.draw-compare .kanji-fallback { font-size: 110px; line-height: 150px; }
.drawn polyline { fill: none; stroke: var(--text); stroke-width: 4.2; stroke-linecap: round; stroke-linejoin: round; }
.drawn .ok { stroke: var(--good); } .drawn .bad { stroke: var(--bad); }
.draw-verdict { text-align: center; font-weight: 600; margin: 6px 0 10px; }
.draw-verdict small { font-weight: 400; color: var(--muted); }
.draw-verdict.good { color: var(--good); } .draw-verdict.close { color: var(--saved); } .draw-verdict.again { color: var(--bad); }
.rate.suggest { outline: 3px solid currentColor; outline-offset: 2px; }
.kanji-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; font-size: .88rem; color: var(--muted); margin: 10px 0 16px; }
/* Spiele */
.game-tiles { display: grid; gap: 12px; }
.game-tile { display: flex; align-items: center; gap: 16px; text-align: left; width: 100%; margin: 0; cursor: pointer; color: var(--text); font: inherit; }
.game-tile:hover:not(:disabled) { border-color: var(--accent); }
.game-tile:disabled { opacity: .55; cursor: default; }
.game-body { display: flex; flex-direction: column; gap: 2px; }
.game-body b { font-size: 1.05rem; }
.mc { text-align: center; }
.mc-dir { margin-bottom: 14px; }
.mc-dir button { font-size: .82rem; padding: 5px 10px; }
.mc-prompt { font-size: 1.6rem; font-weight: 600; margin: 10px 0 4px; line-height: 1.8; }
.mc-prompt.jp { font-size: 2.2rem; }
.mc-listen { font-size: 2.2rem; width: 84px; height: 84px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); cursor: pointer; margin: 6px 0; }
.mc-meaning { font-weight: 600; margin: 0 0 6px; }
.mc-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.mc-option { display: flex; align-items: center; gap: 8px; text-align: left; padding: 12px; border-radius: 12px; min-height: 58px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.mc-option .jp { font-size: 1.25rem; }
.mc-option kbd { opacity: .5; }
.mc-option:hover:not(:disabled) { border-color: var(--accent); }
.mc-option.right { border-color: var(--good); background: var(--good-soft); }
.mc-option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.mc-option.dim { opacity: .5; }
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.pairs-col { display: flex; flex-direction: column; gap: 8px; }
.pair { min-height: 56px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font: inherit; font-size: .92rem; cursor: pointer; transition: opacity .3s, background .2s; }
.pair .jp { font-size: 1.25rem; }
.pair.sel { border-color: var(--accent); background: var(--accent-soft); }
.pair.wrong { border-color: var(--bad); background: var(--bad-soft); }
.pair.matched { border-color: var(--good); background: var(--good-soft); opacity: .45; cursor: default; }
@media (max-width: 560px) { .mc-options { grid-template-columns: 1fr; } }

/* Satzpuzzle */
.pz { text-align: center; }
.pz-line { min-height: 64px; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px;
  padding: 10px; border-bottom: 2px dashed var(--border); margin-bottom: 14px; }
.pz-line .hint { align-self: center; }
.pz-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 6px 0 14px; min-height: 52px; }
.pz-chip { font-family: var(--jp); font-size: 1.2rem; line-height: 1.9; padding: 2px 12px; border-radius: 10px; cursor: pointer;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); box-shadow: 0 1px 0 var(--border); }
.pz-chip:hover { border-color: var(--accent); }
.pz-chip.wrong { border-color: var(--bad); background: var(--bad-soft); }
.pz-chip .tok { pointer-events: none; }
.pz-end { font-family: var(--jp); font-size: 1.2rem; line-height: 1.9; }
.pz-verdict { font-weight: 600; margin: 4px 0 8px; }
.pz-verdict.good { color: var(--good); } .pz-verdict.bad { color: var(--bad); }
.pz-sentence { font-size: 1.3rem; line-height: 2.2; background: var(--bg); border-radius: 12px; padding: 8px 14px; margin: 8px 0; }
.fold { text-align: center; margin: 4px 0 8px; }
.fold summary { display: inline-block; cursor: pointer; font-size: .85rem; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold[open] summary { margin-bottom: -4px; }
.kanji-keyword { font-size: 2.2rem; font-weight: 700; margin: 6px 0 10px; }
.kanji-story { background: var(--bg); border-radius: 10px; padding: 8px 14px; margin: 0 auto 10px; max-width: 480px; font-style: italic; white-space: pre-wrap; }
.kanji-story.proposal { font-style: normal; border-left: 3px solid var(--accent); text-align: left; max-width: none; }
.proposal-ref { font-style: italic; margin: 0 0 6px; }
.cov-open { margin-top: -2px; }
.text-input, .num-input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%; }
.text-input:focus, .num-input:focus { outline: none; border-color: var(--accent); }
textarea.text-input { resize: vertical; }
.num-input { width: 110px; }
.sync-error { color: var(--accent) !important; }
.own-list { list-style: none; padding: 0; margin: 0; }
.own-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.own-list li small { color: var(--muted); flex: 1; min-width: 0; }
.ws-kanji { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; font-size: .85rem; color: var(--muted); }
.ws-kanji span { background: var(--bg); border-radius: 8px; padding: 3px 9px; }
.ws-kanji span.learned { color: var(--good); background: var(--good-soft); }
.ws-kanji b { font-size: 1.05rem; color: var(--text); }

/* ---------- Profil ---------- */
.progress-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.progress-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.progress-table tr:last-child td { border-bottom: 0; }
.progress-table td.jp { font-size: 1.05rem; }
.file-btn { cursor: pointer; }

/* ---------- Kana ---------- */
.kana-group { margin-bottom: 28px; }
.kana-group h3 { margin: 0 0 10px; font-size: 1rem; }
.kana-grid { display: grid; gap: 6px; }
.kana-cell { background: var(--l0); border: 1px solid transparent; border-radius: 10px; padding: 8px 4px; text-align: center; min-height: 64px; transition: transform .1s; }
.kana-cell:hover { transform: scale(1.05); border-color: var(--accent); }
.kana-cell.empty { background: none; pointer-events: none; }
.kana-cell .k { font-family: var(--jp); font-size: 1.6rem; display: block; line-height: 1.2; }
.kana-cell .r { font-size: .75rem; color: var(--muted); }
.lvl1 { background: var(--l1); } .lvl2 { background: var(--l2); } .lvl3 { background: var(--l3); } .lvl4 { background: var(--l4); }
.quiz-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin: 8px 0 12px; }
.big-char { font-family: var(--jp); font-size: 6rem; text-align: center; line-height: 1.3; margin: 8px 0 20px; }
.big-char.romaji { font-family: system-ui, sans-serif; font-size: 4rem; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.choices button { border: 2px solid var(--border); background: var(--surface); border-radius: 12px; padding: 14px; font-size: 1.3rem; font-family: var(--jp); }
.choices button:hover:not(:disabled) { border-color: var(--accent); }
.choices button:disabled { opacity: 1; }
.choices button.correct { border-color: var(--good); background: var(--good-soft); }
.choices button.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choices kbd { float: left; border: 0; }
.type-form { display: flex; gap: 10px; }
.type-form input { flex: 1; font: inherit; font-size: 1.3rem; padding: 10px 14px; text-align: center; border: 2px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); min-width: 0; }
.type-form input:focus { outline: none; border-color: var(--accent); }
.feedback { min-height: 32px; text-align: center; margin: 16px 0 8px; font-weight: 600; }
.feedback.good { color: var(--good); } .feedback.bad { color: var(--bad); }
#kq-next { display: block; margin: 0 auto; }
.result-score { font-size: 3rem; font-weight: 700; text-align: center; margin: 8px 0; }
.result-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.result-list span { background: var(--bad-soft); border-radius: 8px; padding: 4px 10px; font-family: var(--jp); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translate(-50%, 20px);
  background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Handy ---------- */
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0;
    background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .tabs button { flex-direction: column; gap: 0; padding: 6px 2px; border-radius: 10px; font-size: .6rem; letter-spacing: -.02em; flex: 1; min-width: 0; padding-left: 1px; padding-right: 1px; overflow: hidden; text-overflow: ellipsis; }
  .tabs .ti { font-size: 1.15rem; }
  main { padding: 20px 16px 96px; }
  h1 { font-size: 1.6rem; }
  .panel { padding: 18px; }
  .player { padding: 16px 16px 0; }
  .pl-bar { margin: 8px -16px 0; padding: 10px 16px 12px; bottom: calc(58px + env(safe-area-inset-bottom)); }
  .pl-controls .segmented { margin-left: 0; }
  .transcript .jp, .peek .jp { font-size: 1.35rem; }
  .story-hero { flex-direction: column; }
  .story-hero .tapestry { align-self: center; }
  .tapestry.large { --w: 112px; }
  .tapestry.small { --w: 62px; }
  .boxes4, .boxes4.boxes5 { grid-template-columns: repeat(2, 1fr); }
  .flash-word, .check-word { font-size: 2.6rem; }
  .big-char { font-size: 4.5rem; }
  .kana-cell .k { font-size: 1.3rem; }
  .toast { bottom: 84px; }
  .sheet { z-index: 50; }
}

/* ---------- Japanische Gestaltung: Washi-Flächen, Mincho-Titel, Wellenband, Hanko ---------- */
.panel, .stat, .story-card, .topbar { background-image: var(--washi); }
h1, h2, .brand, .story-card b .jp, .story-hero h2 .jp, .pl-title .jp, .scene-title, .kanji-keyword, .result-score { font-family: var(--serif); font-weight: 700; }
h1 { letter-spacing: .02em; }
.brand-jp { font-family: var(--serif); }
/* Wellenband (青海波) unter der Kopfzeile */
.topbar { border-bottom: 0; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 7px; pointer-events: none; opacity: .55;
  background:
    radial-gradient(circle at 50% 100%, transparent 3px, var(--accent) 3px 4px, transparent 4px 6px, var(--accent) 6px 7px, transparent 7px) 0 0 / 14px 7px repeat-x; }
/* Knöpfe und Karten etwas strenger, wie Papier */
button.primary, .segmented button.active { border-radius: 6px; }
.secondary { border-radius: 6px; }
.story-card { border-radius: 10px; }
.story-card:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(60, 40, 20, .14); }
/* Niveau-Label als Hanko-Stempel */
.level-badge { font-family: var(--serif); border: 1.5px solid currentColor; border-radius: 3px; padding: 3px 6px; transform: rotate(-3deg); }
.kicker { font-family: var(--serif); letter-spacing: .12em; }

/* ---------- Shadowing ---------- */
.sh-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.sh-settings .field { margin-bottom: 14px; }
.sh-list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sh-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.sh-list li { border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 4px; }
.sh-list li > label { flex: 1; min-width: 0; }
.sh-list .fav-btn { border: 0; background: none; padding: 6px 8px; flex: none; }
.sh-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; padding: 10px 12px 0; margin: -4px 0 14px; background: var(--bg); border-radius: 10px; }
.sh-filters .field { margin-bottom: 10px; }
.sh-list label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 2px; cursor: pointer; }
.sh-list input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--accent); flex: none; }
.sh-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sh-text .jp { font-size: 1.05rem; }
.sh-text small { color: var(--muted); }
.sh-count { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.shadow-play { text-align: center; }
.sh-status { display: flex; justify-content: center; gap: 6px 18px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; }
.sh-phase { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; margin: 14px 0 8px; }
.phase-speak .sh-phase { color: var(--accent); }
.phase-paused .sh-phase { color: var(--muted); }
.sh-bar { height: 5px; background: var(--l0); border-radius: 3px; overflow: hidden; max-width: 420px; margin: 0 auto 18px; }
.sh-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.phase-listen .sh-bar span { width: 100%; background: var(--good); opacity: .35; }
.phase-speak .sh-bar span { animation: sh-countdown linear forwards; }
@keyframes sh-countdown { from { width: 100%; } to { width: 0; } }
.sh-sentence { font-size: 1.6rem; line-height: 2.2; margin: 6px 0; }
.sh-de { color: var(--muted); margin: 0 0 8px; }
.sh-hidden { color: var(--muted); font-style: italic; margin: 24px 0; }
.sh-controls .primary.big { min-width: 150px; }
.sh-toggles { gap: 6px 18px; font-size: .92rem; }
.sh-toggles label { display: flex; align-items: center; gap: 6px; }
@media (max-width: 640px) { .sh-sentence { font-size: 1.3rem; } }

/* ---------- Profil: klickbare Kacheln, Top 2000 ---------- */
.stat.stat-link { position: relative; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: border-color .15s, transform .15s; }
.stat.stat-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat.stat-link i, .top-tile > i { position: absolute; right: 12px; top: 10px; font-style: normal; color: var(--accent); opacity: .7; }
.stat b small { font-size: .55em; color: var(--muted); font-weight: 400; }
.stat span small { display: block; font-size: .78rem; }
.top-tile { position: relative; display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.top-tile:hover { border-color: var(--accent); }
.top-tile-head b { font-family: var(--serif); font-size: 1.25rem; margin-right: 8px; }
.top-tile-num { font-size: 1.05rem; } .top-tile-num b { font-size: 1.6rem; font-family: var(--serif); }
.top-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--l0); }
.top-bar span { height: 100%; }
.tb-known { background: var(--good); } .tb-learning { background: var(--b2); } .tb-saved { background: var(--saved); opacity: .6; }
.tdot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; border: 1px solid var(--border); }
.td-known { background: var(--b4); } .td-learning { background: var(--b2); } .td-saved { background: var(--b1); }
.td-unknown { background: var(--l0); } .td-absent { background: transparent; border-style: dashed; }
.tw-filter { margin: 10px 0 12px; }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 5px; }
.wcell { border: 1px solid var(--border); border-radius: 7px; padding: 5px 2px 3px; display: flex; flex-direction: column; align-items: center; min-width: 0; color: var(--text); }
.wcell .jp { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.wcell small { font-size: .62rem; color: var(--muted); }
.wcell.td-absent { border-style: dashed; color: var(--muted); }
.wcell.sel, .bt-cell.sel { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 2; }
.tw-detail { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: 16px; width: min(560px, calc(100% - 24px)); margin: 0; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); max-height: 60vh; overflow-y: auto; }
@media (max-width: 640px) { .tw-detail { bottom: calc(66px + env(safe-area-inset-bottom)); } }
.tw-d-word { font-size: 2.2rem; line-height: 1.6; }
/* großer Wandteppich: Bild unter 2000 Fäden */
.tw-art-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; margin-bottom: 14px; }
.tw-art-pick .chip { font-family: var(--jp); font-size: .8rem; padding: 2px 10px; }
.big-tapestry { position: relative; max-width: 560px; margin: 8px auto 14px; padding-top: 8px; }
.big-tapestry::before { content: ""; position: absolute; z-index: 3; top: 0; left: -8px; right: -8px; height: 9px; border-radius: 5px; background: linear-gradient(#8a5d3b, #4d2f1b); box-shadow: 0 2px 3px rgba(0, 0, 0, .35); }
.big-tapestry::after { content: ""; display: block; height: 10px; margin: 0 4px; background: repeating-linear-gradient(90deg, var(--fringe) 0 1.5px, transparent 1.5px 5px); }
.bt-cloth { position: relative; display: grid; grid-template-columns: repeat(var(--cols), 1fr); aspect-ratio: var(--cols) / var(--rows);
  background-size: cover; box-shadow: 0 4px 12px rgba(40, 25, 10, .3); }
.bt-cloth::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: .55;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 2.5px), repeating-linear-gradient(90deg, rgba(0, 0, 0, .1) 0 1px, transparent 1px 3px); }
.bt-cell { position: relative; cursor: pointer; border: 0; border-radius: 0; background: var(--loom); }
.bt-cell.td-known { background: transparent; }
.bt-cell.td-learning { opacity: .62; }   /* Lernkartei: Motiv nur als Ahnung */
.bt-cell.td-saved { opacity: .97; }
.bt-cell.td-unknown { opacity: .97; }
.bt-cell.td-absent { opacity: .97; background: repeating-linear-gradient(90deg, var(--warp) 0 1px, transparent 1px 3px), var(--loom); }
.bt-cell:hover { outline: 1px solid var(--accent); z-index: 2; }
