:root {
  --bg: #0f1012;
  --surface: #1a1c20;
  --surface-2: #24272c;
  --text: #f2f3f5;
  --muted: #9aa0a8;
  --accent: #3e8bff;
  --hires: #e8b54a;
  --danger: #ff6b6b;
  --radius: 10px;
  --player-h: 128px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { width: 28px; height: 28px; fill: currentColor; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  height: 72px; padding: 0 16px;
  background: rgba(15, 16, 18, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--surface-2);
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a {
  padding: 12px 20px; border-radius: 999px;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.tabs a.active { background: var(--surface-2); color: var(--text); }
.quality-pill {
  font-size: 14px; font-weight: 700; color: var(--hires);
  border: 1px solid currentColor; border-radius: 999px; padding: 4px 12px; white-space: nowrap;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; height: 56px; padding: 0 12px;
  border: 0; border-radius: 999px; background: transparent; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; }

/* --- views --- */
main {
  padding: 16px 24px calc(var(--player-h) + 32px);
  max-width: 1600px; margin: 0 auto;
}
h2 { font-size: 24px; margin: 28px 0 14px; }
.empty, .loading, .error-box { color: var(--muted); padding: 40px 0; text-align: center; }
.error-box { color: var(--danger); }

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.card { position: relative; display: block; min-width: 0; }
.card .art {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  border-radius: var(--radius); background: var(--surface);
}
.card.round .art { border-radius: 50%; }
.mosaic { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.mosaic img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.card .t { margin-top: 8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .s { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--hires); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px;
  vertical-align: middle;
}
.card .badge { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.7); }

.search-form { display: flex; gap: 12px; margin: 8px 0 8px; }
.search-form input {
  flex: 1; height: 60px; padding: 0 20px; font: inherit; font-size: 20px;
  color: var(--text); background: var(--surface); border: 1px solid var(--surface-2); border-radius: 999px;
}

.header { display: flex; gap: 28px; align-items: flex-end; margin: 12px 0 20px; }
.header .art { width: 220px; height: 220px; object-fit: cover; border-radius: var(--radius); background: var(--surface); flex: none; }
.header.round .art { border-radius: 50%; }
.header h1 { font-size: 32px; margin: 0 0 6px; }
.header .meta { color: var(--muted); }
.header .meta a { color: var(--text); font-weight: 600; }
.actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  height: 56px; padding: 0 28px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); font-weight: 700;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn:active { filter: brightness(1.2); }

.tracks { display: flex; flex-direction: column; }
.track {
  display: flex; align-items: center; gap: 16px;
  min-height: 68px; padding: 6px 8px; border-radius: var(--radius); cursor: pointer;
}
.track:active { background: var(--surface); }
.track.current { background: var(--surface); }
.track.current .tt { color: var(--accent); }
.track.disabled { opacity: .4; pointer-events: none; }
.track .n { width: 32px; text-align: right; color: var(--muted); flex: none; }
.track img { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface); }
.track .info { flex: 1; min-width: 0; }
.track .tt, .track .ts { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .ts { color: var(--muted); font-size: 15px; }
.track .d { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.track .icon-btn { flex: none; color: var(--muted); }
.disc { color: var(--muted); font-weight: 700; margin: 16px 8px 4px; }

.settings label {
  display: flex; align-items: center; gap: 16px;
  min-height: 72px; padding: 0 16px; margin-bottom: 8px;
  background: var(--surface); border-radius: var(--radius); cursor: pointer;
}
.settings input[type=radio] { width: 26px; height: 26px; accent-color: var(--accent); }
.settings .s { color: var(--muted); font-size: 15px; }
.note { color: var(--muted); font-size: 15px; max-width: 60em; }

/* --- player --- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: var(--player-h);
  background: var(--surface); border-top: 1px solid var(--surface-2);
}
#seek {
  -webkit-appearance: none; appearance: none;
  position: absolute; left: 0; right: 0; top: -14px; width: 100%; height: 28px;
  margin: 0; background: transparent; cursor: pointer;
}
#seek::-webkit-slider-runnable-track {
  height: 6px; background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--surface-2) var(--pct, 0%));
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px;
  border-radius: 50%; background: var(--text);
}
.player-row {
  display: flex; align-items: center; gap: 16px;
  height: 100%; padding: 12px 24px 8px;
}
.now { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.now img { width: 84px; height: 84px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; }
.now img:not([src]) { visibility: hidden; }
.now > div { min-width: 0; }
.now-title { font-weight: 700; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-sub { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls { display: flex; align-items: center; gap: 8px; }
.controls svg { width: 36px; height: 36px; }
.icon-btn.play { width: 80px; height: 80px; background: var(--text); color: var(--bg); }
.icon-btn.play svg { width: 44px; height: 44px; }
.time { width: 150px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.player.buffering .icon-btn.play { opacity: .6; }

/* --- login --- */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { display: flex; flex-direction: column; gap: 16px; width: min(420px, 90vw); }
.login h1 { text-align: center; }
.login input {
  height: 64px; padding: 0 20px; font: inherit; font-size: 20px; color: var(--text);
  background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius);
}
.login button { height: 64px; border: 0; border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.login .error { color: var(--danger); text-align: center; margin: 0; }

@media (max-width: 760px) {
  main { padding: 12px 16px calc(var(--player-h) + 24px); }
  .header { flex-direction: column; align-items: flex-start; }
  .header .art { width: 160px; height: 160px; }
  .time { display: none; }
  .now img { width: 60px; height: 60px; }
  .icon-btn.play { width: 64px; height: 64px; }
}
