/* ============================================================
   STREAMER — Broadcast Console Aesthetic
   Dark mode default | Amber/Gold accent | Mono station data
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&family=Syne:wght@400;600;700;800&display=swap');

/* -- CSS Variables -- */
:root {
  --bg-primary:    #0d0e12;
  --bg-secondary:  #13151c;
  --bg-tertiary:   #1a1d27;
  --bg-card:       #1e2130;
  --bg-hover:      #252840;

  --accent:        #f0a500;
  --accent-dim:    #c4860080;
  --accent-glow:   #f0a50030;
  --accent-text:   #ffc84a;

  --text-primary:  #eceef5;
  --text-secondary:#8b91a8;
  --text-muted:    #565c75;

  --border:        #2a2e42;
  --border-light:  #353a52;

  --green:         #3ecf8e;
  --red:           #f05470;
  --blue:          #5b8af0;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --shadow-sm:     0 2px 8px rgba(0,0,0,.4);
  --shadow:        0 4px 20px rgba(0,0,0,.5);
  --shadow-lg:     0 8px 40px rgba(0,0,0,.6);
  --shadow-accent: 0 0 20px rgba(240,165,0,.2);

  --header-h:      50px;
  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --footer-h:      88px;
  --transition:    .2s ease;
}

/* Light Mode */
[data-theme="light"] {
  --bg-primary:    #f4f5f8;
  --bg-secondary:  #ffffff;
  --bg-tertiary:   #eceef5;
  --bg-card:       #ffffff;
  --bg-hover:      #eef0f8;

  --accent:        #d4820a;
  --accent-dim:    #d4820a50;
  --accent-glow:   #f0a50018;
  --accent-text:   #b36800;

  --text-primary:  #1a1d27;
  --text-secondary:#565c75;
  --text-muted:    #9499b0;

  --border:        #dde0ea;
  --border-light:  #e8eaf2;

  --shadow-sm:     0 2px 8px rgba(0,0,0,.08);
  --shadow:        0 4px 20px rgba(0,0,0,.1);
  --shadow-lg:     0 8px 40px rgba(0,0,0,.12);
}

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

html {
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Syne', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}

/* -- Scrollbar -- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* -- Typography -- */
h1, h2, h3 { font-weight: 800; letter-spacing: -.02em; }
.mono { font-family: 'Space Mono', monospace; }

/* -- Header -- */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--header-h) + var(--safe-top));
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-top) 20px 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-accent);
}

.logo-icon svg { width: 20px; height: 20px; fill: #0d0e12; }

.logo-name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--text-primary);
  text-transform: uppercase;
}

.logo-name span { color: var(--accent); }

.menu-btn {
  width: 40px; height: 40px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--accent-dim); }

/* -- Dropdown Menu -- */
.menu-wrap { position: relative; }

.dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 200;
  animation: dropIn .15s ease;
}

.dropdown.open { display: block; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* -- Main Content -- */
#app-main {
  margin-top: calc(var(--header-h) + var(--safe-top));
  margin-bottom: calc(var(--footer-h) + var(--safe-bottom) + 24px);
  padding: 24px 20px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  flex: 1;
}

/* -- Tabs -- */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Syne', sans-serif;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 9px 12px;
  cursor: pointer;
  transition: var(--transition);
}

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

.tab-btn.active {
  background: var(--accent);
  color: #0d0e12;
  box-shadow: var(--shadow-accent);
}

.tab-btn.active svg { stroke: #0d0e12; }

.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* -- Section Headers -- */
.section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Non-collapsible: trailing line */
.section-label:not(.collapsible)::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Reorder toggle button sits in the section-label before the trailing line */
.reorder-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Syne', sans-serif;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 8px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  margin-left: 4px;
}
.reorder-toggle-btn:hover  { color: var(--accent); border-color: var(--accent-dim); }
.reorder-toggle-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }

/* Collapsible section header — rendered as a button */
.section-label.collapsible {
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
  padding: 14px 0 12px;
  margin-bottom: 0;
  justify-content: space-between;
  transition: color var(--transition);
}
.section-label.collapsible:hover { color: var(--text-secondary); }
.section-label.collapsible:hover .chevron { color: var(--accent); }

.section-label-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chevron {
  color: var(--text-muted);
  transition: transform .25s ease, color var(--transition);
  flex-shrink: 0;
}

/* Collapsed state — rotate chevron, hide body */
.section-label.collapsible[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.section-body {
  transition: max-height .3s ease, opacity .25s ease;
  max-height: 9999px;
  opacity: 1;
  overflow: visible;
}

.section-body.collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* First collapsible gets extra top spacing */
#search-section { margin-top: 8px; }
#recommended-section { margin-top: 0; }

/* Body padding so content isn't flush against the header */
#search-body { padding-top: 14px; }
#recommended-body { padding-top: 14px; }

/* -- Favorites Row -- */
#radio-favorites-section,
#podcast-favorites-section { margin-bottom: 32px; }

.favs-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.fav-card {
  flex-shrink: 0;
  width: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px 10px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.fav-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  opacity: 0;
  transition: var(--transition);
  pointer-events: none;
}

@media (hover: hover) {
  .fav-card:hover { border-color: var(--accent-dim); box-shadow: var(--shadow-accent); }
  .fav-card:hover::before { opacity: 1; }
}
.fav-card.active { border-color: var(--accent); }
.fav-card.active::before { opacity: 1; }

.fav-card-icon {
  width: 44px; height: 44px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  font-size: 1.2rem;
  overflow: hidden;
  flex-shrink: 0;
}

.fav-card-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.fav-card.active .fav-card-icon { background: var(--accent-glow); }

.fav-card-name {
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.fav-card-country {
  font-size: .65rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: 'Space Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: var(--transition);
  color: var(--text-muted);
  z-index: 2;
}

@media (hover: hover) {
  .fav-card:hover .fav-remove { opacity: 1; }
}
.fav-remove:hover { background: var(--red); color: white; }
.fav-remove svg { width: 10px; height: 10px; }

/* Reorder mode */
.fav-card.reorder-mode { cursor: default; }
@media (hover: hover) {
  .fav-card.reorder-mode:hover { transform: none; }
}

.reorder-arrows {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
  justify-content: center;
}

.reorder-arrow {
  width: 26px; height: 26px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
  padding: 0;
}
.reorder-arrow svg { width: 14px; height: 14px; }
.reorder-arrow:hover:not(:disabled) { background: var(--accent); color: #0d0e12; border-color: var(--accent); }
.reorder-arrow:disabled { opacity: .3; cursor: default; }
.fav-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: var(--text-muted);
  font-size: .85rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* -- Station Browser -- */
#stations-section { }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  margin-bottom: 12px;
  transition: var(--transition);
}

.search-bar:focus-within { border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-glow); }

.search-bar svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: 'Syne', sans-serif;
  font-size: .9rem;
  color: var(--text-primary);
  padding: 12px 0;
}

.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input::-webkit-search-cancel-button { display: none; }
.search-bar input::-webkit-search-decoration { display: none; }

.search-bar .clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 50%;
  display: flex;
  transition: var(--transition);
}
.search-bar .clear-btn:hover { color: var(--text-primary); }
.search-bar .clear-btn svg { width: 14px; height: 14px; }

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Syne', sans-serif;
  font-size: .8rem;
  font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b91a8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.filter-select:focus { border-color: var(--accent-dim); }

/* -- Station List -- */
#station-list { display: flex; flex-direction: column; gap: 8px; }

.station-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

@media (hover: hover) {
  .station-item:hover { border-color: var(--border-light); background: var(--bg-hover); }
}
.station-item.playing { border-color: var(--accent); background: var(--bg-hover); }

.station-item.playing::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}

/* Play button */
.play-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: var(--transition);
}

@media (hover: hover) {
  .play-btn:hover { background: var(--accent); color: #0d0e12; border-color: var(--accent); }
}
.station-item.playing .play-btn { background: var(--accent); color: #0d0e12; border-color: var(--accent); }
.play-btn svg { width: 14px; height: 14px; }

/* Station info */
.station-info { flex: 1; min-width: 0; }

.station-name {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-meta {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.station-tag {
  font-size: .68rem;
  font-family: 'Space Mono', monospace;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 1px 6px;
}

.station-tag.country { color: var(--accent-text); }
.station-tag.genre { color: var(--blue); }
.station-tag.src-rb { color: var(--green); }
.station-tag.src-sc { color: #c084fc; }
.station-tag.src-custom { color: #f472b6; }

/* Danger menu item */
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: rgba(240,84,112,.1); color: var(--red); }

/* Delete button (custom stations) */
.delete-btn {
  width: 32px; height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.delete-btn:hover { color: var(--red); background: rgba(240,84,112,.1); }
.delete-btn svg { width: 15px; height: 15px; }

/* -- Add Station Form -- */
.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.required { color: var(--accent); }

.form-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Syne', sans-serif;
  font-size: .88rem;
  padding: 10px 12px;
  outline: none;
  transition: var(--transition);
}

.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-glow); }

.add-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding: 8px 10px;
  background: var(--accent-glow);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.form-error {
  font-size: .82rem;
  color: var(--red);
  background: rgba(240,84,112,.1);
  border: 1px solid rgba(240,84,112,.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.btn-primary {
  background: var(--accent);
  color: #0d0e12;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif;
  font-size: .88rem;
  font-weight: 700;
  padding: 10px 20px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: var(--shadow-accent); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif;
  font-size: .88rem;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Waveform animation — lives in the footer now-playing area */
.waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}

.waveform span {
  display: block;
  width: 3px;
  border-radius: 2px;
  transition: background .3s;
}

/* Idle / stopped — gray static bars at half height */
.waveform span:nth-child(1) { height: 6px; }
.waveform span:nth-child(2) { height: 10px; }
.waveform span:nth-child(3) { height: 14px; }
.waveform span:nth-child(4) { height: 10px; }
.waveform span:nth-child(5) { height: 6px; }

#app-footer:not(.live):not(.paused) .waveform span { background: var(--border); }

/* Paused — amber bars, animation stopped (paused at current position) */
#app-footer.paused .waveform span {
  background: var(--accent);
  animation: wave 1s ease-in-out infinite;
  animation-play-state: paused;
}

/* Live — amber bars, animating */
#app-footer.live .waveform span {
  background: var(--accent);
  animation: wave 1s ease-in-out infinite;
  animation-play-state: running;
}

#app-footer.live .waveform span:nth-child(1),
#app-footer.paused .waveform span:nth-child(1) { animation-delay: 0s; }
#app-footer.live .waveform span:nth-child(2),
#app-footer.paused .waveform span:nth-child(2) { animation-delay: .15s; }
#app-footer.live .waveform span:nth-child(3),
#app-footer.paused .waveform span:nth-child(3) { animation-delay: .3s; }
#app-footer.live .waveform span:nth-child(4),
#app-footer.paused .waveform span:nth-child(4) { animation-delay: .45s; }
#app-footer.live .waveform span:nth-child(5),
#app-footer.paused .waveform span:nth-child(5) { animation-delay: .6s; }

@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(.35); }
}

.now-playing-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Star / Fav button */
.star-btn {
  width: 34px; height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

@media (hover: hover) {
  .star-btn:hover { color: var(--accent); background: var(--accent-glow); }
}
.star-btn.starred { color: var(--accent); }
.star-btn.starred svg { fill: var(--accent); }
.star-btn svg { width: 16px; height: 16px; transition: transform .2s; }
@media (hover: hover) {
  .star-btn:hover svg { transform: scale(1.2); }
}

/* Loading / Empty States */
.state-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: .9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.state-msg svg { width: 40px; height: 40px; opacity: .4; }

/* Spinner */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* Loading bar */
.loading-bar {
  width: 100%; height: 2px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  opacity: 0;
  transition: opacity .3s;
}
.loading-bar.active { opacity: 1; }
.loading-bar::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  animation: loadBar 1.4s ease-in-out infinite;
}

@keyframes loadBar {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* -- Footer / Player -- */
#app-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--footer-h) + var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
}

/* Status bar */
#status-bar {
  padding: 4px 20px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .3s;
}

.status-dot.live { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s ease-in-out infinite; }
.status-dot.loading { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.status-dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

#status-text {
  font-size: .72rem;
  font-family: 'Space Mono', monospace;
  color: var(--text-muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Player controls */
#player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 20px 8px;
  flex: 1;
}

.now-playing {
  flex: 1;
  min-width: 0;
}

.now-playing-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing-sub {
  font-size: .7rem;
  font-family: 'Space Mono', monospace;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctrl-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.ctrl-btn.main {
  background: var(--accent);
  color: #0d0e12;
  width: 40px; height: 40px;
  box-shadow: var(--shadow-accent);
}
@media (hover: hover) {
  .ctrl-btn.main:hover { transform: scale(1.08); box-shadow: 0 0 24px rgba(240,165,0,.4); }
}
.ctrl-btn.main:disabled { background: var(--bg-tertiary); color: var(--text-muted); box-shadow: none; cursor: default; transform: none; }
.ctrl-btn.main svg { width: 16px; height: 16px; }

.ctrl-btn.secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
@media (hover: hover) {
  .ctrl-btn.secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
}
.ctrl-btn.secondary svg { width: 14px; height: 14px; }

/* Volume */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.vol-icon { color: var(--text-muted); cursor: pointer; }
.vol-icon svg { width: 16px; height: 16px; display: block; }
.vol-icon:hover svg { color: var(--accent); }

.vol-pct {
  font-size: .68rem;
  font-family: 'Space Mono', monospace;
  color: var(--text-muted);
  min-width: 2.8ch;
  text-align: right;
  flex-shrink: 0;
}

input[type="range"].vol-slider {
  -webkit-appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--val, 80%), var(--border) var(--val, 80%));
  outline: none;
  cursor: pointer;
  transition: background .1s;
}

input[type="range"].vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(240,165,0,.5);
  transition: transform .15s;
}

input[type="range"].vol-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
input[type="range"].vol-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

/* -- Modal / Dialog -- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 1.2rem; font-weight: 800; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-close svg { width: 14px; height: 14px; }

.about-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

.about-logo-icon {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-accent);
}
.about-logo-icon svg { width: 26px; height: 26px; fill: #0d0e12; }

.about-logo-text h2 { font-size: 1.3rem; }
.about-logo-text p { font-size: .8rem; font-family: 'Space Mono', monospace; color: var(--text-muted); }

.about-desc { font-size: .87rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 16px; }

.about-info {
  display: grid;
  gap: 8px;
}

.about-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.about-info-row span:first-child { color: var(--text-muted); }
.about-info-row span:last-child { color: var(--text-primary); font-weight: 600; font-family: 'Space Mono', monospace; }

/* -- Podcasts -- */
#podcasts-body { padding-top: 14px; }

.podcast-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}
@media (hover: hover) {
  .podcast-item:hover { border-color: var(--border-light); background: var(--bg-hover); }
}
.podcast-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.podcast-art {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

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

.podcast-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podcast-author {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podcast-meta { margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; }

.podcast-chevron { color: var(--text-muted); flex-shrink: 0; transition: transform .2s ease; }
@media (hover: hover) {
  .podcast-item:hover .podcast-chevron { color: var(--accent); }
}
.podcast-chevron.open { transform: rotate(90deg); }

.podcast-item[aria-expanded="true"] {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom-color: transparent;
}
.rec-episode-drawer {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--bg-tertiary);
  padding: 8px;
  margin-bottom: 8px;
}

/* Episode panel */
.episode-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  font-family: 'Syne', sans-serif;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  transition: var(--transition);
}
.episode-back-btn:hover { opacity: .75; }

.episode-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

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

.podcast-art-lg {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.episode-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
@media (hover: hover) {
  .episode-item:hover { border-color: var(--border-light); background: var(--bg-hover); }
}
.episode-item.playing { border-color: var(--accent); background: var(--bg-hover); }
.episode-item.playing::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}

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

.episode-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

.episode-meta { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.ep-remaining {
  font-size: .65rem;
  font-family: 'Space Mono', monospace;
  color: var(--accent-text);
  background: var(--accent-glow);
  border-radius: 3px;
  padding: 1px 5px;
}

/* Episode seek bar — styled range input */
input[type="range"].ep-progress-bar {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 8px;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--val, 0%), var(--border) var(--val, 0%));
  outline: none;
  cursor: pointer;
  transition: height .15s ease;
}

input[type="range"].ep-progress-bar:hover { height: 6px; }

input[type="range"].ep-progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 4px rgba(240,165,0,.5);
  cursor: pointer;
  transition: transform .15s;
}

input[type="range"].ep-progress-bar::-webkit-slider-thumb:hover { transform: scale(1.3); }

input[type="range"].ep-progress-bar::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

input[type="range"].ep-progress-bar::-moz-range-track {
  background: transparent;
}

/* -- Episode download button -- */
.ep-dl-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ep-dl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  transition: var(--transition);
  min-width: 40px;
}

.ep-dl-btn svg { width: 16px; height: 16px; display: block; }
@media (hover: hover) {
  .ep-dl-btn:hover { color: var(--accent); background: var(--accent-glow); }
}

/* Idle */
.ep-dl-idle { color: var(--text-muted); }

/* Downloading */
.ep-dl-downloading { color: var(--accent); }
.ep-dl-spinner { animation: spin .9s linear infinite; }
.ep-dl-pct {
  font-size: .6rem;
  font-family: 'Space Mono', monospace;
  color: var(--accent);
  line-height: 1;
}

/* Cached */
.ep-dl-cached { color: var(--green); }
.ep-dl-size {
  font-size: .6rem;
  font-family: 'Space Mono', monospace;
  color: var(--green);
  line-height: 1;
}
@media (hover: hover) {
  .ep-dl-cached:hover { color: var(--red); background: rgba(240,84,112,.1); }
  .ep-dl-cached:hover svg { stroke: var(--red); }
}
/* -- Export Options -- */
.export-option-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.export-option-row:hover { border-color: var(--accent-dim); background: var(--bg-hover); }

.export-option-check {
  position: relative;
  flex-shrink: 0;
  width: 20px; height: 20px;
  margin-top: 1px;
}

.export-option-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border: 2px solid var(--border-light);
  border-radius: 5px;
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
}

.export-option-check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check-icon {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  stroke: #0d0e12;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}

.export-option-check input[type="checkbox"]:checked + .check-icon { opacity: 1; }

.export-option-text { flex: 1; min-width: 0; }

.export-option-title {
  display: block;
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.export-option-desc {
  display: block;
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

@media (max-width: 600px) {
  #app-main { padding: 16px 14px; }

  .fav-card { width: 120px; }
  .filters { flex-wrap: wrap; }

  .volume-wrap { display: none; }

  .now-playing-name { font-size: .8rem; }

  input[type="range"].vol-slider { width: 70px; }

  #player-controls { gap: 8px; padding: 6px 14px 8px; }
}

@media (min-width: 900px) {
  input[type="range"].vol-slider { width: 120px; }
}

/* -- Toast -- */
.toast-wrap {
  position: fixed;
  bottom: calc(var(--footer-h) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: toastIn .3s ease forwards;
  white-space: nowrap;
}

.toast.out { animation: toastOut .3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}
