*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-card-hover: #222233;
  --bg-player: #14141e;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.35);
  --text-primary: #f0f0f5;
  --text-secondary: #9898a8;
  --text-muted: #5c5c6e;
  --border: rgba(255, 255, 255, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --player-height: 96px;
  --header-height: 72px;
  --sidebar-width: 220px;
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(124, 58, 237, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    var(--bg-primary);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.75rem;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* Main layout */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  padding: 1rem 0.75rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.categories {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.cat-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.cat-btn.active {
  background: var(--accent);
  color: white;
}

.cat-btn .cat-icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}

/* Content */
.content {
  flex: 1;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  padding-bottom: calc(var(--player-height) + 1.5rem);
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.station-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.station-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.1);
}

.station-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.station-card.playing .station-art {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(124, 58, 237, 0); }
}

.station-art {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.station-details {
  flex: 1;
  min-width: 0;
}

.station-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-genre {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-artists {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.content-lead {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.station-decades {
  font-size: 0.72rem;
  color: var(--accent-light);
  margin-top: 0.1rem;
}

.station-ads {
  display: inline-block;
  font-size: 0.7rem;
  margin-top: 0.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-weight: 500;
}

.station-ads.none {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
}

.station-ads.minimal {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.12);
}

.station-country {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
  font-size: 1rem;
}

.hidden {
  display: none !important;
}

/* Player */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-height);
  background: var(--bg-player);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  backdrop-filter: blur(20px);
  z-index: 100;
}

.player-station {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.player-art {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.player-art.has-color {
  background: none;
}

.visualizer {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 28px;
}

.visualizer span {
  width: 4px;
  background: white;
  border-radius: 2px;
  height: 8px;
  transition: height 0.1s ease;
}

.player.playing .visualizer span {
  animation: viz 0.8s ease-in-out infinite alternate;
}

.player.playing .visualizer span:nth-child(1) { animation-delay: 0s; }
.player.playing .visualizer span:nth-child(2) { animation-delay: 0.15s; }
.player.playing .visualizer span:nth-child(3) { animation-delay: 0.3s; }
.player.playing .visualizer span:nth-child(4) { animation-delay: 0.15s; }
.player.playing .visualizer span:nth-child(5) { animation-delay: 0s; }

@keyframes viz {
  0% { height: 6px; }
  100% { height: 28px; }
}

.player-info {
  min-width: 0;
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-now {
  margin-top: 0.15rem;
}

.player-now-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-light);
  margin-bottom: 0.1rem;
}

.player-now-text {
  display: block;
  font-size: 0.82rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-art.has-art .visualizer {
  opacity: 0;
}

.player-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon, .btn-play {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--transition), opacity var(--transition), background var(--transition);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
}

.btn-icon:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
}

.btn-play {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-play:hover:not(:disabled) {
  transform: scale(1.06);
  background: var(--accent-light);
}

.btn-play:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-play svg {
  width: 26px;
  height: 26px;
}

.btn-fav.active svg {
  fill: #ef4444;
  stroke: #ef4444;
}

.player-extra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.volume {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.volume input[type="range"] {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-card);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.volume input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* Status toast */
.status {
  position: fixed;
  bottom: calc(var(--player-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  z-index: 101;
  animation: fadeIn 0.3s ease;
}

.status.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1s ease infinite;
}

.status.error .status-dot {
  background: #ef4444;
  animation: none;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
  }

  .categories {
    flex-direction: row;
    gap: 0.4rem;
    min-width: max-content;
  }

  .cat-btn {
    white-space: nowrap;
    padding: 0.55rem 0.85rem;
    touch-action: manipulation;
  }

  .header {
    flex-direction: column;
    height: auto;
    padding: 1rem;
    gap: 0.75rem;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
  }

  .logo h1 {
    font-size: 1.1rem;
  }

  .content {
    padding: 1rem;
    padding-bottom: calc(140px + 1rem);
  }

  .station-grid {
    grid-template-columns: 1fr;
  }

  .player {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    padding: 0.75rem 1rem 1rem;
    gap: 0.75rem;
  }

  .player-controls {
    justify-content: center;
    order: -1;
  }

  .player-extra {
    justify-content: center;
  }

  .player-station {
    justify-content: center;
    text-align: center;
  }
}
