:root {
  --bg: #14161c;
  --surface: #1d2029;
  --surface-2: #262a35;
  --text: #eef0f5;
  --muted: #9097a7;
  --accent: #ffb347;
  --accent-ink: #1b1306;
  --danger: #ff6b6b;
  --radius: 14px;
  --player-h: 0px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #ebe8e2;
  --text: #1d1f24;
  --muted: #6b6f78;
  --accent: #d97706;
  --accent-ink: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f4f2ee; --surface: #ffffff; --surface-2: #ebe8e2; --text: #1d1f24;
    --muted: #6b6f78; --accent: #d97706; --accent-ink: #ffffff; color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; }
.muted { color: var(--muted); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }

/* ---------- Flip-Bühne ---------- */
#stage { perspective: 1400px; min-height: 100vh; }
#flipper {
  min-height: 100vh;
  transform-origin: center center;
  backface-visibility: hidden;
  will-change: transform;
}
#view {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--player-h) + 32px);
}

/* ---------- Kopfzeile ---------- */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.topbar h1 { font-size: 28px; margin: 0; flex: 1; letter-spacing: -.02em; }
.topbar h2 { font-size: 18px; margin: 0; flex: 1; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
}
.icon-btn:active { transform: scale(.94); }

/* ---------- Suche ---------- */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: var(--radius);
  padding: 0 12px; margin: 12px 0 16px;
}
.search svg { color: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  padding: 14px 0; font-size: 16px;
}
.search button { color: var(--muted); padding: 6px; }
.search input::-webkit-search-cancel-button { display: none; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  padding: 8px 16px; border-radius: 999px; background: var(--surface);
  color: var(--muted); font-weight: 600; font-size: 14px;
}
.tab.active { background: var(--accent); color: var(--accent-ink); }

/* ---------- Cover-Raster ---------- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.card { text-align: left; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card img, .cover-ph {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius);
  background: var(--surface-2); box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.card { cursor: pointer; }
.card:active img { transform: scale(.97); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius); }

/* Favoriten-Stern oben rechts im Cover */
.cover { position: relative; flex: none; }
.fav-star {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0,0,0,.45); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .15s;
}
.fav-star svg { width: 20px; height: 20px; }
.fav-star.on { color: var(--accent); }
.fav-star:active { transform: scale(.85); }
.card .t { font-weight: 600; font-size: 14px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .a { font-size: 12px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; opacity: .5; }
.spinner {
  width: 32px; height: 32px; margin: 48px auto; border-radius: 50%;
  border: 3px solid var(--surface-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Podcast-Seite ---------- */
.hero { display: flex; gap: 16px; align-items: flex-end; margin: 8px 0 16px; }
.hero img { width: 132px; height: 132px; border-radius: var(--radius); object-fit: cover; flex: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); background: var(--surface-2); }
.hero h1 { font-size: 22px; line-height: 1.2; margin: 0 0 4px; }
.hero .author { font-size: 14px; }
.hero-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; background: var(--surface); font-weight: 600; font-size: 14px;
}
.pill svg { width: 18px; height: 18px; }
.pill.on { background: var(--accent); color: var(--accent-ink); }
.desc { color: var(--muted); font-size: 14px; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.desc.open { -webkit-line-clamp: unset; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 24px 0 8px; }

.episodes { list-style: none; padding: 0; margin: 0; }
.ep { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--surface-2); align-items: flex-start; }
.ep-body { flex: 1; min-width: 0; }
.ep-meta { font-size: 12px; color: var(--muted); }
.ep-title { font-weight: 600; margin: 2px 0; cursor: pointer; }
.ep.playing .ep-title { color: var(--accent); }
.ep.played .ep-body { opacity: .5; }
.ep-desc { font-size: 13px; color: var(--muted); white-space: pre-line; margin-top: 6px; display: none; }
.ep.open .ep-desc { display: block; }
.ep-progress { height: 3px; background: var(--surface-2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.ep-progress i { display: block; height: 100%; background: var(--accent); }
.ep-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.round {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); position: relative;
}
.round.primary { background: var(--accent); color: var(--accent-ink); }
.round.done { color: var(--accent); }
.round svg { width: 20px; height: 20px; }
.round .pct { font-size: 10px; font-weight: 700; }
a.round { color: inherit; text-decoration: none; }

/* ---------- Einstellungen ---------- */
.settings-group { background: var(--surface); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--surface-2); }
.row:last-child { border-bottom: 0; }
.row label { font-weight: 500; }
.row small { display: block; color: var(--muted); font-weight: 400; }
.row select {
  background: var(--surface-2); color: var(--text); border: 0; border-radius: 10px; padding: 8px 10px; font: inherit;
}
.btn-danger { color: var(--danger); font-weight: 600; }
.dl-item { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--surface-2); }
.dl-item img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.dl-item .grow { flex: 1; min-width: 0; }

/* ---------- Player ---------- */
#player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--surface-2);
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 10px);
}
.player-progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); max-width: 960px; margin: 0 auto; font-variant-numeric: tabular-nums; }
.player-progress span { width: 44px; }
.player-progress span:last-child { text-align: right; }
#pSeek { flex: 1; accent-color: var(--accent); height: 20px; }
.player-main { display: flex; align-items: center; gap: 12px; max-width: 960px; margin: 4px auto 0; }
#pCover { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; }
.player-meta { flex: 1; min-width: 0; font-size: 14px; }
#pTitle { font-weight: 600; }
.player-controls { display: flex; align-items: center; gap: 6px; }
.ctl { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.ctl svg { width: 30px; height: 30px; }
.ctl .skip-label { position: absolute; font-size: 9px; font-weight: 800; top: 50%; left: 50%; transform: translate(-50%, -18%); }
.ctl.play { width: 56px; height: 56px; background: var(--accent); color: var(--accent-ink); }
.ctl.play svg { width: 30px; height: 30px; }
.ctl:active { transform: scale(.92); }
#player .i-pause { display: none; }
#player.is-playing .i-pause { display: block; }
#player.is-playing .i-play { display: none; }
.rate { font-size: 13px; font-weight: 700; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); min-width: 44px; }

@media (max-width: 560px) {
  .player-main { flex-wrap: wrap; justify-content: center; }
  .player-meta { flex-basis: calc(100% - 60px); }
  .player-controls { order: 3; flex: 1; justify-content: center; gap: 24px; }
  .rate { order: 4; position: absolute; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 22px); }
  .hero img { width: 108px; height: 108px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--player-h) + 20px); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 20; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
