:root {
  --bg: #14181f;
  --panel: #1d222c;
  --panel-2: #262c38;
  --line: #2e3542;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #ffb03b;
  --accent-ink: #1a1408;
  --danger: #ff6b6b;
  --radius: 14px;
  --player-h: 196px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom));
}
body.no-player { padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: currentColor; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(20, 24, 31, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: .2px; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--panel-2); }
.icon-btn.accent { background: var(--accent); color: var(--accent-ink); }
.pill { padding: 7px 14px; border-radius: 999px; background: var(--panel-2); font-size: 14px; }

/* Empty state */
.empty { padding: 48px 28px; text-align: center; color: var(--muted); }
.empty-title { color: var(--text); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 12px 22px; border-radius: 999px; }
.ghost { padding: 12px 18px; border-radius: 999px; color: var(--muted); }

/* List */
.list { list-style: none; margin: 0; padding: 8px 0; }
.track { position: relative; display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.track .main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 14px 4px 16px 16px; text-align: left; }
.track .main:active { background: var(--panel); }
.track .num { width: 26px; flex: none; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.track .meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.track .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.track .more { width: 48px; flex: none; color: var(--muted); display: grid; place-items: center; }
.track .bar { position: absolute; left: 54px; right: 16px; bottom: 7px; height: 3px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.track .bar i { display: block; height: 100%; background: var(--muted); }
.track.done .bar i { background: #5fbf7f; }
.track.done .title { color: var(--muted); }
.track.current .title { color: var(--accent); font-weight: 600; }
.track.current .bar i { background: var(--accent); }

.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq b { width: 3px; background: var(--accent); border-radius: 1px; height: 4px; }
.playing .eq b { animation: eq 0.9s ease-in-out infinite; }
.eq b:nth-child(2) { animation-delay: .2s !important; }
.eq b:nth-child(3) { animation-delay: .4s !important; }
@keyframes eq { 0%,100% { height: 4px; } 50% { height: 14px; } }

/* Player */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0,0,0,.35);
}
.np-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.times { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.times > span { min-width: 56px; }
.times > span:last-child { text-align: right; }
.mini { display: flex; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px; background: var(--panel-2); font-size: 13px; color: var(--text); }
.chip svg { width: 14px; height: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); }

.controls { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 0 2px; }
.ctl { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; }
.ctl:active { background: var(--panel-2); }
.ctl svg { width: 30px; height: 30px; }
.ctl text { font-size: 6.5px; font-weight: 700; fill: currentColor; font-family: system-ui, sans-serif; }
.ctl.play { width: 66px; height: 66px; background: var(--accent); color: var(--accent-ink); }
.ctl.play svg { width: 34px; height: 34px; }

input[type=range] { width: 100%; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--p, 0%), var(--panel-2) var(--p, 0%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); margin-top: -6px; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--panel-2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--accent); }

/* Sheets */
dialog.sheet {
  width: 100%; max-width: 520px; margin: auto auto 0; padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
  border: 0; border-radius: 20px 20px 0 0; background: var(--panel); color: var(--text);
}
dialog.sheet::backdrop { background: rgba(0,0,0,.55); }
dialog.sheet[open] { animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 18px; margin: 0 4px 10px; overflow-wrap: anywhere; }
.sheet-item { display: block; width: 100%; text-align: left; padding: 14px 6px; border-bottom: 1px solid var(--line); font-size: 16px; }
.sheet-item:last-of-type { border-bottom: 0; }
.sheet-item.muted { color: var(--muted); text-align: center; }
.sheet-item.danger { color: var(--danger); }
.danger-bg { background: var(--danger); color: #200; }
.sheet label { display: block; font-size: 14px; color: var(--muted); margin: 10px 4px; }
.sheet input[type=text], .sheet input[type=url] {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.sheet input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 4px 10px; }
.hint.small { font-size: 12px; text-align: center; margin-top: 12px; }
.label { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 14px 4px 8px; }
.row-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.grid-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.grid-btns button, .seg button { padding: 12px 6px; border-radius: 12px; background: var(--panel-2); font-size: 15px; }
.grid-btns button.on, .seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg { display: grid; gap: 8px; }
.seg button { text-align: left; padding: 12px 14px; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--player-h) + 16px + env(safe-area-inset-bottom));
  background: #f2f4f8; color: #111; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center; z-index: 20;
}
body.no-player .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
