*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body, a, button, input, label, [role="button"], #artwork-wrap { cursor: none; }
@media (hover: none) {
  body, a, button, input, label, [role="button"], #artwork-wrap { cursor: pointer; }
}

#cursor {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--glow, #a78bfa);
  box-shadow: 0 0 8px 2px var(--glow, #a78bfa), 0 0 20px 4px rgba(167,139,250,0.4);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(1);
  transition: box-shadow 0.05s, background 0.4s;
  will-change: transform, left, top;
}
@media (hover: none) {
  #cursor { display: none; }
}

#version {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 9998;
  color: rgba(255,255,255,0.2);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  pointer-events: none;
}
body.light #version { color: rgba(15,10,30,0.2); }

:root {
  --glow: #a78bfa;
  --glow2: #60a5fa;
  --text: rgba(255,255,255,0.92);
  --sub: rgba(255,255,255,0.45);
  --panel-w: 280px;
  --bg: #0a0a12;
  --card-bg: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.08);
  --panel-bg: rgba(12,10,26,0.55);
  --panel-border: rgba(255,255,255,0.07);
  --panel-header-border: rgba(255,255,255,0.06);
  --track-hover: rgba(255,255,255,0.05);
  --track-active: rgba(167,139,250,0.12);
  --slider-track: rgba(255,255,255,0.1);
  --slider-thumb: #fff;
  --art-ph-bg: linear-gradient(135deg, #1e1b4b, #0f172a);
  --art-ph-color: rgba(255,255,255,0.15);
  --q-thumb-bg: linear-gradient(135deg, #1e1b4b, #0f172a);
  --q-thumb-color: rgba(255,255,255,0.2);
  --overlay-bg: rgba(0,0,0,0.88);
}

body.light {
  --glow: #7c3aed;
  --glow2: #6d28d9;
  --text: rgba(15,10,30,0.88);
  --sub: rgba(15,10,30,0.4);
  --bg: #e9e4f8;
  --card-bg: rgba(255,255,255,0.55);
  --card-border: rgba(124,58,237,0.18);
  --panel-bg: rgba(245,242,255,0.55);
  --panel-border: rgba(124,58,237,0.14);
  --panel-header-border: rgba(15,10,30,0.07);
  --track-hover: rgba(124,58,237,0.07);
  --track-active: rgba(124,58,237,0.13);
  --slider-track: rgba(15,10,30,0.1);
  --slider-thumb: #7c3aed;
  --art-ph-bg: linear-gradient(135deg, #ddd6fe, #c4b5fd);
  --art-ph-color: rgba(124,58,237,0.35);
  --q-thumb-bg: linear-gradient(135deg, #ede9fe, #ddd6fe);
  --q-thumb-color: rgba(124,58,237,0.3);
  --overlay-bg: rgba(233,228,248,0.94);
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  overflow: hidden;
  transition: background 0.4s ease;
}

/* ── light mode: hide bg-blur and particles, show gradient bg ── */
body.light #bg-blur,
body.light #particles { display: none; }

body.light {
  background: radial-gradient(ellipse at 30% 20%, #d8b4fe55 0%, transparent 55%),
              radial-gradient(ellipse at 75% 80%, #a5b4fc44 0%, transparent 50%),
              radial-gradient(ellipse at 60% 40%, #f0abfc33 0%, transparent 45%),
              linear-gradient(145deg, #ede9fe, #e0e7ff 50%, #f3e8ff);
}

body.light #player {
  box-shadow: 0 8px 40px rgba(124,58,237,0.12), 0 2px 12px rgba(124,58,237,0.08), inset 0 1px 0 rgba(255,255,255,0.7);
}

body.light #artwork-wrap {
  box-shadow: 0 0 32px rgba(124,58,237,0.2), 0 8px 24px rgba(124,58,237,0.15);
}

/* ── blurred artwork background ── */
#bg-blur {
  position: fixed;
  inset: -40px;
  background-size: cover;
  background-position: center;
  filter: blur(60px) brightness(0.35) saturate(1.6);
  transition: background-image 1.2s ease;
  z-index: 0;
}

/* ── particle canvas ── */
#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: z-index 0s;
}
#art-overlay.open ~ #particles,
body:has(#art-overlay.open) #particles { z-index: 11; }

/* ── fullscreen artwork overlay ── */
#art-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--overlay-bg);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, background 0.4s ease;
  cursor: zoom-out;
}
#art-overlay.open {
  opacity: 1;
  pointer-events: all;
}
#art-overlay-img {
  position: relative;
  z-index: 1;
  max-width: min(80vw, 80vh);
  max-height: min(80vw, 80vh);
  width: auto;
  height: auto;
  border-radius: 20px;
  box-shadow: 0 0 80px rgba(167,139,250,0.4), 0 20px 60px rgba(0,0,0,0.6);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  display: none;
}
#art-overlay.open #art-overlay-img { transform: scale(1); }
#art-overlay-placeholder {
  position: relative;
  z-index: 1;
  font-size: 120px;
  color: rgba(255,255,255,0.15);
  display: none;
}
#artwork-wrap { }

/* ── player card ── */
#player {
  position: relative;
  z-index: 2;
  width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 36px 28px 28px;
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  transform: scale(0.93);
  transition: transform 0.5s cubic-bezier(0.4,0,0.2,1), background 0.4s ease, border-color 0.4s ease;
}
#player.playing { transform: scale(1); }

/* ── artwork ── */
#artwork-wrap {
  width: 180px;
  height: 180px;
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 40px rgba(167,139,250,0.25), 0 8px 32px rgba(0,0,0,0.5);
  transition: box-shadow 0.4s;
}
#artwork { width: 100%; height: 100%; object-fit: cover; display: none; }
#artwork-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  background: var(--art-ph-bg);
  color: var(--art-ph-color);
}

/* ── track info ── */
#track-info { text-align: center; }
#track-title {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
#track-artist {
  color: var(--sub);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 3px;
}

/* ── progress ── */
#progress-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
#time-current, #time-total {
  color: var(--sub);
  font-size: 0.72rem;
  min-width: 30px;
}
#time-total { text-align: right; }

#progress-bar {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--slider-track);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}
#progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 14px;
  background: var(--slider-thumb);
  border-radius: 2px;
  box-shadow: 0 0 6px 2px var(--glow), 0 0 18px 4px rgba(167,139,250,0.5);
}

/* ── main controls ── */
#controls {
  display: flex;
  align-items: center;
  gap: 32px;
}
#controls button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sub);
  font-size: 1rem;
  padding: 4px;
  transition: color 0.2s, text-shadow 0.2s;
  line-height: 1;
}
#controls button:hover {
  color: var(--text);
  text-shadow: 0 0 12px var(--glow), 0 0 24px var(--glow2);
}
#btn-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 2.4rem;
  height: 2rem;
  color: var(--text) !important;
  text-shadow: 0 0 16px var(--glow), 0 0 32px var(--glow2);
}
#btn-play:hover {
  text-shadow: 0 0 24px var(--glow), 0 0 48px var(--glow2), 0 0 64px var(--glow) !important;
}
.play-icon { font-size: 1.6rem; }
.pause-bar {
  display: inline-block;
  width: 3px;
  height: 18px;
  background: currentColor;
  border-radius: 2px;
}

/* ── secondary controls ── */
#secondary-controls {
  display: flex;
  align-items: center;
  gap: 24px;
}
#secondary-controls button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sub);
  font-size: 1.05rem;
  padding: 4px;
  transition: color 0.2s, text-shadow 0.2s;
  line-height: 1;
  position: relative;
}
#secondary-controls button:hover {
  color: var(--text);
  text-shadow: 0 0 10px var(--glow);
}
#secondary-controls button.active {
  color: var(--glow);
  text-shadow: 0 0 10px var(--glow), 0 0 22px var(--glow2);
}
#secondary-controls button.active::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 6px var(--glow);
}

/* ── volume ── */
#volume-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
#vol-icon { color: var(--sub); font-size: 0.85rem; }
#volume {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--slider-track);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}
#volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 2px;
  height: 12px;
  background: var(--slider-thumb);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--glow), 0 0 14px rgba(167,139,250,0.6);
}

/* ── upload label ── */
#upload-label {
  color: var(--sub);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: color 0.2s, text-shadow 0.2s;
}
#upload-label:hover {
  color: var(--text);
  text-shadow: 0 0 10px var(--glow);
}

/* ── side panels shared ── */
#panel-lyrics,
#panel-queue {
  position: absolute;
  top: 0;
  transform: scaleX(0.92);
  width: var(--panel-w);
  height: 100%;
  z-index: 5;
  background: var(--panel-bg);
  backdrop-filter: blur(28px);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.4,0,0.2,1), background 0.4s ease, border-color 0.4s ease;
}
#panel-lyrics { right: calc(100% + 16px); transform-origin: right center; }
#panel-queue  { left: calc(100% + 16px);  transform-origin: left center; }

#panel-lyrics.open,
#panel-queue.open {
  opacity: 1;
  pointer-events: all;
  transform: scaleX(1);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--panel-header-border);
  flex-shrink: 0;
}
.panel-close {
  background: none;
  border: none;
  color: var(--sub);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  transition: color 0.2s;
}
.panel-close:hover { color: var(--text); }

/* ── queue list ── */
#queue-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(167,139,250,0.3) transparent;
}
#queue-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 10px;
  margin: 0 6px;
}
#queue-list li:hover { background: var(--track-hover); }
#queue-list li.active { background: var(--track-active); }
#queue-list li.active .q-title { color: var(--glow); }

.q-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--q-thumb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--q-thumb-color);
  overflow: hidden;
}
.q-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.q-num { color: var(--sub); font-size: 0.7rem; min-width: 18px; text-align: right; }
.q-info { flex: 1; overflow: hidden; }
.q-title {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.q-artist {
  color: var(--sub);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── lyrics panel ── */
#lyrics-input, #lyrics-display { user-select: text; }

#lyrics-input {
  display: none;
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 12px 16px;
  resize: none;
  font-family: inherit;
}
#lyrics-display {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  color: var(--text);
  opacity: 0.8;
  font-size: 0.82rem;
  line-height: 1.9;
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(167,139,250,0.3) transparent;
}
#lyrics-display:empty::before {
  content: 'No lyrics yet — click edit to paste them.';
  color: var(--sub);
  font-style: italic;
}
#lyrics-edit-btn {
  flex-shrink: 0;
  margin: 0 16px 12px;
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.2);
  border-radius: 10px;
  color: var(--glow);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.04em;
  font-family: inherit;
}
#lyrics-edit-btn:hover { background: rgba(167,139,250,0.2); }

/* ── mobile tap ripple ── */
.tap-ripple {
  position: fixed;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  background: rgba(167,139,250,0.35);
  box-shadow: 0 0 12px 4px rgba(167,139,250,0.3);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(0);
  animation: tap-ripple 0.5s ease-out forwards;
}
@keyframes tap-ripple {
  to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
body.light .tap-ripple {
  background: rgba(124,58,237,0.25);
  box-shadow: 0 0 12px 4px rgba(124,58,237,0.2);
}

/* ── mobile: panels overlap the player ── */
@media (max-width: 600px) {
  #player { width: 92vw; }

  #panel-lyrics,
  #panel-queue {
    left: 0; right: 0; top: 0;
    width: 100%; height: 100%;
    border-radius: 28px;
    transform: translateY(6%) scale(0.97);
    transform-origin: center bottom;
  }
  #panel-lyrics.open,
  #panel-queue.open { transform: translateY(0) scale(1); }

  .panel-close { font-size: 1rem; padding: 6px 10px; color: var(--text); }
}
