:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f4f5f7;
  --line: #e5e7eb;
  --fg: #181b20;
  --muted: #646b76;
  --accent: #1d5dd8;
  --active-bg: #eef4ff;
  --on-accent: #ffffff;
  --player-h: 100px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #1c1f23;
    --line: #2c3036;
    --fg: #f1f3f5;
    --muted: #a1a8b2;
    --accent: #8ab4ff;
    --active-bg: #19263b;
    --on-accent: #111315;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, .grip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 56px 24px calc(var(--player-h) + env(safe-area-inset-bottom) + 32px);
}
.masthead { margin-bottom: 30px; }
.masthead h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -.035em;
}
.sub { margin: 10px 0 0; color: var(--muted); font-size: 14px; }

.deck { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.card {
  position: relative;
  display: grid;
  grid-template-columns: 28px 24px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 14px;
  min-height: 82px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  touch-action: pan-y;
}
.card.playing { background: var(--active-bg); }
.card.dragging { background: var(--surface); outline: 1px solid var(--accent); }
.card.drag-placeholder { opacity: .25; }
.grip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 44px;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  border-radius: 4px;
}
.grip:active { cursor: grabbing; }
.grip svg { width: 16px; height: 16px; }
.idx { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.card.playing .idx, .card.playing .title { color: var(--accent); }
.meta { min-width: 0; }
.title {
  display: block;
  font-size: 15px;
  font-weight: 550;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.len { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.play-mini {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}
.card.playing .play-mini { color: var(--accent); }
.play-mini svg { width: 20px; height: 20px; }
.play-mini .i-play { transform: translateX(1px); }
.play-mini .i-pause { display: none; }
.card.is-playing .play-mini .i-play { display: none; }
.card.is-playing .play-mini .i-pause { display: block; }
.hint { margin: 22px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.player[data-empty="true"] { display: none; }
.progress { position: relative; height: 4px; background: var(--line); cursor: pointer; }
.progress-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--accent); }
.seek {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 24px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.progress:has(.seek:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 660px;
  margin: 0 auto;
  padding: 16px 24px;
}
.np { flex: 1; min-width: 0; }
.np-title { font-size: 14px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-time { margin-top: 5px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.np-time .sep { margin: 0 3px; }
.controls { display: flex; align-items: center; gap: 6px; }
.ctl {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.ctl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ctl .lbl { font-size: 10px; }
.ctl.toggle[aria-pressed="true"], #shuffleBtn.pulse { color: var(--accent); }
.ctl.play { width: 46px; height: 46px; margin-left: 6px; padding: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.ctl.play svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.ctl.play .i-play { transform: translateX(1px); }
.ctl.play .i-pause { display: none; }
.player.is-playing .ctl.play .i-play { display: none; }
.player.is-playing .ctl.play .i-pause { display: block; }

@media (hover: hover) {
  .play-mini:hover, .ctl:not(.play):hover { background: var(--surface); }
  .ctl.play:hover { opacity: .85; }
}
@media (max-width: 420px) {
  .wrap { padding: 32px 16px calc(var(--player-h) + env(safe-area-inset-bottom) + 24px); }
  .card { grid-template-columns: 24px 20px minmax(0, 1fr) 44px; gap: 8px; padding-inline: 4px; }
  .grip { width: 24px; }
  .player-row { padding: 16px; gap: 8px; }
  .controls { gap: 2px; }
  .ctl.play { margin-left: 2px; }
}
