/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-glass: rgba(22, 33, 62, 0.7);
  --text-primary: #e8e8f0;
  --text-secondary: #8b8ba3;
  --text-muted: #5c5c7a;
  --accent: #7c3aed;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --accent-light: #a78bfa;
  --success: #34d399;
  --border: rgba(255, 255, 255, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── App Shell ──────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* ─── Header ─────────────────────────────────────────────────── */
.header {
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, var(--bg-secondary) 0%, transparent 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
}

.logo h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #e8e8f0 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ─── Episodes ───────────────────────────────────────────────── */
.episodes {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 120px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.episode-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.episode-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  opacity: 0;
  transition: opacity 0.3s;
}

.episode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, 0.2);
}

.episode-card:hover::before {
  opacity: 1;
}

.episode-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 30px var(--accent-glow);
}

.episode-card.active::before {
  opacity: 1;
}

.episode-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-light);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
}

.episode-date {
  font-size: 11px;
  color: var(--text-muted);
}

.episode-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.episode-author {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.episode-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.episode-duration {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.play-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.play-indicator:hover {
  transform: scale(1.1);
}

.play-indicator svg {
  width: 14px;
  height: 14px;
  fill: white;
  margin-left: 2px;
}

.episode-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.transcript-btn {
  padding: 4px 10px;
  border: 1px solid rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.1);
  color: var(--accent-light);
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  white-space: nowrap;
}

.transcript-btn:hover {
  background: rgba(124, 58, 237, 0.25);
}

.transcript-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.transcript-panel.open {
  max-height: 600px;
  overflow-y: auto;
  padding-top: 14px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.transcript-panel p {
  margin-bottom: 12px;
}

.transcript-panel p:last-child {
  margin-bottom: 0;
}

.viz-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s;
  text-align: center;
}

.viz-panel.open {
  max-height: 550px;
  overflow-y: auto;
  padding-top: 14px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
}

.viz-panel svg {
  width: 100%;
  height: auto;
  max-height: 500px;
  border-radius: var(--radius-sm);
}

/* ─── Player Bar ─────────────────────────────────────────────── */
.player {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  transition: transform 0.3s;
}

.player.hidden {
  transform: translateX(-50%) translateY(100%);
}

.player-progress {
  padding: 0;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  position: relative;
}

.progress-bar:hover {
  height: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 0 3px 3px 0;
  width: 0%;
  transition: width 0.1s linear;
}

.player-content {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

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

.player-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-author {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.control-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  flex-shrink: 0;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.control-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.play-btn {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: 50%;
}

.play-btn:hover {
  background: #6d28d9;
}

.speed-btn {
  font-size: 12px;
  font-weight: 600;
  width: auto;
  padding: 0 8px;
  font-family: var(--font);
}

.player-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Loading ────────────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  color: var(--text-muted);
  gap: 16px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 32px;
  color: var(--text-muted);
}

.empty-state .emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h2 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
.episodes::-webkit-scrollbar {
  width: 4px;
}

.episodes::-webkit-scrollbar-track {
  background: transparent;
}

.episodes::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (min-width: 481px) {
  .app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}