:root {
  color-scheme: dark;
  --accent: #c8ff3d;
  --accent-rgb: 200, 255, 61;
  --accent-2: #7cf3ff;
  --ink: #f3f4ef;
  --muted: rgba(243, 244, 239, 0.42);
  --line: rgba(255, 255, 255, 0.09);
  --glass: rgba(10, 11, 14, 0.48);
  --font: "Inter", "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", ui-monospace, monospace;
  --disc: min(44vmin, 540px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

html { overflow: hidden; }

body {
  position: fixed;
  inset: 0;
  width: 100%;
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: #040406;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, a, input, select { touch-action: manipulation; }
button { font: inherit; color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: fixed; left: -9999px; top: 0; width: 1px; height: 1px;
  overflow: hidden; opacity: 0; pointer-events: none;
}
.legacy {
  position: fixed; left: -9999px; top: 0; width: 1px; height: 1px;
  overflow: hidden; opacity: 0; pointer-events: none;
}

/* ---------------- backdrop ---------------- */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #040406; }
.backdrop__art {
  position: absolute; inset: -10%; width: 120%; height: 120%;
  object-fit: cover;
  filter: blur(16px) saturate(1.5) brightness(0.52) contrast(1.05);
  transform: scale(1.1);
  opacity: 1;
  transition: opacity 0.7s ease;
}
.backdrop__art--next {
  z-index: 1; opacity: 0;
}
.backdrop__art--next.is-visible { opacity: 1; }
.backdrop__veil {
  position: absolute; inset: 0; z-index: 2;
  background:
    radial-gradient(ellipse 62% 58% at 50% 40%, rgba(3, 4, 6, 0.06), rgba(3, 4, 6, 0.52) 68%, rgba(2, 3, 5, 0.9)),
    linear-gradient(180deg, rgba(2, 3, 5, 0.34) 0%, rgba(2, 3, 5, 0.06) 38%, rgba(2, 3, 5, 0.82) 100%);
}
.backdrop__scan {
  position: absolute; inset: 0; z-index: 3; opacity: 0.55;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.014) 3px 4px);
  pointer-events: none;
}
.backdrop__grain {
  position: absolute; inset: 0; z-index: 4; opacity: 0.18; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.42) 0.4px, transparent 0.4px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

/* ---------------- top bar ---------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 45;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) clamp(16px, 3vw, 38px) 0;
  transition: opacity 0.6s ease;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  font-size: 12px; font-weight: 700; letter-spacing: 0.34em;
  color: rgba(255, 255, 255, 0.78);
}
.brand__line {
  width: 26px; height: 1px; display: block;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.75;
}
.topbar__right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line);
  background: var(--glass); color: rgba(255, 255, 255, 0.72);
  cursor: pointer; backdrop-filter: blur(18px);
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease, transform 0.2s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.24); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .icon { width: 20px; height: 20px; }
.broadcast-btn { width: 46px; height: 46px; }
.broadcast-dot {
  position: absolute; top: 8px; right: 8px; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: 0; box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.9);
  transition: opacity 0.3s ease;
}
body.in-room .broadcast-btn {
  color: var(--accent); border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.16);
}
body.in-room .broadcast-dot { opacity: 1; animation: blink 2.4s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------------- stage ---------------- */
.stage {
  position: relative; z-index: 35;
  height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(72px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
}
.stage__inner {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(8px, 1.6vh, 16px);
  width: 100%; max-width: 1100px;
  transition: opacity 0.5s ease;
}

.vinyl-wrap {
  position: relative; width: var(--disc); aspect-ratio: 1;
  display: grid; place-items: center; isolation: isolate;
  margin-bottom: clamp(64px, 11vh, 125px);
  transition: transform 0.6s var(--ease), opacity 0.6s ease;
}
.vinyl-glow {
  position: absolute; inset: -16%; border-radius: 50%; z-index: 0;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.32), rgba(var(--accent-rgb), 0) 62%);
  filter: blur(28px); opacity: 0.4;
  transition: opacity 0.7s ease;
}
body.is-playing .vinyl-glow { opacity: 0.9; animation: glow-pulse 4.6s ease-in-out infinite; }
@keyframes glow-pulse { 0%, 100% { opacity: 0.55; transform: scale(0.98); } 50% { opacity: 0.95; transform: scale(1.04); } }

.ripples { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; z-index: 1; }
.ripples i {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(var(--accent-rgb), 0.78);
  box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.18);
  opacity: 0; transform: scale(0.92);
}
body.is-playing .ripples i { animation: ripple 4.4s ease-out infinite; }
body.is-playing .ripples i:nth-child(2) { animation-delay: 1.4s; }
body.is-playing .ripples i:nth-child(3) { animation-delay: 2.8s; }
@keyframes ripple {
  0% { transform: scale(0.94); opacity: 0.8; }
  62% { opacity: 0.22; }
  100% { transform: scale(1.54); opacity: 0; }
}

.spectrum {
  position: absolute; inset: -5%; border-radius: 50%; z-index: 1; pointer-events: none;
  background: conic-gradient(from 0deg,
    transparent 0 12%, rgba(var(--accent-rgb), 0.6) 17%, transparent 24% 42%,
    rgba(var(--accent-rgb), 0.3) 48%, transparent 55% 74%,
    rgba(var(--accent-rgb), 0.55) 82%, transparent 90%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  opacity: 0; animation: spin 14s linear infinite; animation-play-state: paused;
  transition: opacity 0.5s ease;
}
body.is-playing .spectrum { opacity: 0.7; animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }

.disc-tilt {
  position: relative; z-index: 2; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.4s ease-out;
  will-change: transform;
}
.disc {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 46%, #1a1b20 0 5%, #0b0c10 6% 12%, #08090c 13% 100%);
  box-shadow:
    0 36px 90px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 0 70px rgba(0, 0, 0, 0.85);
  animation: spin 22s linear infinite;
  animation-play-state: paused;
  overflow: hidden;
}
body.is-playing .disc { animation-play-state: running; }
.disc__art {
  position: absolute; inset: 10%; width: 80%; height: 80%;
  border-radius: 50%; object-fit: cover;
  filter: saturate(1.1) contrast(1.04);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 10px 40px rgba(0, 0, 0, 0.6);
  z-index: 1;
  transition: filter 0.6s ease;
}
.disc__grooves {
  position: absolute; inset: 0; border-radius: 50%; z-index: 2; pointer-events: none;
  background: repeating-radial-gradient(circle at 50% 50%,
    rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}
.disc__sheen {
  position: absolute; inset: 0; border-radius: 50%; z-index: 4; pointer-events: none;
  background: conic-gradient(from 218deg, transparent 0 22%, rgba(255, 255, 255, 0.075) 30%, transparent 38% 100%);
  mix-blend-mode: screen;
}
.disc__hole {
  position: absolute; left: 50%; top: 50%; width: 10px; height: 10px;
  margin: -5px 0 0 -5px; border-radius: 50%; z-index: 5;
  background: #020203; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.disc__label {
  position: absolute; left: 50%; top: 50%; width: 15%; aspect-ratio: 1; z-index: 3;
  transform: translate(-50%, -50%);
  border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.04) 66%, transparent 72%);
  color: rgba(255, 255, 255, 0.52);
  font-size: clamp(7px, 0.9vmin, 10px); font-weight: 700; letter-spacing: 0.14em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* ---------------- liquid glass + calibrated sound ring ---------------- */
.ring-canvas,
.room-ring-canvas {
  display: none; position: absolute; left: 50%; top: 50%;
  width: 160%; height: 160%;
  transform: translate(-50%, -50%);
  pointer-events: none; z-index: 3;
}
.room-ring-canvas { width: 150%; height: 150%; }
html.has-ring #ring-main { display: block; }
html.has-room-ring #ring-room { display: block; }
.has-ring .ripples,
.has-ring .spectrum,
.has-room-ring .room-disc-ripples { display: none; }

.disc .glass-canvas,
.room-disc .glass-canvas {
  display: none; position: absolute; inset: 0;
  width: 100%; height: 100%; border-radius: 50%; z-index: 3;
  pointer-events: none;
}
html.has-liquid #glass-main { display: block; }
html.has-room-liquid #glass-room { display: block; }

html.has-liquid .disc {
  background: transparent;
  animation: none !important;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.62),
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 0 70px rgba(var(--accent-rgb), 0.12),
    inset 0 0 44px rgba(255, 255, 255, 0.035);
}
html.has-liquid .disc .disc__art,
html.has-liquid .disc .disc__grooves,
html.has-liquid .disc .disc__label,
html.has-liquid .disc .disc__hole,
html.has-liquid .disc .disc__sheen { display: none; }
html.has-liquid .disc::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  z-index: 5; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.20);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 0 38px rgba(255, 255, 255, 0.05),
    inset 0 -26px 60px rgba(0, 0, 0, 0.22);
}
html.has-liquid .disc::before {
  content: ''; position: absolute; inset: 2.5%; border-radius: 50%;
  z-index: 4; pointer-events: none;
  background: conic-gradient(from 210deg,
    transparent 0 16%, rgba(255, 255, 255, 0.17) 24%, transparent 34% 62%,
    rgba(255, 255, 255, 0.08) 72%, transparent 82% 100%);
  mix-blend-mode: screen;
  opacity: 0.7;
  animation: spin 26s linear infinite;
  animation-play-state: paused;
}
html.has-liquid body.is-playing .disc::before { animation-play-state: running; }
html.has-room-liquid .room-disc {
  background: transparent;
  animation: none !important;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.66),
    0 0 0 1px rgba(255, 255, 255, 0.15),
    0 0 80px rgba(var(--accent-rgb), 0.14),
    inset 0 0 46px rgba(255, 255, 255, 0.04);
}
html.has-room-liquid .room-disc img,
html.has-room-liquid .room-disc .room-disc__grooves,
html.has-room-liquid .room-disc .room-disc__hole,
html.has-room-liquid .room-disc .room-disc__sheen { display: none; }
html.has-room-liquid .room-disc::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  z-index: 5; pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 0 42px rgba(255, 255, 255, 0.06);
}

.tonearm { position: absolute; top: -11%; right: -3%; width: 46%; height: 54%; z-index: 6; pointer-events: none; transform: rotate(-24deg); transition: transform 0.9s var(--ease); }
body.is-playing .tonearm { transform: rotate(-9deg); }
.tonearm__pivot {
  position: absolute; top: 2%; right: 0; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle, #3a3d46, #111318 68%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.tonearm__arm {
  position: absolute; top: 12%; right: 12px; width: 4px; height: 78%;
  transform-origin: top center; transform: rotate(26deg);
  border-radius: 4px;
  background: linear-gradient(90deg, #23252b, #8d929c 46%, #3a3d45 100%);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}
.tonearm__arm i {
  position: absolute; left: 50%; bottom: -14px; width: 18px; height: 26px;
  transform: translateX(-50%); border-radius: 3px 3px 6px 6px;
  background: linear-gradient(160deg, #5a5e68, #15171b);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.buffering {
  position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); z-index: 8;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(6, 7, 10, 0.72); border: 1px solid var(--line);
  color: rgba(255, 255, 255, 0.68); font-size: 11px; letter-spacing: 0.06em;
  backdrop-filter: blur(16px); white-space: nowrap;
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16); border-top-color: var(--accent);
  animation: bufferspin 0.8s linear infinite;
}
@keyframes bufferspin { to { transform: rotate(360deg); } }

/* ---------------- now playing ---------------- */
.track-line { text-align: center; max-width: min(94vw, 860px); min-width: 0; }
.track-line h1 {
  margin: 0; font-size: clamp(22px, 3.1vmin, 38px); font-weight: 650;
  letter-spacing: -0.025em; line-height: 1.1;
  color: rgba(255, 255, 255, 0.96);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45);
}
.now-meta, #now-meta {
  margin: 6px 0 0; font-family: var(--mono);
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
}

.timeline {
  display: grid; grid-template-columns: 38px minmax(0, 380px) 38px;
  align-items: center; gap: 9px;
  width: min(86vw, 480px);
  font-family: var(--mono); font-size: 9px; color: rgba(255, 255, 255, 0.32);
  font-variant-numeric: tabular-nums;
}
.timeline span:last-child { text-align: right; }

/* custom seek rail: native range stays hidden behind it so touch dragging
   never depends on a 7px browser thumb. */
.seek-control {
  position: relative; height: 30px; display: flex; align-items: center;
  touch-action: none; cursor: pointer; user-select: none;
  -webkit-user-select: none;
}
.seek-rail {
  position: relative; width: 100%; height: 2px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
}
.seek-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.35);
}
.seek-knob {
  position: absolute; top: 50%; left: 0; width: 10px; height: 10px;
  margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.7);
  transition: transform 0.15s ease;
  pointer-events: none;
}
.seek-control.is-seeking .seek-knob { transform: scale(1.45); }
#seek {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none;
}
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; background: transparent; cursor: pointer; }
#seek { height: 20px; }
#seek::-webkit-slider-runnable-track {
  height: 2px; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), rgba(255, 255, 255, 0.14) var(--fill, 0%));
}
#seek::-moz-range-track { height: 2px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); }
#seek::-moz-range-progress { height: 2px; border-radius: 99px; background: var(--accent); }
#seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 7px; height: 7px; margin-top: -2.5px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.8);
}
#seek::-moz-range-thumb { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--accent); }

.transport {
  display: flex; align-items: center; gap: clamp(12px, 2.6vw, 24px);
  margin-top: clamp(0px, 0.6vh, 6px);
}
.round {
  display: grid; place-items: center;
  width: 46px; height: 46px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line);
  background: var(--glass); color: rgba(255, 255, 255, 0.7);
  cursor: pointer; backdrop-filter: blur(18px);
  transition: color 0.24s ease, border-color 0.24s ease, background 0.24s ease, transform 0.18s var(--ease), box-shadow 0.3s ease;
}
.round:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.24); }
.round:active { transform: scale(0.93); }
.round .icon { width: 19px; height: 19px; }
.round--play {
  width: 66px; height: 66px; border: 0;
  background: var(--accent); color: #070806;
  box-shadow: 0 10px 42px rgba(var(--accent-rgb), 0.28), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}
.round--play:hover { color: #070806; background: var(--accent); box-shadow: 0 12px 54px rgba(var(--accent-rgb), 0.4); }
.round--play .icon { width: 24px; height: 24px; }
.round--list { margin-left: 2px; color: rgba(255, 255, 255, 0.46); }
.round--list .icon { width: 20px; height: 20px; }
.round:focus-visible, .icon-btn:focus-visible, .tool:focus-visible, .room-btn:focus-visible, .mini-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}

/* ---------------- sheet / playlist ---------------- */
.veil {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(2, 3, 5, 0.42);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(2px);
}
body.sheet-open .veil { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; z-index: 50; top: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  width: min(420px, 42vw); padding-top: env(safe-area-inset-top);
  background: linear-gradient(180deg, rgba(11, 12, 15, 0.94), rgba(6, 7, 9, 0.96));
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(34px) saturate(1.1);
  transform: translateX(104%);
  transition: transform 0.55s var(--ease);
  box-shadow: -30px 0 90px rgba(0, 0, 0, 0.45);
}
body.sheet-open .sheet { transform: none; }
.sheet__grip { display: none; }
.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 22px 20px 14px;
}
.sheet__title { display: flex; align-items: baseline; gap: 10px; }
.kicker {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.36);
}
.sheet__count {
  font-family: var(--mono); font-size: 10px; color: var(--accent);
  padding: 2px 7px; border: 1px solid rgba(var(--accent-rgb), 0.26);
  border-radius: 999px;
}
.sheet__head .icon-btn { width: 38px; height: 38px; }
.sheet__head .icon-btn .icon { width: 17px; height: 17px; }

.tracks {
  list-style: none; margin: 0; padding: 4px 10px 16px;
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 2px;
  scrollbar-width: none;
}
.tracks::-webkit-scrollbar { width: 0; }
.track {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto auto;
  gap: 12px; align-items: center;
  padding: 9px 10px; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; min-width: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.track:hover { background: rgba(255, 255, 255, 0.035); }
.track.active {
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.1), rgba(255, 255, 255, 0.015) 60%);
  border-color: rgba(var(--accent-rgb), 0.2);
  box-shadow: inset 2px 0 0 var(--accent);
}
.track-index { display: none; }
.track-thumb {
  width: 48px; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 7px; display: block;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.track-main { min-width: 0; }
.track-title {
  display: block; font-size: 13px; font-weight: 550; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.82);
}
.track.active .track-title { color: var(--ink); }
.track-sub { display: none; }
.track-duration { font-family: var(--mono); font-size: 9px; color: rgba(255, 255, 255, 0.3); }
.track-dl {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 9px; color: rgba(255, 255, 255, 0.26);
  text-decoration: none; transition: color 0.2s ease, background 0.2s ease;
}
.track-dl .icon { width: 15px; height: 15px; }
.track-dl:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }

.sheet__tools {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.tool {
  position: relative; display: grid; place-items: center;
  width: 42px; height: 42px; padding: 0;
  border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: rgba(255, 255, 255, 0.42);
  cursor: pointer; transition: color 0.2s ease, background 0.2s ease;
}
.tool:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
.tool .icon { width: 18px; height: 18px; }
.tool__dot {
  position: absolute; top: 9px; right: 9px; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: 0; box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.8);
}
.tool.has-timer .tool__dot { opacity: 1; }
.tool-spacer { flex: 1; }

.drawer {
  padding: 4px 20px 14px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.drawer__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drawer__label { font-size: 11px; color: var(--muted); }
.drawer select, .drawer input[type="number"] {
  flex: 1; min-width: 120px; height: 38px;
  border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045); color: var(--ink);
  font: inherit; font-size: 12px; padding: 0 10px;
}
.drawer input[type="number"] { flex: 0 0 90px; min-width: 0; }
.sleep-remaining { font-family: var(--mono); font-size: 10px; color: var(--accent); }
.mini-btn {
  appearance: none; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05);
  color: var(--muted); border-radius: 999px; padding: 7px 12px;
  font: inherit; font-size: 11px; cursor: pointer;
}
#volume-row input { height: 28px; }
#volume-row { padding: 12px 20px 16px; border-top: 1px solid var(--line); }

/* ---------------- room ---------------- */
.room {
  position: fixed; inset: 0; z-index: 25;
  opacity: 0; visibility: hidden; pointer-events: none;
  overflow: hidden; perspective: 1200px;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}
body.in-room .room { opacity: 1; visibility: visible; pointer-events: auto; }
.room__bg {
  position: absolute; inset: -12%; width: 124%; height: 124%;
  object-fit: cover;
  filter: blur(52px) brightness(0.4) saturate(1.6) contrast(1.06);
  transform: scale(1.18);
}
.room__veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 62% 62% at 50% 52%, rgba(var(--accent-rgb), 0.14), transparent 60%),
    radial-gradient(ellipse 70% 62% at 50% 44%, rgba(2, 3, 5, 0.12), rgba(2, 3, 5, 0.7) 76%),
    linear-gradient(180deg, rgba(2, 3, 5, 0.42), rgba(2, 3, 5, 0.28) 42%, rgba(2, 3, 5, 0.9));
}
.room__floor {
  position: absolute; left: -24%; right: -24%; bottom: -14%; height: 58%;
  background:
    repeating-linear-gradient(90deg, rgba(var(--accent-rgb), 0.3) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(var(--accent-rgb), 0.3) 0 1px, transparent 1px 64px);
  transform: perspective(560px) rotateX(68deg);
  transform-origin: 50% 100%;
  opacity: 0.58;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 46%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 46%, #000 100%);
}
.room__orbits { position: absolute; left: 50%; top: 47%; width: 82vmin; height: 82vmin; margin: -41vmin 0 0 -41vmin; transform-style: preserve-3d; transform: rotateX(16deg); }
.room__orbits i {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(var(--accent-rgb), 0.16);
  transform: rotateX(64deg) rotateZ(8deg);
  animation: orbit-spin 36s linear infinite;
}
.room__orbits i:nth-child(2) { inset: 12%; border-style: dashed; opacity: 0.55; animation-direction: reverse; animation-duration: 26s; transform: rotateX(-58deg) rotateZ(-14deg); }
.room__orbits i:nth-child(3) { inset: 26%; opacity: 0.4; animation-duration: 18s; transform: rotateX(72deg) rotateZ(26deg); }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
.room__floaters i {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: 0.55;
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.7);
  animation: float-y 9s ease-in-out infinite alternate;
}
.room__floaters i:nth-child(1) { left: 16%; top: 32%; animation-delay: -1s; }
.room__floaters i:nth-child(2) { right: 20%; top: 27%; animation-delay: -3.4s; width: 4px; height: 4px; }
.room__floaters i:nth-child(3) { left: 26%; bottom: 30%; animation-delay: -5.2s; width: 3px; height: 3px; }
.room__floaters i:nth-child(4) { right: 28%; bottom: 34%; animation-delay: -7s; }
@keyframes float-y { from { transform: translate3d(0, -8px, 0); } to { transform: translate3d(6px, 12px, 0); } }

/* floating cover shards: depth in the room */
.room__shards i {
  position: absolute; width: clamp(84px, 11vw, 156px); aspect-ratio: 16 / 10;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.16);
  background-image: var(--cover-image); background-size: cover; background-position: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  filter: saturate(1.2) brightness(0.9);
  opacity: 0.3; transform-style: preserve-3d;
  animation: shard-float 11s ease-in-out infinite alternate;
}
.room__shards i:nth-child(1) { left: 7%; top: 25%; transform: rotate(-13deg) rotateY(22deg) translateZ(-30px); }
.room__shards i:nth-child(2) { right: 8%; top: 34%; width: clamp(64px, 8vw, 118px); opacity: 0.2; transform: rotate(11deg) rotateY(-24deg) translateZ(-80px); animation-delay: -4s; }
.room__shards i:nth-child(3) { left: 17%; bottom: 17%; width: clamp(56px, 7vw, 96px); opacity: 0.15; transform: rotate(9deg) rotateY(-28deg) translateZ(-110px); animation-delay: -7s; }
@keyframes shard-float {
  from { translate: 0 -7px; }
  to { translate: 5px 10px; }
}

/* the spatial room centerpiece */
.room-stage {
  position: absolute; left: 50%; top: 47%;
  width: min(52vmin, 440px); aspect-ratio: 1;
  transform: translate(-50%, -50%) rotateX(12deg) translateZ(-80px);
  transform-style: preserve-3d; pointer-events: none; z-index: 2;
}
.room-disc-glow {
  position: absolute; inset: -18%; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.38), transparent 64%);
  filter: blur(34px); opacity: 0.55;
}
body.is-playing .room-disc-glow { animation: glow-pulse 4.6s ease-in-out infinite; }
.room-disc-ripples { position: absolute; inset: 0; border-radius: 50%; }
.room-disc-ripples i {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  opacity: 0;
}
body.is-playing .room-disc-ripples i { animation: ripple 4.8s ease-out infinite; }
body.is-playing .room-disc-ripples i:nth-child(2) { animation-delay: 1.6s; }
body.is-playing .room-disc-ripples i:nth-child(3) { animation-delay: 3.2s; }
.room-disc {
  position: absolute; inset: 0; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 50% 46%, #191a1f 0 5%, #0b0c10 6% 12%, #07080b 13% 100%);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 0 80px rgba(0, 0, 0, 0.85);
  animation: spin 26s linear infinite; animation-play-state: paused;
  overflow: hidden;
}
body.is-playing .room-disc { animation-play-state: running; }
.room-disc img {
  position: absolute; inset: 11%; width: 78%; height: 78%;
  border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 16px 50px rgba(0, 0, 0, 0.7);
}
.room-disc__grooves {
  position: absolute; inset: 0; border-radius: 50%;
  background: repeating-radial-gradient(circle, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}
.room-disc__sheen {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 220deg, transparent 0 24%, rgba(255, 255, 255, 0.08) 32%, transparent 40% 100%);
  mix-blend-mode: screen;
}
.room-disc__hole {
  position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: #020203; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.room__hud {
  position: absolute; left: 50%; top: clamp(84px, 12vh, 132px);
  width: min(90vw, 560px); z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; transform-style: preserve-3d;
  transform: translateX(-50%) rotateX(3deg) translateZ(70px);
  transition: transform 0.6s var(--ease), opacity 0.5s ease;
}
.room__hud.hud-pulse { animation: hud-pulse 0.9s var(--ease); }
@keyframes hud-pulse {
  0%, 100% { transform: translateX(-50%) rotateX(3deg) translateZ(70px) scale(1); }
  45% { transform: translateX(-50%) rotateX(3deg) translateZ(80px) scale(1.03); }
}
.room__top { display: flex; align-items: center; gap: 12px; }
.room__live {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.5);
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9);
  animation: blink 2.2s ease-in-out infinite;
}
.room__code {
  font-family: var(--mono); font-size: clamp(16px, 2.2vmin, 22px); font-weight: 600;
  letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--ink); text-shadow: 0 0 26px rgba(var(--accent-rgb), 0.25);
}
.room__sync {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.42);
}
.dot {
  width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.28);
  flex: none;
}
.dot.on { background: var(--accent); box-shadow: 0 0 9px rgba(var(--accent-rgb), 0.8); }
.dot.busy { background: #ffc76b; box-shadow: 0 0 9px rgba(255, 199, 107, 0.7); }
.room__lock {
  padding: 6px 11px; border-radius: 999px;
  background: rgba(255, 199, 107, 0.1); border: 1px solid rgba(255, 199, 107, 0.26);
  color: #ffd79a; font-size: 10px;
}
.room__listeners {
  list-style: none; display: flex; flex-wrap: wrap; justify-content: center;
  gap: 7px; margin: 4px 0 0; padding: 0; max-width: 90vw;
}
.room__listeners li {
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.055); border: 1px solid rgba(255, 255, 255, 0.11);
  color: rgba(255, 255, 255, 0.68); font-size: 10px;
  backdrop-filter: blur(12px);
  transform: translateZ(26px);
  animation: float-y 7s ease-in-out infinite alternate;
}
.room__listeners li:nth-child(2n) { transform: translateZ(46px) translateY(2px); animation-delay: -2.2s; }
.room__listeners li:nth-child(3n) { transform: translateZ(16px) translateY(-2px); animation-delay: -4.4s; }
.room__meta {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.34);
}
.room__meta #listener-count { color: var(--accent); font-size: 11px; }
.room__actions { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.room-btn {
  display: grid; place-items: center; width: 42px; height: 42px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045); color: rgba(255, 255, 255, 0.6);
  cursor: pointer; backdrop-filter: blur(14px);
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease);
}
.room-btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.26); }
.room-btn:active { transform: scale(0.93); }
.room-btn .icon { width: 18px; height: 18px; }
.room-btn--leave { color: rgba(255, 140, 140, 0.7); }

body.in-room .stage { pointer-events: none; }
body.in-room .stage__inner .vinyl-wrap,
body.in-room .track-line {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
body.in-room .timeline {
  display: grid;
  position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(74vw, 420px);
  grid-template-columns: 1fr;
  z-index: 36;
  opacity: 1; visibility: visible; pointer-events: auto;
}
body.in-room .timeline > span { display: none; }
body.in-room .transport {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0; z-index: 36; opacity: 1; pointer-events: auto;
}
body.in-room .transport .round { background: rgba(6, 7, 10, 0.62); }
body.in-room .transport .round--play { background: var(--accent); }
body.in-room .vinyl-wrap .tonearm { display: none; }

/* ---------------- modal / downloads ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 18px;
  background: rgba(2, 3, 5, 0.66); backdrop-filter: blur(16px);
}
.modal__card {
  width: min(520px, 100%); max-height: 82dvh; overflow: auto;
  border-radius: 20px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 13, 16, 0.97), rgba(7, 8, 10, 0.98));
  padding: 20px; box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
}
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal__head h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -0.02em; }
.modal__head .icon-btn { width: 36px; height: 36px; }
.downloads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.downloads a {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 12px; border-radius: 10px; text-decoration: none;
  color: rgba(255, 255, 255, 0.78); background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent; font-size: 12px;
}
.downloads a:hover { border-color: var(--line); background: rgba(255, 255, 255, 0.05); }
.downloads .size { font-family: var(--mono); font-size: 9px; color: rgba(255, 255, 255, 0.3); white-space: nowrap; }

.toast {
  position: fixed; z-index: 70; left: 50%; top: calc(74px + env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: min(88vw, 520px); padding: 9px 14px;
  border-radius: 999px; border: 1px solid var(--line);
  background: rgba(8, 9, 12, 0.9); backdrop-filter: blur(18px);
  color: rgba(255, 255, 255, 0.72); font-size: 11px; letter-spacing: 0.02em;
  text-align: center; pointer-events: none;
}

/* idle state: keep the stage, fade chrome */
body.ui-idle .topbar, body.ui-idle .track-line, body.ui-idle .timeline, body.ui-idle .transport { opacity: 0.16; }
body.ui-idle .topbar, body.ui-idle .track-line, body.ui-idle .timeline, body.ui-idle .transport { transition: opacity 0.8s ease; }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  :root { --disc: min(62vmin, 470px); }
  .stage { padding: calc(70px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
  .stage__inner { gap: 10px; }
  .tonearm { display: none; }
  .track-line h1 { font-size: clamp(19px, 5.4vw, 26px); }
  #now-meta { font-size: 8px; letter-spacing: 0.18em; }
  .timeline { width: min(88vw, 420px); grid-template-columns: 32px minmax(0, 1fr) 32px; gap: 7px; font-size: 8px; }
  .seek-control { height: 44px; }
  .seek-rail { height: 3px; }
  .seek-knob { width: 16px; height: 16px; margin: -8px 0 0 -8px; }
  .ring-canvas { width: 160%; height: 160%; }
  .room-ring-canvas { width: 150%; height: 150%; }
  .transport { gap: 14px; }
  .round { width: 44px; height: 44px; }
  .round--play { width: 60px; height: 60px; }
  .round .icon { width: 18px; height: 18px; }
  .round--play .icon { width: 22px; height: 22px; }
  .round--list { margin-left: 0; }

  .sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    height: min(84dvh, 760px);
    border-left: 0; border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px 22px 0 0;
    transform: translateY(104%);
    padding-top: 0;
  }
  body.sheet-open .sheet { transform: none; }
  .sheet__grip {
    display: block; width: 38px; height: 4px; margin: 9px auto 0;
    border-radius: 99px; background: rgba(255, 255, 255, 0.16);
  }
  .sheet__head { padding: 14px 16px 10px; }
  .tracks { padding: 2px 8px 10px; }
  .track { grid-template-columns: 46px minmax(0, 1fr) auto auto; gap: 10px; padding: 9px 8px; }
  .track-thumb { width: 46px; }
  .sheet__tools { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .tool { width: 44px; height: 44px; }

  .room__hud { top: calc(78px + env(safe-area-inset-top)); width: min(92vw, 480px); transform: translateX(-50%) rotateX(2deg) translateZ(40px); }
  .room-stage { width: min(62vmin, 330px); top: 50%; }
  .room__shards { display: none; }
  .room__code { font-size: 16px; letter-spacing: 0.24em; }
  .room__listeners li { font-size: 9px; padding: 4px 9px; }
  .room__floor { height: 52%; opacity: 0.42; }
  body.in-room .stage { pointer-events: none; }
  body.in-room .stage__inner .vinyl-wrap,
  body.in-room .track-line { display: none; }
  body.in-room .timeline { bottom: calc(94px + env(safe-area-inset-bottom)); width: min(80vw, 360px); }
  body.in-room .transport { z-index: 36; }
  .modal { padding: 12px; }
  .modal__card { max-height: 86dvh; padding: 16px; }
  .toast { top: calc(66px + env(safe-area-inset-top)); }
}

@media (max-width: 420px) {
  :root { --disc: min(62vw, 360px); }
  .brand__mark { letter-spacing: 0.28em; }
  .brand__line { width: 16px; }
  .round { width: 42px; height: 42px; }
  .round--play { width: 58px; height: 58px; }
  .transport { gap: 11px; }
  #now-meta { font-size: 7.5px; }
  .room__actions { gap: 10px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  :root { --disc: min(38vh, 300px); }
  .stage { padding-top: calc(54px + env(safe-area-inset-top)); padding-bottom: 8px; }
  .stage__inner { gap: 4px; }
  .track-line h1 { font-size: 16px; }
  #now-meta, .timeline span { display: none; }
  .timeline { grid-template-columns: 1fr; width: min(64vw, 380px); }
  .transport { margin-top: 0; }
  .round { width: 38px; height: 38px; }
  .round--play { width: 50px; height: 50px; }
  .room__hud { top: calc(54px + env(safe-area-inset-top)); gap: 6px; }
  body.in-room .stage__inner .vinyl-wrap { transform: scale(0.55) translateY(-2vh); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  body.is-playing .ripples i, body.is-playing .spectrum, body.is-playing .vinyl-glow { animation: none !important; }
}
