:root {
  --bg-primary: #080c14;
  --bg-secondary: #0d1424;
  --bg-card: rgba(18, 25, 42, 0.75);
  --bg-card-hover: rgba(28, 38, 64, 0.85);
  --border-subtle: rgba(255, 215, 0, 0.12);
  --border-focus: rgba(255, 215, 0, 0.35);
  
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  
  --gold: #d4af37;
  --gold-glow: rgba(212, 175, 55, 0.35);
  --scarlet: #dc2626;
  --cyan: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.35);
  --emerald: #10b981;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Safe area insets for camera notches & home indicators */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(212, 175, 55, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.05) 0%, transparent 40%);
}

.app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height accounting for mobile browser bars */
  width: 100vw;
  overflow: hidden;
  padding-top: var(--sat);
  padding-left: var(--sal);
  padding-right: var(--sar);
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-glow); }

/* ─── Top Header Navigation (Camera Safe Area Padded) ───────────────────────── */
.header {
  height: 60px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(13, 20, 36, 0.9);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(16px, var(--sar)) 0 max(16px, var(--sal));
  flex-shrink: 0;
  z-index: 50;
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 0 12px var(--gold-glow);
}

.brand-info h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info .tagline {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 10px;
  color: #f87171;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.live-dot {
  width: 5px;
  height: 5px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.6; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.header-center {
  flex: 1;
  max-width: 420px;
  margin: 0 20px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  background: rgba(8, 12, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 7px 14px 7px 34px;
  color: var(--text-main);
  font-size: 12px;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 14px var(--gold-glow);
  background: rgba(13, 20, 36, 0.95);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-pill-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.action-pill-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold);
  border-color: var(--gold);
}

.pwa-install-btn {
  display: none;
  background: linear-gradient(135deg, var(--gold) 0%, #b89327 100%);
  color: #080c14;
  font-weight: 600;
  border: none;
}
.pwa-install-btn:hover { color: #000; box-shadow: 0 0 14px var(--gold-glow); }

/* ─── Main Workspace Layout ────────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: grid;
  grid-template-columns: 270px 1fr;
  overflow: hidden;
  position: relative;
}

/* Sidebar: Station Selector & Playlists */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 14px;
  gap: 20px;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.station-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.station-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.station-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  transform: translateX(2px);
}

.station-btn.active {
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0.03) 100%);
  border-color: var(--border-focus);
  color: #fff;
}

.station-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  height: 70%;
  width: 3px;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--gold);
}

.station-icon { font-size: 16px; width: 22px; text-align: center; }
.station-info { flex: 1; min-width: 0; }
.station-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-sub { font-size: 10.5px; color: var(--text-muted); }

.seasonal-pill {
  font-size: 9px;
  padding: 2px 5px;
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 5px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Playlist header */
.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  margin-bottom: 6px;
}
.add-pl-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 4px;
}
.add-pl-btn:hover { color: var(--gold); }

/* ─── Main Content Area ────────────────────────────────────────────────────── */
.content-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 80% 20%, rgba(13, 20, 36, 0.6) 0%, rgba(8, 12, 20, 0.95) 70%);
  padding: clamp(14px, 2vw, 24px) clamp(16px, 3vw, 32px);
  gap: 16px;
}

/* Station Hero Banner */
.station-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: clamp(14px, 2vw, 20px) clamp(16px, 2.5vw, 26px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.hero-meta h2 {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-meta p {
  color: var(--text-dim);
  font-size: clamp(11.5px, 1.2vw, 13px);
  max-width: 600px;
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 24px);
  z-index: 1;
}

.stat-item { text-align: right; }
.stat-val { font-size: clamp(15px, 1.8vw, 18px); font-weight: 700; font-family: var(--font-mono); color: var(--gold); }
.stat-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* Track list */
.tracklist-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: 12px;
  background: rgba(13, 20, 36, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.track-row {
  display: grid;
  grid-template-columns: 40px 48px 1fr 140px 70px 60px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
}

.track-row:hover { background: var(--bg-card-hover); }

.track-row.playing {
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.12) 0%, rgba(212, 175, 55, 0.02) 100%);
  border-left: 3px solid var(--gold);
}
.track-row.playing .track-title { color: var(--gold); }

.track-rank { font-family: var(--font-mono); color: var(--text-muted); font-size: 12px; }
.track-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: #111; }
.track-main { min-width: 0; padding-right: 12px; }
.track-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.track-artist { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-album { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.track-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.action-btn { background: transparent; border: none; color: var(--text-muted); font-size: 14px; cursor: pointer; padding: 4px; }
.action-btn:hover { color: var(--gold); }

/* ─── Bottom Persistent Audio Player Deck ──────────────────────────────────── */
.player-deck {
  height: clamp(68px, 9vh, 80px);
  background: rgba(10, 15, 26, 0.96);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  align-items: center;
  padding: 0 max(16px, var(--sar)) max(6px, var(--sab)) max(16px, var(--sal));
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.6);
}

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

.np-artwork {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  background: #111;
  flex-shrink: 0;
}

.np-info { min-width: 0; }
.np-title { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-station-badge { font-size: 9px; color: var(--gold); text-transform: uppercase; font-family: var(--font-mono); margin-top: 1px; }

/* Central Controls */
.deck-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 580px;
  margin: 0 auto;
  width: 100%;
}

.ctrl-buttons { display: flex; align-items: center; gap: 16px; }
.ctrl-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 17px; }
.ctrl-btn:hover { color: #fff; }

.play-main-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, #b89327 100%);
  color: #080c14;
  font-size: 18px;
  box-shadow: 0 0 16px var(--gold-glow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scrub-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.time-lbl { font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); min-width: 36px; }
.time-lbl.right { text-align: right; }
.scrub-bar { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; cursor: pointer; overflow: hidden; }
.scrub-progress { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold) 0%, #fff 100%); border-radius: 2px; }

/* Right Deck */
.deck-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.visualizer-canvas { width: 120px; height: 34px; background: rgba(0, 0, 0, 0.4); border-radius: 6px; border: 1px solid var(--border-subtle); }
.volume-ctrl { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.vol-slider { -webkit-appearance: none; width: 70px; height: 4px; background: rgba(255, 255, 255, 0.15); border-radius: 2px; outline: none; }
.vol-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); cursor: pointer; }

/* Mobile Bottom Navigation (Hidden on Desktop) */
.mobile-nav-bar {
  display: none;
  height: 52px;
  background: rgba(13, 20, 36, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding-bottom: var(--sab);
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
}

.mob-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  cursor: pointer;
}
.mob-tab-btn.active { color: var(--gold); }
.mob-tab-btn .tab-icon { font-size: 16px; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-focus);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

/* Camera Lens Studio Modal */
.camera-viewfinder-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-subtle);
  margin: 14px 0;
}
.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-shutter-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--gold);
  cursor: pointer;
  margin: 0 auto;
  display: block;
  box-shadow: 0 0 16px rgba(255,255,255,0.4);
}

/* Responsive Auto-Sizing for Device Screens */
@media (max-width: 860px) {
  .main-wrapper { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.mobile-open {
    display: flex;
    position: fixed;
    inset: 60px 0 120px 0;
    z-index: 150;
    background: var(--bg-secondary);
    width: 100%;
  }

  .player-deck {
    grid-template-columns: 1fr auto;
    height: 64px;
    bottom: 52px;
    position: fixed;
    left: 0;
    right: 0;
    padding-bottom: 0;
  }
  .deck-right { display: none; }
  .track-row { grid-template-columns: 32px 40px 1fr 40px; }
  .track-album, .track-time { display: none; }
  .mobile-nav-bar { display: grid; }
  .content-area { padding: 12px 14px 130px 14px; }
  .header-center { display: none; }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .main-wrapper { grid-template-columns: 220px 1fr; }
  .player-deck { grid-template-columns: 220px 1fr 220px; }
  .visualizer-canvas { width: 90px; }
}
