:root {
  --bg: #03040a;
  --panel: rgba(12, 16, 28, 0.55);
  --panel-strong: rgba(10, 14, 26, 0.82);
  --border: rgba(150, 165, 220, 0.14);
  --border-strong: rgba(180, 195, 245, 0.26);
  --text: #e9edff;
  --text-dim: #9aa4c8;
  --text-mute: #666f92;
  --accent: #a18aff;
  --accent-2: #6ea8ff;
  --danger: #ff7a90;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --blur: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

button:focus-visible,
[role="slider"]:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ------------- Scene ------------- */
.scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.6s var(--ease);
}
.scene.is-ready { opacity: 1; }

/* ------------- Intro ------------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1400px 900px at 50% 65%, rgba(120, 100, 255, 0.14), transparent 65%),
    radial-gradient(900px 700px at 20% 15%, rgba(90, 150, 255, 0.10), transparent 60%),
    radial-gradient(800px 500px at 85% 90%, rgba(160, 110, 255, 0.10), transparent 65%),
    linear-gradient(180deg, #02030a 0%, #05070f 100%);
  transition: opacity 1.1s var(--ease), visibility 1.1s var(--ease);
}
.intro.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro__inner {
  text-align: center;
  padding: 32px;
  max-width: 440px;
}

.intro__logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.intro__dot,
.brand__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 22px 5px rgba(161, 138, 255, 0.55);
  animation: pulse 4s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

.intro__name {
  font-size: 26px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 300;
}

.intro__sub {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  margin: 0 0 42px;
}

.intro__status {
  min-height: 18px;
  margin: 18px 0 0;
  font-size: 12.5px;
  color: var(--text-mute);
  letter-spacing: 0.05em;
}
.intro__status.is-error { color: var(--danger); }

.intro__hint {
  margin: 22px 0 0;
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 30px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(161, 138, 255, 0.18), rgba(110, 168, 255, 0.06));
  color: var(--text);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  transition: transform 0.35s var(--ease), background 0.35s var(--ease), border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(200, 210, 255, 0.42);
  background: linear-gradient(180deg, rgba(161, 138, 255, 0.3), rgba(110, 168, 255, 0.12));
  box-shadow: 0 10px 50px -12px rgba(161, 138, 255, 0.6);
}
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: 0.6; cursor: default; }

/* ------------- Topbar ------------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}
.topbar.is-visible { opacity: 1; transform: none; }

.topbar__left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand__name {
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.spaceTag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  color: var(--text-dim);
  font-size: 11.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.spaceTag__icon { display: inline-flex; color: var(--accent); }

/* ------------- Now playing ------------- */
.nowplaying {
  position: fixed;
  left: 44px;
  top: 50%;
  z-index: 6;
  max-width: 340px;
  opacity: 0;
  transform: translate(-10px, -50%);
  transition: opacity 1.1s var(--ease) 0.25s, transform 1.1s var(--ease) 0.25s;
  pointer-events: none;
}
.nowplaying.is-visible {
  opacity: 1;
  transform: translate(0, -50%);
}

.nowplaying__art {
  width: 168px;
  height: 168px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  background: linear-gradient(140deg, rgba(161, 138, 255, 0.18), rgba(18, 22, 40, 0.6));
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9), 0 0 40px -12px rgba(161, 138, 255, 0.25);
  position: relative;
}
.nowplaying__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nowplaying__artPlaceholder {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120px 80px at 30% 30%, rgba(161, 138, 255, 0.45), transparent 70%),
    radial-gradient(140px 100px at 80% 80%, rgba(110, 168, 255, 0.4), transparent 70%),
    radial-gradient(100px 70px at 60% 20%, rgba(255, 255, 255, 0.08), transparent 70%);
  animation: artPulse 8s ease-in-out infinite;
}
@keyframes artPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
}

.nowplaying__title {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
  line-height: 1.25;
}
.nowplaying__artist {
  margin: 0;
  color: var(--text-dim);
  font-size: 12.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ------------- Playlist ------------- */
.playlist {
  position: fixed;
  top: 70px;
  bottom: 130px;
  right: 22px;
  width: 320px;
  max-width: calc(100vw - 44px);
  z-index: 9;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: 0 30px 90px -30px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.4s var(--ease);
}

.playlist__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.playlist__list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(161, 138, 255, 0.3) transparent;
}
.playlist__list::-webkit-scrollbar { width: 6px; }
.playlist__list::-webkit-scrollbar-thumb { background: rgba(161, 138, 255, 0.24); border-radius: 6px; }

.track {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
  color: var(--text-dim);
}
.track:hover { background: rgba(161, 138, 255, 0.08); color: var(--text); }
.track.is-current { color: var(--text); background: rgba(161, 138, 255, 0.12); }
.track__idx { font-size: 11.5px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.track__meta { min-width: 0; }
.track__title {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track__artist {
  font-size: 11.5px;
  color: var(--text-mute);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track__bar {
  display: none;
  gap: 2px;
  align-items: flex-end;
  height: 14px;
}
.track.is-current .track__bar { display: inline-flex; }
.track.is-current .track__idx { display: none; }
.track__bar i {
  display: block;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  animation: bars 1.2s ease-in-out infinite;
}
.track__bar i:nth-child(1) { animation-delay: -0.2s; height: 40%; }
.track__bar i:nth-child(2) { animation-delay: -0.5s; height: 90%; }
.track__bar i:nth-child(3) { animation-delay: -0.8s; height: 60%; }
@keyframes bars {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

.playlist__empty {
  padding: 20px;
  font-size: 12.5px;
  color: var(--text-mute);
  text-align: center;
  margin: 0;
}

/* ------------- Player ------------- */
.player {
  position: fixed;
  left: 22px;
  right: 22px;
  bottom: 18px;
  z-index: 10;
  padding: 14px 18px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(var(--blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
  box-shadow: 0 24px 80px -30px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 1s var(--ease) 0.35s, transform 1s var(--ease) 0.35s, bottom 0.5s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.player.is-visible { opacity: 1; transform: none; }
.player.is-collapsed {
  bottom: 14px;
  left: auto;
  right: 66px;
  padding: 10px 14px;
  width: auto;
}
.player.is-collapsed .player__progress,
.player.is-collapsed .player__volume,
.player.is-collapsed #collapseBtn,
.player.is-collapsed #listBtn,
.player.is-collapsed #shuffleBtn,
.player.is-collapsed #repeatBtn { display: none; }

.player__progress {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 12px;
}
.time {
  font-size: 11px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
.time:last-child { text-align: right; }

.progress,
.volume {
  position: relative;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.progress__track,
.volume__track {
  position: relative;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: rgba(150, 165, 220, 0.14);
  overflow: visible;
}
.progress__fill,
.volume__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.15s linear;
}
.progress__thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text);
  transform: translate(-50%, -50%) scale(0.7);
  box-shadow: 0 0 0 0 rgba(161, 138, 255, 0);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), left 0.15s linear;
}
.progress:hover .progress__thumb,
.progress.is-active .progress__thumb {
  transform: translate(-50%, -50%) scale(1);
  box-shadow: 0 0 0 6px rgba(161, 138, 255, 0.16);
}

.player__controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.player__side {
  display: flex;
  align-items: center;
  gap: 6px;
}
.player__side--center { justify-content: center; gap: 4px; }
.player__side--right { justify-content: flex-end; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-dim);
  transition: color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--ease);
  position: relative;
}
.iconbtn:hover { color: var(--text); background: rgba(161, 138, 255, 0.1); }
.iconbtn.is-on { color: var(--accent); background: rgba(161, 138, 255, 0.14); }

.playbtn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0a0d16;
  background: var(--text);
  transition: transform 0.3s var(--ease), background 0.3s var(--ease), box-shadow 0.3s var(--ease);
  box-shadow: 0 0 0 0 rgba(161, 138, 255, 0);
}
.playbtn:hover {
  transform: scale(1.04);
  background: #fff;
  box-shadow: 0 0 0 8px rgba(161, 138, 255, 0.14);
}
.playbtn:active { transform: scale(0.97); }

.player__volume {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  max-width: 200px;
}
.player__volume .volume { flex: 1; }

/* ------------- Expand ------------- */
.expand {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.expand:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }

/* ------------- Toast ------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%) translateY(10px);
  z-index: 30;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(22, 16, 30, 0.85);
  border: 1px solid rgba(255, 122, 144, 0.35);
  color: #ffd2da;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%); }

/* ------------- Responsive ------------- */
@media (max-width: 900px) {
  .nowplaying { left: 24px; max-width: 260px; }
  .nowplaying__art { width: 132px; height: 132px; }
  .nowplaying__title { font-size: 19px; }
}

@media (max-width: 720px) {
  .nowplaying {
    top: auto;
    bottom: 150px;
    left: 50%;
    transform: translate(-50%, 0);
    text-align: center;
    width: calc(100% - 48px);
    max-width: 420px;
  }
  .nowplaying.is-visible { transform: translate(-50%, 0); }
  .nowplaying__art { margin: 0 auto 14px; width: 108px; height: 108px; }
  .nowplaying__title { font-size: 18px; }
  .nowplaying__artist { font-size: 11px; }

  .player { left: 12px; right: 12px; bottom: 12px; padding: 12px 12px 10px; gap: 8px; }
  .player.is-collapsed { right: 60px; }
  .player__progress { grid-template-columns: 36px 1fr 36px; gap: 8px; }
  .player__volume { max-width: 140px; }
  .playlist {
    top: 62px; bottom: 150px; right: 12px; left: 12px;
    width: auto; max-width: none;
  }
}

@media (max-width: 420px) {
  .player__side--left, .player__side--right { gap: 2px; }
  .iconbtn { width: 30px; height: 30px; }
  .playbtn { width: 42px; height: 42px; }
  .player__volume { max-width: 110px; }
}

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