/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --bg: #0d0d1a;
  --bg-card: #1a1a2e;
  --bg-card2: #12122a;
  --bg-hover: #1e1e38;
  --accent: #7c6ff7;
  --accent-dark: #5a50d4;
  --accent-dim: rgba(124,111,247,0.15);
  --text: #e8e8f5;
  --text-muted: #7a7a9a;
  --border: #252540;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.18s ease;
}

/* ── Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124,111,247,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(124,111,247,0.06), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

::selection { background: rgba(124,111,247,0.35); }

/* Custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dark); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

img { max-width: 100%; height: auto; }

/* ── Layout ────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(18,18,42,0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 58px;
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.02;
  gap: 1px;
}

.topbar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.topbar-logo span { color: var(--text-muted); font-weight: 400; }

/* Author byline under the wordmark — the only link styled to read as a link here. */
.topbar-byline {
  font-size: .62rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  letter-spacing: .01em;
}
.topbar-byline:hover { color: var(--text); }

.topbar-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.topbar-nav a {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: var(--transition);
}

.topbar-nav a:hover,
.topbar-nav a.active { color: var(--text); background: var(--bg-hover); }

.main-content {
  flex: 1;
  padding: 1.5rem 1rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--accent-dark); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

/* ── Podcast Card ──────────────────────────────────────────── */
.podcast-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

.podcast-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.podcast-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-card2);
}

.podcast-card-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--accent-dim), var(--bg-card2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.podcast-card-body {
  padding: 0.875rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.podcast-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.podcast-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Episode List ──────────────────────────────────────────── */
.episode-list { display: flex; flex-direction: column; gap: 0.5rem; }

.episode-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: start;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.episode-item:hover { border-color: var(--accent); background: var(--bg-hover); }
.episode-item.unread { border-left: 3px solid var(--accent); }
.episode-item.read { opacity: 0.7; }

.episode-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

.episode-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.episode-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

/* ── Status Badges ─────────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-done { color: var(--success); background: rgba(34,197,94,0.12); }
.status-error { color: var(--error); background: rgba(239,68,68,0.12); }
.status-pending { color: var(--text-muted); background: rgba(122,122,154,0.12); }
.status-queued { color: var(--info); background: rgba(59,130,246,0.12); }
.status-downloading { color: var(--warning); background: rgba(245,158,11,0.12); animation: pulse 1.5s infinite; }
.status-transcribing { color: var(--accent); background: var(--accent-dim); animation: pulse 1.5s infinite; }

@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.5 } }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--bg-card2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-icon { padding: 0.4rem; border-radius: var(--radius-sm); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-label { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }

input[type="text"],
input[type="url"],
input[type="number"],
textarea,
select {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.6rem 0.875rem;
  font-size: 0.9rem;
  width: 100%;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 100px; resize: vertical; }

.input-row { display: flex; gap: 0.5rem; }
.input-row input { flex: 1; }

/* ── Search ────────────────────────────────────────────────── */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.search-bar input {
  padding-left: 2.25rem;
  background: var(--bg);
  border-color: var(--border);
}

.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  pointer-events: none;
}

/* ── Transcript ────────────────────────────────────────────── */
.transcript-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.chapter-nav {
  position: sticky;
  top: 72px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.chapter-nav h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.chapter-item {
  display: block;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 0.125rem;
}

.chapter-item:hover, .chapter-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.chapter-item .ch-time {
  display: block;
  font-size: 0.72rem;
  color: var(--accent);
  font-family: monospace;
  margin-bottom: 0.125rem;
}

.transcript-body {}

.segment {
  display: grid;
  grid-template-columns: 80px auto 1fr;
  gap: 0.5rem;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid transparent;
  transition: background var(--transition);
  border-radius: var(--radius-sm);
}

.segment:hover { background: var(--bg-hover); }
.segment:target, .segment.highlight { background: var(--accent-dim); }

.seg-time {
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--accent);
  cursor: pointer;
  padding-top: 0.1rem;
  white-space: nowrap;
}

.seg-speaker {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  height: fit-content;
  white-space: nowrap;
}

/* Speaker colors */
.speaker-0 { background: rgba(124,111,247,0.2); color: #a09bf7; }
.speaker-1 { background: rgba(34,197,94,0.2); color: #4ade80; }
.speaker-2 { background: rgba(251,191,36,0.2); color: #fbbf24; }
.speaker-3 { background: rgba(239,68,68,0.2); color: #f87171; }
.speaker-4 { background: rgba(14,165,233,0.2); color: #38bdf8; }

.seg-text { font-size: 0.9rem; line-height: 1.7; }

mark { background: rgba(124,111,247,0.3); color: var(--text); border-radius: 2px; padding: 0 2px; }

/* ── Summary Card ──────────────────────────────────────────── */
.summary-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(124,111,247,0.05) 100%);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.summary-card h3 { color: var(--accent); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.75rem; }

.takeaways { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.takeaway {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}
.takeaway::before { content: '→'; color: var(--accent); flex-shrink: 0; }

/* ── Action Bar ────────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;            /* Firefox */
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.action-bar::-webkit-scrollbar { display: none; }   /* WebKit */
.action-bar > * { flex-shrink: 0; }

/* Episode metadata strip: stays on one line, horizontally swipeable on mobile */
.meta-line {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.meta-line::-webkit-scrollbar { display: none; }
.meta-line > * { flex-shrink: 0; white-space: nowrap; }

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header-art {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card2);
}

.page-header-info { flex: 1; min-width: 0; }
.page-header-info h1 { font-size: 1.4rem; font-weight: 700; line-height: 1.2; margin-bottom: 0.25rem; }
.page-header-info p { font-size: 0.875rem; color: var(--text-muted); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ── Collapsible ───────────────────────────────────────────── */
details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem 0;
  user-select: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '▶'; font-size: 0.7rem; transition: transform 0.2s; }
details[open] summary::before { transform: rotate(90deg); }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  max-width: 320px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--error); }
.toast-info { border-left: 4px solid var(--accent); }

@keyframes slideIn { from { transform: translateX(100%); opacity:0 } to { transform: translateX(0); opacity:1 } }

/* ── Digest ────────────────────────────────────────────────── */
.digest-body {
  font-size: 0.95rem;
  line-height: 1.8;
  max-width: 720px;
}

.digest-body h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.digest-body h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
.digest-body p { margin-bottom: 0.875rem; }
.digest-body blockquote { border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.5rem 1rem; background: var(--accent-dim); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-style: italic; }

/* ── Misc ──────────────────────────────────────────────────── */
.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 0.75rem; }

.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.divider { height: 1px; background: var(--border); margin: 1rem 0; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  .topbar, .action-bar, .chapter-nav, .btn, .modal-overlay { display: none !important; }
  body { background: #fff; color: #000; }
  .seg-text { font-size: 11pt; }
  .seg-time, .seg-speaker { color: #555; }
  .summary-card { border: 1px solid #ccc; }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar-nav a { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
  .transcript-layout { grid-template-columns: 1fr; }
  .chapter-nav { position: static; max-height: 200px; margin-bottom: 1rem; }
  .segment { grid-template-columns: 70px 1fr; }
  .seg-speaker { display: none; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.6rem; }
  .action-bar { gap: 0.375rem; }
  .btn { font-size: 0.8rem; padding: 0.4rem 0.75rem; }
}

@media (max-width: 480px) {
  .main-content { padding: 1rem 0.75rem; }
  .topbar { padding: 0 0.75rem; }
  .topbar-nav a span { display: none; }
  .episode-item { grid-template-columns: 1fr; }
  .episode-actions { margin-top: 0.5rem; }
  /* Denser podcast tiles on phones — 3 per row, smaller */
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.5rem; }
  .podcast-card-body { padding: 0.5rem; }
  .podcast-card-title { font-size: 0.8rem; }
  .podcast-card-meta { font-size: 0.68rem; }
  .gen-avatar-initials { font-size: 1.1rem; }
}

/* ═══════════════════════════════════════════════════════════════
   v2 — Premium UX layer
   ═══════════════════════════════════════════════════════════════ */

/* ── Reading progress bar (top) ─────────────────────────────── */
#read-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  z-index: 300;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(124,111,247,0.6);
}

/* ── Mobile bottom navigation ───────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 150;
  background: rgba(18,18,42,0.92);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
  justify-content: space-around;
}

.bottom-nav a,
.bottom-nav .bn-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 600;
  transition: var(--transition);
  min-width: 56px;
}

.bottom-nav .bn-more { background: none; border: none; cursor: pointer; font-family: inherit; }

.bottom-nav a .bn-icon,
.bottom-nav .bn-more .bn-icon { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a.active .bn-icon { transform: translateY(-1px); filter: drop-shadow(0 2px 6px rgba(124,111,247,0.5)); }

/* ── Audio player (sticky bottom) ───────────────────────────── */
.audio-player {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 1rem;
  width: min(680px, calc(100% - 1.5rem));
  z-index: 140;
  background: rgba(26,26,46,0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  padding: 0.75rem 1rem;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}

.audio-player.visible { display: flex; animation: playerUp 0.25s ease; }
@keyframes playerUp { from { transform: translate(-50%, 120%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.ap-row { display: flex; align-items: center; gap: 0.75rem; }

.ap-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.ap-btn:hover { background: var(--accent-dark); transform: scale(1.05); }
.ap-btn.small { width: 34px; height: 34px; font-size: 0.85rem; background: var(--bg-card2); color: var(--text); border: 1px solid var(--border); }
.ap-btn.small:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.05); }

.ap-time { font-family: monospace; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

.ap-scrubber {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
}
.ap-scrubber-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #a78bfa); border-radius: 10px; width: 0%; pointer-events: none; }
.ap-scrubber-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 13px; height: 13px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4); left: 0%; pointer-events: none;
}

.ap-speed {
  background: var(--bg-card2); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 20px; padding: 0.2rem 0.6rem; font-size: 0.72rem; cursor: pointer; font-weight: 600;
}
.ap-speed:hover { border-color: var(--accent); color: var(--accent); }

.ap-title { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* segment currently playing */
.segment.playing {
  background: linear-gradient(90deg, var(--accent-dim), transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.segment { cursor: pointer; }

/* ── Reader font-size scale (set on #transcript-content) ────── */
.fs-sm .seg-text, .fs-sm.digest-body { font-size: 0.82rem; }
.fs-md .seg-text, .fs-md.digest-body { font-size: 0.95rem; }
.fs-lg .seg-text, .fs-lg.digest-body { font-size: 1.08rem; line-height: 1.85; }
.fs-xl .seg-text, .fs-xl.digest-body { font-size: 1.22rem; line-height: 1.9; }

.reader-tools {
  display: flex; align-items: center; gap: 0.5rem;
  margin-left: auto;
}
.reader-tools .btn-icon { font-weight: 700; }

/* ── Skeleton loaders ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(100deg, var(--bg-card) 30%, var(--bg-hover) 50%, var(--bg-card) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.skel-card { aspect-ratio: 1; border-radius: var(--radius); }
.skel-line { height: 12px; margin: 6px 0; }
.skel-line.short { width: 55%; }
.skel-line.med { width: 80%; }

/* ── Continue / hero strip ──────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, rgba(124,111,247,0.18), rgba(124,111,247,0.04));
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.hero h2 { font-size: 1.05rem; margin-bottom: 0.25rem; }
.hero p { font-size: 0.85rem; color: var(--text-muted); }

/* ── Stat chips ─────────────────────────────────────────────── */
.stats-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat {
  flex: 1; min-width: 100px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.875rem 1rem;
}
.stat .num { font-size: 1.6rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat .label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Fade-in for content ────────────────────────────────────── */
.fade-in { animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Toggle switch ──────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 24px; transition: 0.2s;
}
.switch .slider::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ── Segmented control ──────────────────────────────────────── */
.segmented {
  display: inline-flex; background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px; gap: 3px;
}
.segmented button {
  border: none; background: transparent; color: var(--text-muted);
  padding: 0.4rem 0.875rem; border-radius: 6px; font-size: 0.82rem; cursor: pointer; font-weight: 500;
  transition: var(--transition);
}
.segmented button.active { background: var(--accent); color: #fff; }

/* ── Mobile adaptations for v2 ──────────────────────────────── */
@media (max-width: 768px) {
  .topbar-nav { display: none; }       /* replaced by bottom-nav */
  .bottom-nav { display: flex; }
  .main-content { padding-bottom: 5.5rem; }  /* room for bottom-nav */
  body.has-player .main-content { padding-bottom: 9.5rem; }
  .audio-player { bottom: calc(4.2rem + env(safe-area-inset-bottom)); width: calc(100% - 1rem); }
  .search-bar { max-width: none; }
}

@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
}

/* Larger touch targets on mobile */
@media (max-width: 768px) {
  .btn { min-height: 40px; }
  .episode-item { padding: 1rem 0.875rem; }
  .chapter-item { padding: 0.65rem; }
  input, textarea, select { font-size: 16px; }  /* prevent iOS/Android zoom */
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── App Footer ─────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  color: var(--text-muted);
  font-size: .75rem;
  line-height: 1.8;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}
.app-footer a { color: var(--accent); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
.app-footer strong { color: var(--text); }

/* ── Light theme (CR 8) ─────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg: #f2f2fb;
  --bg-card: #ffffff;
  --bg-card2: #e8e8f6;
  --bg-hover: #ddddf8;
  --accent: #5a4fd4;
  --accent-dark: #4a3fc4;
  --accent-dim: rgba(90,79,212,0.12);
  --text: #1a1a2e;
  --text-muted: #5a5a7a;
  --border: #c8c8e4;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
}

[data-theme="light"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(90,79,212,0.05), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(90,79,212,0.03), transparent 55%),
    var(--bg);
}

[data-theme="light"] .topbar { background: rgba(242,242,251,0.92); }
[data-theme="light"] .bottom-nav { background: rgba(242,242,251,0.96); }
[data-theme="light"] .audio-player { background: rgba(255,255,255,0.97); border-color: var(--border); }
[data-theme="light"] mark { color: var(--text); }

/* theme toggle button in topbar */
.theme-btn {
  font-size: 1.1rem !important;
  padding: .35rem .45rem !important;
  line-height: 1;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* ── UX improvements ────────────────────────────────────────────────────── */

/* #2 elapsed time badge */
.elapsed-badge {
  font-size: .72rem;
  color: var(--text-muted);
  font-style: italic;
}

/* #3 error detail in episode list */
.error-detail {
  font-size: .72rem;
  color: var(--error);
  margin-top: .25rem;
  font-family: monospace;
  word-break: break-all;
  white-space: pre-wrap;
}

/* #4 tag chips on episode cards */
.episode-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-top: .375rem;
}
.tag:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* #4 tag cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
  align-items: center;
  line-height: 1.8;
}
.tag-cloud-item {
  text-decoration: none;
  transition: transform .15s;
}
.tag-cloud-item:hover {
  transform: scale(1.05);
}
.tag-count {
  font-size: .65em;
  color: var(--text-muted);
  margin-left: .2rem;
}

/* #11 feed health warning badge */
.badge-warn {
  background: rgba(255,160,0,.15);
  border: 1px solid rgba(255,160,0,.4);
  color: #ffa000;
  font-size: .7rem;
  padding: .15rem .5rem;
  border-radius: 20px;
  cursor: default;
}

/* #8 mobile settings bottom-sheet */
@media (max-width: 640px) {
  #podcast-settings {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    margin: 0;
    border-radius: 12px 12px 0 0;
    max-height: 80vh;
    overflow-y: auto;
    border-bottom: none;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 24px rgba(0,0,0,.4);
  }
  #podcast-settings::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto .875rem;
  }
  body.settings-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 499;
  }
}

/* ═══════════════════════════════════════════════════════════════
   v3 — Unified icons, bottom-sheet, context menu, FAB
   ═══════════════════════════════════════════════════════════════ */

/* Inline SVG icons (Lucide outline) inherit text color via currentColor */
.icon {
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}
.btn .icon { vertical-align: -0.18em; }
.icon.danger { color: var(--error); }

/* Topic overview list inside the summary card */
.topic-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.topic-list li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.4;
}
.topic-list li::before {
  content: '';
  position: absolute;
  left: 0; top: 0.55em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Bottom-sheet (mobile) / centered dialog (desktop) ──────── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 0.5rem 0.75rem calc(1rem + env(safe-area-inset-bottom));
  animation: sheetUp 0.22s cubic-bezier(.2,.7,.3,1);
}
.sheet::before {
  content: '';
  display: block;
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0.5rem auto 0.75rem;
}
.sheet-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.5rem 0.5rem;
}
.sheet-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  text-align: left;
  padding: 0.85rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.sheet-item:hover { background: var(--bg-hover); }
.sheet-item .icon { color: var(--text-muted); }
.sheet-item.danger { color: var(--error); }
.sheet-item.danger .icon { color: var(--error); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 640px) {
  .sheet-overlay { align-items: center; }
  .sheet { border-radius: var(--radius); margin: 1rem; animation: fadeIn 0.15s ease; }
  .sheet::before { display: none; }
}

/* ── Context (⋮) popover menu ───────────────────────────────── */
.menu-popover {
  position: absolute;
  z-index: 1100;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  padding: 0.35rem;
  animation: fadeIn 0.12s ease;
}
.menu-popover button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.menu-popover button:hover { background: var(--bg-hover); }
.menu-popover button .icon { color: var(--text-muted); }
.menu-popover button.danger { color: var(--error); }
.menu-popover button.danger .icon { color: var(--error); }

/* ── Floating Action Button ─────────────────────────────────── */
.fab {
  position: fixed;
  right: 1.1rem;
  bottom: 1.5rem;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(124,111,247,0.5);
  z-index: 140;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(124,111,247,0.6); }
.fab:active { transform: translateY(0); }
.fab .icon { width: 26px; height: 26px; }
/* Lift above the mobile bottom-nav */
@media (max-width: 768px) {
  .fab { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* ── Role-based visibility (owner vs read-only guest) ─────────────────────── */
[data-guest-only] { display: none; }
body.role-guest [data-owner-only] { display: none !important; }
body.role-guest [data-guest-only] { display: flex; }
/* Bottom-nav links set display:flex themselves, which would beat the generic
   [data-guest-only] hide — these higher-specificity rules keep them correct. */
.bottom-nav [data-guest-only] { display: none; }
body.role-guest .bottom-nav [data-guest-only] { display: flex; }

/* ── Generated avatar (newsletters / missing artwork) ─────────────────────── */
.gen-avatar {
  position: relative; width: 100%; aspect-ratio: 1;
  background: var(--av-bg, var(--accent-dim));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.gen-avatar-initials { font-weight: 700; font-size: 1.4rem; letter-spacing: .02em; }
.gen-avatar-badge {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0,0,0,.5); border-radius: 6px; padding: 2px;
  display: inline-flex; color: #fff;
}

/* ── Takeaway ticker (start screen) ───────────────────────────────────────── */
.ticker-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: .6rem;
}
.tz-shortcut {
  display: inline-flex; align-items: center; gap: .35rem; flex: none;
  padding: .35rem .7rem; border-radius: 999px;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--border); font-size: .8rem; font-weight: 600;
  text-decoration: none; transition: border-color var(--transition), background var(--transition);
}
.tz-shortcut:hover { border-color: var(--accent); }
.tz-shortcut .icon { width: 15px; height: 15px; }
.ticker {
  display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.ticker::-webkit-scrollbar { display: none; }
/* Desktop: no touch swipe — show a thin scrollbar + grab cursor (JS adds drag-to-scroll). */
@media (min-width: 769px) {
  .ticker { scrollbar-width: thin; cursor: grab; }
  .ticker::-webkit-scrollbar { display: block; height: 8px; }
  .ticker.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
  .ticker.dragging .ticker-card { pointer-events: none; }
}
.ticker-card {
  flex: 0 0 clamp(220px, 72vw, 290px); scroll-snap-align: start;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .85rem .95rem; cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  display: flex; flex-direction: column; gap: .4rem;
}
.ticker-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.ticker-source {
  display: flex; align-items: center; gap: .35rem;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
}
.ticker-source .icon { width: 13px; height: 13px; }
.ticker-source span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker-feed { cursor: pointer; }
.ticker-feed:hover { color: var(--accent); text-decoration: underline; }
.ticker-date {
  margin-left: auto; flex: none; text-transform: none; letter-spacing: 0;
  font-size: .7rem; color: var(--text-muted); opacity: .85;
}
.ticker-takeaway {
  font-size: .9rem; line-height: 1.35; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ticker-episode {
  font-size: .76rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Deep-link highlight when arriving at a specific transcript moment */
.seg-highlight { background: var(--accent-dim); border-radius: var(--radius-sm); transition: background .3s; }

/* ── Library chat (Frag deine Bibliothek) ─────────────────────────────────── */
.chat-msg { max-width: 92%; padding: .8rem 1rem; border-radius: var(--radius); font-size: .92rem; }
.chat-user {
  align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-assistant {
  align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border);
  border-bottom-left-radius: 4px; width: 100%; max-width: 100%;
}
.chat-source:hover { border-color: var(--accent); }
mark { background: var(--accent-dim); color: var(--accent); border-radius: 3px; padding: 0 2px; }
