/* ── tokens ─────────────────────────────────────────────────────────────── */
:root {
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(255, 255, 255, 0.12);
  --edge: rgba(255, 255, 255, 0.16);
  --edge-soft: rgba(255, 255, 255, 0.08);
  --ink: rgba(255, 255, 255, 0.95);
  --ink-dim: rgba(255, 255, 255, 0.62);
  --ink-faint: rgba(255, 255, 255, 0.38);
  --accent: #b9a7ff;
  --accent-2: #7fe6ff;
  --radius: 26px;
  --blur: 34px;
  /* Per-track hues, set from JS. */
  --hue-a: 265;
  --hue-b: 195;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #07060f;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── backdrop ───────────────────────────────────────────────────────────── */
.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: 0; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.75;
  transition: background 1.2s ease;
  will-change: transform;
}
.blob-a {
  width: 62vmax; height: 62vmax; top: -22vmax; left: -14vmax;
  background: hsl(var(--hue-a) 90% 62%);
  animation: drift-a 26s ease-in-out infinite;
}
.blob-b {
  width: 52vmax; height: 52vmax; bottom: -20vmax; right: -12vmax;
  background: hsl(var(--hue-b) 92% 58%);
  animation: drift-b 32s ease-in-out infinite;
}
.blob-c {
  width: 40vmax; height: 40vmax; top: 32%; left: 42%;
  background: hsl(calc(var(--hue-a) + 40) 88% 55%);
  opacity: 0.5;
  animation: drift-c 38s ease-in-out infinite;
}

@keyframes drift-a {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(8vmax, 6vmax, 0) scale(1.12); }
}
@keyframes drift-b {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.05); }
  50%      { transform: translate3d(-9vmax, -5vmax, 0) scale(0.92); }
}
@keyframes drift-c {
  0%, 100% { transform: translate3d(-4vmax, 0, 0) scale(0.95); }
  50%      { transform: translate3d(6vmax, -8vmax, 0) scale(1.1); }
}

/* Fine noise keeps the gradients from banding on wide displays. */
.grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
  opacity: 0.16;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* ── layout ─────────────────────────────────────────────────────────────── */
.shell {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(340px, 480px);
  gap: 22px;
  align-content: center;
  justify-content: center;
  padding: 28px;
}

.panel {
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow:
    0 30px 70px -30px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  position: relative;
  overflow: hidden;
}

/* Specular sheen along the top edge — the tell that sells "glass". */
.panel::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 45%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent);
  pointer-events: none;
}

/* ── now playing ────────────────────────────────────────────────────────── */
.now-playing {
  padding: 26px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.art {
  position: relative;
  aspect-ratio: 1;
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid var(--edge-soft);
  background: linear-gradient(135deg,
    hsl(var(--hue-a) 80% 60% / 0.9),
    hsl(var(--hue-b) 85% 55% / 0.85));
  transition: background 0.8s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.art-glow {
  position: absolute; inset: -30%;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.5), transparent 55%);
  mix-blend-mode: soft-light;
}
.art-mark {
  width: 34%; height: 34%;
  color: rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.35));
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.art.playing .art-mark { opacity: 0; transform: scale(0.85); }

/* Fake spectrum — cheap, and it reads as "audio is moving". */
.viz {
  position: absolute;
  inset: auto 0 0 0;
  height: 46%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 7px;
  padding-bottom: 26px;
}
.viz span {
  width: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.5);
  height: 12%;
  transform-origin: bottom;
  animation: bounce 1.1s ease-in-out infinite;
}
.viz span:nth-child(2) { animation-duration: 0.86s; animation-delay: 0.12s; }
.viz span:nth-child(3) { animation-duration: 1.32s; animation-delay: 0.05s; }
.viz span:nth-child(4) { animation-duration: 0.94s; animation-delay: 0.22s; }
.viz span:nth-child(5) { animation-duration: 1.18s; animation-delay: 0.09s; }
@keyframes bounce {
  0%, 100% { height: 14%; opacity: 0.65; }
  50%      { height: 78%; opacity: 1; }
}

.meta { min-height: 74px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.title {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist code {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

/* ── seek bar ───────────────────────────────────────────────────────────── */
.scrub { display: flex; flex-direction: column; gap: 7px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]:disabled { cursor: default; opacity: 0.5; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  /* --pct is written by JS so the fill tracks the thumb. */
  background: linear-gradient(90deg,
    hsl(var(--hue-b) 90% 72%) 0%,
    hsl(var(--hue-a) 90% 78%) var(--pct, 0%),
    rgba(255, 255, 255, 0.16) var(--pct, 0%));
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.16);
}
input[type="range"]::-moz-range-progress {
  height: 6px; border-radius: 99px; background: hsl(var(--hue-a) 90% 78%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  margin-top: -4px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transform: scale(0.55);
  transition: transform 0.16s ease;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: none; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb { transform: scale(1); }

.times {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

/* ── controls ───────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.14s ease, background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
button:active { transform: scale(0.93); }
button svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.ghost {
  width: 40px; height: 40px;
  border-radius: 13px;
  color: var(--ink-dim);
}
.ghost svg { width: 18px; height: 18px; }
.ghost:hover { background: var(--glass-strong); color: var(--ink); }
.ghost[aria-pressed="true"] {
  color: #fff;
  background: hsl(var(--hue-a) 85% 65% / 0.35);
  box-shadow: inset 0 0 0 1px hsl(var(--hue-a) 90% 80% / 0.5);
}

.play {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #14121f;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.8), inset 0 1px 0 #fff;
}
.play:hover { background: #fff; }
.play svg { width: 24px; height: 24px; stroke-width: 2.2; }
.play .icon-pause { display: none; }
body.playing .play .icon-play { display: none; }
body.playing .play .icon-pause { display: block; }

.volume {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
  color: var(--ink-faint);
}
.vol-icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.volume input { flex: 1; }

/* ── queue ──────────────────────────────────────────────────────────────── */
.queue { display: flex; flex-direction: column; min-height: 0; max-height: min(76vh, 660px); }

.queue-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--edge-soft);
}
.queue-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.queue-head p { margin: 3px 0 0; font-size: 12px; color: var(--ink-faint); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--edge-soft);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.search:focus-within { border-color: hsl(var(--hue-a) 90% 80% / 0.6); background: rgba(255, 255, 255, 0.13); }
.search svg { width: 14px; height: 14px; fill: none; stroke: var(--ink-faint); stroke-width: 1.8; stroke-linecap: round; }
.search input {
  border: none; background: none; outline: none;
  color: var(--ink); font: inherit; font-size: 12.5px; width: 92px;
}
.search input::placeholder { color: var(--ink-faint); }
.search input::-webkit-search-cancel-button { filter: invert(1) opacity(0.5); }

.tracks {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  outline: none;
}
.tracks::-webkit-scrollbar { width: 8px; }
.tracks::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }

.track {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.16s ease;
  border: 1px solid transparent;
}
.track:hover { background: rgba(255, 255, 255, 0.07); }
.track.active {
  background: rgba(255, 255, 255, 0.13);
  border-color: var(--edge-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.track .num {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  text-align: center;
}
.track.active .num { color: hsl(var(--hue-b) 90% 80%); }

.track .lines { min-width: 0; }
.track .t {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track .a {
  font-size: 11.5px;
  color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.track .badge {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.empty { padding: 40px 22px; text-align: center; color: var(--ink-dim); font-size: 13px; line-height: 1.6; }
.empty code { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 6px; }

.queue-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--edge-soft);
}
.add {
  padding: 8px 14px;
  border-radius: 11px;
  font-size: 12.5px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--edge-soft);
  color: var(--ink);
}
.add:hover { background: var(--glass-strong); }
.hint { font-size: 11.5px; color: var(--ink-faint); }

/* ── drop target ────────────────────────────────────────────────────────── */
.drop-veil {
  position: fixed; inset: 16px;
  z-index: 5;
  display: grid; place-items: center;
  border-radius: 30px;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  background: rgba(10, 8, 24, 0.55);
  backdrop-filter: blur(8px);
  font-size: 15px;
  letter-spacing: 0.02em;
}

:focus-visible { outline: 2px solid hsl(var(--hue-b) 95% 78%); outline-offset: 3px; }

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  body { overflow: auto; }
  .shell {
    grid-template-columns: minmax(0, 460px);
    height: auto;
    min-height: 100%;
    padding: 18px;
    align-content: start;
    padding-top: 24px;
  }
  .queue { max-height: 52vh; }
  .art { max-width: 62%; margin: 0 auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .blob, .viz span { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* Repeat-one gets a small marker so the three states stay distinguishable. */
.ghost[data-mode="one"] { position: relative; }
.ghost[data-mode="one"]::after {
  content: "1";
  position: absolute;
  right: 5px; bottom: 4px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

/* Author rules for .viz/.drop-veil outrank the UA's [hidden], so restate it. */
.viz[hidden], .drop-veil[hidden] { display: none; }
