:root {
  --papier: #f6f8f6;
  --tinte: #233e3a;
  --leise: #657873;
  --linie: #d8e1db;
  --flaeche: #e7eee8;
  --spur: #dde5e0;
  --gruen: #365e51;
  --karte: #ffffff;
  --serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Sperre */
.gesperrt main, .offen .sperre { display: none; }
.cover-link { display: block; border-radius: 6px; }
.cover-link:focus-visible { outline: 2px solid var(--gruen); outline-offset: 3px; }
.sperre {
  min-height: 100svh;
  max-width: 460px;
  margin: 0 auto;
  padding: 48px 24px calc(48px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
}
.sperre h1 {
  margin: 0 0 32px;
  font: 400 clamp(40px, 11vw, 54px)/1.05 var(--serif);
  letter-spacing: -.04em;
}
.anmeldung { width: 100%; text-align: left; }
.anmeldung label { display: block; font-size: 14px; color: var(--leise); margin-bottom: 8px; }
.anmeldung-zeile { display: flex; gap: 10px; }
.anmeldung input {
  flex: 1; min-width: 0;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid #b7c7bd;
  border-radius: 10px;
  background: #fff;
  font-size: 17px;
}
.anmeldung input:focus { outline: none; border-color: var(--gruen); box-shadow: 0 0 0 3px rgba(54, 94, 81, .15); }
.anmeldung button {
  min-height: 50px; padding: 0 22px;
  border: 0; border-radius: 10px;
  background: var(--gruen); color: #fff;
  font-weight: 500;
}
.anmeldung-fehler { min-height: 22px; margin: 10px 0 0; font-size: 14px; color: #923d4d; }

/* Seite */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.kopfzeile {
  padding: 4px 4px 22px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--linie);
}
.kopfzeile h1 {
  margin: 0;
  font: 400 36px/1.1 var(--serif);
  letter-spacing: -.04em;
}
.bibliothek { display: grid; }

@media (min-width: 900px) {
  main { padding-top: 48px; padding-left: 48px; padding-right: 48px; }
  .kopfzeile { margin-bottom: 40px; padding-bottom: 28px; }
  .kopfzeile h1 { font-size: 50px; }
}

/* Bibliothek: Cover-Raster */
.bibliothek { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
@media (min-width: 640px) { .bibliothek { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 20px; } }
@media (min-width: 960px) { .bibliothek { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 24px; } }

.unsichtbar {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.buch {
  position: relative; margin: 0;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 14px;
  padding: 8px 8px 10px;
  box-shadow: 0 1px 2px rgba(35, 62, 58, .04), 0 8px 24px rgba(35, 62, 58, .06);
  display: flex; flex-direction: column;
}
.buch .kachel-podcast { margin-top: auto; }
.buch .meta { margin-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 639px) { .buch .meta { font-size: 11px; letter-spacing: 0; } }
@media (min-width: 640px) { .buch { padding: 12px 12px 14px; border-radius: 18px; } }
.kachel { position: relative; }
.cover {
  display: block;
  width: 100%; height: auto; aspect-ratio: 1;
  border-radius: 6px;
  background: var(--rahmen);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
@media (hover: hover) {
  .kachel:hover .cover { opacity: .94; }
}
.cover-play {
  position: absolute; right: 8px; bottom: 8px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--farbe); color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
  transition: transform .12s ease;
}
.cover-play:active { transform: scale(.92); }
.cover-play:focus-visible { outline: 2px solid var(--farbe); outline-offset: 3px; }
.cover-play svg { width: 18px; height: 18px; fill: currentColor; }
.cover-play::after { content: ""; position: absolute; inset: -6px; } /* größere Tippfläche */
.cover-play .i-play { margin-left: 2px; }
.cover-play .i-pause, .buch.spielt .cover-play .i-play { display: none; }
.buch.spielt .cover-play .i-pause { display: block; }
.buchfortschritt {
  position: absolute; left: 0; right: 0; bottom: -8px;
  height: 3px; border-radius: 2px;
  background: var(--spur);
  overflow: hidden;
}
.buchfortschritt span { display: block; height: 100%; background: var(--farbe); }
.meta {
  margin: 14px 2px 0;
  font-size: 12px; letter-spacing: .03em;
  color: var(--leise);
  font-variant-numeric: tabular-nums;
}
.kachel-podcast {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 10px;
  border-radius: 10px;
  background: var(--flaeche); color: var(--gruen);
  font-size: 14px; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.kachel-podcast svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.kachel-podcast svg circle { fill: currentColor; stroke: none; }
.kachel-podcast:active { opacity: .75; }
@media (hover: hover) { .kachel-podcast:hover { background: #dbe6de; } }
.kachel-podcast:focus-visible { outline: 2px solid var(--gruen); outline-offset: 2px; }
@media (min-width: 640px) {
  .cover-play { width: 44px; height: 44px; right: 12px; bottom: 12px; }
  .cover-play svg { width: 21px; height: 21px; }
}

/* Detailseite */
.detail { --farbe: var(--gruen); --farbe-leicht: color-mix(in srgb, var(--farbe) 13%, transparent); }
.zurueck {
  display: inline-flex; align-items: center; gap: 2px;
  margin: 0 0 18px -8px; padding: 8px 10px 8px 4px;
  color: var(--gruen); text-decoration: none; font-size: 15px; font-weight: 500;
  border-radius: 10px;
}
.zurueck svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.zurueck:focus-visible { outline: 2px solid var(--gruen); }
.d-raster { display: grid; gap: 24px; }
.d-kopf { display: flex; gap: 16px; align-items: center; }
.d-cover {
  width: 132px; height: 132px; flex: none;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(35, 62, 58, .06), 0 10px 26px rgba(35, 62, 58, .12);
}
.d-angaben { min-width: 0; }
.d-meta { margin: 0 0 6px !important; }
.d-titel { margin: 0; font: 400 24px/1.12 var(--serif); letter-spacing: -.03em; text-wrap: balance; }
.d-autor { margin: 6px 0 0; font-size: 14px; color: var(--leise); }
.d-weiter { margin: 10px 0 0; font-size: 13px; color: var(--farbe); font-weight: 500; }

.spieler {
  margin-top: 18px;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 18px;
  padding: 16px 16px 10px;
  box-shadow: 0 1px 2px rgba(35, 62, 58, .04), 0 8px 24px rgba(35, 62, 58, .06);
  container-type: inline-size;
}
.s-kapitel { margin: 0; font-size: 15px; font-weight: 500; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail .aktionen { border-top: 0; padding-top: 0; margin-top: 14px; container-type: inline-size; }

.mitlesen {
  position: relative;
  margin-top: 24px;
  max-height: min(60vh, 640px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 40vh;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 18px;
  font: 400 19px/1.6 var(--serif);
  color: #9aa8a3;
  overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 48px), transparent 100%);
}
.mitlesen:focus-visible { outline: 2px solid var(--gruen); }
.mitlesen p { margin: 0 0 1em; transition: color .3s; }
.mitlesen p.jetzt { color: var(--tinte); }
.mitlesen span { cursor: pointer; border-radius: 4px; transition: background-color .15s, color .15s; }
.mitlesen span.jetzt { background: var(--farbe-leicht); color: var(--farbe); box-shadow: 0 0 0 2px var(--farbe-leicht); }

.kapitelliste {
  position: relative;
  list-style: none; margin: 24px 0 0; padding: 4px 0;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 18px;
}
.kapitelliste li + li { border-top: 1px solid var(--linie); }
.kapitelliste button {
  width: 100%; display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center;
  padding: 13px 16px; border: 0; background: transparent; text-align: left;
  font-size: 15px; line-height: 1.35;
}
.k-nr { color: var(--leise); font-size: 13px; font-variant-numeric: tabular-nums; text-align: center; }
.k-zeit { color: var(--leise); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kapitelliste .fertig .k-titel { color: var(--leise); }
.kapitelliste .fertig .k-nr { font-size: 0; }
.kapitelliste .fertig .k-nr::before { content: "✓"; font-size: 14px; color: var(--farbe); }
.kapitelliste .aktuell button {
  background: linear-gradient(to right, var(--farbe-leicht) var(--k, 0%), transparent var(--k, 0%));
}
.kapitelliste .aktuell .k-titel { font-weight: 600; }
.kapitelliste .aktuell .k-nr, .kapitelliste .aktuell .k-zeit { color: var(--farbe); }
.kapitelliste li:first-child .aktuell, .kapitelliste li:first-child button { border-radius: 14px 14px 0 0; }

/* Breite Ansicht: links Player und Kapitel, rechts der Text über die volle Höhe */
@media (min-width: 900px) {
  main:has(.detail:not([hidden])) { max-width: 1480px; }
  .d-raster {
    display: grid; gap: 20px 36px;
    grid-template-columns: minmax(330px, 380px) 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "links text" "liste text";
    height: calc(100vh - 140px); min-height: 560px;
  }
  .d-links { grid-area: links; }
  .mitlesen { grid-area: text; margin: 0; max-height: none; height: 100%; font-size: 22px; line-height: 1.65; padding: 36px 56px 45vh; }
  .mitlesen p { max-width: 50em; }
  .kapitelliste { grid-area: liste; margin: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .ohne-text .d-raster { grid-template-areas: "links liste" "links liste"; grid-template-rows: auto 1fr; }
  .ohne-text .kapitelliste { max-width: 760px; }
  .d-cover { width: 104px; height: 104px; }
}
@media (min-width: 1200px) {
  .d-raster { grid-template-columns: 400px 1fr; }
  .mitlesen { font-size: 23px; padding: 44px 72px 45vh; }
}

/* Zeitleiste */
.leiste {
  --p: 0%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px;
  margin: 12px 0 0;
  background: transparent;
  touch-action: none;
}
.leiste::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--farbe) var(--p), var(--spur) var(--p));
}
.leiste::-moz-range-track { height: 5px; border-radius: 3px; background: var(--spur); }
.leiste::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--farbe); }
.leiste::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; margin-top: -6.5px;
  border-radius: 50%; border: 3px solid #fff;
  background: var(--farbe);
  box-shadow: 0 1px 4px rgba(35, 62, 58, .25);
}
.leiste::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff;
  background: var(--farbe); box-shadow: 0 1px 4px rgba(35, 62, 58, .25);
}
.leiste:focus-visible { outline: none; }
.leiste:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--farbe-leicht); }

.zeiten {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: -2px;
  font-size: 13px; color: var(--leise);
  font-variant-numeric: tabular-nums;
}
.zeiten span { min-width: 64px; }
.zeiten .rest { text-align: right; }
.tempo {
  border: 0; background: transparent; color: var(--leise);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 6px 10px; border-radius: 8px;
}
.tempo.anders { color: var(--farbe); background: var(--farbe-leicht); }

/* Tasten */
.tasten {
  display: flex; justify-content: center; align-items: center;
  gap: clamp(4px, 4cqi, 22px);
  margin: 8px 0 2px;
}
.tasten button {
  border: 0; background: transparent;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--tinte);
  transition: transform .12s ease;
}
.tasten button:active { transform: scale(.92); }
.tasten button:focus-visible { outline: 2px solid var(--farbe); outline-offset: 2px; }
.t-zurueck svg, .t-vor svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tasten .t-zurueck, .tasten .t-vor { color: var(--leise); }
.t-zurueck:disabled, .t-vor:disabled { opacity: .35; cursor: default; }
.t-minus svg, .t-plus svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.t-minus text, .t-plus text { fill: currentColor; stroke: none; font-size: 8.5px; font-weight: 600; font-family: var(--sans); }
.tasten .t-play {
  width: 68px; height: 68px;
  background: var(--farbe);
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--farbe) 32%, transparent);
}
.t-play svg { width: 30px; height: 30px; fill: currentColor; }
.t-play .i-play { margin-left: 3px; }
.t-play .i-pause, .detail.spielt .t-play .i-play { display: none; }
.detail.spielt .t-play .i-pause { display: block; }
.laedt .t-play { position: relative; }
.laedt .t-play svg { opacity: 0; }
.laedt .t-play::after {
  content: ""; position: absolute; inset: 22px;
  border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  border-radius: 50%;
  animation: drehen .8s linear infinite;
}
@keyframes drehen { to { transform: rotate(360deg); } }

.fehler { margin: 8px 0 0; text-align: center; font-size: 13px; color: #923d4d; }

/* Aktionen */
.aktionen {
  display: flex; gap: 8px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--linie);
}
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--linie);
  background: #fff; color: var(--tinte);
  font-size: 15px; font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.knopf svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.knopf-podcast { background: var(--gruen); border-color: var(--gruen); color: #fff; flex: 1; min-width: 0; }
.knopf-podcast svg circle { fill: currentColor; stroke: none; }
.kopieren { width: 44px; flex: none; padding: 0; color: var(--leise); }
.knopf-laden { flex: none; }
.knopf .groesse { color: var(--leise); font-weight: 400; }
.knopf .groesse::before { content: "· "; }
.knopf:active { opacity: .8; }
.knopf:focus-visible { outline: 2px solid var(--gruen); outline-offset: 2px; }
@container (max-width: 380px) { .knopf .groesse { display: none; } }

/* Rückmeldung */
.hinweis {
  position: fixed; z-index: 20; left: 50%; top: calc(16px + env(safe-area-inset-top));
  transform: translate(-50%, -12px);
  background: var(--tinte); color: #fff;
  padding: 11px 18px; border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .15);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.hinweis.zeigen { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 2s !important; }
}
