[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(15, 23, 42, 0.95);
  --panel-2: #111c32;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #7c3aed;
  --border: rgba(148, 163, 184, 0.2);
  --overlay: rgba(2, 8, 23, 0.7);
  --volume-bg: rgba(148, 163, 184, 0.25);
  --volume-fill: #38bdf8;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5f9;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-2: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --border: rgba(100, 116, 139, 0.25);
  --overlay: rgba(241, 245, 249, 0.8);
  --volume-bg: rgba(100, 116, 139, 0.2);
  --volume-fill: #2563eb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg), #0f172a 60%, #1d4ed8);
  color: var(--text);
  transition: background 0.3s;
}
[data-theme="light"] body {
  background: linear-gradient(135deg, var(--bg), #e2e8f0 60%, #93c5fd);
}

button, input {
  font: inherit;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

.hero-card,
.toolbar-card,
.card-section,
.player-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 45px rgba(2, 8, 23, 0.25);
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

h1, h2, h3, p {
  margin: 0;
}
h1 { display: flex; align-items: center; gap: 8px; }

.hero-copy {
  margin-top: 8px;
  color: var(--muted);
  max-width: 560px;
  line-height: 1.6;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(320px, 100%);
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.toolbar-card {
  margin-top: 16px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill,
.secondary-btn,
.primary-btn,
.icon-btn {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}
.pill:active,
.secondary-btn:active,
.primary-btn:active,
.icon-btn:active {
  transform: scale(0.94);
}

#cast-button {
  --connected-color: var(--accent);
  --disconnected-color: var(--muted);
  width: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.pill {
  padding: 8px 12px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text);
}

.pill.active, .secondary-btn, .primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.card-section {
  margin-top: 16px;
  padding: 20px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-size: 0.86rem;
}

.collapse-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms ease, color 200ms ease, background 200ms ease;
  flex-shrink: 0;
  margin-left: auto;
}

.collapse-toggle:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.15);
}

.card-section.collapsed .collapse-toggle {
  transform: rotate(-90deg);
}

.card-section.collapsed .featured-grid,
.card-section.collapsed .station-grid {
  display: none;
}

.featured-grid,
.station-grid {
  display: grid;
  gap: 14px;
}

.featured-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

.station-card {
  padding: 16px;
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.station-card__top,
.station-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.station-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--panel-2);
}

.station-thumb-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  user-select: none;
}

.station-card__title {
  flex: 1;
  min-width: 0;
}

.station-card__title h3 {
  word-wrap: break-word;
  line-height: 1.3;
}

.station-card p,
.station-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.station-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.station-badges span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.16);
  color: #c4b5fd;
  font-size: 0.78rem;
}

.secondary-btn,
.primary-btn {
  padding: 8px 12px;
}

.primary-btn:disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-btn {
  width: 38px;
  height: 38px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text);
}

.icon-btn.active {
  background: rgba(244, 114, 182, 0.22);
  color: #f9a8d4;
}

.player-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  width: calc(100% - 32px);
  max-width: calc(1120px - 32px);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  min-width: 0;
}

.player-info span {
  color: var(--muted);
  font-size: 0.92rem;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume-wrap input[type="range"] {
  width: 0;
  overflow: hidden;
  transition: width 200ms ease;
  cursor: pointer;
}

.volume-wrap:hover input[type="range"],
.volume-wrap:focus-within input[type="range"] {
  width: 80px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--volume-bg);
  outline: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--volume-fill);
  cursor: pointer;
  border: 2px solid var(--panel);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--volume-fill);
  cursor: pointer;
  border: 2px solid var(--panel);
}

.empty-state {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

/* now-playing overlay */

.now-playing-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.now-playing-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.now-playing-sheet {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: slideUp 250ms ease;
  max-height: 85vh;
  overflow-y: auto;
}

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

.now-playing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.close-btn {
  font-size: 1.2rem;
  line-height: 1;
}

.now-playing-art {
  width: 160px;
  height: 160px;
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.now-playing-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.now-playing-placeholder {
  font-size: 3rem;
  line-height: 1;
  opacity: 0.4;
  user-select: none;
}

.now-playing-title {
  font-size: 1.2rem;
  text-align: center;
}

.now-playing-meta {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.now-playing-track {
  color: var(--accent);
  font-size: 0.85rem;
  text-align: center;
  padding: 4px 12px;
  background: rgba(56, 189, 248, 0.1);
  border-radius: 999px;
  max-width: 100%;
  word-wrap: break-word;
}

.now-playing-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.now-playing-volume {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 260px;
}

.now-playing-volume input[type="range"] {
  flex: 1;
}

.now-playing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.now-playing-actions .secondary-btn {
  font-size: 0.85rem;
}

.sleep-timer-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.sleep-timer-picker .secondary-btn {
  font-size: 0.85rem;
}

.sleep-timer-status {
  color: var(--accent);
  font-size: 0.85rem;
  text-align: center;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px 10px 110px;
  }

  .hero-card {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }

  .hero-copy {
    font-size: 0.9rem;
  }

  .search-box {
    min-width: 0;
    padding: 10px 12px;
  }

  .toolbar-card {
    padding: 12px 14px;
  }

  .pill {
    font-size: 0.82rem;
    padding: 6px 10px;
  }

  .card-section {
    padding: 14px;
  }

  .station-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
  }

  .featured-grid {
    gap: 10px;
  }

  .station-card {
    padding: 12px;
    gap: 8px;
  }

  .station-card__title h3 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .player-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    bottom: 10px;
    gap: 6px;
  }

  .player-info {
    width: 100%;
    order: -1;
    min-width: 0;
  }

  .player-info strong {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-info span {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-controls {
    gap: 6px;
  }

  .volume-wrap input[type="range"] {
    width: 0;
  }

  .volume-wrap:hover input[type="range"],
  .volume-wrap:focus-within input[type="range"] {
    width: 60px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }

  .primary-btn,
  .secondary-btn {
    font-size: 0.85rem;
    padding: 6px 10px;
  }

  .now-playing-sheet {
    border-radius: 16px 16px 0 0;
    padding: 14px;
    gap: 10px;
  }

  .now-playing-art {
    width: 100px;
    height: 100px;
  }

  .now-playing-title {
    font-size: 1rem;
  }

  .now-playing-meta {
    font-size: 0.82rem;
  }

  .now-playing-controls {
    gap: 10px;
  }

  .now-playing-volume {
    max-width: 100%;
  }

  .now-playing-actions {
    gap: 6px;
  }

  .now-playing-actions .secondary-btn {
    font-size: 0.78rem;
    padding: 6px 8px;
  }

  .sleep-timer-picker {
    gap: 6px;
  }

  .sleep-timer-picker .secondary-btn {
    font-size: 0.78rem;
    padding: 6px 8px;
  }
}

.update-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  animation: slideUp 250ms ease;
}

.update-banner .secondary-btn {
  font-size: 0.82rem;
  padding: 6px 10px;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .player-bar {
    padding: 8px 10px;
    gap: 4px;
  }

  .player-controls {
    gap: 4px;
  }

  .icon-btn {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  .volume-wrap:hover input[type="range"],
  .volume-wrap:focus-within input[type="range"] {
    width: 44px;
  }

  .station-grid {
    grid-template-columns: 1fr;
  }
}
