/* ─────────────────────────────────────────────────────────────────────────────
   WAVE — style.css
   Mobile-first. Three breakpoints: mobile < 600px, tablet 600–1024px, desktop 1024px+
   Design: deep black, chartreuse accent, Bebas Neue display, DM Sans body
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Ensure [hidden] always wins even against display:grid / display:flex rules */
[hidden] { display: none !important; }
button { cursor: pointer; font-family: inherit; }
img { display: block; }
input { font-family: inherit; }

/* ── Tokens ──────────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0a0a0c;
  --bg-2:        #101014;
  --bg-3:        #17171d;
  --bg-4:        #1f1f27;
  --border:      rgba(255,255,255,0.06);
  --border-2:    rgba(255,255,255,0.10);
  --text:        #efefef;
  --text-2:      #a0a0b0;
  --text-3:      #5a5a6e;
  --accent:      #d8f930;      /* sharp lime-yellow */
  --accent-2:    rgba(216,249,48,0.12);
  --accent-glow: rgba(216,249,48,0.25);
  --danger:      #ff4d6d;
  --radius:      14px;
  --radius-sm:   9px;
  --radius-xs:   6px;
  --player-h:    72px;        /* mobile player height */
  --mobile-nav:  58px;        /* bottom nav height */
  --sidebar-w:   200px;
  --transition:  0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ── Base ────────────────────────────────────────────────────────────────────── */
html {
  height: 100%;
  /* safe area padding for notched phones */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

body {
  height: 100%;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Ambient blobs ───────────────────────────────────────────────────────────── */
.ambient {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: 0.10;
  animation: drift 22s ease-in-out infinite;
  will-change: transform;
}
.blob-1 { width:700px; height:700px; background:radial-gradient(circle,#6c3fff,transparent 65%); top:-250px; left:-200px; animation-duration:26s; }
.blob-2 { width:450px; height:450px; background:radial-gradient(circle,#d8f930,transparent 65%); bottom:-100px; right:5%; opacity:.06; animation-duration:18s; animation-delay:-7s; }
.blob-3 { width:350px; height:350px; background:radial-gradient(circle,#ff4d6d,transparent 65%); top:45%; left:35%; opacity:.05; animation-duration:22s; animation-delay:-12s; }
@keyframes drift {
  0%,100% { transform:translate(0,0) scale(1); }
  33%      { transform:translate(40px,-30px) scale(1.04); }
  66%      { transform:translate(-25px,20px) scale(0.97); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT  (default — < 600px)
   Stack: [main] grows, [player] fixed bottom, [mobile-nav] fixed very bottom
   ═══════════════════════════════════════════════════════════════════════════════ */

body {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.sidebar { display: none; } /* hidden on mobile */

.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* leave room for fixed player + bottom nav */
  padding-bottom: calc(var(--player-h) + var(--mobile-nav) + 12px);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.main::-webkit-scrollbar { width: 4px; }
.main::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 2px; }

/* ── Mobile bottom nav ────────────────────────────────────────────────────────── */
.mobile-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-nav);
  background: rgba(16,16,20,0.96);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 0;
  background: none; border: none;
  color: var(--text-3);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--transition);
}
.mobile-nav-btn svg { width: 22px; height: 22px; }
.mobile-nav-btn.active { color: var(--accent); }
.mobile-nav-btn span { display: block; }

/* ── Player bar (mobile) ───────────────────────────────────────────────────────── */
.player {
  position: fixed;
  bottom: var(--mobile-nav);
  left: 0; right: 0;
  height: var(--player-h);
  background: rgba(16,16,20,0.95);
  backdrop-filter: blur(32px) saturate(1.8);
  -webkit-backdrop-filter: blur(32px) saturate(1.8);
  border-top: 1px solid var(--border);
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.player-progress-wrap {
  height: 3px;
  background: var(--bg-3);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.progress-bar {
  position: absolute; inset: 0;
  /* make it easier to tap on mobile */
  padding: 8px 0; margin: -8px 0;
}
.progress-fill {
  height: 3px;
  background: var(--accent);
  width: 0%;
  border-radius: 0 2px 2px 0;
  pointer-events: none;
  transition: width 0.25s linear;
}
.progress-thumb {
  position: absolute;
  top: 50%; left: 0%;
  transform: translate(-50%, -50%);
  width: 11px; height: 11px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  margin-top: 1.5px; /* align to 3px bar */
}
.player-progress-wrap:hover .progress-fill,
.player:hover .progress-fill { height: 4px; }
.player-progress-wrap:hover .progress-thumb,
.player:hover .progress-thumb { opacity: 1; }

.player-inner {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  min-width: 0;
}

/* Track info */
.player-info {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.player-art-wrap {
  position: relative;
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--bg-3);
}
.player-art {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity 0.3s;
}
.player-art[src=""] { opacity: 0; }
/* hide sidebar art before a track is loaded — prevents broken-image icon */
#sidebar-art[src=""], #sidebar-art:not([src]) { visibility: hidden; }
.player-art-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.player-art-placeholder svg { width: 20px; height: 20px; }

.player-meta { flex: 1; min-width: 0; }
.player-title {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.player-artist {
  display: block;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Controls */
.player-controls {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.ctrl-btn {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  background: none; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition), background var(--transition), transform 0.12s;
  flex-shrink: 0;
}
.ctrl-btn svg { width: 20px; height: 20px; }
.ctrl-btn:hover { color: var(--text); background: var(--bg-3); }
.ctrl-btn:active { transform: scale(0.92); }

.play-btn {
  width: 44px; height: 44px;
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 20px var(--accent-glow);
}
.play-btn svg { color: #000; fill: #000; }
.play-btn:hover { background: #c8e820; transform: scale(1.06); box-shadow: 0 0 28px var(--accent-glow); }
.play-btn:active { transform: scale(0.96); }

/* icon switching via player data-state */
.icon-play, .icon-pause, .icon-spin { display: none; }
.player[data-state="idle"]    .icon-play  { display: block; }
.player[data-state="playing"] .icon-pause { display: block; }
.player[data-state="paused"]  .icon-play  { display: block; }
.player[data-state="loading"] .icon-spin  { display: block; }
.icon-spin { animation: spin 0.75s linear infinite; stroke: #000 !important; fill: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* time + volume — hidden on mobile */
.player-right { display: none; }
.player-times { display: none; }

/* ── Views ────────────────────────────────────────────────────────────────────── */
.view { display: none; padding: 20px 16px; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.view-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 0.06em;
  color: var(--text);
}
.queue-count {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ── Search bar ────────────────────────────────────────────────────────────────── */
.search-header { margin-bottom: 24px; }
.search-wrap { position: relative; }

.search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--text-3); pointer-events: none; z-index: 1;
}
.search-clear {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  border-radius: 50%; border: none;
  background: var(--bg-3); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  z-index: 1;
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear:hover { background: var(--bg-4); color: var(--text); }

.search-input {
  width: 100%;
  padding: 13px 44px 13px 44px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus {
  border-color: rgba(216,249,48,0.35);
  box-shadow: 0 0 0 3px var(--accent-2);
}

/* Suggestions dropdown */
.suggestions-box {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.suggestion-item {
  padding: 11px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  display: flex; align-items: center; gap: 10px;
  transition: background 0.1s, color 0.1s;
  border-bottom: 1px solid var(--border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.5; }
.suggestion-item:hover { background: var(--bg-4); color: var(--text); }

/* ── State messages ──────────────────────────────────────────────────────────── */
.state-message {
  text-align: center;
  padding: 60px 20px 40px;
}
.state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
  line-height: 1;
}
.state-headline {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 8px;
}
.state-sub { font-size: 13px; color: var(--text-3); }

.state-loading, .state-error {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 0;
  font-size: 14px; color: var(--text-2);
}
.state-error { color: var(--danger); }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--bg-4);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Results Grid ─────────────────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* ── Track Card ──────────────────────────────────────────────────────────────── */
.track-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  animation: cardIn 0.3s ease both;
  transition: border-color var(--transition), transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
@keyframes cardIn {
  from { opacity:0; transform:translateY(12px); }
  to   { opacity:1; transform:translateY(0); }
}
.track-card:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
.track-card.playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 24px var(--accent-glow);
}

/* stagger animation */
.track-card:nth-child(1)  { animation-delay:.00s }
.track-card:nth-child(2)  { animation-delay:.03s }
.track-card:nth-child(3)  { animation-delay:.06s }
.track-card:nth-child(4)  { animation-delay:.09s }
.track-card:nth-child(5)  { animation-delay:.12s }
.track-card:nth-child(6)  { animation-delay:.15s }
.track-card:nth-child(7)  { animation-delay:.18s }
.track-card:nth-child(8)  { animation-delay:.21s }
.track-card:nth-child(9)  { animation-delay:.24s }
.track-card:nth-child(10) { animation-delay:.27s }

.card-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-3);
  overflow: hidden;
}
.card-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.35s;
}
.track-card:hover .card-thumb { transform: scale(1.05); }

.card-thumb-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-3);
}

/* Play overlay */
.card-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.track-card:hover .card-overlay,
.track-card.playing .card-overlay { opacity: 1; }
.card-play-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: transform 0.15s;
}
.card-play-btn:hover { transform: scale(1.1); }
.card-play-btn svg { width: 20px; height: 20px; fill: #000; margin-left: 2px; }

/* Playing indicator */
.card-playing-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  color: #000; text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s;
}
.track-card.playing .card-playing-badge { opacity: 1; }

/* Queue button */
.card-queue-btn {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s, background 0.15s;
  z-index: 2;
}
.track-card:hover .card-queue-btn { opacity: 1; }
.card-queue-btn svg { width: 13px; height: 13px; stroke: #fff; }
.card-queue-btn:hover { background: var(--accent); border-color: var(--accent); }
.card-queue-btn:hover svg { stroke: #000; }

.card-info { padding: 10px 12px 12px; }
.card-title {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
  line-height: 1.3;
}
.card-artist {
  font-size: 11px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-duration {
  font-family: 'DM Mono', monospace;
  font-size: 10px; color: var(--text-3);
  margin-top: 5px;
}

/* ── Queue list ───────────────────────────────────────────────────────────────── */
.empty-queue {
  text-align: center; padding: 60px 20px;
  color: var(--text-3);
}
.empty-queue svg { width: 36px; height: 36px; margin: 0 auto 16px; opacity: 0.4; }
.empty-queue p { font-size: 15px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.empty-queue span { font-size: 13px; }

.queue-list { display: flex; flex-direction: column; gap: 2px; }

.queue-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.queue-item:hover { background: var(--bg-2); }
.queue-item.playing {
  background: var(--accent-2);
  border-color: rgba(216,249,48,0.15);
}

.queue-idx {
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--text-3);
  width: 22px; text-align: right; flex-shrink: 0;
}
.queue-item.playing .queue-idx { color: var(--accent); }

.queue-thumb {
  width: 42px; height: 42px;
  border-radius: var(--radius-xs);
  object-fit: cover; flex-shrink: 0;
  background: var(--bg-3);
}

.queue-meta { flex: 1; min-width: 0; }
.queue-track-name {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-artist-name {
  font-size: 11px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.queue-dur {
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--text-3); flex-shrink: 0;
}

.queue-remove {
  width: 26px; height: 26px;
  border-radius: 50%; border: none;
  background: none; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.queue-item:hover .queue-remove { opacity: 1; }
.queue-remove:hover { color: var(--danger); }
.queue-remove svg { width: 13px; height: 13px; }

/* ── Toast ─────────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--player-h) + var(--mobile-nav) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  padding: 10px 18px;
  border-radius: 100px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.accent { border-color: var(--accent); color: var(--accent); }
.toast.error  { border-color: var(--danger); color: var(--danger); }

/* ── Sidebar NP equalizer animation ─────────────────────────────────────────── */
.sidebar-np-eq {
  display: flex; align-items: flex-end; gap: 2px;
  height: 16px; margin-left: auto; flex-shrink: 0;
}
.sidebar-np-eq span {
  display: block; width: 3px;
  background: var(--accent); border-radius: 1px;
  animation: eq 0.8s ease-in-out infinite alternate;
}
.sidebar-np-eq span:nth-child(1) { height: 8px;  animation-delay: 0s;    animation-duration: 0.7s; }
.sidebar-np-eq span:nth-child(2) { height: 14px; animation-delay: 0.15s; animation-duration: 0.9s; }
.sidebar-np-eq span:nth-child(3) { height: 10px; animation-delay: 0.3s;  animation-duration: 0.6s; }
.sidebar-np-eq span:nth-child(4) { height: 6px;  animation-delay: 0.45s; animation-duration: 1.0s; }
@keyframes eq { to { transform: scaleY(0.3); } }

/* pause eq when not playing — body[data-playstate] is set by setPlayerState()
   The old .player ~ * rule was broken because .sidebar comes before .player in
   the DOM and the ~ combinator only matches forward siblings.               */
body[data-playstate="idle"]    .sidebar-np-eq span,
body[data-playstate="paused"]  .sidebar-np-eq span,
body[data-playstate="loading"] .sidebar-np-eq span { animation-play-state: paused; }

/* ── Repeat button ────────────────────────────────────────────────────────── */
/* Only one icon visible at a time based on data-repeat on #player */
.icon-repeat-off,
.icon-repeat-all,
.icon-repeat-one { display: none; }

/* off — dimmed, no accent */
.player[data-repeat="off"]  .icon-repeat-off { display: block; }
/* all — accent colour */
.player[data-repeat="all"]  .icon-repeat-all { display: block; }
/* one — accent colour */
.player[data-repeat="one"]  .icon-repeat-one { display: block; }

/* The repeat button itself: dim when off, accent when active */
.repeat-btn { color: var(--text-3); }
.player[data-repeat="all"]  .repeat-btn,
.player[data-repeat="one"]  .repeat-btn { color: var(--accent); }
/* dot indicator under the button when active */
.repeat-btn { position: relative; }
.player[data-repeat="all"]  .repeat-btn::after,
.player[data-repeat="one"]  .repeat-btn::after {
  content: '';
  position: absolute; bottom: 3px; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* Same icons in expanded player */
.expanded-player .icon-repeat-off,
.expanded-player .icon-repeat-all,
.expanded-player .icon-repeat-one { display: none; }
.expanded-player[data-repeat="off"]  .icon-repeat-off { display: block; }
.expanded-player[data-repeat="all"]  .icon-repeat-all { display: block; }
.expanded-player[data-repeat="one"]  .icon-repeat-one { display: block; }
.exp-repeat-btn { color: var(--text-3); }
.expanded-player[data-repeat="all"]  .exp-repeat-btn,
.expanded-player[data-repeat="one"]  .exp-repeat-btn { color: var(--accent); }
.exp-repeat-btn { position: relative; }
.expanded-player[data-repeat="all"]  .exp-repeat-btn::after,
.expanded-player[data-repeat="one"]  .exp-repeat-btn::after {
  content: '';
  position: absolute; bottom: 4px; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Clear all button ─────────────────────────────────────────────────────── */
.clear-all-btn {
  display: flex; align-items: center; gap: 5px;
  margin-left: auto;
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-2);
  background: none;
  color: var(--text-3);
  font-size: 11px; font-weight: 500;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.clear-all-btn svg { width: 13px; height: 13px; }
.clear-all-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(255,77,109,0.08);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TABLET  600px – 1023px
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  :root {
    --player-h: 78px;
    --sidebar-w: 64px;  /* icon-only sidebar */
  }

  body {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "sidebar main"
      "player  player";
    overflow: hidden;
  }

  .sidebar {
    display: flex;
    grid-area: sidebar;
    flex-direction: column;
    align-items: center;
    padding: 20px 0 16px;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    gap: 24px;
    overflow: hidden;
  }

  .logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 20px; letter-spacing: 0.1em;
    color: var(--accent); line-height: 1;
    user-select: none; writing-mode: vertical-rl;
    text-orientation: mixed;
  }
  .logo span { color: var(--text); }

  .nav { display: flex; flex-direction: column; gap: 4px; width: 100%; }

  .nav-btn {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    padding: 10px 0;
    background: none; border: none;
    color: var(--text-3);
    font-size: 9px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
    width: 100%;
    transition: color var(--transition), background var(--transition);
    border-radius: 0;
  }
  .nav-btn svg { width: 20px; height: 20px; }
  .nav-btn span { display: block; }
  .nav-btn:hover { color: var(--text); background: var(--bg-3); }
  .nav-btn.active { color: var(--accent); }

  .sidebar-np { display: none; } /* no room in icon-only mode */

  .main {
    grid-area: main;
    padding-bottom: 0;
  }

  .mobile-nav { display: none; }

  .player {
    grid-area: player;
    position: static;
    bottom: auto;
    border-top: 1px solid var(--border);
    height: var(--player-h);
  }

  .player-inner { padding: 0 20px; gap: 16px; }

  .player-right {
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
  }
  .player-times {
    display: flex; align-items: center; gap: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 11px; color: var(--text-3);
    white-space: nowrap;
  }
  .time-sep { opacity: 0.4; }
  .player-volume { display: none; } /* still hidden on tablet */

  .view { padding: 28px 24px; }

  .results-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  .toast {
    bottom: calc(var(--player-h) + 12px);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DESKTOP  1024px+
   Full sidebar with labels + volume control
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  :root {
    --player-h: 84px;
    --sidebar-w: 210px;
  }

  .sidebar {
    align-items: flex-start;
    padding: 28px 18px;
    gap: 28px;
  }

  .logo {
    font-size: 36px;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    letter-spacing: 0.08em;
  }

  .nav { width: auto; }

  .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    width: 100%;
    font-size: 13px; letter-spacing: 0.02em;
    text-transform: none; font-weight: 500;
    border-radius: var(--radius-sm);
  }
  .nav-btn svg { width: 18px; height: 18px; }
  .nav-btn:hover { background: var(--bg-3); }

  .sidebar-np {
    display: flex; align-items: center; gap: 10px;
    margin-top: auto;
    padding: 12px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 100%;
    overflow: hidden;
  }
  .sidebar-np img {
    width: 34px; height: 34px;
    border-radius: var(--radius-xs);
    object-fit: cover; flex-shrink: 0;
    background: var(--bg-4);
  }
  .sidebar-np-text {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
  }
  #sidebar-title {
    font-size: 12px; font-weight: 500;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #sidebar-artist {
    font-size: 10px; color: var(--text-2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  .player-inner { padding: 0 28px; gap: 20px; }
  .player-inner .player-info { flex: 1; }
  .player-inner .player-controls { flex-shrink: 0; }
  .player-inner .player-right { flex: 1; justify-content: flex-end; }

  .player-volume {
    display: flex; align-items: center; gap: 8px;
  }
  .vol-btn svg { width: 18px; height: 18px; }
  .vol-slider {
    -webkit-appearance: none; appearance: none;
    width: 88px; height: 4px;
    background: var(--bg-4);
    border-radius: 2px; outline: none; cursor: pointer;
  }
  .vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
    transition: background 0.15s;
  }
  .vol-slider:hover::-webkit-slider-thumb { background: var(--accent); }
  .vol-slider::-moz-range-thumb {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--text); border: none; cursor: pointer;
  }

  .view { padding: 36px 40px; }

  .state-headline { font-size: 52px; }

  .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 18px;
  }

  /* show queue-remove always on desktop since no hover on touch */
  .queue-remove { opacity: 0; }
  .queue-item:hover .queue-remove { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   WIDE DESKTOP  1400px+
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1400px) {
  :root { --sidebar-w: 230px; }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); }
}

button:focus:not(:focus-visible) { outline: none; }

/* ═══════════════════════════════════════════════════════════════════════════════
   EXPANDED PLAYER
   ─────────────────────────────────────────────────────────────────────────────
   Two completely separate layouts:
     MOBILE  (< 768px) : full-screen bottom sheet, blurred-art bg, flex column
     DESKTOP (≥ 768px) : centered frosted-glass card, CSS grid two-column
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Shell — shared ──────────────────────────────────────────────────────────── */
.expanded-player {
  position: fixed; inset: 0; z-index: 200;
  pointer-events: none;
  isolation: isolate;
}
.expanded-player.open { pointer-events: auto; }

/* ─────────────────────────────────────────────────────────────────────────────
   MOBILE LAYOUT  (default — no media query)
   ───────────────────────────────────────────────────────────────────────────── */

/* Blurred album-art fills the whole screen behind the panel */
.exp-bg {
  position: absolute; inset: -60px; z-index: 0;
  background-size: cover; background-position: center;
  filter: blur(72px) saturate(1.8) brightness(0.2);
  opacity: 0;
  transition: opacity 0.45s ease;
}
.expanded-player.open .exp-bg { opacity: 1; }

/* Dark gradient over the blurred bg */
.exp-overlay {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg,
    rgba(10,10,12,0.10) 0%,
    rgba(10,10,12,0.60) 52%,
    rgba(10,10,12,0.94) 100%);
  opacity: 0;
  transition: opacity 0.45s ease;
}
.expanded-player.open .exp-overlay { opacity: 1; }

/* Desktop backdrop — hidden on mobile */
.exp-backdrop { position: absolute; inset: 0; z-index: 2; display: none; }

/* Panel slides up from bottom */
.exp-panel {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.46s cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
  /* safe area for notched phones */
  padding-bottom: env(safe-area-inset-bottom, 12px);
}
.expanded-player.open .exp-panel { transform: translateY(0); }

/* Drag handle */
.exp-handle-bar {
  flex-shrink: 0;
  display: flex; justify-content: center;
  padding: 14px 0 6px;
}
.exp-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}

/* Top bar */
.exp-topbar {
  flex-shrink: 0;
  display: flex; align-items: center;
  padding: 0 20px 10px;
}
.exp-close {
  width: 34px; height: 34px;
  border-radius: 50%; border: none;
  background: rgba(255,255,255,0.10);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}
.exp-close svg { width: 20px; height: 20px; }
.exp-close:hover  { background: rgba(255,255,255,0.18); }
.exp-close:active { transform: scale(0.88); }
.exp-topbar-label {
  flex: 1; text-align: center;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3);
}
.exp-topbar-spacer { width: 34px; flex-shrink: 0; }

/* Album art — grows to fill available vertical space */
.exp-art-section {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 40px 12px;
}
.exp-art-wrap {
  position: relative;
  width: 100%; max-width: 272px;
  aspect-ratio: 1;
  border-radius: 16px; overflow: hidden;
  background: var(--bg-3);
  box-shadow: 0 28px 64px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.05);
  transform: scale(0.93);
  transition: transform 0.5s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow  0.5s ease;
}
.expanded-player[data-state="playing"] .exp-art-wrap {
  transform: scale(1);
  box-shadow: 0 36px 80px rgba(0,0,0,0.8),
              0 0 48px rgba(216,249,48,0.07),
              0 0 0 1px rgba(255,255,255,0.05);
}
.exp-art {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: opacity 0.3s;
}
.exp-art[src=""] { opacity: 0; }
.exp-art-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
}
.exp-art-placeholder svg { width: 52px; height: 52px; }

/* Bottom block — fixed at the bottom, never grows */
.exp-bottom {
  flex-shrink: 0;
  padding: 4px 28px 16px;
  display: flex; flex-direction: column; gap: 14px;
}

/* ── Title marquee ──────────────────────────────────────────────────────────── */
.exp-info { min-width: 0; width: 100%; }

/* Clipping wrapper with soft edge fades */
.exp-title-wrap {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right,
    transparent 0, black 10px, black calc(100% - 10px), transparent 100%);
  mask-image: linear-gradient(to right,
    transparent 0, black 10px, black calc(100% - 10px), transparent 100%);
}
/* The title itself — inline-block so scrollWidth is measurable */
.exp-title {
  display: inline-block;
  white-space: nowrap;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px; letter-spacing: 0.04em;
  color: var(--text); line-height: 1.05;
}
/* JS adds .scrolling when text overflows. Text is doubled inside so
   translateX(-50%) = seamlessly back to the start. */
.exp-title.scrolling {
  animation: exp-marquee 11s linear 1.5s infinite;
  padding-right: 72px;
}
@keyframes exp-marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.exp-artist {
  font-size: 13px; color: var(--text-2);
  margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Progress bar ───────────────────────────────────────────────────────────── */
.exp-progress-section {
  display: flex; flex-direction: column; gap: 5px;
  width: 100%;
}
/* Tall transparent wrapper = easy touch target */
.exp-progress-hitbox {
  width: 100%; height: 28px;
  display: flex; align-items: center;
  cursor: pointer; position: relative;
}
/* Thin visual track inside */
.exp-progress-track {
  width: 100%; height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px; position: relative;
  pointer-events: none;
  transition: height 0.15s;
}
.exp-progress-hitbox:hover .exp-progress-track { height: 5px; }
.exp-progress-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background: var(--accent); border-radius: 2px;
  width: 0%; pointer-events: none;
  transition: width 0.25s linear;
}
.exp-progress-thumb {
  position: absolute; top: 50%; left: 0%;
  transform: translate(-50%, -50%);
  width: 12px; height: 12px;
  background: var(--accent); border-radius: 50%;
  pointer-events: none; opacity: 0;
  transition: opacity 0.15s;
}
.exp-progress-hitbox:hover .exp-progress-thumb { opacity: 1; }
.exp-times {
  display: flex; justify-content: space-between;
  font-family: 'DM Mono', monospace;
  font-size: 10px; color: var(--text-3);
}

/* ── Controls ───────────────────────────────────────────────────────────────── */
.exp-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; width: 100%;
}
.exp-ctrl {
  width: 48px; height: 48px;
  border-radius: 50%; border: none;
  background: rgba(255,255,255,0.07); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}
.exp-ctrl svg { width: 22px; height: 22px; }
.exp-ctrl:hover  { background: rgba(255,255,255,0.13); }
.exp-ctrl:active { transform: scale(0.88); }

.exp-play-btn {
  width: 64px; height: 64px;
  background: var(--accent) !important; color: #000;
  box-shadow: 0 0 28px var(--accent-glow), 0 6px 20px rgba(0,0,0,0.35);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s !important;
}
.exp-play-btn svg { width: 28px; height: 28px; color: #000; fill: #000; }
.exp-play-btn:hover  { background: #c8e820 !important; transform: scale(1.06) !important; }
.exp-play-btn:active { transform: scale(0.93) !important; }

/* Play / Pause / Spin icon state  */
.expanded-player .icon-play,
.expanded-player .icon-pause,
.expanded-player .icon-spin { display: none; }
.expanded-player[data-state="idle"]    .icon-play  { display: block; }
.expanded-player[data-state="paused"]  .icon-play  { display: block; }
.expanded-player[data-state="playing"] .icon-pause { display: block; }
.expanded-player[data-state="loading"] .icon-spin  { display: block; }
.expanded-player .icon-spin {
  animation: spin 0.75s linear infinite;
  stroke: #000 !important; fill: none !important;
}

/* ── Volume ─────────────────────────────────────────────────────────────────── */
.exp-volume {
  display: flex; align-items: center; gap: 9px;
  width: 100%; max-width: 240px;
  margin: 0 auto;
}
.exp-vol-icon {
  width: 15px; height: 15px;
  color: var(--text-3); flex-shrink: 0; fill: currentColor;
}
.exp-vol-slider {
  flex: 1; min-width: 0;
  -webkit-appearance: none; appearance: none;
  height: 3px; background: rgba(255,255,255,0.15);
  border-radius: 2px; outline: none; cursor: pointer;
}
.exp-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.exp-vol-slider:hover::-webkit-slider-thumb { background: var(--accent); transform: scale(1.25); }
.exp-vol-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); border: none; cursor: pointer;
}

/* Very short phones (landscape / iPhone SE) */
@media (max-height: 640px) and (max-width: 767px) {
  .exp-art-section { padding: 4px 44px 6px; }
  .exp-art-wrap    { max-width: 180px; }
  .exp-bottom      { gap: 10px; padding: 4px 24px 10px; }
  .exp-title       { font-size: 26px; }
}

/* Mini player bar — pointer cursor to hint it opens the expanded player */
.player-info { cursor: pointer; }

/* Logo is clickable — goes home */
.logo { cursor: pointer; user-select: none; }

/* ─────────────────────────────────────────────────────────────────────────────
   DESKTOP LAYOUT  (≥ 768px)
   Completely independent from mobile. Centered floating card.
   Left column: album art  |  Right column: all controls
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 768px) {

  /* Kill the mobile bg layers */
  .exp-bg, .exp-overlay { display: none; }

  /* Dark blurred backdrop — click to close */
  .exp-backdrop {
    display: block;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer; opacity: 0;
    transition: opacity 0.3s ease;
  }
  .expanded-player.open .exp-backdrop { opacity: 1; }

  /* No drag handle on desktop */
  .exp-handle-bar { display: none; }

  /* ── Floating card ── */
  .exp-panel {
    /* Reset mobile positioning */
    position: absolute;
    inset: auto;
    top: 50%; left: 50%;

    /* Card dimensions */
    width: min(760px, calc(100vw - 48px));
    /* Fixed height so nothing can overflow */
    height: auto;
    max-height: calc(100vh - 100px);

    /* Two-column grid */
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: auto 1fr;

    /* Card styling */
    border-radius: 20px; overflow: hidden;
    background: rgba(13,13,17,0.97);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(40px) saturate(1.4);
    -webkit-backdrop-filter: blur(40px) saturate(1.4);
    box-shadow: 0 40px 100px rgba(0,0,0,0.9),
                0 0 0 1px rgba(255,255,255,0.04);

    /* Entry animation: fade + slight scale instead of slide-up */
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    transition: transform 0.42s cubic-bezier(0.16,1,0.3,1),
                opacity 0.3s ease;
    padding-bottom: 0;
  }
  .expanded-player.open .exp-panel {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  /* Top bar — spans both grid columns */
  .exp-topbar {
    grid-column: 1 / -1; grid-row: 1;
    padding: 18px 24px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  /* ── Left column: album art ── */
  .exp-art-section {
    grid-column: 1 / 2; grid-row: 2;
    padding: 28px 20px 28px 28px;
    background: rgba(0,0,0,0.22);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: center;
    /* Fixed column, no growth */
    min-height: 0; min-width: 0;
  }
  .exp-art-wrap {
    /* Fixed max so it never tries to escape the column */
    width: 100%; max-width: 220px;
    border-radius: 12px;
    /* Override the mobile scale animation */
    transform: none !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7),
                0 0 0 1px rgba(255,255,255,0.06) !important;
  }

  /* ── Right column: all controls ── */
  .exp-bottom {
    grid-column: 2 / 3; grid-row: 2;
    /* Critical: min-width:0 prevents flex children from overflowing grid cell */
    min-width: 0; min-height: 0;
    width: 100%;
    padding: 32px 32px;
    display: flex; flex-direction: column;
    justify-content: center; gap: 22px;
    box-sizing: border-box;
  }

  /* Title */
  .exp-info { min-width: 0; width: 100%; }
  .exp-title-wrap { width: 100%; }
  .exp-title  { font-size: 34px; }
  .exp-artist { font-size: 14px; }

  /* Progress — must be constrained to column width */
  .exp-progress-section { width: 100%; min-width: 0; }
  .exp-progress-hitbox  { width: 100%; min-width: 0; }

  /* Controls — centered in the column, not full width */
  .exp-controls { width: 100%; justify-content: center; gap: 12px; }
  .exp-ctrl     { width: 46px; height: 46px; }
  .exp-play-btn { width: 62px; height: 62px; }

  /* Volume — fill the full column width, no artificial max */
  .exp-volume  { width: 100%; max-width: none; margin: 0; }
}
