/* ---------- Base ---------- */
:root {
  color-scheme: dark;
  --bg: #08080c;
  --panel: #121219;
  --panel-2: #171721;
  --text: #f5f3ef;
  --muted: #9d9ba8;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #ffb454;
  --accent-2: #ff6a3d;
  --accent-rgb: 255, 180, 84;
  --radius: 24px;
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(120% 70% at 50% -15%, rgba(var(--accent-rgb), 0.18), transparent 62%),
    radial-gradient(90% 60% at 110% 110%, rgba(var(--accent-rgb), 0.07), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.6s ease;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Layout ---------- */
.app {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top, 0px)) 18px calc(26px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand > div {
  min-width: 0;
}

.brand h1,
.brand p {
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.32);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.badge.is-offline {
  color: #ffc06a;
  border-color: rgba(255, 192, 106, 0.4);
  background: rgba(255, 192, 106, 0.1);
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Player card ---------- */
.player {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #16161f 0%, #101017 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.player::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 60% at 15% 0%, rgba(var(--accent-rgb), 0.13), transparent 65%);
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.art {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding: 16px 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background:
    radial-gradient(110% 130% at 8% 0%, rgba(var(--accent-rgb), 0.22), transparent 58%),
    radial-gradient(100% 120% at 100% 100%, rgba(var(--accent-rgb), 0.08), transparent 60%),
    #0c0c12;
  overflow: hidden;
}

.disc {
  position: relative;
  width: 138px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 34% 28%, #2a2a35, #0a0a0f 72%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 20px 44px rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  animation: spin 14s linear infinite;
  animation-play-state: paused;
}

body.is-playing .disc {
  animation-play-state: running;
}

.disc::after {
  content: "";
  position: absolute;
  width: 7%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #07070b;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.disc-label {
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(from 220deg, var(--accent), var(--accent-2), var(--accent));
  color: #17100a;
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.art-meta {
  min-width: 0;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.kicker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

body:not(.is-playing) .kicker-dot {
  opacity: 0.45;
  box-shadow: none;
}

#track-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.artist {
  margin: 7px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

/* ---------- Seek ---------- */
.seek {
  position: relative;
  margin-top: 16px;
  padding: 0 2px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent) 0 var(--pct, 0%),
    rgba(255, 255, 255, 0.12) var(--pct, 0%) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.22);
  transition: transform 0.15s ease;
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.22);
}

.times {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin-top: 12px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

.play-btn {
  width: 68px;
  height: 68px;
  padding: 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #17100a;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(var(--accent-rgb), 0.26);
  transition: transform 0.16s ease, box-shadow 0.25s ease;
}

.play-btn:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 18px 38px rgba(var(--accent-rgb), 0.32);
}

.play-btn:active {
  transform: scale(0.97);
}

.icon-play,
.icon-pause {
  grid-area: 1 / 1;
}

.icon-pause {
  display: none;
}

body.is-playing .icon-play {
  display: none;
}

body.is-playing .icon-pause {
  display: block;
}

/* ---------- Track list ---------- */
.tracks {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #14141c 0%, #101017 100%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
}

.section-title {
  margin: 2px 6px 10px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  text-align: left;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 15px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.track:hover {
  background: rgba(255, 255, 255, 0.04);
}

.track.is-current {
  border-color: rgba(var(--accent-rgb), 0.3);
  background: rgba(var(--accent-rgb), 0.07);
}

.track-num {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background 0.2s ease, color 0.2s ease;
}

.track.is-current .track-num {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #17100a;
}

.track-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.track-title {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.track.is-current .track-pos {
  color: var(--accent);
}

.bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
}

.track.is-playing .bars {
  display: flex;
}

.bars i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: bottom;
  animation: eq 0.9s ease-in-out infinite;
}

.bars i:nth-child(2) {
  animation-delay: 0.18s;
}

.bars i:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes eq {
  0%,
  100% {
    transform: scaleY(0.32);
  }
  50% {
    transform: scaleY(1);
  }
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
}

.storage-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.storage-note::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #ff9b9b;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.reset-btn:hover {
  background: rgba(255, 110, 110, 0.1);
}

/* ---------- Setup ---------- */
.setup {
  margin: 8px 0;
  padding: 46px 24px 40px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #16161f 0%, #101017 100%);
  box-shadow: var(--shadow);
}

.setup-disc {
  width: 74px;
  aspect-ratio: 1;
  margin: 0 auto 22px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 5px),
    conic-gradient(from 220deg, var(--accent), var(--accent-2), var(--accent));
  box-shadow: 0 16px 40px rgba(var(--accent-rgb), 0.22);
  animation: spin 3.5s linear infinite;
}

.setup h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.setup-detail {
  margin: 0 auto;
  max-width: 34ch;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

.setup-bar {
  height: 8px;
  margin: 24px auto 10px;
  max-width: 320px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.setup-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.setup-pct {
  margin: 0 0 6px;
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons / dialog / toast ---------- */
.btn {
  padding: 10px 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 550;
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn.danger {
  border-color: #e5484d;
  background: #e5484d;
  color: #fff;
}

.btn.danger:hover {
  background: #f2555a;
}

dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #16161f;
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
}

.dialog-body {
  padding: 24px;
}

dialog h2 {
  margin: 0 0 8px;
  font-size: 1.12rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

dialog p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #20202b;
  color: var(--text);
  font-size: 0.8rem;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

audio {
  display: none;
}

.noscript {
  margin: 24px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 110, 110, 0.35);
  border-radius: 14px;
  background: rgba(255, 110, 110, 0.08);
  color: #ffb3b3;
  font-size: 0.9rem;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 380px) {
  .app {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand p {
    display: none;
  }

  .brand h1 {
    font-size: 0.94rem;
  }

  .badge {
    padding: 5px 8px;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
  }

  .disc {
    width: 112px;
  }

  .art {
    gap: 15px;
    padding: 14px 12px 16px;
  }

  #track-title {
    font-size: 1.12rem;
  }

  .track {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px;
  }

  .track-num {
    width: 34px;
    height: 34px;
  }
}

@media (min-width: 900px) {
  .app {
    width: min(980px, 100%);
    padding-top: 40px;
    gap: 22px;
  }

  .layout {
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    align-items: start;
    gap: 22px;
  }

  .player {
    position: sticky;
    top: 32px;
    padding: 22px;
  }

  .disc {
    width: 160px;
  }

  #track-title {
    font-size: 1.45rem;
  }

  .art {
    padding: 22px 18px;
    min-height: 226px;
  }
}

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

  .disc,
  .setup-disc {
    animation: none !important;
  }
}
