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

:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface-hover: #27272a;
  --surface-elevated: #1f1f23;
  --text: #fafafa;
  --text-secondary: #d4d4d8;
  --text-muted: #71717a;
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.25);
  --accent-hover: #c4b5fd;
  --accent-subtle: rgba(167, 139, 250, 0.12);
  --border: #27272a;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --mini-player-h: 72px;
  --header-h: 56px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  letter-spacing: -0.01em;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* Header */
header {
  background: var(--surface);
  padding: 16px 20px 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  padding-bottom: 10px;
  letter-spacing: -0.02em;
}

#tab-bar {
  display: flex;
  gap: 0;
}

.tab {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: -0.01em;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab:hover { color: var(--text-secondary); }

/* Tab content */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(var(--mini-player-h) + 20px);
}

.tab-content.active { display: block; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 16px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state span {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Search */
.search-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding-bottom: 16px;
}

#search-input {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#search-input::placeholder { color: var(--text-muted); }

/* Podcast cards */
.podcast-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  align-items: center;
  border: 1px solid var(--border);
}

.podcast-card:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.podcast-card img {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

.card-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.card-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.btn-sub {
  padding: 8px 18px;
  border-radius: 24px;
  border: 1px solid var(--accent);
  background: none;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  letter-spacing: -0.01em;
}

.btn-sub.subscribed {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 700;
}

.btn-sub:hover {
  background: var(--accent-subtle);
}

.btn-sub.subscribed:hover {
  background: var(--accent-hover);
}

/* Episode rows */
.episode-row {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
  align-items: flex-start;
  border: 1px solid var(--border);
}

.episode-row:hover { background: var(--surface-hover); }

.episode-row img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
  margin-top: 2px;
}

.episode-content { flex: 1; min-width: 0; }

.episode-content h3 {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.episode-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-download, .btn-transcript-sm {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-download:hover, .btn-transcript-sm:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.btn-download.downloaded {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-download.downloading {
  opacity: 0.6;
  pointer-events: none;
}

/* Podcast detail */
#podcast-detail { display: none; }
#podcast-detail.active { display: block; }

.podcast-header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
}

.podcast-header img {
  width: 84px;
  height: 84px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.podcast-header-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.podcast-header-info .podcast-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.podcast-header-info .podcast-desc.expanded {
  -webkit-line-clamp: unset;
}

.btn-show-more {
  font-size: 0.75rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 4px;
  font-weight: 600;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 0 14px;
  font-weight: 600;
}

.back-btn:hover { color: var(--accent-hover); }

/* Section headers */
.section-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 0 12px;
}

/* Player */
#player-container {
  text-align: center;
  padding-top: 8px;
}

#player-artwork {
  width: 220px;
  height: 220px;
  border-radius: 20px;
  margin: 0 auto 24px;
  background: var(--border);
  background-size: cover;
  background-position: center;
  box-shadow: 0 12px 48px rgba(167, 139, 250, 0.12), 0 4px 16px rgba(0,0,0,0.5);
}

#player-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

#player-info p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#player-progress {
  margin: 28px 0 16px;
  padding: 0 8px;
}

#seek-bar {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

#seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.4);
  transition: transform 0.1s;
}

#seek-bar::-webkit-slider-thumb:active { transform: scale(1.15); }

.time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

#player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  margin: 20px 0;
}

#player-controls button {
  font-size: 1.8rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
  filter: grayscale(0.1);
}

#player-controls button:active { transform: scale(0.88); }
#player-controls button:hover { filter: grayscale(0); }

#btn-play-pause {
  font-size: 3.2rem !important;
  filter: grayscale(0) !important;
  transition: transform 0.15s !important;
}

#btn-play-pause:hover { transform: scale(1.08) !important; }
#btn-play-pause:active { transform: scale(0.92) !important; }

#player-extras {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}

#speed-select {
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#speed-select:focus { border-color: var(--accent); }

.btn-secondary {
  padding: 8px 16px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Transcript Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface-elevated);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-close {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-close:hover { background: var(--surface-hover); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  line-height: 1.7;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-body .cue {
  color: var(--accent);
  font-weight: 600;
  margin: 16px 0 4px;
  font-size: 0.8rem;
}

/* Mini Player */
#mini-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mini-player-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
  z-index: 10;
}

#mini-artwork {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--border);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#mini-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

#mini-info span { display: block; }

#mini-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

#mini-podcast {
  font-size: 0.75rem;
  color: var(--text-muted);
}

#mini-play-pause {
  font-size: 1.8rem;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}

#mini-play-pause:active { transform: scale(0.9); }

/* Scrollbar */
.tab-content::-webkit-scrollbar { width: 4px; }
.tab-content::-webkit-scrollbar-track { background: transparent; }
.tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
