:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1e1e1e;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #e40000;
  --player-h: 84px;
  --header-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { height: 100%; background: var(--bg); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--player-h) + var(--safe-bottom) + 8px);
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  gap: 12px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.back-btn svg { width: 24px; height: 24px; }
.back-btn:active { background: var(--surface2); }

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-icon { margin-right: 4px; }

/* Main */
main { max-width: 800px; margin: 0 auto; }

.view { display: none; padding: 16px 16px 0; }
.view.active { display: block; }

/* Section header */
.section-header { margin-bottom: 20px; }
.section-header h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; }
.section-header .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

/* Shows grid */
.shows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.show-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}
.show-card:active { transform: scale(0.96); }
.show-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }

.show-card-art {
  aspect-ratio: 16/9;
  background: var(--surface2);
  position: relative;
  overflow: hidden;
}
.show-card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.show-card-art .live-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.show-card-body { padding: 12px; }
.show-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}
.show-card-host {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.show-card-schedule {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.show-card-play {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 20px;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  width: 100%;
  justify-content: center;
  transition: opacity 0.15s;
}
.show-card-play:active { opacity: 0.7; }
.show-card-play svg { width: 14px; height: 14px; }

/* Skeleton */
.skeleton-card {
  background: var(--surface);
  border-radius: 12px;
  aspect-ratio: 3/4;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Show hero */
.show-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
}
.show-hero-art {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}
.show-hero-info { flex: 1; min-width: 0; }
.show-hero-title { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 4px; }
.show-hero-host { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.show-hero-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.hero-live-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 16px;
  border-radius: 24px;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}
.hero-live-btn:active { opacity: 0.7; }
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: livepulse 1.5s ease-in-out infinite;
}
@keyframes livepulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Episodes */
.episodes-list { display: flex; flex-direction: column; gap: 12px; }

.episode-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  gap: 12px;
  padding: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.episode-card:active { background: var(--surface2); }

.episode-art {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}
.episode-info { flex: 1; min-width: 0; }
.episode-title { font-size: 0.9rem; font-weight: 700; line-height: 1.3; margin-bottom: 4px; }
.episode-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.episode-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.episode-card-arrow {
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
}

.episode-play-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.episode-play-btn:hover { background: var(--surface2); border-color: #444; }
.episode-play-btn svg { width: 12px; height: 12px; }
.episode-play-btn.playing { border-color: var(--accent); color: var(--accent); }

/* Empty / error states */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}
.empty-state p { margin-top: 8px; font-size: 0.85rem; }

/* Player bar */
.player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(18,18,18,0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: var(--safe-bottom);
}

.player-progress-wrap {
  position: relative;
  height: 3px;
  background: var(--surface2);
  cursor: pointer;
}
.player-progress-bg { height: 100%; width: 100%; }
.player-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.5s linear;
  pointer-events: none;
}
.player-seek {
  position: absolute;
  top: -6px; left: 0; right: 0;
  width: 100%;
  height: 16px;
  opacity: 0;
  cursor: pointer;
}

.player-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  height: calc(var(--player-h) - 3px);
}

.player-art {
  width: 48px; height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface2);
  flex-shrink: 0;
}
.player-art img { width: 100%; height: 100%; object-fit: cover; }

.player-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.player-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.player-track {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-show {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.ctrl-btn:active { background: var(--surface2); }
.ctrl-btn svg { width: 24px; height: 24px; }
.skip-back svg, .skip-fwd svg { width: 22px; height: 22px; color: var(--text-muted); }

.play-pause { background: var(--accent); width: 44px; height: 44px; }
.play-pause:active { background: #c00; }
.play-pause svg { width: 22px; height: 22px; }

.player-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  width: 108px;
  text-align: right;
  flex-shrink: 0;
}

/* Now playing marquee for live */
.now-playing-bar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
  overflow: hidden;
}
.now-playing-label {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.now-playing-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Episode detail */
.ep-hero {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.ep-hero-art {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 16px;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}

.ep-hero-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.ep-hero-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  margin-top: 4px;
}

.ep-hero-desc {
  font-size: 0.88rem;
  line-height: 1.65;
  color: #ccc;
  margin-top: 8px;
}

.ep-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.ep-play-btn:active { opacity: 0.8; transform: scale(0.98); }
.ep-play-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.ep-play-btn.playing { opacity: 0.85; }

.ep-restart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 10px;
  transition: border-color 0.15s, color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.ep-restart-btn:hover { border-color: var(--text-muted); color: var(--text); }
.ep-restart-btn:active { transform: scale(0.98); }

/* Tracklist */
.tracklist-section { margin-top: 28px; }

.tracklist-heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.track-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 6px;
  padding-left: 4px;
}
.track-row:last-child { border-bottom: none; }
.track-row:active { background: var(--surface2); }
.track-row.active-track .track-artist,
.track-row.active-track .track-title { color: var(--accent); }

.track-num {
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 22px;
  text-align: right;
  flex-shrink: 0;
}
.track-info { flex: 1; min-width: 0; }
.track-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-artist {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.track-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}

.no-tracklist {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 16px 0;
  font-style: italic;
}

/* Responsive */
@media (min-width: 600px) {
  .shows-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .show-hero { flex-direction: row; }
  .show-hero-art { width: 120px; height: 120px; }
}
