:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --link: #1c5cab;
  --deemph: #d6d5ce;
  --focus: #2a78d6;
  /* Rating chips: diverging blue (10) - white (7) - red (4 and under), same in both themes;
     text colour picked per step for contrast. The ring keeps every chip the same visible size. */
  --r10: #1c5cab; --r10-ink: #ffffff;
  --r9: #6da7ec;  --r9-ink: #0b0b0b;
  --r8: #cde2fb;  --r8-ink: #0b0b0b;
  --r7: #ffffff;  --r7-ink: #0b0b0b;
  --r6: #fbd0cb;  --r6-ink: #0b0b0b;
  --r5: #ee8a80;  --r5-ink: #0b0b0b;
  --r4: #b93130;  --r4-ink: #ffffff;
  --chip-ring: #c3c2b7; /* white would vanish on the light page */
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 4px 16px rgba(11, 11, 11, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --link: #86b6ef;
    --deemph: #3a3a37;
    --focus: #86b6ef;
    --chip-ring: #ffffff;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --link: #86b6ef; --deemph: #3a3a37; --focus: #86b6ef;
  --chip-ring: #ffffff; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Header */
.masthead { padding: 28px 0 18px; }
.home { font-size: 13px; color: var(--ink-2); text-decoration: none; }
.home:hover { color: var(--ink); }
h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.1; margin: 10px 0 6px; letter-spacing: -0.02em; }
.lede { margin: 0; color: var(--ink-2); }

/* Filter bar + tabs (sticky) */
.controls {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: 10px;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters input, .filters select {
  height: 36px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); padding: 0 10px; min-width: 0;
}
.filters input { flex: 1 1 240px; }
.filters select { flex: 0 1 auto; max-width: 190px; }
.filters select.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.active { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 0; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.active:empty { margin-top: 0; }
.chip-filter {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 2px 4px 2px 10px; cursor: pointer;
}
.chip-filter span { color: var(--muted); }
.chip-filter b { font-weight: 600; color: var(--ink); }
.chip-filter i { font-style: normal; width: 18px; height: 18px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--ink-2); }
.chip-filter:hover i { background: var(--surface-2); color: var(--ink); }
.linkish { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; text-align: left; }
.linkish:hover { text-decoration: underline; }

.tabs { display: flex; gap: 2px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 0; padding: 10px 12px; cursor: pointer; white-space: nowrap;
  color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 500;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

main.wrap { padding-top: 20px; padding-bottom: 40px; min-height: 60vh; }
section + section { margin-top: 28px; }
h2 { font-size: 18px; margin: 0 0 4px; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin: 0 0 10px; }
.sub { color: var(--ink-2); font-size: 13px; margin: 0 0 12px; }
.empty { color: var(--ink-2); padding: 40px 0; text-align: center; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 13px; color: var(--ink-2); }
.kpi .value { font-size: 30px; font-weight: 650; line-height: 1.15; margin-top: 2px; letter-spacing: -0.01em; }
.kpi .note { font-size: 12px; color: var(--muted); }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-2-even { grid-template-columns: 1fr; }
}

/* Charts */
figure { margin: 0; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart text.cap { fill: var(--ink-2); font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .bar { fill: var(--accent); transition: opacity 120ms; }
.chart .bar.dim { fill: var(--deemph); }
.chart .bar.hover { opacity: 0.75; }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:focus-visible { fill: var(--surface-2); }
details.tableview { margin-top: 8px; font-size: 13px; }
details.tableview summary { cursor: pointer; color: var(--ink-2); }
details.tableview table { margin-top: 8px; }

/* Tooltip */
.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 8px 10px; font-size: 13px; line-height: 1.35; max-width: 260px;
}
.tip strong { display: block; font-size: 15px; }
.tip span { color: var(--ink-2); display: block; }

/* Ranked lists on overview */
.rank { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.rank li { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; border-top: 1px solid var(--grid); counter-increment: rank; }
.rank li:first-child { border-top: 0; }
.rank li::before { content: counter(rank); color: var(--muted); font-size: 12px; width: 16px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.rank .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.rank .aux { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.more { margin-top: 10px; font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.toolbar h2 { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--ink-2); user-select: none; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; cursor: pointer;
  width: 34px; height: 20px; border-radius: 999px; background: var(--axis); position: relative; transition: background 120ms;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 120ms;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:checked + span { color: var(--ink); }

/* Rating chips */
.r {
  display: inline-grid; place-items: center; width: 26px; height: 22px; padding: 0;
  border: 1px solid var(--chip-ring); border-radius: 6px;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  text-decoration: none; flex: none; line-height: 1;
}
.r10 { background: var(--r10); color: var(--r10-ink); }
.r9 { background: var(--r9); color: var(--r9-ink); }
.r8 { background: var(--r8); color: var(--r8-ink); }
.r7 { background: var(--r7); color: var(--r7-ink); }
.r6 { background: var(--r6); color: var(--r6-ink); }
.r5 { background: var(--r5); color: var(--r5-ink); }
.r4 { background: var(--r4); color: var(--r4-ink); }
a.r:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips { display: flex; flex-wrap: nowrap; gap: 3px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 12px; text-align: left; vertical-align: middle; white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--grid); white-space: nowrap; }
tbody tr + tr td { border-top: 1px solid var(--grid); }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
td.dim { color: var(--ink-2); }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
th button::after { content: ""; width: 0.8em; color: var(--muted); }
th[aria-sort="ascending"] button::after { content: "▲"; font-size: 9px; color: var(--ink); }
th[aria-sort="descending"] button::after { content: "▼"; font-size: 9px; color: var(--ink); }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
@media (max-width: 640px) {
  .opt { display: none; }
  th, td { padding: 8px 8px; }
}

/* Gig list */
.year-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 8px; position: sticky; top: var(--controls-h, 120px); background: var(--page); z-index: 1; padding: 4px 0; }
.year-head:first-child { margin-top: 0; }
.year-head h2 { font-size: 22px; margin: 0; }
.year-head span { color: var(--muted); font-size: 13px; }
.gig { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.gig + .gig { margin-top: 8px; }
.when { text-align: center; line-height: 1.1; padding-top: 2px; }
.when .d { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.when .m { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.when .range { font-size: 11px; color: var(--muted); margin-top: 2px; }
.where { font-weight: 600; }
.where .city { color: var(--ink-2); font-weight: 400; }
.where .days { color: var(--muted); font-weight: 400; font-size: 13px; }
.bill { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 5px; }
.bill li { display: flex; align-items: flex-start; gap: 8px; }
.bill .act { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; min-height: 22px; }
.bill .artist { font-weight: 500; color: var(--ink); }
.tag { font-size: 11px; color: var(--ink-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
.tag.nth { border: 0; padding: 0; color: var(--muted); }
.bill .hidden-acts { color: var(--muted); font-size: 13px; }
.show-more { display: flex; justify-content: center; margin-top: 16px; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; padding-bottom: 32px; padding-top: 16px; border-top: 1px solid var(--border); }
.foot a { color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Phones: the filter bar would eat a third of the screen if it stuck, so let it scroll away */
@media (max-width: 640px) {
  .controls { position: static; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--page); }
  .filters select { flex: 1 1 140px; max-width: none; }
  .year-head { top: 0; }
  .gig { grid-template-columns: 48px 1fr; gap: 10px; padding: 12px; }
  .kpi .value { font-size: 26px; }
}

/* Combined artists: the +N toggle and the per-act rows it opens */
.tag-btn { margin-left: 6px; background: transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; line-height: 1.5; }
.tag-btn:hover { background: var(--surface-2); color: var(--ink); }
.tag-btn.open { border-color: var(--accent); color: var(--ink); }
.tag-btn .caret { font-size: 9px; }
tr.sub td { background: var(--surface-2); border-top-color: transparent; font-size: 13px; color: var(--ink-2); }
tbody tr + tr.sub td { border-top: 0; }
.sub-name { padding-left: 16px; position: relative; }
.sub-name::before { content: "↳"; position: absolute; left: 0; color: var(--muted); }
.r.gap { background: transparent; border-color: transparent; }
