:root {
  --bg: #08080b;
  --panel: #121218;
  --panel-2: #1a1a22;
  --line: #2a2a35;
  --text: #f2f2f5;
  --muted: #9a9aab;
  --accent: #e8ff3c;
  --accent-ink: #0b0b00;
  --a: #ff4d6d;
  --b: #4dd2ff;
  --up: #4ade80;
  --down: #f87171;
  --danger: #ff5a4d;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 'Space Grotesk', system-ui, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 34px; line-height: 1.1; margin: 0 0 10px; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 10px; }
.lede { color: var(--muted); font-size: 17px; margin: 0 0 20px; max-width: 760px; }
.hint { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.section-h { margin-top: 28px; }
.share-hint { margin-top: 28px; }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 24px; background: rgba(8,8,11,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { background: none; border: 0; padding: 4px 0; font-weight: 700; font-size: 18px; white-space: nowrap; color: var(--text); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#brand-artist { color: var(--accent); margin-left: 4px; }
nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 999px; font: inherit; cursor: pointer; white-space: nowrap; }
nav button.on { background: var(--panel-2); color: var(--text); }

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }
.view.narrow { max-width: 720px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1 1 200px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

input, button, select, textarea { font: inherit; }
input[type=search], input:not([type]), input[type=number], select, textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; min-width: 0;
}
textarea { width: 100%; resize: vertical; min-height: 70px; }
input:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { cursor: pointer; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
button:disabled { opacity: .4; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.ghost:hover:not(:disabled) { border-color: var(--muted); }
.big { padding: 14px 22px; font-size: 17px; }
.small { padding: 4px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--muted); padding: 4px; font-size: 13px; text-decoration: underline; }
.link:hover { color: var(--text); }
.danger { border-color: #4a2320; }
.danger-btn { background: transparent; color: var(--danger); border-color: var(--danger); }
.filebtn { display: inline-block; cursor: pointer; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line); background: var(--panel-2); }
kbd { font: 11px/1 ui-monospace, monospace; padding: 2px 5px; border: 1px solid currentColor; border-radius: 4px; opacity: .6; margin-left: 4px; }
details > summary { cursor: pointer; color: var(--muted); }
label.inline { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
label.inline input { width: 80px; }

.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#toast.err { border-color: var(--danger); }

/* Home */
#artist-search { width: 100%; margin: 4px 0 8px; font-size: 17px; padding: 14px 16px; }
#import-card { margin-top: 16px; border-color: #4b5216; }

/* Setup */
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.preset { text-align: left; padding: 12px 14px; }
.preset b { display: block; }
.preset span { color: var(--muted); font-size: 13px; }
.preset.on { border-color: var(--accent); background: rgba(232,255,60,.07); }
.filters { display: flex; flex-direction: column; gap: 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px 24px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.field select, .field input:not([type]) { width: 100%; }
.field .row select { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 12px; font-size: 14px; border-radius: 999px; color: var(--muted); }
.chips button .hint { font-size: 12px; }
.chips button.on { border-color: var(--accent); color: var(--text); background: rgba(232,255,60,.1); }
.album-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.album-chips button { display: flex; gap: 8px; align-items: center; text-align: left; padding: 6px; font-size: 13px; line-height: 1.25; }
.album-chips img { width: 40px; height: 40px; border-radius: 6px; flex: none; }
.album-chips button.on { border-color: var(--accent); background: rgba(232,255,60,.08); }
.album-chips .hint { display: block; font-size: 11px; }
.pool-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.pool-head h2 { font-size: 24px; margin: 0; }
#pool-count { color: var(--accent); }
#song-search { flex: 1 1 240px; }
.list-opts { margin-top: 10px; }
.toggle { display: flex; gap: 8px; align-items: center; cursor: pointer; white-space: nowrap; }
.toggle input, .plist input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Lists */
.plist { list-style: none; padding: 0; margin: 8px 0 0; }
.plist li {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 8px 6px; border-bottom: 1px solid var(--line);
}
.plist.ranked li { grid-template-columns: 3.2ch 44px 1fr auto; }
.plist .pos { font-weight: 700; font-size: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.plist.ranked li:nth-child(-n+3) .pos { color: var(--accent); }
.plist img.cv { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--panel-2); }
.plist img.round { border-radius: 50%; }
.plist li.off { opacity: .4; }
.plist li.clickable { cursor: pointer; }
.plist li.clickable:hover { background: rgba(255,255,255,.03); }
.t-main { min-width: 0; }
.t-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-take { color: var(--text); font-size: 13px; font-style: italic; margin-top: 2px; overflow-wrap: anywhere; }
.t-right { text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.t-right b { color: var(--text); font-size: 15px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px; font-weight: 500; }
.badge.warn { border-color: #6b5a1d; color: #e5c454; }
.delta { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.same { color: var(--muted); }

/* Matchup */
.progress { margin-bottom: 18px; }
.progress-label { display: flex; gap: 14px; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; }
.progress-label span { color: var(--muted); font-size: 14px; }
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: stretch; }
.vs { align-self: center; font-weight: 700; font-size: 28px; color: var(--muted); }
.side {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; min-width: 0; transition: transform .15s, border-color .15s;
}
.side[data-side=a] { border-top: 3px solid var(--a); }
.side[data-side=b] { border-top: 3px solid var(--b); }
.side.chosen { transform: scale(1.02); border-color: var(--accent); }
.art { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--panel-2); max-height: 300px; }
.art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta h2 { font-size: 22px; margin: 0; line-height: 1.2; overflow-wrap: anywhere; }
.meta p { margin: 2px 0 0; color: var(--muted); }
.meta .record { font-size: 13px; }
.player {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.player .play { width: 52px; height: 52px; border-radius: 50%; padding: 0; display: grid; place-items: center; background: var(--text); border-color: var(--text); color: var(--bg); }
.player .play::before { content: ''; border-style: solid; border-width: 9px 0 9px 15px; border-color: transparent transparent transparent currentColor; margin-left: 4px; }
.player.playing .play::before { border-width: 0 5px; border-color: currentColor; height: 18px; width: 6px; margin: 0; }
.side[data-side=a] .player.playing .play { background: var(--a); border-color: var(--a); }
.side[data-side=b] .player.playing .play { background: var(--b); border-color: var(--b); }
.ptrack { min-width: 0; }
.pbar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; cursor: pointer; }
.pbar > div { height: 100%; width: 0; background: var(--text); }
.side[data-side=a] .pbar > div { background: var(--a); }
.side[data-side=b] .pbar > div { background: var(--b); }
.ptime { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pstatus { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plinks { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.plinks a { color: var(--muted); }
.player.empty .play { opacity: .35; cursor: not-allowed; }
.pick { width: 100%; margin-top: auto; }
.controls { display: flex; gap: 10px; justify-content: center; margin: 20px 0 8px; flex-wrap: wrap; }

/* Compare */
#cmp-pick { margin-bottom: 16px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 10px 0 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .num { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
.tile .lbl { color: var(--muted); font-size: 13px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.scatter svg { width: 100%; height: auto; display: block; }
.scatter circle { cursor: pointer; }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.side-by-side h3 { font-size: 14px; color: var(--muted); margin: 0 0 6px; font-weight: 500; }
.sbs-row { display: grid; grid-template-columns: 3ch 1fr; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sbs-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.sbs-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbs-row.match .name { color: var(--up); }
.members { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 10px; }
.members label { display: flex; gap: 6px; align-items: center; }
.members input { accent-color: var(--accent); width: 18px; height: 18px; }
table.matrix { border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.matrix th, table.matrix td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; }
table.matrix th:first-child { text-align: left; }
.takes { list-style: none; padding: 0; margin: 0; }
.takes li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.takes q { font-style: italic; }

/* Share */
.img-wrap { margin: 14px 0; background: var(--panel-2); border-radius: 12px; min-height: 200px; display: grid; place-items: center; overflow: hidden; }
.img-wrap img { width: 100%; height: auto; display: block; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--panel-2); padding: 8px 14px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.steps ol { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 10px; }
.copyrow { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
code { background: var(--panel-2); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); word-break: break-all; }
details.steps summary { list-style: none; color: var(--text); }
details.steps summary h2 { display: inline; }
details.steps summary::after { content: ' ▾'; color: var(--muted); }

/* Song dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg-head { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 18px 20px 0; }
.dlg-head img { width: 96px; height: 96px; border-radius: 10px; object-fit: cover; }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-body h3 { font-size: 14px; color: var(--muted); font-weight: 500; margin: 6px 0 0; }
.versions { list-style: none; padding: 0; margin: 0; }
.versions li { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.versions img { width: 36px; height: 36px; border-radius: 4px; }
.versions li.rep .t-name::after { content: ' ✓'; color: var(--accent); }
.dlg-stats { width: 100%; border-collapse: collapse; font-size: 14px; }
.dlg-stats td { padding: 4px 0; border-top: 1px solid var(--line); }
.dlg-stats td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.dlg-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

@media (max-width: 760px) {
  main { padding: 18px 16px 60px; }
  .top { padding: 8px 10px; }
  .brand span { display: none; }
  body.open .brand { display: none; }
  body.open nav { flex: 1; justify-content: space-between; }
  nav button { padding: 8px 7px; font-size: 14px; }
  h1 { font-size: 27px; }
  .presets { grid-template-columns: 1fr 1fr; }
  .matchup { grid-template-columns: 1fr; gap: 12px; }
  .vs { justify-self: center; font-size: 20px; }
  .side { display: grid; grid-template-columns: 72px 1fr; gap: 10px 12px; padding: 12px; }
  .art { width: 72px; height: 72px; max-height: none; border-radius: 8px; }
  .player, .pick { grid-column: 1 / -1; }
  .player { grid-template-columns: 44px 1fr auto; padding: 8px 10px; }
  .player .play { width: 44px; height: 44px; }
  .meta h2 { font-size: 17px; }
  kbd { display: none; }
  .cols, .side-by-side { grid-template-columns: 1fr; }
  .plist.ranked li { grid-template-columns: 3ch 40px 1fr auto; gap: 8px; }
  .plist img.cv { width: 40px; height: 40px; }
}
