:root {
  --bg: #0e0f13;
  --bg2: #15171d;
  --card: #1a1c23;
  --card2: #22252e;
  --line: #2b2e38;
  --text: #f2f0ec;
  --muted: #9a9ca6;
  --faint: #6b6e7a;
  --accent: #ff7a3d;
  --accent2: #ffc24b;
  --good: #5fd38d;
  --bad: #ff5f6d;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
img { display: block; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(14, 15, 19, .88); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand img { border-radius: 8px; }
.top-right { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }

.view { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); outline: none; }
.loading { display: grid; place-items: center; min-height: 40vh; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(21, 23, 29, .96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 10px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.tabs a .ti { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--text); }
.tabs a.on .ti { filter: none; opacity: 1; }
.tabs .badge { position: absolute; }

h1 { font-size: 26px; letter-spacing: -.02em; margin: 6px 0 4px; }
h2 { font-size: 18px; margin: 28px 0 10px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 14px; font-size: 14px; line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card2); font-weight: 650; text-decoration: none; font-size: 15px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0d05; }
.btn.spotify { background: #1ed760; border-color: #1ed760; color: #08130c; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack > * + * { margin-top: 12px; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2);
}
textarea { min-height: 60px; resize: vertical; }

/* week */
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.week-nav { display: flex; gap: 6px; }
.week-nav button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.week-nav button:disabled { opacity: .35; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 9px; font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.stat b { display: block; color: var(--text); font-size: 18px; }

.banner { display: flex; gap: 12px; align-items: center; background: linear-gradient(135deg, rgba(255,122,61,.16), rgba(255,194,75,.08)); border: 1px solid rgba(255,122,61,.35); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.4; }
.banner .grow { flex: 1; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .4s; }

.release { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.rel-head { display: flex; gap: 12px; padding: 12px; align-items: center; }
.rel-head img { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--card2); flex: none; }
.rel-title { font-weight: 750; font-size: 16px; line-height: 1.25; }
.rel-artist { color: var(--muted); font-size: 14px; margin-top: 2px; }
.rel-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); letter-spacing: .01em; white-space: nowrap; }
.pill.new { background: rgba(95,211,141,.14); color: var(--good); }
.pill.pre { background: rgba(255,194,75,.13); color: var(--accent2); }
.pill.known { background: rgba(130,150,255,.14); color: #a9b6ff; }
.pill.hl { background: rgba(255,122,61,.16); color: var(--accent); }
.pill.disc { background: rgba(200,120,255,.15); color: #d6a6ff; }

.tracks { border-top: 1px solid var(--line); }
.track { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; width: 100%; text-align: left; background: none; border-bottom: 1px solid rgba(255,255,255,.04); }
.track:last-child { border-bottom: 0; }
.track:active { background: var(--card2); }
.track .no { width: 22px; color: var(--faint); font-size: 13px; text-align: right; flex: none; }
.track .tt { flex: 1; min-width: 0; }
.track .tn { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .ta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.track .tags { display: flex; gap: 4px; flex: none; align-items: center; }
.track.dim .tn { color: var(--muted); font-weight: 500; }
.track img.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--card2); }
.rated { font-size: 18px; flex: none; }
.more { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; padding: 10px; color: var(--muted); font-size: 13px; font-weight: 650; }
.reason { color: var(--accent2); font-size: 12.5px; margin-top: 3px; white-space: normal; line-height: 1.35; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* rating form */
.rate-head { display: flex; gap: 14px; align-items: center; }
.rate-head img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--card2); flex: none; }
.rate-head .t1 { font-size: 19px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
.rate-head .t2 { color: var(--muted); margin-top: 3px; font-size: 14px; }
.rate-head .t3 { margin-top: 6px; display: flex; gap: 5px; flex-wrap: wrap; }
.embed { width: 100%; height: 80px; border: 0; border-radius: 12px; margin-top: 14px; background: var(--card2); }
.player-row { display: flex; gap: 8px; margin-top: 8px; }
.player-row .btn { flex: 1; }
.lbl { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }
.overall { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.overall button { border: 1px solid var(--line); background: var(--bg2); border-radius: 14px; padding: 12px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 650; color: var(--muted); }
.overall button .e { font-size: 26px; }
.overall button.on { border-color: var(--accent); background: rgba(255,122,61,.14); color: var(--text); }
.overall button.on[data-v="0"] { border-color: var(--bad); background: rgba(255,95,109,.12); }
.overall button.on[data-v="3"] { border-color: var(--accent2); background: rgba(255,194,75,.14); }
.subs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .subs { grid-template-columns: 1fr; } }
.sub-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 3px 4px 3px 12px; font-size: 14px; font-weight: 600; }
.sub-row .tb { display: flex; gap: 4px; }
.sub-row button { width: 40px; height: 30px; border-radius: 9px; border: 1px solid transparent; background: transparent; font-size: 17px; opacity: .45; }
.sub-row button.on { opacity: 1; background: var(--card2); border-color: var(--line); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--bg2); border-radius: 999px; padding: 9px 13px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chip.on { border-color: var(--accent); color: var(--text); background: rgba(255,122,61,.14); }
.like { border: 1px solid var(--line); background: var(--bg2); border-radius: 999px; padding: 9px 13px; font-size: 14px; font-weight: 600; color: var(--muted); }
.like.on { border-color: #1ed760; color: #1ed760; background: rgba(30,215,96,.1); }
.save-row { display: flex; gap: 8px; margin-top: 18px; }
.save-row .btn.primary { flex: 1; padding: 14px; font-size: 16px; }

/* queue */
.queue-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--bg2); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line); padding: 10px 16px calc(18px + var(--safe-b)); max-width: 720px; margin: 0 auto; animation: up .22s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

.toast { position: fixed; left: 50%; bottom: calc(88px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; width: max-content; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* profile */
.md p { margin: 0 0 10px; line-height: 1.5; }
.md ul { margin: 0 0 10px; padding-left: 20px; line-height: 1.5; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; font-size: 14px; }
.bar .tr { height: 10px; background: var(--bg2); border-radius: 5px; overflow: hidden; }
.bar .tr i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.links a { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-weight: 600; }
.links a:last-child { border-bottom: 0; }
.links a span { color: var(--muted); font-weight: 500; font-size: 13px; }
.log { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.log div { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.log b { color: var(--text); font-weight: 600; }
.ok-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; }
.no-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; }

.hero { text-align: center; padding: 40px 8px 10px; }
.hero img { margin: 0 auto 18px; border-radius: 24px; }
.hero h1 { font-size: 30px; }
.hero p { color: var(--muted); line-height: 1.5; max-width: 440px; margin: 10px auto 24px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; line-height: 1.4; }

@media (min-width: 640px) {
  .view { padding-top: 24px; }
}

.linkbtn { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; font-size: inherit; }
.pair { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.pair .qr { width: 170px; height: 170px; background: #fff; border-radius: 10px; padding: 4px; flex: none; }
.pair .qr svg { width: 100%; height: 100%; display: block; }
.pair .code { font-size: 30px; font-weight: 800; letter-spacing: .08em; margin: 6px 0; font-variant-numeric: tabular-nums; }
