:root {
  --bg: #12141a;
  --surface: #1c1f28;
  --surface-hover: #262a36;
  --border: #2e3340;
  --text: #eef0f5;
  --text-dim: #9aa1b2;
  --accent: #6c8cff;
  --accent-hover: #8aa4ff;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body > .mam-credit { margin-top: auto; padding-top: 6px; padding-bottom: 6px; gap: 2px 10px; font-size: 11px; border-top-width: 2px; }
body > .mam-credit img { height: 15px; }
body > .mam-credit .mam-contribute { flex-basis: auto; margin-top: 0; font-size: 10px; }
body:has(.player-bar:not(.hidden)) > .mam-credit { margin-bottom: var(--player-h, 118px); }

header {
  position: relative;
  padding: 32px 24px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0 0 4px; font-size: 28px; cursor: pointer; }
.app-version { font-size: 13px; font-weight: 400; color: var(--text-dim); vertical-align: middle; }
.tagline { color: var(--text-dim); margin: 0 0 20px; }

#search-form {
  display: flex;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

#search-input {
  flex: 1;
  width: 100%;
  padding: 12px 36px 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
}

#search-input:focus { outline: 2px solid var(--accent); }

.search-clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
}

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

.search-submit-btn {
  padding: 0;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.nav-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 16px;
}

.nav-btn:hover { background: var(--surface-hover); }
.nav-btn.active { background: var(--accent); color: #0b0d12; border-color: var(--accent); }

.favorites-toggle-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 16px;
}

.favorites-toggle-btn:hover { background: var(--surface-hover); }
.favorites-toggle-btn.active { background: var(--accent); color: #0b0d12; border-color: var(--accent); }

.nav-badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--accent);
  color: #0b0d12;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  vertical-align: middle;
}

.subscribe-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  width: 100%;
  /* Pushes the button to the bottom of the card regardless of how tall the
     name/artist text above it is, so it lines up across a row of cards of
     different heights (grid rows stretch siblings to equal height). */
  margin-top: auto;
}
.subscribe-btn.active { color: var(--accent); border-color: var(--accent); }

button {
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0b0d12;
  font-weight: 600;
  cursor: pointer;
  font-size: 15px;
}

button:hover { background: var(--accent-hover); }

main { width: 100%; max-width: 900px; min-width: 0; margin: 0 auto; padding: 24px; }

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

.podcast-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  display: flex;
  flex-direction: column;
}

.favorite-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
}

.favorite-btn:hover { background: var(--surface-hover); color: var(--text); }
.favorite-btn.active { color: #ffcc4d; border-color: #ffcc4d; }

.card-favorite-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  background: rgba(18, 20, 26, 0.65);
  z-index: 1;
}

.share-icon {
  vertical-align: middle;
  flex-shrink: 0;
}

.card-share-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 20, 26, 0.65);
  z-index: 1;
}

.podcast-card:hover { background: var(--surface-hover); }

.podcast-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--border);
}

.podcast-card .name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.podcast-card .artist { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.podcast-card .latest-date, .show-header .latest-date { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.show-header .latest-date { margin: 4px 0 0; }

.hidden { display: none !important; }

#back-btn {
  background: none;
  color: var(--accent);
  padding: 8px 0;
  font-size: 14px;
}
#back-btn:hover { background: none; color: var(--accent-hover); }

.show-header {
  display: flex;
  gap: 16px;
  margin: 12px 0 24px;
  align-items: flex-start;
}

.show-header img {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
}

.show-header h2 { margin: 0 0 8px; }
.show-header p { color: var(--text-dim); font-size: 14px; margin: 0; }
#show-description { color: var(--text-dim); font-size: 14px; margin: 0; max-height: 4.5em; overflow: hidden; overflow-wrap: break-word; word-break: break-word; }
#show-description p { margin: 0 0 0.6em; }
#show-description a { color: var(--accent); }
#show-description.expanded { max-height: none; overflow: visible; }
.read-more-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 0;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: block;
}
.read-more-btn:hover { background: none; color: var(--accent-hover); }
.show-header-actions {
  margin-left: auto;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.show-header .favorite-btn {
  font-size: 13px;
  padding: 8px 14px;
}

.episode {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.episode-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.episode-info { flex: 1; min-width: 0; }
.episode-info .ep-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.episode-info .ep-meta { color: var(--text-dim); font-size: 12px; }

.ep-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.ep-title-row .ep-title { flex: 1; min-width: 0; margin-bottom: 0; }

/* Per-show episode list (opened from a search result): the play button sits
   to the left of the title/meta block, vertically centered against it,
   instead of beside the title text like the other episode lists. */
.ep-main-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.episode-actions { display: flex; gap: 8px; flex-shrink: 0; }

.episode-notes {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: break-word;
  word-break: break-word;
}
.episode-notes p { margin: 0 0 0.6em; }
.episode-notes p:last-child { margin-bottom: 0; }
.episode-notes a { color: var(--accent); }

.episode-actions button, .episode-actions a {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 6px;
}

.episode-actions a {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
}

.episode-actions .queue-btn,
.episode-actions .remove-btn,
.episode-actions .share-btn,
.episode-actions .notes-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.episode-actions .queue-btn.active { color: var(--accent); border-color: var(--accent); }

/* The Download and +Playlist buttons swap between short/long labels
   ("⬇ Download" <-> "✓ Offline", "+ Playlist" <-> "✓ In playlist", plus a
   progress-bar fill + "NN%" mid-download) -- fix their box size and disable
   flex growth so the label change never shifts surrounding icon buttons.
   Mid-download now shows just "NN%" (see .download-btn.downloading below)
   instead of the much wider "Downloading… NN%", so both buttons can share
   the same, narrower width. */
.episode-actions .download-btn:not(.icon-btn),
.episode-actions .queue-btn:not(.icon-btn) {
  flex: 0 0 auto;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 112px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex: 0 0 auto;
}
.play-btn.icon-btn {
  background: var(--accent);
  color: #0b0d12;
  border: none;
}
.play-btn.icon-btn:hover { background: var(--accent-hover); }
.download-btn.icon-btn,
.notes-btn.icon-btn,
.remove-btn.icon-btn,
.share-btn.icon-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.notes-btn.icon-btn.active { color: var(--accent); border-color: var(--accent); }
.remove-btn.icon-btn:hover { color: #ff6b6b; border-color: #ff6b6b; }
.icon-actions { gap: 8px; justify-content: center; }

/* The Playlist icon-action row (Download/Share/Notes/Remove) always wraps
   onto its own full-width line below the drag-handle/title/reorder-btns
   line, at every viewport width -- not just mobile -- so justify-content:
   center on .icon-actions above has a full-width line to actually center
   within instead of just shrink-wrapping flush against the reorder buttons. */
.playlist-item .episode-row {
  flex-wrap: wrap;
  align-items: center;
}
.playlist-item .episode-actions { flex: 1 1 100%; margin-top: 8px; }

.drag-handle {
  cursor: grab;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
}
.drag-handle:hover { color: var(--text); }

.episode.is-playing {
  background: linear-gradient(180deg, #2f386a, #242c52);
  border-color: #4a5a99;
}

.playlist-item.dragging {
  cursor: grabbing;
  position: relative;
  z-index: 20;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  opacity: 0.97;
}

.reorder-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.move-up-btn, .move-down-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 26px;
  height: 20px;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.move-up-btn:disabled, .move-down-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.radio-section { margin-bottom: 28px; }
.radio-section h3 { margin: 0 0 12px; font-size: 15px; }
.radio-section h3 .hint { display: block; font-size: 12px; font-weight: 400; color: var(--text-dim); margin-top: 2px; }

.radio-search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
/* Each row is its own flex container so items never wrap between rows —
   keeps the Search button beside the input at any viewport width. */
.radio-search-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.radio-search-input-wrap {
  position: relative;
  display: flex;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
}
.radio-search-form input,
.radio-search-form select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}
.radio-search-input-wrap input { flex: 1; min-width: 0; padding-right: 36px; }
.radio-search-form select { flex: 1 1 160px; }
.radio-search-form .radio-search-row button { flex: 0 0 auto; }

/* "Sexier" native selects: a custom chevron + dark popup list (color-scheme)
   instead of the browser's default flat arrow/light dropdown, without
   pulling in a full custom-dropdown component. */
.radio-search-form select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color-scheme: dark;
  padding: 10px 34px 10px 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa1b2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.radio-search-form select:hover { border-color: var(--accent); background-color: var(--surface-hover); }
.radio-search-form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.25); }

/* Fully custom dropdown for genre/country: replaces the native popup (which
   mobile browsers render with their own OS picker UI, ignoring page CSS)
   with a themed list we control everywhere. JS wraps each .enhanced-select
   in .custom-select and hides the native element once wrapped. */
.custom-select {
  position: relative;
  flex: 1 1 160px;
  min-width: 0;
}
.custom-select select.enhanced-select { display: none; }
.custom-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.custom-select-btn:hover { border-color: var(--accent); background-color: var(--surface-hover); }
.custom-select-btn:focus-visible,
.custom-select.open .custom-select-btn {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.25);
}
.custom-select-chevron {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}
.custom-select.open .custom-select-chevron { transform: rotate(-135deg) translateY(1px); }
.custom-select-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
.custom-select-list.hidden { display: none; }
.custom-select-option {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.custom-select-option:hover,
.custom-select-option.highlighted { background: var(--surface-hover); }
.custom-select-option.selected { color: var(--accent); font-weight: 600; }

.station-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* The favorite-stations list drags rows vertically (via offsetTop), so it
   uses a single-column stack instead of the multi-column search-results
   grid above -- same layout shift the playlist view needs for its drag. */
.station-grid.reorderable {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}

.station-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.station-card:hover { background: var(--surface-hover); }
.station-card.is-playing { border-color: var(--accent); }
.station-card.dragging {
  cursor: grabbing;
  position: relative;
  z-index: 20;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  opacity: 0.97;
}

.station-icon {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.station-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.station-icon-fallback {
  font-weight: 700;
  font-size: 17px;
  color: #0b0d12;
}

.station-info { flex: 1; min-width: 0; }
.station-name {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.station-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.station-play-btn { flex-shrink: 0; }
.station-favorite-btn {
  background: var(--surface-hover);
  color: var(--text-dim);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.station-favorite-btn.active { color: #ffcc4d; border-color: #ffcc4d; }

.playlist-view h2, .downloads-view h2, .new-episodes-view h2, .radio-view h2 { margin: 0 0 16px; }
.downloads-view h2 .hint, .new-episodes-view h2 .hint { display: block; font-size: 12px; font-weight: 400; color: var(--text-dim); margin-top: 4px; }

.storage-warning {
  background: rgba(230, 162, 60, 0.12);
  border: 1px solid rgba(230, 162, 60, 0.4);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.playlist-list { display: flex; flex-direction: column; }

.download-btn, .queue-btn, .remove-btn, .share-btn, .notes-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.download-btn.active { color: #4dd08a; border-color: #4dd08a; }
.download-btn.downloading,
.download-btn.downloading:disabled {
  color: var(--text);
  border-color: var(--accent);
  opacity: 1;
}
/* Mid-download fill: a literal progress bar drawn as a two-stop gradient
   background, sized by --dl-progress (set from JS on each progress tick).
   Renders as a flat accent-colored bar growing left-to-right behind the
   "NN%" text -- no extra markup needed. */
.download-btn.downloading:not(.icon-btn) {
  background-image: linear-gradient(
    to right,
    var(--accent) var(--dl-progress, 0%),
    var(--surface-hover) var(--dl-progress, 0%)
  );
  transition: background-image 0.15s linear;
}

.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, #2f386a, #242c52);
  border-top: 1px solid #4a5a99;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  /* Above the brand strip (z-index 1), which is later in the DOM and was painting over the bar */
  z-index: 50;
}

.player-bar audio { display: none; }

/* On desktop the primary/secondary wrapper divs are transparent to layout
   (display:contents), so play-pause-btn/player-main/skip buttons/volume all
   sit in one row exactly as before the mobile-stacking rework below. */
.player-primary-row,
.player-secondary-row {
  display: contents;
}

.play-pause-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Shown while a newly-picked episode is fetching data -- without this the
   button just sat on the old ▶/⏸ glyph with no sign anything was happening,
   which is what made episode switches feel like they'd hung. */
.play-pause-btn.loading {
  color: transparent;
}

.play-pause-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: player-spin 0.7s linear infinite;
}

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

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

.player-title {
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.time-label {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 34px;
  text-align: center;
}

.progress-bar {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.progress-bar::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.skip-btn {
  flex-shrink: 0;
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  padding: 10px 14px;
}

.skip-btn:hover { background: var(--border); }

.live-badge {
  display: none;
  color: #ff5c5c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.player-bar.live-mode .progress-row { display: none; }
.player-bar.live-mode .live-badge { display: block; }
.player-bar.live-mode #rewind-btn,
.player-bar.live-mode #skip-btn { display: none; }

.volume-control {
  position: relative;
  flex-shrink: 0;
}

.volume-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.volume-btn:hover { background: var(--border); }

.pi-cast-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.pi-cast-btn:hover { background: var(--border); }
.pi-cast-btn.is-active { border-color: var(--accent); }
.pi-cast-icon { width: 20px; height: 20px; display: block; }
.pi-cast-btn.is-active .pi-cast-icon { filter: drop-shadow(0 0 3px var(--accent)); }

.pi-cast-status {
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  animation: pi-cast-status-pulse 1.4s ease-in-out infinite;
}

@keyframes pi-cast-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.volume-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.status-msg { color: var(--text-dim); padding: 24px; text-align: center; grid-column: 1 / -1; }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  max-width: min(90vw, 380px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.connection-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.connection-modal.hidden { display: none; }

.connection-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 360px;
  text-align: center;
  color: var(--text);
}

.connection-modal-title { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
.connection-modal-box p { margin: 0 0 12px; }
.connection-modal-box .hint { color: var(--text-dim); font-size: 13px; }

.connection-modal-box button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.connection-modal-box button:hover { background: var(--accent-hover); }

.tip-btn { display: inline-flex; align-items: center; gap: 5px; }
.tip-heart { height: 18px; width: auto; border-radius: 3px; vertical-align: middle; transition: transform .15s ease; }
.tip-btn:hover .tip-heart { transform: scale(1.2); }
.tip-icon-inline { height: 26px; width: auto; border-radius: 4px; vertical-align: middle; margin-right: 2px; }

.tip-modal-box { max-width: 320px; }
.tip-qr { width: 180px; height: auto; border-radius: 12px; background: #fff; padding: 10px; margin: 4px 0 14px; }
.tip-venmo-btn {
  display: inline-block;
  background: #3d95ce;
  color: #fff;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 12px;
}
.tip-venmo-btn:hover { background: #4ea3dc; }
#tip-modal-ok { background: var(--surface); border: 1px solid var(--border); }
#tip-modal-ok:hover { background: var(--surface-hover); }

.suggest-icon { transition: transform .15s ease; }
#suggest-btn:hover .suggest-icon { transform: scale(1.15); }

.suggest-modal-box { max-width: 380px; text-align: left; }
.suggest-modal-box .connection-modal-title { text-align: center; }
.suggest-intro { margin: 0 0 14px; line-height: 1.5; }

.suggest-textarea, .suggest-contact-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
}

.suggest-textarea { margin-bottom: 10px; }
.suggest-contact-input { margin-bottom: 16px; }

.suggest-textarea:focus, .suggest-contact-input:focus {
  outline: none;
  border-color: var(--accent);
}

.suggest-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.suggest-cancel-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.suggest-cancel-btn:hover { background: var(--surface-hover); }

.suggest-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.suggest-send-btn:hover { background: var(--accent-hover); }

.pull-refresh-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  transition: height 0.15s ease-out;
}

.pull-refresh-indicator.armed {
  color: var(--accent);
}

.pull-refresh-indicator.refreshing {
  transition: none;
}

@media (max-width: 640px) {
  header { padding: 20px 14px 16px; }
  h1 { font-size: 22px; }
  .tagline { font-size: 13px; margin-bottom: 14px; }

  #search-form { max-width: 100%; }

  .view-nav {
    flex-wrap: wrap;
    gap: 6px;
  }
  .nav-btn { padding: 7px 10px; font-size: 12px; }

  main { padding: 14px; }

  .results { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .station-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

  .show-header {
    flex-wrap: wrap;
  }
  .show-header img { width: 84px; height: 84px; }
  .show-header-actions {
    margin-left: 0;
    flex-direction: row;
    width: 100%;
    order: 3;
  }

  .episode-row {
    flex-direction: column;
    align-items: stretch;
  }
  .episode-actions {
    flex-wrap: wrap;
  }
  .episode-actions button, .episode-actions a {
    flex: 1 1 auto;
    text-align: center;
  }

  /* Shrink the label font/padding and re-fix at a narrower width for
     mobile, still wide enough for every label state (now including the
     "NN%" progress fill) so the row doesn't wobble. */
  .episode-actions .download-btn:not(.icon-btn),
  .episode-actions .queue-btn:not(.icon-btn) {
    font-size: 12px;
    padding: 8px 8px;
    width: 90px;
  }

  /* The ▲▼ reorder buttons are a keyboard/accessibility fallback for the
     drag handle -- on touch screens the drag handle alone is enough, and
     the arrows just eat space, so they're hidden below the desktop
     breakpoint. */
  .playlist-item .reorder-btns,
  .station-card .reorder-btns { display: none; }

  /* Playlist rows stack in a column here with align-items:center, which
     shrink-wrapped short titles and floated the drag handle toward the
     middle. Stretch the info block so the handle always sits flush left. */
  .playlist-item .episode-info { align-self: stretch; }

  .icon-actions.episode-actions { flex-wrap: nowrap; justify-content: center; }
  .icon-actions .icon-btn { flex: 0 0 auto; }

  .player-bar {
    padding: 8px 12px;
    gap: 8px;
    flex-direction: column;
    align-items: stretch;
  }
  /* Stack into two rows on mobile: play/progress on top, skip + volume
     underneath, instead of squeezing everything into one packed row. */
  .player-primary-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .player-secondary-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  .play-pause-btn { width: 36px; height: 36px; font-size: 14px; }
  .skip-btn { padding: 8px 10px; font-size: 12px; }
  .player-title { font-size: 12px; }
  .volume-btn { width: 32px; height: 32px; font-size: 14px; }
  .volume-popover { right: -6px; }
  .pi-cast-btn { width: 32px; height: 32px; font-size: 14px; }
  .pi-cast-icon { width: 16px; height: 16px; }

  body:has(.player-bar:not(.hidden)) > .mam-credit { margin-bottom: var(--player-h, 148px); }
}
