/* ============================================================
   Riptide Abyssal — Deep Immersive Music Player
   ============================================================ */

/* ── Fonts ─────────────────────────────────────────────────── */
/* Sora (display), Plus Jakarta Sans (body), JetBrains Mono (data) */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Base palette */
  --void: #06060c;
  --bg: #0a0a12;
  --surface: #111120;
  --surface-elevated: #181830;
  --glass: rgba(14, 14, 30, 0.65);
  --glass-thick: rgba(10, 10, 20, 0.85);

  /* Accent colors */
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.12);
  --cyan-glow: rgba(0, 229, 255, 0.35);
  --violet: #a855f7;
  --violet-dim: rgba(168, 85, 247, 0.12);
  --violet-glow: rgba(168, 85, 247, 0.35);
  --rose: #f43f5e;
  --rose-dim: rgba(244, 63, 94, 0.12);
  --emerald: #10b981;

  /* Text */
  --text: #e8e8f0;
  --text-secondary: #9898b0;
  --text-muted: #5a5a78;

  /* Borders */
  --border: rgba(100, 100, 150, 0.12);
  --border-hover: rgba(0, 229, 255, 0.25);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow-cyan: 0 0 24px rgba(0, 229, 255, 0.15);
  --shadow-glow-violet: 0 0 24px rgba(168, 85, 247, 0.15);

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Timing */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition: 0.2s var(--ease);
  --transition-slow: 0.35s var(--ease);

  /* Layout */
  --topbar-height: 52px;
  --player-height: 76px;
  --content-max: 1280px;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--void);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Atmospheric gradient mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% 30%, rgba(0, 229, 255, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 85% 70%, rgba(168, 85, 247, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(244, 63, 94, 0.015) 0%, transparent 60%);
  z-index: 0;
  pointer-events: none;
}

/* Grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  z-index: 9999;
  pointer-events: none;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(100, 100, 150, 0.25);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(100, 100, 150, 0.4); }
html {
  scrollbar-color: rgba(100, 100, 150, 0.25) transparent;
  scrollbar-width: thin;
}

/* ── Links ─────────────────────────────────────────────────── */
a {
  color: var(--cyan);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: #66f0ff; }

/* ── Accessibility ─────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1em;
  background: var(--cyan);
  color: var(--void);
  padding: 0.5em 1em;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 700;
  font-family: 'Sora', sans-serif;
  z-index: 99999;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Sora', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

/* ── Top Navigation Bar ────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  z-index: 1000;
  background: var(--glass-thick);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.brand {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.menu-toggle:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 100px;
  font-family: 'Sora', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.nav-tab:hover {
  color: var(--text);
  background: rgba(0, 229, 255, 0.06);
  border-color: rgba(0, 229, 255, 0.12);
  text-decoration: none;
}

.nav-tab.active {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: rgba(0, 229, 255, 0.2);
}

.nav-tab svg { flex-shrink: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-hover);
}
.theme-toggle .icon-moon { display: none; }
html.light .theme-toggle .icon-sun { display: none; }
html.light .theme-toggle .icon-moon { display: block; }

/* ── Main Content Area ─────────────────────────────────────── */
#content-area {
  position: relative;
  z-index: 1;
  margin-top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height) - var(--player-height));
  overflow-y: auto;
  padding: 1.5rem 1.25rem 2rem;
}

.htmx-settling #content-area { opacity: 0; }
#content-area { transition: opacity 0.15s ease-in; }

.content-frame {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ── View Headers ──────────────────────────────────────────── */
.view-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.view-header h1 {
  font-size: 1.75rem;
  color: var(--text);
}

.view-header .meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── Artist Grid ───────────────────────────────────────────── */
.artist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.artist-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-slow);
  animation: fadeInUp 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 35ms);
  overflow: hidden;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}

.artist-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--cyan-dim), var(--violet-dim));
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.artist-card:hover {
  border-color: rgba(0, 229, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow-cyan);
}
.artist-card:hover::before { opacity: 1; }

.artist-monogram {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(0, 229, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--cyan);
  flex-shrink: 0;
}

.artist-info {
  position: relative;
  min-width: 0;
}

.artist-name {
  display: block;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artist-stats {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  letter-spacing: 0.02em;
}

/* ── Album Grid ────────────────────────────────────────────── */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

.album-card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-slow);
  animation: fadeInUp 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 35ms);
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  padding: 0;
}

.album-card:hover {
  border-color: rgba(168, 85, 247, 0.25);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow-violet);
}

.album-art {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--surface), var(--surface-elevated));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.album-art::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.08), rgba(168, 85, 247, 0.08));
  opacity: 0;
  transition: opacity var(--transition);
}
.album-card:hover .album-art::after { opacity: 1; }

.album-initial {
  font-family: 'Sora', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.5;
  transition: all var(--transition);
}
.album-card:hover .album-initial {
  color: var(--violet);
  opacity: 0.8;
  transform: scale(1.05);
}

.album-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 12, 0.5);
  opacity: 0;
  transition: opacity var(--transition);
}
.album-card:hover .album-play-overlay { opacity: 1; }

.play-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--void);
  font-size: 1.1rem;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.4);
  transform: scale(0.8);
  transition: transform var(--transition) var(--ease-bounce);
}
.album-card:hover .play-ring { transform: scale(1); }

.album-info {
  padding: 0.85rem 1rem;
}

.album-title {
  display: block;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Track List ────────────────────────────────────────────── */
.tracklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tracklist-header {
  display: grid;
  grid-template-columns: 3rem 1fr 10rem 5rem;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.track-row {
  display: grid;
  grid-template-columns: 3rem 1fr 10rem 5rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  transition: all var(--transition);
  animation: fadeInUp 0.35s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 20ms);
  cursor: default;
}

.track-row:hover {
  background: rgba(0, 229, 255, 0.04);
}

.track-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--cyan);
  border-radius: 1px;
  opacity: 0;
  transform: scaleY(0);
  transition: all var(--transition);
}
.track-row:hover::before {
  opacity: 1;
  transform: scaleY(1);
}

.track-row.is-current {
  background: var(--cyan-dim);
}
.track-row.is-current::before {
  opacity: 1;
  transform: scaleY(1);
}

.track-index {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 0.5rem;
}
.track-row:hover .track-index { color: var(--text-secondary); }

.track-info-cell {
  min-width: 0;
}

.track-title {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.track-album-cell {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}

.track-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--transition);
}
.track-row:hover .track-actions { opacity: 1; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-family: 'Sora', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-hover);
  background: rgba(0, 229, 255, 0.06);
  color: var(--cyan);
}

.btn-primary {
  background: var(--cyan);
  color: var(--void);
  border-color: var(--cyan);
}
.btn-primary:hover {
  background: #33eaff;
  box-shadow: var(--shadow-glow-cyan);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  color: var(--cyan);
  border-color: rgba(0, 229, 255, 0.3);
  background: var(--cyan-dim);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.7rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: 'Sora', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
}
.btn-ghost:hover { color: var(--text); }

/* ── Player Bar ────────────────────────────────────────────── */
#player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--player-height);
  z-index: 10001;
  background: var(--glass-thick);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-top: 1px solid var(--border);
}

/* Progress bar (top edge of player) */
.player-progress-wrap {
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 5px;
  cursor: pointer;
  z-index: 2;
}

.player-progress-track {
  width: 100%;
  height: 100%;
  background: rgba(100, 100, 150, 0.15);
  overflow: hidden;
}

.seek-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-radius: 0 2px 2px 0;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

.player-progress-wrap:hover .player-progress-track {
  height: 7px;
  margin-top: -1px;
}
.player-progress-wrap:hover .seek-bar-fill {
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.player-inner {
  height: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
}

/* Track info in player */
#player-bar .track-info {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

#player-bar .track-title {
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-bar .track-artist {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-bar .track-title:empty::before,
#player-bar .track-artist:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  font-style: italic;
}

/* Player controls (center) */
.player-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.ctrl-btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.ctrl-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.ctrl-btn.ctrl-play {
  width: 2.8rem;
  height: 2.8rem;
  background: var(--cyan);
  color: var(--void);
  margin: 0 0.25rem;
}

.ctrl-btn.ctrl-play:hover {
  background: #33eaff;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
  transform: scale(1.05);
}

.ctrl-btn.ctrl-small {
  width: 2rem;
  height: 2rem;
}

.ctrl-btn.active.toggle-wave {
  color: var(--cyan);
  background: var(--cyan-dim);
}
.ctrl-btn.active.toggle-viz {
  color: var(--violet);
  background: var(--violet-dim);
}

/* Player right section (volume, time) */
.player-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.timestamp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 3rem;
  text-align: center;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 3px;
  background: rgba(100, 100, 150, 0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.volume-slider::-webkit-slider-thumb:hover {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}
.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-secondary);
  border: none;
  cursor: pointer;
}

/* ── Waveform Panel ────────────────────────────────────────── */
#waveform-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--player-height);
  z-index: 9997;
  background: var(--glass-thick);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  visibility: hidden;
  pointer-events: none;
  transform: translateY(100%);
  transition: transform 0.25s var(--ease), visibility 0s 0.25s;
}
#waveform-container.active {
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: transform 0.25s var(--ease), visibility 0s 0s;
}

.waveform-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.waveform-header button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  transition: color var(--transition);
}
.waveform-header button:hover { color: var(--text); }

#waveform {
  padding: 0 1.25rem 0.75rem;
}

/* ── Visualizer Overlay ────────────────────────────────────── */
#visualizer-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #0a0a14 0%, #000 100%);
  z-index: 9998;
  flex-direction: column;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease, visibility 0s 0.35s;
}
#visualizer-overlay.active {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.35s ease, visibility 0s 0s;
}

#analyser-canvas {
  width: 100%;
  height: 100%;
}

.viz-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 2;
}
.viz-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.viz-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}

/* ── Queue Panel ───────────────────────────────────────────── */
#queue-panel {
  position: fixed;
  right: 0;
  top: var(--topbar-height);
  bottom: var(--player-height);
  width: min(380px, 85vw);
  z-index: 9998;
  background: var(--glass-thick);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  display: flex;
  flex-direction: column;
  visibility: hidden;
  pointer-events: none;
}
#queue-panel.visible {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.queue-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.queue-header h2 {
  font-size: 0.95rem;
  margin: 0;
  flex: 1;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.queue-item:hover { background: rgba(255, 255, 255, 0.03); }
.queue-item.is-current {
  color: var(--cyan);
  background: var(--cyan-dim);
}
.queue-item.is-current::before {
  content: '';
  width: 3px;
  height: 1.2rem;
  background: var(--cyan);
  border-radius: 2px;
  flex-shrink: 0;
}

.queue-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Search ────────────────────────────────────────────────── */
.search-input-wrap {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1.2rem 0.85rem 2.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: all var(--transition);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: rgba(0, 229, 255, 0.35);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.08), var(--shadow-glow-cyan);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Empty States ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state p {
  font-size: 1rem;
  margin-bottom: 1.25rem;
}
.empty-state .btn {
  margin-top: 0.5rem;
}

/* ── Flash Messages ────────────────────────────────────────── */
.flash {
  padding: 0.85rem 1.15rem;
  background: var(--cyan-dim);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  color: var(--text);
  font-size: 0.9em;
}

/* ── Error Toast ───────────────────────────────────────────── */
.error-toast {
  position: fixed;
  bottom: calc(var(--player-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(30, 10, 15, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-left: 3px solid var(--rose);
  color: #ff8a8a;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius);
  font-size: 0.85em;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.error-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── Placeholder text ──────────────────────────────────────── */
.placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem;
  text-align: center;
}

/* ── Sidebar overlay (mobile) ──────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 229, 255, 0.15); }
  50% { box-shadow: 0 0 16px rgba(0, 229, 255, 0.3); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ── Downloads ─────────────────────────────────────────────── */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.job-card {
  padding: 1rem;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.job-card-title {
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}

.job-card-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.job-progress {
  width: 100%;
  height: 3px;
  background: rgba(100, 100, 150, 0.15);
  border-radius: 2px;
  margin-top: 0.6rem;
  overflow: hidden;
}

.job-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  border-radius: 2px;
  transition: width 0.3s var(--ease);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 767px) {
  body { overflow: auto; }

  .menu-toggle { display: inline-flex; }

  .topbar-nav {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    background: var(--glass-thick);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.25rem;
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    z-index: 999;
  }
  .topbar-nav.mobile-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .topbar-nav .nav-tab {
    width: 100%;
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
  }

  #content-area {
    height: auto;
    min-height: calc(100vh - var(--topbar-height) - var(--player-height));
    padding: 1rem;
  }

  /* Stack player vertically on very small screens */
  .player-inner {
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    padding-top: 0.6rem;
  }
  .player-controls { order: -1; width: 100%; justify-content: center; }
  #player-bar .track-info { flex-basis: 100%; }
  .player-right {
    margin-left: auto;
  }
  .volume-slider { width: 50px; }

  /* Cards */
  .artist-grid {
    grid-template-columns: 1fr;
  }
  .album-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  /* Track list: hide album column */
  .tracklist-header,
  .track-row {
    grid-template-columns: 2.5rem 1fr 4rem;
  }
  .track-album-cell { display: none; }
  .track-actions { opacity: 1; }

  /* Queue */
  #queue-panel {
    width: 100vw;
  }

  /* View header */
  .view-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .view-header h1 {
    font-size: 1.35rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .artist-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  .album-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (min-width: 1024px) {
  .artist-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
  .album-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* ── Light Theme ───────────────────────────────────────────── */
html.light {
  --void: #f4f2ef;
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-elevated: #f0eeeb;
  --glass: rgba(255, 255, 255, 0.7);
  --glass-thick: rgba(250, 249, 247, 0.88);
  --text: #1a1a2e;
  --text-secondary: #64648a;
  --text-muted: #9898b0;
  --border: rgba(100, 100, 150, 0.15);
  --border-hover: rgba(74, 108, 247, 0.3);
  --cyan: #0099cc;
  --cyan-dim: rgba(0, 153, 204, 0.08);
  --cyan-glow: rgba(0, 153, 204, 0.2);
  --violet: #7c3aed;
  --violet-dim: rgba(124, 58, 237, 0.08);
  --violet-glow: rgba(124, 58, 237, 0.2);
  --rose: #e11d48;
  --rose-dim: rgba(225, 29, 72, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.1);
  --shadow-glow-cyan: 0 0 20px rgba(0, 153, 204, 0.1);
  --shadow-glow-violet: 0 0 20px rgba(124, 58, 237, 0.1);
}

html.light body::before {
  background:
    radial-gradient(ellipse 80% 50% at 15% 30%, rgba(0, 153, 204, 0.03) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 85% 70%, rgba(124, 58, 237, 0.03) 0%, transparent 70%);
}

html.light body::after { opacity: 0.015; }

html.light .error-toast {
  background: rgba(255, 240, 240, 0.95);
  color: #c92a2a;
}

html.light ::-webkit-scrollbar-thumb { background: rgba(100, 100, 150, 0.2); }
