:root {
  --bg: #121212; --card: #1b1b1b; --card2: #242424; --line: #2c2c2c;
  --text: #ececec; --muted: #9a9a9a; --green: #1db954; --green-ink: #000; --red: #f06a62; --amber: #e8b04b;
  --l0: #262626; --l1: #0f3a21; --l2: #13642f; --l3: #178f41; --l4: #1db954; --l5: #7be3a0;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration-color: #555; text-underline-offset: 2px; }
a:hover { color: var(--green); }
h1 { font-size: 30px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
h2 small, h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
code, pre { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: #0c0c0c; border-radius: 6px; }
code { padding: 1px 5px; }
pre { padding: 10px 12px; overflow-x: auto; white-space: pre; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small, small { font-size: 12.5px; }
.bad { color: var(--red); }
.note { margin: 0 0 14px; font-size: 13.5px; }
[hidden] { display: none !important; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; background: rgba(18,18,18,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand .thumb { width: 30px; height: 30px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { background: var(--card2); color: var(--text); }
@media (max-width: 720px) {
  .top-in { flex-wrap: wrap; gap: 4px; padding-top: 8px; }
  .tabs { margin: 0 -16px; padding: 0 12px 8px; width: calc(100% + 32px); }
}

main, main.wrap { padding-top: 18px; padding-bottom: 30px; }
.foot { padding-bottom: 40px; font-size: 13px; }

/* Buttons, chips, flash */
.btn { display: inline-block; padding: 7px 14px; border-radius: 999px; background: var(--card2); color: var(--text); text-decoration: none;
       font: inherit; font-weight: 600; font-size: 14px; border: 0; cursor: pointer; }
.btn:hover { background: #333; color: var(--text); }
.btn.green { background: var(--green); color: var(--green-ink); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; align-items: center; }
.chips.sub { margin-top: -6px; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--card); color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 600; border: 1px solid var(--line); }
.chip:hover { color: var(--text); }
.chip.on { background: var(--text); color: #000; border-color: var(--text); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.flash { background: #17301f; border: 1px solid #245c37; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.flash.err { background: #361c1c; border-color: #6b2d2d; }
.flash.warn { background: #33290f; border-color: #6a5420; }

/* Cards & layout */
.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.ok-card { border: 1px solid #245c37; }
.err-card { border: 1px solid #6b2d2d; }
.grid2, .grid3 { display: grid; gap: 16px; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.grid2, .grid3 { margin-bottom: 16px; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .grid3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 640px) and (max-width: 979px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.empty-state { text-align: center; padding: 40px 20px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile span { font-size: 13px; }
.tile b { font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile.big b { color: var(--green); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.fact { background: var(--card); border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.fact span { display: block; font-size: 12.5px; }
.fact b { display: block; color: var(--text); font-size: 16px; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ranked lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list li:last-child { border-bottom: 0; }
.list.compact li { padding: 5px 0; }
.list.cols { columns: 2 320px; column-gap: 24px; }
.list.cols li { break-inside: avoid; }
.rank { width: 24px; flex: none; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-main > b, .li-main > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-main > b a { text-decoration: none; }
.li-main > .muted { font-size: 13px; }
.li-main > .muted a { text-decoration: none; }
.li-num { flex: none; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; }
.li-num small { font-weight: 400; font-size: 12px; }
.more { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; }
.thumb { width: 42px; height: 42px; border-radius: 4px; object-fit: cover; flex: none; background: var(--card2); display: inline-block; }
.thumb.round { border-radius: 50%; }
.hbar { display: block; height: 4px; background: var(--l0); border-radius: 2px; margin: 5px 0 2px; overflow: hidden; }
.hbar span { display: block; height: 100%; background: var(--green); border-radius: 2px; }
.mv { font-size: 12px; font-weight: 700; }
.mv.up { color: var(--green); } .mv.down { color: var(--red); } .mv.same { color: var(--muted); } .mv.new { color: var(--amber); text-transform: uppercase; }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
ol.steps { padding-left: 20px; }
ol.steps li { margin-bottom: 4px; }
.upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--card2); padding: 12px; border-radius: 10px; }
.upload input { flex: 1; min-width: 0; color: var(--muted); }

/* Bar chart */
.bars { display: flex; align-items: stretch; gap: 2px; height: calc(var(--h) + 20px); }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: default; }
.bar-track { flex: 1; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; background: var(--green); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-col:hover .bar-fill { background: var(--l5); }
.bar-lbl { height: 20px; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; padding-top: 4px; line-height: 1; }

/* Heatmaps */
.cell { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--l0); }
.cell.l1 { background: var(--l1); } .cell.l2 { background: var(--l2); } .cell.l3 { background: var(--l3); }
.cell.l4 { background: var(--l4); } .cell.l5 { background: var(--l5); }
.cell.empty { background: transparent; }
.cell:hover { outline: 2px solid var(--text); outline-offset: 1px; }
.heat { display: grid; grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 11px; color: var(--muted); }
.heat-h { text-align: left; }
.heat-d { align-self: center; }
.cal-wrap { overflow-x: auto; padding-bottom: 4px; }
.cal { display: flex; gap: 3px; min-width: 700px; }
.cal-week { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cal-m { height: 14px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: visible; }

/* Now playing */
.now { display: grid; grid-template-columns: 96px 1fr; gap: 16px; background: linear-gradient(135deg, #1f3a2a, var(--card) 60%); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; align-items: center; }
.now-art { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: var(--card2); }
.now-main { min-width: 0; }
.now-label { flex-wrap: wrap; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.now .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.now.paused .dot { background: var(--muted); }
.now-title { display: block; font-size: 20px; font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.now-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-prog { height: 4px; background: rgba(255,255,255,.12); border-radius: 2px; margin: 10px 0 4px; overflow: hidden; }
.now-prog span { display: block; height: 100%; background: var(--text); width: 0; }
.now-time { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.now-queue { grid-column: 1 / -1; display: flex; gap: 10px; overflow-x: auto; font-size: 12.5px; }
.now-queue:empty { display: none; }
.now-queue .q { display: flex; align-items: center; gap: 8px; min-width: 190px; max-width: 220px; background: rgba(0,0,0,.25); border-radius: 8px; padding: 6px; }
.now-queue .q img { width: 36px; height: 36px; border-radius: 4px; flex: none; }
.now-queue .q div { min-width: 0; } .now-queue .q b, .now-queue .q span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-queue .qh { align-self: center; color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .05em; white-space: nowrap; }
@media (min-width: 900px) { .now { grid-template-columns: 96px 1fr minmax(0, 46%); } .now-queue { grid-column: auto; flex-wrap: wrap; max-height: 100px; overflow: hidden; } }

/* Image tiles */
.tiles-img { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.ti { display: flex; flex-direction: column; gap: 2px; text-decoration: none; min-width: 0; }
.ti .thumb { width: 100%; height: auto; aspect-ratio: 1; border-radius: 6px; margin-bottom: 6px; }
.tiles-img.round .ti .thumb { border-radius: 50%; }
.ti b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ti span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* History table */
.search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.search input[type=search] { flex: 1; min-width: 180px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; }
table.hist { width: 100%; border-collapse: collapse; }
.hist th, .hist td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.hist th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.hist td a { text-decoration: none; }
.hist tr.day td { background: var(--card2); font-weight: 700; font-size: 13px; }
.hist tr.dim td { opacity: .5; }
.hist .time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; width: 1%; }
.hist .t-img { width: 1%; padding-right: 0; } .hist .t-img .thumb { width: 36px; height: 36px; }
.hist .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pad { padding: 16px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 12px 0; }
@media (max-width: 640px) { .hide-s { display: none; } }

/* Artist page */
.artist-head { display: flex; gap: 20px; align-items: center; margin-bottom: 18px; }
.artist-head .thumb { width: 140px; height: 140px; }
.artist-head p { margin: 0 0 6px; }
@media (max-width: 560px) { .artist-head { flex-direction: column; align-items: flex-start; } .artist-head .thumb { width: 110px; height: 110px; } }

/* Tooltip */
#tip { position: fixed; z-index: 100; pointer-events: none; background: #f2f2f2; color: #111; font-size: 12.5px; font-weight: 600;
       padding: 5px 9px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.5); max-width: 260px; }
.cal-week { min-width: 0; }
.cal-m { width: 0; }
.heat-h { overflow: visible; white-space: nowrap; min-width: 0; }
@media (max-width: 560px) { .heat { gap: 2px; } .heat .cell { border-radius: 2px; } }

/* Visitors: landing page, demo, private link */
.land { padding-top: 40px; }
.land-head { margin: 8px 0 24px; max-width: 760px; }
.land-head h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.15; margin-bottom: 10px; }
.lead { font-size: 16.5px; margin: 0; }
.land-hero { margin: 12vh auto 0; text-align: center; }
.land-hero .lead { max-width: 560px; margin: 0 auto; }
.land-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 28px; }
.land-choices .btn { min-width: 200px; text-align: center; }
.land-form { display: grid; gap: 8px; margin-bottom: 12px; }
.land-form .upload { margin-bottom: 4px; }
.land-login { max-width: 420px; margin: 10vh auto 0; }
.land-login h1 { font-size: 22px; margin-bottom: 14px; }
input.text { font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: #111; color: var(--text); width: 100%; min-width: 0; }
.upload input.text { flex: 1; width: auto; }
.upload input[type=password] { font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: #111; color: var(--text); flex: 1; min-width: 0; }
button.btn { border: 0; cursor: pointer; }
button.btn:disabled { opacity: .7; cursor: progress; }
.btn.big { padding: 11px 20px; font-size: 16px; justify-self: start; }
.btn.danger { background: #6b2d2d; }
.btn.danger:hover { background: #8a3a3a; }
.linkrow { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; }
.linkrow input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--card2); color: var(--muted); padding: 2px 7px; border-radius: 999px; }
.flash.demo { background: #1b2433; border-color: #2d3f5c; }

/* Your own history, in the browser (?action=upload) */
.land-private { margin-top: 18px; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
        min-height: 130px; padding: 18px; border: 2px dashed #3a3a3a; border-radius: 12px; background: var(--card2); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--green); background: #1d2b22; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop span { font-size: 15px; overflow-wrap: anywhere; }
.local .brand .thumb { width: 30px; height: 30px; background: var(--green); }
