:root {
  --bg-deep: #0a0a12;
  --bg-card: rgba(22, 22, 38, 0.72);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f8;
  --muted: #8b8b9e;
  --accent: #7c5cff;
  --accent-dim: #5a3fd9;
  --glow: rgba(124, 92, 255, 0.35);
  --radius: 20px;
  --font: system-ui, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 120% 80% at 10% -20%, rgba(124, 92, 255, 0.25), transparent 50%),
    radial-gradient(ellipse 100% 60% at 100% 0%, rgba(56, 189, 248, 0.12), transparent 45%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(236, 72, 153, 0.08), transparent 40%);
  background-attachment: fixed;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vw, 40px);
  padding-bottom: 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom, 0px));
  padding-left: max(clamp(16px, 4vw, 40px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 4vw, 40px), env(safe-area-inset-right, 0px));
  padding-top: max(clamp(16px, 4vw, 40px), env(safe-area-inset-top, 0px));
}

.app {
  width: min(920px, 100%);
  display: grid;
  gap: 24px;
}

header {
  text-align: center;
}

header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.header-note a {
  color: var(--accent);
  text-decoration: none;
}

.header-note a:hover {
  text-decoration: underline;
}

header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 768px) {
  html,
  body {
    background-attachment: scroll;
  }

  body {
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }

  .app {
    width: 100%;
    max-width: 100%;
    gap: 14px;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  header h1 {
    font-size: clamp(1.35rem, 5.5vw, 1.75rem);
  }

  .player-card {
    border-radius: 16px;
    padding: 16px 14px 18px;
  }

  .cover-wrap {
    max-width: min(260px, 78vw);
    margin-bottom: 16px;
    border-radius: 14px;
  }

  .cover-placeholder {
    font-size: clamp(2.25rem, 14vw, 3.25rem);
  }

  .track-meta {
    margin-bottom: 14px;
  }

  .track-meta h2 {
    font-size: 1.05rem;
    padding-inline: 4px;
  }

  .track-meta .artist {
    font-size: 0.88rem;
  }

  .progress-row {
    gap: 10px;
    align-items: center;
    min-height: 44px;
  }

  .time {
    font-size: 0.7rem;
    min-width: 2.35rem;
  }

  .progress {
    height: 10px;
    border-radius: 999px;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }

  .controls {
    gap: 10px 14px;
    margin-top: 16px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .btn {
    width: 52px;
    height: 52px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .btn.primary {
    width: 70px;
    height: 70px;
  }

  .btn svg {
    width: 24px;
    height: 24px;
  }

  .btn.primary svg {
    width: 30px;
    height: 30px;
  }

  .volume-row {
    max-width: none;
    width: 100%;
    margin-top: 18px;
    padding-inline: 4px;
    gap: 10px;
  }

  .volume-row input[type="range"] {
    height: 8px;
  }

  .volume-row input[type="range"]::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }

  .volume-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .sidebar {
    padding: 16px 14px;
    border-radius: 16px;
    min-height: 0;
    max-height: min(52svh, 420px);
  }

  .sidebar h3 {
    margin-bottom: 12px;
  }

  .add-local {
    margin-bottom: 12px;
  }

  .add-local label {
    min-height: 48px;
    padding: 14px 12px;
    font-size: 0.92rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .playlist {
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .playlist li {
    padding: 12px 10px;
    min-height: 52px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .playlist .thumb {
    width: 48px;
    height: 48px;
  }

  .playlist .info .t {
    font-size: 0.92rem;
  }

  .playlist .info .a {
    font-size: 0.78rem;
  }

  footer {
    font-size: 0.72rem;
    line-height: 1.45;
    padding-inline: 4px;
    margin-top: 4px;
  }

  .footer-hint {
    display: block;
    margin-top: 4px;
    opacity: 0.9;
  }
}

@media (max-width: 380px) {
  .controls {
    gap: 8px 10px;
  }

  .btn {
    width: 48px;
    height: 48px;
  }

  .btn.primary {
    width: 64px;
    height: 64px;
  }
}

.player-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 32px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.cover-wrap {
  position: relative;
  aspect-ratio: 1;
  max-width: 320px;
  margin: 0 auto 24px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px var(--glow), 0 8px 24px rgba(0, 0, 0, 0.4);
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.player-card.playing .cover-wrap img,
.player-card.playing .cover-placeholder {
  transform: scale(1.03);
}

.cover-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    145deg,
    hsl(var(--art-hue, 268), 52%, 42%),
    hsl(calc(var(--art-hue, 268) + 32), 38%, 16%) 55%,
    #0d0d18
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  opacity: 0.95;
  transition: transform 0.5s ease;
}

.track-meta {
  text-align: center;
  margin-bottom: 20px;
}

.track-meta h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.track-meta .artist {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 2.5rem;
}

.time.end {
  text-align: right;
}

.progress {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 999px;
  pointer-events: none;
  transition: width 0.08s linear;
}

.progress:hover .progress-fill,
.progress:focus-visible .progress-fill {
  box-shadow: 0 0 12px var(--glow);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn:active {
  transform: scale(0.96);
}

.btn.primary {
  width: 64px;
  height: 64px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  box-shadow: 0 8px 32px var(--glow);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn svg {
  width: 22px;
  height: 22px;
}

.btn.primary svg {
  width: 28px;
  height: 28px;
}

.btn.active {
  color: var(--accent);
  background: rgba(124, 92, 255, 0.2);
}

.volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.volume-row svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.volume-row input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

.volume-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.volume-row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  cursor: pointer;
}

.sidebar {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  max-height: min(560px, 70vh);
  display: flex;
  flex-direction: column;
}

.sidebar h3 {
  margin: 0 0 16px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.add-local {
  margin-bottom: 16px;
}

.add-local label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.add-local label:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(124, 92, 255, 0.08);
}

.add-local input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.playlist {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.playlist li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.playlist li:hover {
  background: rgba(255, 255, 255, 0.06);
}

.playlist li.active {
  background: rgba(124, 92, 255, 0.18);
  border-color: rgba(124, 92, 255, 0.35);
}

.playlist .thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
  background: #1a1a2e;
}

.playlist img.thumb {
  object-fit: cover;
}

.playlist .thumb.thumb-art {
  background: linear-gradient(
    135deg,
    hsl(var(--hue, 260), 48%, 44%),
    hsl(calc(var(--hue, 260) + 38), 42%, 20%)
  );
}

.playlist .info {
  min-width: 0;
  flex: 1;
}

.playlist .info .t {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist .info .a {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 8px;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}
