/* ============================================================== Tokens */
:root {
  --bg: #f5f2ec;
  --bg-2: #ede9e1;
  --surface: #ffffff;
  --tabs-bg: color-mix(in srgb, var(--surface) 60%, var(--bg)); /* deckend; auch Seitenfläche unter dem Viewport */
  --surface-2: #ebe7df;
  --text: #1c1b1a;
  --muted: #74706a;
  --line: rgb(28 27 26 / .09);
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: rgb(194 65 12 / .12);
  --danger: #b91c1c;
  --glass: rgb(255 255 255 / .62);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .05);
  --shadow: 0 12px 32px rgb(0 0 0 / .14);
  --tint: #8a5a3c;
  --radius: 18px;
  --tabs-h: 62px;
  --mini-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* iOS-26-Web-App: Endet der Viewport schon über dem Home-Indikator (--viewport-gap, per JS
     gemessen), ist dort kein zusätzlicher Abstand nötig – fixierte Elemente werden unterhalb
     des Viewports ohnehin nicht gezeichnet. */
  --safe-b-eff: max(0px, calc(var(--safe-b) - var(--viewport-gap, 0px)));
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --bg-2: #18191c; --surface: #1c1d21; --surface-2: #26282d;
    --text: #f1eee9; --muted: #9b9890; --line: rgb(255 255 255 / .08);
    --accent: #fb923c; --accent-ink: #1f1206; --accent-soft: rgb(251 146 60 / .14);
    --danger: #f87171; --glass: rgb(28 29 33 / .6);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4); --shadow: 0 14px 40px rgb(0 0 0 / .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --bg-2: #18191c; --surface: #1c1d21; --surface-2: #26282d;
  --text: #f1eee9; --muted: #9b9890; --line: rgb(255 255 255 / .08);
  --accent: #fb923c; --accent-ink: #1f1206; --accent-soft: rgb(251 146 60 / .14);
  --danger: #f87171; --glass: rgb(28 29 33 / .6);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4); --shadow: 0 14px 40px rgb(0 0 0 / .55);
  color-scheme: dark;
}

/* ================================================================ Base */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { height: 100%; }
/* Mindestens bildschirmhoch (100lvh): In installierten Web-Apps unter iOS 26 ist der Viewport nur so
   hoch wie der Seiteninhalt, höchstens bildschirmhoch (gemessen auf dem iPhone 14 Pro: leere bzw. kurze
   Seiten 793/794 pt, lange Seiten 852 pt). Kurze Seiten hinterließen so einen Streifen unten.
   +1 px hält die Seite zusätzlich scrollbar. Ohne lvh-Unterstützung gilt die erste Zeile. */
body {
  min-height: calc(100% + 1px);
  min-height: max(calc(100% + 1px), 100lvh);
}
/* Seitenfläche (Canvas): sichtbar nur im Streifen, den iOS unter dem Viewport malt – dort die Farbe
   des untersten Elements, damit keine Kante entsteht (Bibliothek: Tab-Leiste, Player: Hintergrund) */
html { background: var(--tabs-bg); }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
svg { width: 24px; height: 24px; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, .display { font-family: var(--font-display); }

/* ============================================================== Layout */
#view {
  min-height: 100%;
  padding: calc(var(--safe-t) + 12px) max(16px, var(--safe-r)) calc(var(--tabs-h) + var(--mini-h) + var(--safe-b-eff) + 28px) max(16px, var(--safe-l));
  max-width: 820px;
  margin: 0 auto;
  outline: none;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 16px; }
.topbar h1 { font-size: 32px; margin: 0; letter-spacing: -.03em; font-weight: 800; line-height: 1.1; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--text); transition: background .15s, transform .1s;
}
.icon-btn:active { background: var(--surface-2); transform: scale(.94); }
.icon-btn.filled { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px var(--accent-soft); }
.icon-btn.glass { background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: calc(var(--tabs-h) + var(--safe-b-eff)); padding: 0 var(--safe-r) var(--safe-b-eff) var(--safe-l);
  display: flex; background: var(--tabs-bg);
  border-top: 1px solid var(--line);
}
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabs button svg { width: 23px; height: 23px; }
.tabs button[aria-current="page"] { color: var(--accent); }

/* ============================================================== Covers */
.cover { width: 100%; aspect-ratio: 1; border-radius: 12px; object-fit: cover; background: var(--surface-2); display: block; }
.cover-ph {
  display: grid; place-items: center; color: rgb(255 255 255 / .92); font-family: var(--font-display); font-weight: 800; letter-spacing: .02em;
  background:
    radial-gradient(120% 90% at 0% 0%, rgb(255 255 255 / .22), transparent 55%),
    linear-gradient(140deg, hsl(var(--h) 55% 48%), hsl(calc(var(--h) + 45) 55% 26%));
}

/* ================================================================ Hero */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: 104px 1fr; gap: 16px; align-items: center;
  padding: 16px; margin-bottom: 18px; border-radius: 24px; cursor: pointer;
  color: #fff;
  background:
    radial-gradient(140% 120% at 0% 0%, color-mix(in srgb, var(--tint) 85%, white 15%), transparent 60%),
    linear-gradient(135deg, var(--tint), color-mix(in srgb, var(--tint) 45%, black));
  box-shadow: 0 16px 36px color-mix(in srgb, var(--tint) 35%, transparent);
}
.hero-art .cover { border-radius: 14px; box-shadow: 0 10px 24px rgb(0 0 0 / .35); font-size: 28px; }
.hero-meta { min-width: 0; padding-right: 52px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; opacity: .8; }
.hero-title { font-family: var(--font-display); font-size: 20px; font-weight: 800; line-height: 1.2; margin: 4px 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-sub { font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero .bar { background: rgb(255 255 255 / .25); margin-top: 10px; }
.hero .bar > i { background: #fff; }
.hero-left { font-size: 12px; opacity: .8; margin-top: 6px; font-variant-numeric: tabular-nums; }
.hero-play {
  position: absolute; right: 16px; bottom: 16px; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; background: #fff; color: color-mix(in srgb, var(--tint) 70%, black);
  box-shadow: 0 6px 18px rgb(0 0 0 / .25); transition: transform .1s;
}
.hero-play:active { transform: scale(.92); }
.hero-play svg { width: 26px; height: 26px; }

/* ============================================================= Library */
.search input {
  width: 100%; padding: 12px 16px; border-radius: 14px; border: 1px solid transparent;
  background: var(--surface-2); outline: none; transition: border-color .15s, background .15s;
}
.search input:focus { border-color: var(--accent); background: var(--surface); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 12px -16px 0; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 4px; }
.list-head select { border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; padding: 6px 0; }
.list-head .icon-btn { width: 40px; height: 40px; color: var(--muted); }

.chip {
  padding: 7px 14px; border-radius: 999px; background: var(--surface-2);
  font-size: 14px; font-weight: 600; white-space: nowrap; color: var(--muted); transition: background .15s, color .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.chip small { font-weight: 500; opacity: .75; }
.chip svg { width: 18px; height: 18px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.chip:active { transform: scale(.97); }

.books { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.book {
  display: grid; grid-template-columns: 68px 1fr auto; gap: 14px; align-items: center;
  padding: 10px 6px 10px 10px; border-radius: var(--radius); cursor: pointer; transition: background .15s;
}
.book:active { background: var(--surface); }
.book.current { background: var(--surface); box-shadow: var(--shadow-sm); }
.book .meta { min-width: 0; }
.book .title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book .author { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book .sub { color: var(--muted); font-size: 12px; margin-top: 5px; display: flex; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.book .sub .bm { display: inline-flex; align-items: center; gap: 2px; }
.book .sub svg { width: 13px; height: 13px; }
.book .cover { width: 68px; font-size: 20px; box-shadow: var(--shadow-sm); }
.book .icon-btn { color: var(--muted); }
.bar { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; }
.badge.done { padding: 1px 4px; }
.badge svg { width: 12px; height: 12px; }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; }
.tile { cursor: pointer; }
.tile-art { position: relative; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 22px color-mix(in srgb, var(--tint) 28%, transparent); transition: transform .15s; }
.tile:active .tile-art { transform: scale(.97); }
.tile-art .cover { border-radius: 0; font-size: 34px; }
.tile.current .tile-art { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile-bar { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 4px; border-radius: 4px; background: rgb(0 0 0 / .35); overflow: hidden; }
.tile-bar > i { display: block; height: 100%; background: #fff; }
.tile-done, .tile-new {
  position: absolute; top: 8px; left: 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgb(0 0 0 / .55); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tile-done { width: 26px; height: 26px; display: grid; place-items: center; }
.tile-done svg { width: 16px; height: 16px; }
.tile-new { padding: 4px 8px; }
.tile-more {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgb(0 0 0 / .4); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tile-more svg { width: 20px; height: 20px; }
.tile-title { font-weight: 650; font-size: 15px; margin-top: 9px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-sub { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); max-width: 420px; margin: 0 auto; }
.empty-art {
  width: 104px; height: 104px; border-radius: 32px; margin: 0 auto; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #7c2d12));
  color: #fff; box-shadow: 0 18px 40px var(--accent-soft); transform: rotate(-6deg);
}
.empty-art svg { width: 52px; height: 52px; }
.empty h2 { color: var(--text); margin: 24px 0 8px; font-size: 22px; letter-spacing: -.02em; }
.empty .btn { margin-top: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; background: var(--surface-2); font-weight: 650; min-height: 46px;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.danger-fill { background: var(--danger); color: #fff; }
.confirm-text { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; }

/* ========================================================= Mini player */
.mini {
  position: fixed; z-index: 19; left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r));
  bottom: calc(var(--tabs-h) + var(--safe-b-eff) + 8px);
  height: var(--mini-h); max-width: 800px; margin: 0 auto;
  display: grid; grid-template-columns: 50px 1fr 46px; gap: 12px; align-items: center;
  padding: 8px 8px 8px 8px; border-radius: 20px; text-align: left; overflow: hidden;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--tint) 30%, transparent), transparent 70%),
    var(--glass);
  backdrop-filter: saturate(1.6) blur(22px); -webkit-backdrop-filter: saturate(1.6) blur(22px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.mini .cover { width: 50px; font-size: 15px; border-radius: 10px; }
.mini .t { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .c { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .pp { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); }
.mini .pp svg { width: 24px; height: 24px; }
.mini .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }

/* ========================================================= Full player */
/*
 * Ein Bildschirm, der nie scrollt: feste Spalte aus Header → Cover → Titel → Kapitel →
 * Scrubber → Steuerung → Gesamtfortschritt → Bottom-Bar. Nur das Cover-Feld ist flexibel
 * und misst sich als Size-Container am tatsächlich übrigen Platz.
 */
.player {
  /* Alle Größen hängen an der Viewport-Größe → auf Handy und Tablet gleiche Proportionen */
  --player-pad-x: clamp(16px, 5.5vw, 40px);
  --player-pad-top: clamp(6px, 1svh, 12px);
  --player-pad-bottom-min: clamp(10px, 1.6svh, 18px); /* nur ohne Safe Area (SE, Safari) */
  --player-gap: clamp(6px, 1.6svh, 18px);
  --player-max-width: min(100%, 600px); /* Tablets: zentriert, Hintergrund bleibt vollflächig */
  --player-max-width-wide: 900px;
  --player-gap-wide: 24px;
  --panel-width-wide: 55%;
  --cover-max: min(80vw, var(--player-max-width));
  --cover-fallback: min(80vw, 42svh); /* bis der ResizeObserver --cover-size setzt */
  --cover-radius: 22px;
  --cover-initials-scale: .28;
  --title-lines: 2;
  /* Unteres Ende des Verlaufs = Seitenhintergrund → keine Naht, auch wenn iOS das Fenster
     über dem Home-Indikator enden lässt */
  --player-bottom: var(--bg);
  --control-main: clamp(64px, 9.5svh, 108px);
  --control-skip: clamp(52px, 7.6svh, 86px);
  --control-small: clamp(44px, 6svh, 64px);
  --font-title: clamp(19px, 2.75svh, 32px);
  --font-subtitle: clamp(13px, 1.8svh, 19px);
  --font-pill: clamp(13px, 1.65svh, 17px);
  --font-time: clamp(12px, 1.55svh, 16px);
  --font-action-value: clamp(14px, 1.8svh, 19px);
  --font-action-label: clamp(10px, 1.3svh, 14px);
  --font-head-label: clamp(11px, 1.4svh, 14px);
  --action-icon: clamp(22px, 2.8svh, 30px);
  --head-button: clamp(40px, 5.2svh, 60px);
  --skip-label-scale: .17; /* Sekundenzahl im Spul-Knopf relativ zur Knopfgröße */

  /* Volle Fenstergröße über inset: 0 – bewusst ohne 100dvh: In installierten Web-Apps
     unter iOS 26 endet 100dvh über dem Home-Indikator und hinterlässt einen schwarzen Streifen. */
  position: fixed; inset: 0; z-index: 30; isolation: isolate;
  /* bis an den physischen Rand, auch wenn iOS den Viewport zu früh enden lässt (siehe measureViewportGap) */
  overflow: hidden; overscroll-behavior: none;
  display: flex; flex-direction: column;
  /* unten: Bottom-Bar direkt über der Safe Area, Mindestabstand nur ohne Safe Area */
  padding: calc(var(--safe-t) + var(--player-pad-top)) max(var(--player-pad-x), var(--safe-r)) max(var(--safe-b-eff), var(--player-pad-bottom-min)) max(var(--player-pad-x), var(--safe-l));
  background: var(--player-bottom);
  animation: slide-up .32s cubic-bezier(.2, .8, .2, 1);
}
@media (max-height: 700px) { .player { --title-lines: 1; } }
.player-bg {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(110% 60% at 50% 0%, color-mix(in srgb, var(--tint) 75%, transparent), transparent 70%),
    radial-gradient(80% 45% at 100% 55%, color-mix(in srgb, var(--tint) 22%, transparent), transparent 70%),
    var(--player-bottom);
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }
.player .art .cover.cover-ph { font-size: calc(var(--cover-size, var(--cover-max)) * var(--cover-initials-scale)); }
.player-inner {
  width: 100%; max-width: var(--player-max-width); margin: 0 auto;
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: var(--player-gap);
}
.player-head { flex: none; }
/* Hochformat: Cover oben (flexibel), darunter das Bedien-Panel mit Bottom-Bar */
.player-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--player-gap); }
.player-panel { flex: none; display: flex; flex-direction: column; gap: var(--player-gap); min-width: 0; }
.player-panel > * { flex: none; }
/* Kein overflow: hidden – das machte die Seite unscrollbar und löste die Viewport-Kürzung aus.
   Verrutschen verhindert die Wisch-Sperre auf dem Player (touchmove), Gummiband-Effekt overscroll-behavior. */
html.player-open, html.player-open body { overscroll-behavior: none; }
html.player-open { background: var(--bg); }
.player-head { display: flex; align-items: center; justify-content: space-between; }
.player-head .icon-btn { width: var(--head-button); height: var(--head-button); }
.player-head .icon-btn svg { width: 55%; height: 55%; }
.player-head .label { font-size: var(--font-head-label); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text); opacity: .7; }

.player .art {
  flex: 1 1 0; min-height: 0; width: 100%;
  display: grid; place-items: center; cursor: pointer;
}
.player .art .cover {
  width: var(--cover-size, var(--cover-fallback)); max-width: min(100%, var(--cover-max)); max-height: 100%; aspect-ratio: 1;
  border-radius: var(--cover-radius); font-size: 64px;
  box-shadow: 0 24px 50px color-mix(in srgb, var(--tint) 45%, rgb(0 0 0 / .35)), 0 4px 12px rgb(0 0 0 / .2);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.player:has([data-p-pp] use[href="#i-play"]) .art .cover { transform: scale(.92); }
.player .titles { text-align: center; padding: 0 8px; }
.player .titles h2 { margin: 0; font-size: var(--font-title); line-height: 1.2; letter-spacing: -.02em; font-weight: 800;
  display: -webkit-box; -webkit-line-clamp: var(--title-lines); line-clamp: var(--title-lines);
  -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.player .titles p { margin: 4px 0 0; color: var(--muted); font-size: var(--font-subtitle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chapter-pill {
  display: flex; align-items: center; gap: 8px; margin: 0 auto; max-width: 100%;
  padding: 7px 10px 7px 8px; border-radius: 999px; background: var(--glass);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line);
  font-size: var(--font-pill); font-weight: 600;
}
.chapter-pill [data-p-chapter-n]:not(:empty) { background: var(--text); color: var(--bg); border-radius: 999px; padding: .05em .6em; font-size: .85em; font-variant-numeric: tabular-nums; }
.chapter-pill .ct { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chapter-pill svg { width: 1.15em; height: 1.15em; opacity: .6; }

.scrub { width: 100%; }
.scrub input[type="range"] { width: 100%; }
.times { display: flex; justify-content: space-between; font-size: var(--font-time); color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; font-weight: 500; }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 30px; background: transparent; margin: 0; --p: 0%; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 6px;
  background: linear-gradient(to right, var(--text) var(--p), color-mix(in srgb, var(--text) 14%, transparent) var(--p));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--text);
  margin-top: -7px; box-shadow: 0 2px 6px rgb(0 0 0 / .25); transition: transform .1s;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.25); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: color-mix(in srgb, var(--text) 14%, transparent); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--text); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--text); }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.controls button { display: grid; place-items: center; border-radius: 50%; position: relative; transition: transform .1s, background .15s; }
.controls .small { width: var(--control-small); height: var(--control-small); color: var(--text); opacity: .85; } /* 4: nicht wie deaktiviert wirken */
.controls .skip { width: var(--control-skip); height: var(--control-skip); }
.controls .skip svg { width: 64%; height: 64%; }
.controls .skip span { position: absolute; font-size: calc(var(--control-skip) * var(--skip-label-scale)); font-weight: 800; top: 50%; left: 50%; transform: translate(-50%, -28%); font-variant-numeric: tabular-nums; }
.controls .main { width: var(--control-main); height: var(--control-main); background: var(--text); color: var(--bg); box-shadow: 0 12px 28px rgb(0 0 0 / .22); }
.controls .main svg { width: 45%; height: 45%; }
.controls button:active { transform: scale(.92); }

.booktrack-wrap { margin-top: 2px; }
.booktrack {
  --seg-height: 4px;
  --seg-gap: 2px;
  --seg-min: 4px; /* sehr kurze Kapitel bleiben sichtbar */
  display: flex; gap: var(--seg-gap); height: var(--seg-height);
}
.booktrack .track-seg {
  flex: var(--grow) 1 0; min-width: var(--seg-min);
  border-radius: var(--seg-height); overflow: hidden;
  background: color-mix(in srgb, var(--text) 10%, transparent);
}
.booktrack .track-seg > i { display: block; width: 0; height: 100%; background: color-mix(in srgb, var(--text) 45%, transparent); }
.book-left { text-align: center; font-size: var(--font-action-label); color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 8px; }

.actions {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 6px;
  border-radius: 22px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.actions button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: clamp(7px, 1.1svh, 12px) 2px; border-radius: 16px; font-size: var(--font-action-label); font-weight: 600; color: var(--muted); transition: background .15s; }
.actions button b { font-size: var(--font-action-value); color: var(--text); height: var(--action-icon); display: grid; place-items: center; font-variant-numeric: tabular-nums; font-weight: 750; }
.actions button b svg { width: var(--action-icon); height: var(--action-icon); }
.actions button.on { background: var(--accent-soft); }
.actions button.on, .actions button.on b { color: var(--accent); }
.actions button:active { background: var(--surface-2); }

/* Nur im Dock-Layout sichtbar */
.dock-only { display: none; }
.dock-progress { width: 100%; flex-direction: column; gap: var(--dock-times-gap); }
.dock-bar { height: var(--dock-bar-height); border-radius: var(--dock-bar-height); overflow: hidden; background: color-mix(in srgb, var(--text) 14%, transparent); }
.dock-bar > i { display: block; height: 100%; width: 0; background: var(--text); }
.dock-times { display: flex; justify-content: space-between; font-size: var(--font-time); color: var(--muted); font-variant-numeric: tabular-nums; }
.dock-sleep {
  align-self: center; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--dock-touch-min); padding: 0 var(--dock-sleep-pad-x); border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); color: var(--text);
  font-size: var(--font-pill); font-weight: 650; font-variant-numeric: tabular-nums;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.dock-sleep svg { width: 1.3em; height: 1.3em; }
.dock-sleep.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/*
 * Querformat (Handy und Tablet): Dock-Layout, z. B. auf einer Ladestation.
 * Links das Cover in voller Höhe, rechts zentriert Titel, Fortschritt, große Controls, Sleep.
 * Muss nach den Grundregeln stehen.
 */
@media (orientation: landscape) {
  .player {
    --dock-gap: clamp(20px, 5vw, 64px);
    --dock-control-gap: clamp(10px, 3vw, 40px);
    --dock-touch-min: 56px;
    --dock-control-main: clamp(72px, 22svh, 120px);
    --dock-control-skip: clamp(var(--dock-touch-min), 16svh, 92px);
    --dock-panel-max: 460px;
    --dock-bar-height: 4px;
    --dock-times-gap: 6px;
    --dock-sleep-pad-x: 18px;
    --font-dock-title: clamp(14px, 3.6svh, 20px);
    --player-max-width: none;
    padding-top: max(var(--safe-t), var(--player-pad-bottom-min));
  }
  .player-head, .chapter-pill, .scrub, .booktrack-wrap, .actions,
  .controls .small, .player .titles p { display: none; }
  .dock-only { display: flex; }

  .player-body { flex-direction: row; align-items: center; justify-content: center; gap: var(--dock-gap); }
  .player .art { flex: 0 1 auto; height: 100%; aspect-ratio: 1; max-width: 55%; }
  .player .art .cover { max-width: 100%; --cover-max: 100%; }

  .player-panel { flex: 1 1 0; max-width: var(--dock-panel-max); justify-content: center; align-items: stretch; gap: clamp(10px, 3.5svh, 28px); }
  .player .titles { padding: 0; }
  .player .titles h2 {
    display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: var(--font-dock-title); font-weight: 600; letter-spacing: 0; color: var(--muted);
  }
  .controls { justify-content: center; gap: var(--dock-control-gap); }
  .controls button { flex: none; } /* Touch-Ziele nie unter --dock-touch-min drücken */
  .controls .main { width: var(--dock-control-main); height: var(--dock-control-main); }
  .controls .skip { width: var(--dock-control-skip); height: var(--dock-control-skip); }
}

/* ============================================================== Sheets */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .45);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(var(--safe-b-eff) + 22px);
  animation: slide-up .28s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -10px 40px rgb(0 0 0 / .2);
}
.sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--surface-2); margin: 0 auto 14px; }
.sheet h3 { margin: 2px 0 16px; font-size: 21px; letter-spacing: -.02em; font-weight: 800; }
.sheet .row-btn {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 6px; border-bottom: 1px solid var(--line); text-align: left;
}
.sheet .row-btn svg { color: var(--muted); }
.sheet .row-btn:last-of-type { border-bottom: 0; }
.sheet .row-btn.danger, .sheet .row-btn.danger svg { color: var(--danger); }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 650; font-size: 14px; color: var(--muted); transition: background .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgb(0 0 0 / .14); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li > button.main { flex: 1; display: flex; gap: 12px; align-items: baseline; padding: 13px 4px; text-align: left; min-width: 0; }
.list .n { color: var(--muted); font-size: 13px; width: 26px; flex: none; font-variant-numeric: tabular-nums; }
.list .lt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .note { display: block; font-size: 13px; color: var(--muted); white-space: normal; }
.list .tm { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.list li.current { background: var(--accent-soft); border-radius: 12px; border-bottom-color: transparent; }
.list li.current .lt, .list li.current .n { color: var(--accent); font-weight: 700; }
.list li.done .lt { color: var(--muted); }
.list .icon-btn { color: var(--muted); width: 40px; height: 40px; }
.list .icon-btn svg { width: 20px; height: 20px; }

.speed-val { text-align: center; font-family: var(--font-display); font-size: 52px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 0 0 6px; letter-spacing: -.03em; }
.speed-row { display: flex; align-items: center; gap: 12px; }
.speed-row input { flex: 1; }
.speed-row .icon-btn { background: var(--surface-2); font-size: 22px; font-weight: 700; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 10px; }
.preset-grid .chip { padding: 12px 0; font-size: 16px; }
.chip.wide { width: 100%; padding: 12px; margin-bottom: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; line-height: 1.45; }
.hint.center { text-align: center; }

/* Sleep */
.sleep-status {
  display: flex; align-items: center; gap: 14px; padding: 14px; margin-bottom: 16px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--accent-soft);
}
.sleep-ring { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.sleep-info { flex: 1; min-width: 0; }
.sleep-count { font-family: var(--font-display); font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sleep-status-actions { display: flex; flex-direction: column; gap: 6px; }
.stepper { display: flex; align-items: center; gap: 12px; padding: 10px; margin-bottom: 12px; border-radius: 18px; background: var(--bg); }
.stepper .icon-btn { background: var(--surface); font-size: 24px; font-weight: 700; box-shadow: var(--shadow-sm); }
.stepper-val { flex: 1; text-align: center; font-size: 15px; }
.stepper-val b { font-family: var(--font-display); font-size: 30px; font-variant-numeric: tabular-nums; }
.stepper-val small { display: block; color: var(--muted); font-size: 12px; }
.time-field { display: block; text-align: center; padding: 14px; border-radius: 18px; background: var(--bg); }
.time-field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.time-field input {
  border: 0; background: transparent; text-align: center; font-family: var(--font-display);
  font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; width: 100%; outline: none; color: var(--text);
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"], .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }

/* ============================================================ Settings */
.group { background: var(--surface); border-radius: var(--radius); margin: 0 0 8px; overflow: hidden; box-shadow: var(--shadow-sm); }
.group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 6px 8px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 54px; }
.setting:last-child { border-bottom: 0; }
.setting.disabled { opacity: .45; }
.setting .lbl { flex: 1; min-width: 0; }
.setting .lbl small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.setting select, .time-input { background: var(--surface-2); border: 0; border-radius: 10px; padding: 7px 10px; max-width: 48%; font-variant-numeric: tabular-nums; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 31px; background: var(--surface-2); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgb(0 0 0 / .25); transition: transform .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.setting .btn { padding: 8px 14px; min-height: 36px; }

/* =============================================================== Stats */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.kpi .v { font-family: var(--font-display); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .k { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chart { background: var(--surface); border-radius: var(--radius); padding: 16px 16px 12px; margin-top: 10px; box-shadow: var(--shadow-sm); }
.chart h3 { margin: 0 0 14px; font-size: 16px; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 160px; }
.bars .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bars .val { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars .b { width: 100%; max-width: 30px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bars .b.zero { background: var(--surface-2); }
.bars .d { font-size: 12px; color: var(--muted); }
.bars .col.today .d { color: var(--text); font-weight: 700; }

/* =============================================================== Toast */
.toast {
  --toast-dock-offset: 16px;
  position: fixed; left: 50%; z-index: 50; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b-eff) + 24px);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.player:not([hidden]) ~ .toast { bottom: auto; top: calc(var(--safe-t) + 64px); }
@media (orientation: landscape) {
  .player:not([hidden]) ~ .toast { top: auto; bottom: calc(var(--safe-b-eff) + var(--toast-dock-offset)); }
}

@media (min-width: 640px) {
  .hero { grid-template-columns: 140px 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* „Zurück zur letzten Position“ nach größeren Sprüngen */
.times { align-items: center; gap: 8px; }
.jump-back {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 6px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 700; white-space: nowrap;
  animation: fade .2s;
}
.jump-back svg { width: 15px; height: 15px; }

/* Auswahl-Liste (Zusammenführen) */
.pick-row { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 4px; min-width: 0; cursor: pointer; }
.pick-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.pick-row .lt { white-space: normal; }

/* Kapitel umbenennen */
.sheet-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px 0 6px; min-height: 36px; }
.sheet-tools .hint { margin: 0; }
.list .ed { color: var(--accent); flex: none; display: grid; place-items: center; }
.list .ed svg { width: 18px; height: 18px; }
.list.editing li > button.main { align-items: center; }

.sheet-actions .btn { min-width: 0; }
.sheet-actions.three { display: grid; grid-template-columns: 1fr 1fr; }
.sheet-actions.three [data-ask="cancel"] { grid-column: 1 / -1; order: 3; background: transparent; color: var(--muted); }

/* Export */
.export-info { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--bg); font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.export-info svg { width: 18px; height: 18px; color: var(--accent); }
.export-actions { display: grid; gap: 8px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* Diagnose (#viewport-debug) */
#viewport-debug {
  position: fixed; left: 8px; right: 8px; top: calc(var(--safe-t) + 56px); z-index: 60; margin: 0;
  padding: 10px 12px; border-radius: 12px; background: rgb(0 0 0 / .78); color: #9cf59c;
  font: 12px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; pointer-events: none;
}

/* Doppeltipp-Rückmeldung auf dem Cover */
.player .art { position: relative; }
.tap-feedback {
  position: absolute; top: 50%; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 14px; border-radius: 999px; background: rgb(0 0 0 / .55); color: #fff;
  font-weight: 800; font-size: 14px; pointer-events: none; animation: tap-pop .6s ease-out forwards;
}
.tap-feedback.back { left: 12%; }
.tap-feedback.fwd { right: 12%; }
.tap-feedback svg { width: 26px; height: 26px; }
@keyframes tap-pop { 0% { opacity: 0; transform: translateY(-50%) scale(.7); } 25% { opacity: 1; transform: translateY(-50%) scale(1); } 100% { opacity: 0; transform: translateY(-50%) scale(1.05); } }

/* Kapitelsuche */
.chapter-search {
  width: 100%; margin: 0 0 8px; padding: 10px 14px; border-radius: 12px; border: 1px solid transparent;
  background: var(--surface-2); outline: none; font-size: 15px;
}
.chapter-search:focus { border-color: var(--accent); background: var(--bg); }

/* Reihen */
.badge.series { background: var(--surface-2); color: var(--muted); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.field-row .field-narrow { flex: 0 0 84px; }
.field input[type="number"] { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.next-book { display: flex; gap: 14px; align-items: center; margin: 0 0 16px; }
.next-book .cover { width: 72px; flex: none; font-size: 22px; }

/* Einmaliger Gesten-Hinweis */
.gesture-hint {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 16px; border-radius: var(--cover-radius); background: rgb(0 0 0 / .72); color: #fff; text-align: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .25s;
}
.gesture-hint .gh-zones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; font-size: 12px; opacity: .9; }
.gesture-hint .gh-zones span { display: flex; flex-direction: column; gap: 2px; padding: 8px 4px; border: 1px dashed rgb(255 255 255 / .35); border-radius: 10px; }
.gesture-hint .gh-zones b { font-size: 15px; }
.gesture-hint p { margin: 0; font-size: 13px; line-height: 1.4; opacity: .9; max-width: 28ch; }

/* Gedrückt halten: kein iOS-Kontextmenü, sichtbare Rückmeldung */
.controls button { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.controls .skip.holding { background: color-mix(in srgb, var(--text) 12%, transparent); transform: scale(.94); }
