/* Theme tokens. Light is the base; dark applies via OS preference unless the viewer picked
   a theme with the toggle (data-theme on <html>). */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f0efec;
  --text: #0b0b0b; --text-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,.10);
  --wash: rgba(11,11,11,.05); --edge: rgba(11,11,11,.28); --shadow: rgba(0,0,0,.18);
  --accent: #2a78d6; --new: #0a7a52;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10);
    --wash: rgba(255,255,255,.06); --edge: rgba(255,255,255,.3); --shadow: rgba(0,0,0,.5);
    --accent: #3987e5; --new: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10);
  --wash: rgba(255,255,255,.06); --edge: rgba(255,255,255,.3); --shadow: rgba(0,0,0,.5);
  --accent: #3987e5; --new: #199e70;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text-2);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.top { display: flex; align-items: center; gap: 20px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--page); z-index: 5; }
.brand { font-weight: 600; color: var(--text); letter-spacing: .02em; }
nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav button, .seg button { background: none; border: 0; padding: 5px 11px; border-radius: 6px;
  cursor: pointer; color: var(--text-2); white-space: nowrap; }
nav button:hover, .seg button:hover { background: var(--wash); }
nav button[aria-current="true"] { background: var(--surface-2); color: var(--text); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search { position: relative; }
.search input { background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 10px; width: 220px; }
.search input:focus { outline: 1px solid var(--accent); }
#theme { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 15px; line-height: 1; }
#theme:hover { border-color: var(--edge); }
#results { position: absolute; right: 0; top: 34px; width: 320px; max-width: 90vw; list-style: none; margin: 0; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; max-height: 360px; overflow: auto;
  box-shadow: 0 8px 24px var(--shadow); }
#results li { padding: 5px 8px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
#results li:hover { background: var(--wash); }
#results li span:last-child { color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: center; padding: 10px 16px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.sel { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.sel select, .filters select { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }

main { padding: 0 16px 48px; max-width: 1500px; margin: 0 auto; transition: opacity .15s; }
main.loading { opacity: .5; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; min-width: 0; }
.card h2 { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--text); }
.card .sub { color: var(--muted); margin: 0 0 10px; font-size: 12px; }
.ch { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
button.tbl { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 2px 9px; cursor: pointer; color: var(--text-2); font-size: 12px; }
button.tbl:hover { border-color: var(--edge); }
button.tbl[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.stat b { display: block; font-size: 24px; color: var(--text); font-weight: 600; }
.stat span { color: var(--muted); }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.cols2 > .card { margin-bottom: 0; }
.cols2 + .card, .cols2 + .cols2 { margin-top: 14px; }

svg text { fill: var(--muted); font-size: 11px; }
svg .grid line { stroke: var(--grid); }
svg .axis path, svg .axis line { stroke: var(--axis); }
svg .rowlabel { fill: var(--text-2); font-size: 12px; cursor: pointer; }
svg .rowlabel:hover { fill: var(--text); text-decoration: underline; }
svg .total { fill: var(--muted); }

.tablewrap { max-height: 380px; overflow: auto; margin-top: 4px; border: 1px solid var(--grid); border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 500; text-align: left; padding: 6px 10px; white-space: nowrap; }
table.data td { padding: 5px 10px; border-top: 1px solid var(--grid); color: var(--text-2); white-space: nowrap; }
table.data td.n, table.data th.n { text-align: right; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.chip:hover { border-color: var(--edge); }
.chip i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chip.off { opacity: .7; }
.chip.static { cursor: default; }
.chip small { color: var(--muted); }

.legend-ramp { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.legend-ramp i { width: 120px; height: 8px; border-radius: 4px; display: inline-block; }

.grid-albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.album { position: relative; cursor: pointer; min-width: 0; }
.album .cover { aspect-ratio: 1; border-radius: 6px; background: var(--surface-2); object-fit: cover; width: 100%; display: block; }
.album .plays { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.72); color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.album .t { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.album .a { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }

/* ranked lists with inline bars */
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--grid); }
.rank li.link { cursor: pointer; }
.rank li.link:hover .nm { text-decoration: underline; color: var(--text); }
.rank .i { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rank .nm { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .nm small { color: var(--muted); margin-left: 6px; }
.rank .v { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank .b { grid-column: 2 / 4; height: 3px; background: var(--grid); border-radius: 2px; overflow: hidden; }
.rank .b i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

#panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); padding: 18px 20px; overflow: auto; z-index: 20;
  box-shadow: -20px 0 40px var(--shadow); }
#close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }
#panel h1 { margin: 0 0 2px; font-size: 20px; color: var(--text); padding-right: 30px; }
#panel h3 { margin: 18px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.meta { color: var(--muted); }
.meta b { color: var(--text-2); font-weight: 500; }
.more { display: inline-block; margin: 10px 0 0; padding: 4px 12px; border-radius: 6px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 500; }
.more:hover { filter: brightness(1.08); }
.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid var(--grid); }
.rowlist li.link { cursor: pointer; }
.rowlist li.link:hover .n { color: var(--text); text-decoration: underline; }
.rowlist .v { color: var(--muted); white-space: nowrap; }
.new { color: var(--new); font-size: 11px; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 6px; }
.covers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

/* full artist page */
.ap-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.ap-photo { width: 160px; height: 160px; border-radius: 10px; background: linear-gradient(135deg, var(--surface-2), var(--grid)); overflow: hidden; flex: none; }
.ap-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ap-head h1 { margin: 0 0 4px; font-size: 28px; color: var(--text); }
.ap-head .body { flex: 1; min-width: 240px; }
.back { display: inline-block; margin: 4px 0 10px; color: var(--muted); cursor: pointer; background: none; border: 0; padding: 0; }
.back:hover { color: var(--text); }
.sim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.sim { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--surface-2); min-width: 0; }
.sim:hover { border-color: var(--edge); }
.sim b { color: var(--text); font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim span { color: var(--muted); font-size: 12px; }

/* discover */
.recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.rec { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.rec .pic { position: relative; aspect-ratio: 16 / 10; background: linear-gradient(135deg, var(--surface-2), var(--grid)); }
.rec .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.rec .play { position: absolute; right: 8px; bottom: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.72); color: #fff; font-size: 13px; display: grid; place-items: center; }
.rec .play:hover { background: var(--accent); }
.rec .play:disabled { opacity: .35; cursor: default; background: rgba(0,0,0,.72); }
.rec .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rec .nm { color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; }
.rec .nm:hover { text-decoration: underline; }
.rec .meta { font-size: 12px; }
.rec .tg { display: flex; flex-wrap: wrap; gap: 4px; }
.rec .tg span { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--wash); color: var(--text-2); }
.rec .why { font-size: 12px; color: var(--muted); margin-top: auto; }
.rec .why a { color: var(--text-2); cursor: pointer; text-decoration: none; }
.rec .why a:hover { color: var(--text); text-decoration: underline; }
.rec .barwrap { padding: 5px 0; cursor: help; }
.rec .bar { height: 3px; border-radius: 2px; background: var(--grid); overflow: hidden; }
.rec .bar i { display: block; height: 100%; background: var(--accent); }
.more-btn { display: block; margin: 16px auto 4px; padding: 7px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; color: var(--text); }
.more-btn:hover { border-color: var(--edge); }
#lens select { background: transparent; border: 0; padding: 5px 6px; color: var(--text-2); cursor: pointer; }
#lens select.on { background: var(--surface-2); color: var(--text); border-radius: 6px; box-shadow: inset 0 0 0 1px var(--border); }

.events { width: 100%; border-collapse: collapse; }
.events th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--grid); }
.events td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.events tr.month td { color: var(--text); font-weight: 600; padding-top: 16px; border-bottom: 1px solid var(--axis); }
.events .d { white-space: nowrap; color: var(--text-2); }
.events .a { color: var(--text); cursor: pointer; }
.events .a:hover { text-decoration: underline; }
.events .v { color: var(--muted); }
.events .dist { white-space: nowrap; color: var(--muted); }
.events a.tix { color: var(--accent); text-decoration: none; white-space: nowrap; }
.events a.tix:hover { text-decoration: underline; }

#tip { position: fixed; pointer-events: none; z-index: 50; background: var(--surface-2); border: 1px solid var(--edge);
  border-radius: 8px; padding: 7px 10px; box-shadow: 0 8px 24px var(--shadow); max-width: 300px; }
#tip .h { color: var(--muted); margin-bottom: 3px; }
#tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
#tip .r .k { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
#tip .r .k i { width: 10px; height: 2px; display: inline-block; flex: none; }
#tip .r b { color: var(--text); font-weight: 600; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.note { color: var(--muted); font-size: 12px; margin-top: 8px; }
[hidden] { display: none !important; }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  nav { order: 3; width: 100%; }
  .tools { margin-left: auto; }
  .search input { width: 150px; }
  .filters { padding: 8px 12px; gap: 8px 10px; }
  main { padding: 0 12px 40px; }
  .card { padding: 12px; }
  .stat b { font-size: 20px; }
  .cols2 { grid-template-columns: 1fr; }
  .events .hide-s, .events th.hide-s { display: none; }
  .events { table-layout: auto; word-break: break-word; }
  .events td, .events th { padding: 6px 4px; }
  .events .d, .events .dist { white-space: normal; }
  .recs { grid-template-columns: 1fr; }
  .ap-photo { width: 100%; height: 200px; }
  .ap-head h1 { font-size: 22px; }
  .covers { grid-template-columns: repeat(3, 1fr); }
  #panel { padding: 16px 14px; }
}
