:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-hover: #1a2333;
  --border: #232f44;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --danger: #ef4444;
  --radius: 14px;
  --player-h: 84px;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--player-h) + 28px);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 15, 23, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}

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

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #042f2e;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-hover);
}

/* Main */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px;
}

.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 0.95rem;
  pointer-events: none;
  opacity: 0.7;
}

.search-box input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

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

.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.toggle-https {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.toggle-https input {
  accent-color: var(--accent);
}

/* Grid */
.stations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.station-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  position: relative;
}

.station-card:hover {
  background: var(--surface-hover);
  border-color: #334155;
  transform: translateY(-1px);
}

.station-card.playing {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), var(--surface));
}

.station-logo {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: #0f172a;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

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

.station-title {
  font-size: 0.94rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.station-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-badges {
  display: flex;
  gap: 5px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-weight: 600;
}

.badge-live {
  background: var(--accent-soft);
  color: var(--accent);
}

.fav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.fav-btn.active {
  color: #fbbf24;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Sticky Player */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(15, 23, 36, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.player-inner {
  max-width: 1200px;
  margin: 0 auto;
  min-height: var(--player-h);
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.player-station {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.player-thumb-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.player-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #0b0f17;
  border: 1px solid var(--border);
}

.equalizer {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 10px;
  display: none;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 10px 8px;
}

.equalizer.active {
  display: flex;
}

.equalizer span {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: eq 0.9s infinite ease-in-out;
}

.equalizer span:nth-child(2) { animation-delay: 0.2s; }
.equalizer span:nth-child(3) { animation-delay: 0.4s; }
.equalizer span:nth-child(4) { animation-delay: 0.15s; }

@keyframes eq {
  0%, 100% { height: 25%; }
  50% { height: 90%; }
}

.player-meta {
  min-width: 0;
}

.player-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-status.error {
  color: var(--danger);
}

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

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.15s;
}

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

.play-btn {
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: #042f2e;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:hover {
  background: var(--accent-hover);
  color: #fff;
}

.player-extras {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sleep-wrap select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.78rem;
}

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

.volume-wrap input {
  width: 80px;
  accent-color: var(--accent);
}

@media (max-width: 720px) {
  .player-inner {
    grid-template-columns: 1fr auto;
  }
  .player-extras {
    display: none;
  }
  .btn-ghost span {
    display: none;
  }
}
