/* Sumtunes web. Colours are CSS variables set by js/theme.js (copied from ios/Sumtunes/Theme.swift);
   the defaults below are the dark lime Sumbook palette. Desktop first; narrow windows get a bottom bar. */

@font-face { font-family: "Selawik"; src: url("../fonts/Selawik-Light.ttf") format("truetype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Selawik"; src: url("../fonts/Selawik-Regular.ttf") format("truetype"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "Selawik"; src: url("../fonts/Selawik-Bold.ttf") format("truetype"); font-weight: 600 800; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: block; }

:root {
  --bg: #050705; --rail: #080b08; --panel: #0d110d; --raised: #121a12; --line: #1a221a; --line2: #2b352b;
  --ink: #f1f7ef; --muted: #a1b39c; --faint: #5e6d5a; --accent: #7cff35; --selected: #1d3a12;
  --loss: #ff6b7f; --flat: #4da8ff; --amber: #ffb938; --on-accent: #000000;
  --accent-rgb: 124 255 53; --ink-rgb: 241 247 239; --bg-rgb: 5 7 5; --loss-rgb: 255 107 127; --amber-rgb: 255 185 56; --on-accent-rgb: 0 0 0;
  --font: "Selawik", "Segoe UI", system-ui, sans-serif;
  --brand: "Plus Jakarta Sans", system-ui, sans-serif;
  --radius: 16px;
  --sidebar: 236px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background-color .25s ease, color .25s ease;
}
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
img { display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
::selection { background: rgb(var(--accent-rgb) / .35); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Utilities */
.muted { color: var(--muted); } .faint { color: var(--faint); } .accent { color: var(--accent); } .amber { color: var(--amber); }
.small { font-size: 13px; } .xsmall { font-size: 12px; } .strong { font-weight: 700; } .center { text-align: center; }
.num, .row-num, .rank, .stat-value, .hero-value, .hero-mini-value { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.spacer { flex: 1; }
.icon { display: inline-flex; flex: none; line-height: 0; }

/* ---- Wordmark: SUMTUNES, always Plus Jakarta Sans ExtraBold; a wave runs through it while loading ---- */
.wordmark { display: inline-flex; gap: .11em; font-family: var(--brand); font-weight: 800; color: var(--accent); letter-spacing: 0; line-height: 1; user-select: none; }
.wordmark > span { display: inline-block; will-change: transform, opacity; }
.wordmark.animating > span { animation: wave 1.15s ease-in-out infinite; }
@keyframes wave {
  0%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-.2em); opacity: 1; }
  60% { transform: translateY(0); opacity: .55; }
}
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.loading-mark { display: grid; place-items: center; min-height: 320px; }
.loading-more { display: grid; place-items: center; height: 56px; }

/* ---- Shell ---- */
.layout { min-height: 100vh; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 50; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 10px; font-weight: 700; }
.skip-link:focus-visible { top: 12px; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
  display: flex; flex-direction: column; gap: 22px; padding: 26px 16px 18px;
  background: var(--rail); border-right: 1px solid var(--line);
}
.sidebar-brand { padding: 4px 12px 6px; align-self: flex-start; border-radius: 8px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 11px;
  color: var(--muted); font-weight: 500; transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--panel); color: var(--ink); }
.nav-link.on { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.nav-short { display: none; }
.sidebar-foot { margin-top: auto; display: grid; gap: 6px; padding: 0 4px; }
.sidebar-refresh { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.sidebar-refresh:hover { background: var(--panel); color: var(--ink); }
.sidebar-updated { font-size: 12px; color: var(--faint); padding: 0 10px; min-height: 17px; }
.mobile-bar { display: none; }

.main { margin-left: var(--sidebar); padding: 30px 40px 64px; max-width: calc(var(--sidebar) + 1360px); outline: none; }
.main > * { animation: none; }
.main.entered > * { animation: enter .28s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .main.entered > *, .wordmark.animating > span { animation: none !important; }
  .wordmark.animating > span { opacity: .6; }
  * { transition-duration: .01ms !important; }
}

/* ---- Page header ---- */
.page-header { display: flex; align-items: center; gap: 14px; min-height: 64px; margin-bottom: 18px; }
.page-heading { min-width: 0; flex: 1; }
.page-title { font-size: 32px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-button { display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; max-width: 100%; }
.title-button:hover .icon { transform: translateY(2px); }
.title-button .icon { transition: transform .15s ease; }
.page-subtitle { color: var(--muted); font-size: 15px; margin-top: 3px; min-height: 21px; }
.page-actions { display: flex; gap: 8px; }
.detail-bar { margin-bottom: 6px; min-height: 48px; }
.detail-bar .page-title { font-size: 18px; }

.overview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px 28px; flex-wrap: wrap; margin-bottom: 18px; }
.overview-head .page-header { margin: 0; }
.page-heading-slot { min-width: 0; flex: 1 1 320px; }
.range-bar { display: flex; align-items: center; gap: 8px; padding-top: 10px; flex: 0 1 470px; }

/* ---- Controls ---- */
.segmented { display: flex; flex: 1; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.segmented button {
  flex: 1; min-width: 0; height: 34px; padding: 0 12px; border-radius: 999px; white-space: nowrap;
  color: var(--muted); font-weight: 500; font-size: 14px; transition: background-color .2s var(--ease), color .2s ease;
}
.segmented button:hover:not(.on) { color: var(--ink); background: var(--raised); }
.segmented button.on { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink); transition: background-color .15s ease, border-color .15s ease;
}
.icon-btn:hover:not(:disabled) { background: var(--raised); border-color: var(--line2); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.small { width: 28px; height: 28px; background: transparent; border-color: transparent; color: var(--faint); }
.calendar-btn { width: 42px; height: 42px; }
.calendar-btn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px;
  border-radius: 999px; font-weight: 700; font-size: 15px; white-space: nowrap; border: 1px solid transparent;
  transition: filter .15s ease, background-color .15s ease, opacity .15s ease, transform .1s ease;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover:not(:disabled) { filter: brightness(1.08); }
.btn-outline { border-color: rgb(var(--accent-rgb) / .55); color: var(--accent); }
.btn-outline:hover:not(:disabled) { background: rgb(var(--accent-rgb) / .1); }
.btn-ghost { color: var(--ink); background: var(--raised); }
.btn-ghost:hover { background: var(--line2); }
.btn-danger { background: var(--loss); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-danger-outline { border-color: rgb(var(--loss-rgb) / .5); color: var(--loss); }
.btn-danger-outline:hover { background: rgb(var(--loss-rgb) / .1); }
.btn-small { height: 32px; padding: 0 14px; font-size: 14px; }
.btn-large { height: 50px; font-size: 16px; }
.btn-block { width: 100%; }
.btn .wordmark { color: currentColor; }
.text-btn { color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px 6px; border-radius: 8px; }
.text-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-btn.block { display: block; width: 100%; padding: 8px; margin-top: 4px; }

/* ---- Cards & grid ---- */
.ov-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; align-items: stretch; transition: opacity .2s ease; }
.ov-grid.stale { opacity: .55; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: 1 / -1; }
.stack { display: grid; gap: 18px; align-content: start; }
.span-12:has(> .loading-mark), .filter-bar, .stats-link { align-self: start; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  transition: background-color .25s ease, border-color .25s ease;
}
.card.flush { padding: 4px 16px; }
.card-header { display: flex; align-items: baseline; gap: 10px; }
.card-header-text { flex: 1; min-width: 0; }
.card-title { font-size: 19px; font-weight: 700; }
.card-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-trailing { color: var(--faint); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-header .btn, .card-header .pill { align-self: center; }
.sub-heading { font-size: 15px; font-weight: 700; margin-top: 4px; }

.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.pill-accent { color: var(--accent); background: rgb(var(--accent-rgb) / .13); }
.pill-amber { color: var(--amber); background: rgb(var(--amber-rgb) / .14); }
.pill-muted { color: var(--muted); background: var(--raised); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-height: 104px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.stat-value { font-size: 25px; font-weight: 700; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-value.accent { color: var(--accent); }
.stat-detail { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Banners ---- */
.banners:empty { display: none; }
.banners { display: grid; gap: 12px; margin-bottom: 18px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 14px; background: var(--raised); border: 1px solid var(--line2); }
.banner-text { flex: 1; display: grid; gap: 2px; font-size: 14px; }
.banner-text strong { font-size: 15px; }
.banner-error { border-color: rgb(var(--amber-rgb) / .5); color: var(--amber); }
.banner-error .banner-text { color: var(--ink); }
.banner-warn { border-color: rgb(var(--amber-rgb) / .6); }
.banner-warn > .icon:first-child { color: var(--amber); }
.banner-warn:hover { background: var(--line); }

/* ---- Empty states ---- */
.empty-note { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 28px 12px; color: var(--faint); }
.empty-title { color: var(--ink); font-size: 17px; font-weight: 700; }
.empty-text { color: var(--muted); font-size: 14px; max-width: 46ch; }
.empty-note.error > .icon { color: var(--amber); }
.empty-note .btn { margin-top: 8px; }

/* ---- Artwork, ranks, rows ---- */
.art { position: relative; display: inline-grid; place-items: center; flex: none; overflow: hidden; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s ease; }
.art.loaded img { opacity: 1; }
.art.instant img { transition: none; }
.art.loaded .art-placeholder { visibility: hidden; }
.art-placeholder { color: var(--faint); }
.rank { width: 26px; flex: none; font-weight: 700; font-size: 15px; color: var(--faint); }
.rank.podium { color: var(--accent); }
.share-bar { display: block; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.share-bar > span { display: block; height: 100%; border-radius: inherit; background: rgb(var(--accent-rgb) / .85); }

.rows { display: grid; gap: 2px; }
.rows.divided > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 7px 8px; margin: 0 -8px; border-radius: 12px; min-width: 0;
  transition: background-color .12s ease;
}
a.row:hover, button.row:hover, .row.selectable:hover { background: var(--raised); }
button.row { width: calc(100% + 16px); text-align: left; }
.row.static { margin: 0; padding: 7px 0; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.row-title { font-weight: 600; font-size: 15.5px; }
.row-sub { color: var(--muted); font-size: 13.5px; }
.row-main .share-bar { margin-top: 3px; }
.row-num { color: var(--muted); font-size: 14.5px; flex: none; }
.row-num.strong { color: var(--ink); font-weight: 600; }
.row-time { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.rows.compact .play-line { display: flex; justify-content: space-between; padding: 7px 0; font-size: 15px; }
.has-menu { -webkit-touch-callout: none; }

/* Top artists */
.bubbles { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 18px 10px; }
.bubble { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 6px 2px; border-radius: 14px; min-width: 0; transition: background-color .12s ease; }
.bubble:hover { background: var(--raised); }
.bubble-art { position: relative; width: min(100%, 96px); aspect-ratio: 1; }
.bubble-art .art { width: 100%; height: 100%; }
.bubble.first .bubble-art .art { box-shadow: 0 0 0 2.5px var(--accent); }
.bubble-rank { position: absolute; left: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--raised); color: var(--ink); box-shadow: 0 0 0 2px var(--panel); font-variant-numeric: tabular-nums; }
.bubble-rank.podium { background: var(--accent); color: var(--on-accent); }
.bubble-name { font-weight: 600; font-size: 14px; max-width: 100%; margin-top: 4px; }
.bubble-plays { font-size: 12px; color: var(--muted); }

/* Albums */
.album-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px; }
.album-tile { display: grid; gap: 4px; min-width: 0; padding: 6px; margin: -6px; border-radius: 14px; transition: background-color .12s ease; }
.album-tile:hover { background: var(--raised); }
.album-art { position: relative; aspect-ratio: 1; }
.album-art .art { width: 100%; height: 100%; }
.album-rank { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; }
.album-name { font-weight: 600; font-size: 14px; margin-top: 4px; }
.album-sub { font-size: 12px; color: var(--muted); }

/* Hero: one wide strip — the big number, its change, and the other four stats to click. */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: center; gap: 28px; }
.hero-top { display: flex; align-items: flex-start; gap: 12px; }
.hero-number { display: grid; text-align: left; flex: 1; min-width: 0; border-radius: 12px; }
.hero-number.clickable { cursor: pointer; }
.hero-number.clickable:hover .hero-value { filter: brightness(1.1); }
.hero-value { font-size: clamp(44px, 4.4vw, 64px); font-weight: 700; color: var(--accent); line-height: 1.05; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-caption { color: var(--muted); font-size: 14px; }
.hero-change { display: grid; justify-items: end; gap: 2px; text-align: right; padding-top: 8px; }
.change { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.change.up { color: var(--accent); } .change.down { color: var(--loss); } .change.flat { color: var(--flat); }
.hero-minis { display: flex; background: var(--rail); border-radius: 12px; padding: 6px; }
.hero .hero-mini { padding: 12px 4px; }
.hero-mini { flex: 1; min-width: 0; display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 9px; transition: background-color .12s ease; }
button.hero-mini:hover { background: var(--raised); }
.hero-mini-value { font-size: 20px; font-weight: 700; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.hero-mini-label { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }

/* ---- Charts ---- */
.chart { display: grid; gap: 8px; }
.selection-line { display: flex; align-items: center; gap: 6px; min-height: 20px; font-size: 13px; color: var(--faint); }
.selection-line.on { color: var(--accent); font-weight: 600; }
.chart-plot { position: relative; outline-offset: 4px; cursor: pointer; }
.chart-plot.with-grid { margin-right: 38px; }
.chart-gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.chart-gridline span { position: absolute; right: -38px; top: -8px; width: 34px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chart-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.chart-bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.chart-bar {
  width: 100%; border-radius: 3px 3px 1px 1px;
  background: linear-gradient(to bottom, var(--accent), rgb(var(--accent-rgb) / .45));
  transition: opacity .15s ease, height .3s var(--ease);
}
.chart-bar-slot:hover .chart-bar { filter: brightness(1.15); }
.chart-bar.dimmed { opacity: .35; }
.clock .chart-bar, .chart-plot:not(.with-grid) .chart-bar { background: rgb(var(--accent-rgb) / .4); }
.chart-plot:not(.with-grid) .chart-bar.peak { background: var(--accent); }
.stats .chart-plot:not(.with-grid) .chart-bar { background: rgb(var(--accent-rgb) / .85); }
.chart-axis { position: relative; height: 16px; font-size: 11px; color: var(--faint); }
.chart-axis.with-grid { margin-right: 38px; }
.chart-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-axis span:first-child { transform: none; left: 0 !important; }
.chart-axis span:last-child:not(:first-child) { transform: none; left: auto !important; right: 0; }

/* Filters */
.filter-bar { border-color: rgb(var(--accent-rgb) / .45); padding: 14px 16px; gap: 12px; }
.filter-bar.paused { border-color: var(--line); }
.filter-head { display: flex; align-items: center; gap: 10px; }
.filter-text { flex: 1; }
.filter-title { font-size: 15px; font-weight: 700; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; max-width: 280px; padding: 0 4px 0 11px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; font-weight: 600; transition: opacity .2s ease; }
.filter-bar.paused .filter-chip { opacity: .45; }
.chip-x { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); flex: none; }
.chip-x:hover { background: var(--line2); color: var(--ink); }

.stats-link { flex-direction: row; align-items: center; gap: 14px; padding: 14px 16px; }
.stats-link:hover { border-color: var(--line2); background: var(--raised); }
.stats-link-icon { width: 42px; height: 42px; border-radius: 11px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.stats-link-text { flex: 1; display: grid; gap: 2px; }
.stats-link-text strong { font-size: 17px; }

/* ---- Menus & dialogs ---- */
.menu {
  position: fixed; z-index: 100; min-width: 220px; max-width: min(360px, calc(100vw - 16px)); padding: 6px;
  background: var(--raised); border: 1px solid var(--line2); border-radius: 14px;
  box-shadow: 0 18px 48px rgb(0 0 0 / .45), 0 2px 8px rgb(0 0 0 / .25);
  opacity: 0; transform: scale(.97) translateY(-4px); transform-origin: top left; transition: opacity .12s ease, transform .12s ease;
  max-height: min(420px, calc(100vh - 16px)); overflow: auto;
}
.menu.show { opacity: 1; transform: none; }
.menu-section { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.menu-separator { height: 1px; background: var(--line2); margin: 6px 4px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: 9px; text-align: left; font-size: 14px; color: var(--ink); }
.menu-item:hover, .menu-item:focus { background: var(--line2); outline: none; }
.menu-item.destructive { color: var(--loss); }
.menu-item .icon:first-child { color: var(--muted); }
.menu-item.destructive .icon:first-child { color: var(--loss); }
.menu-check { margin-left: auto; color: var(--accent); }

.dialog {
  border: 1px solid var(--line2); border-radius: 20px; padding: 0; background: var(--bg); color: var(--ink);
  box-shadow: 0 30px 80px rgb(0 0 0 / .5); opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .15s ease, transform .15s ease;
  max-width: calc(100vw - 24px);
}
.dialog.show { opacity: 1; transform: none; }
.dialog::backdrop { background: rgb(0 0 0 / .5); backdrop-filter: blur(3px); }
.dialog.anchored { position: fixed; margin: 0; }
.confirm-dialog { width: 420px; }
.confirm { padding: 22px; display: grid; gap: 12px; }
.confirm-title { font-size: 19px; font-weight: 700; }
.confirm-text { color: var(--muted); font-size: 14px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.calendar-dialog { width: 400px; }
.calendar { padding: 16px; display: grid; gap: 14px; }
.calendar-head { display: flex; align-items: center; gap: 4px; }
.calendar-head .icon-btn { background: transparent; border-color: transparent; color: var(--muted); }
.calendar-head .icon-btn:hover:not(:disabled) { background: var(--panel); color: var(--ink); }
.calendar-year { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 8px; border-radius: 10px; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.calendar-year:hover { background: var(--panel); }
.whole-year {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 0 16px; border-radius: 14px;
  color: var(--accent); background: rgb(var(--accent-rgb) / .12); border: 1px solid rgb(var(--accent-rgb) / .5); font-weight: 700; font-size: 16px;
  transition: background-color .15s ease;
}
.whole-year:hover:not(:disabled) { background: rgb(var(--accent-rgb) / .2); }
.whole-year.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.whole-year:disabled { opacity: .4; }
.whole-label { flex: 1; text-align: left; }
.whole-plays { font-size: 14px; font-weight: 600; opacity: .8; }
.month-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.month-chip {
  display: grid; justify-items: center; gap: 6px; min-height: 58px; align-content: center; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); font-size: 16px; font-weight: 600; transition: background-color .12s ease, border-color .12s ease;
}
.month-chip:hover:not(:disabled):not(.on) { border-color: var(--line2); background: var(--raised); }
.month-chip.empty { color: var(--faint); }
.month-chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.month-chip:disabled { opacity: .35; }
.month-meter { display: block; width: 34px; height: 3px; border-radius: 999px; background: var(--line); overflow: hidden; }
.month-meter span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.month-chip.on .month-meter { background: rgb(var(--on-accent-rgb) / .18); }
.month-chip.on .month-meter span { background: rgb(var(--on-accent-rgb) / .75); }
.year-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 300px; overflow: auto; padding: 2px; }
.year-chip { height: 44px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; font-variant-numeric: tabular-nums; }
.year-chip:hover { background: var(--raised); }
.year-chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 14px; background: var(--raised); border: 1px solid var(--line2);
  box-shadow: 0 12px 32px rgb(0 0 0 / .4); font-size: 14px; transition: opacity .2s ease, transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="error"] { border-color: rgb(var(--amber-rgb) / .6); }

/* ---- History ---- */
.history { display: grid; gap: 20px; max-width: 920px; }
.history-day { display: grid; gap: 8px; }
.history-day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.history-day-head h2 { font-size: 15px; font-weight: 700; }
.history .rows.divided > li + li { border-top: 0; }
.history .rows.divided > li + li .row { border-top: 1px solid var(--line); border-radius: 0; }
.history .row { margin: 0 -8px; padding: 9px 8px; }
.history .row:hover { border-radius: 10px; }
.history-foot { max-width: 920px; margin-top: 20px; }
.sentinel { height: 1px; }

/* ---- Search ---- */
.search-field {
  display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px 0 16px; max-width: 920px;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; transition: border-color .15s ease;
}
.search-field:focus-within { border-color: rgb(var(--accent-rgb) / .7); }
.search-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: 17px; }
.search-input::placeholder { color: var(--faint); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-spin { width: 76px; display: flex; justify-content: flex-end; }
.scopes { margin: 14px 0 18px; max-width: 520px; }
.search-body { display: grid; gap: 14px; padding-bottom: 80px; }
.select-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 18px; align-items: start; }
.row.selectable { cursor: pointer; }
.row.selectable.picked { background: rgb(var(--loss-rgb) / .1); }
.check { appearance: none; width: 22px; height: 22px; flex: none; margin: 0; border-radius: 50%; border: 2px solid var(--faint); display: grid; place-items: center; cursor: pointer; transition: background-color .12s ease, border-color .12s ease; }
.check:checked { background: var(--loss); border-color: var(--loss); }
.check:checked::after { content: ""; width: 6px; height: 10px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.remove-bar { position: fixed; bottom: 20px; left: calc(var(--sidebar) + 40px); right: 40px; z-index: 30; display: flex; justify-content: center; pointer-events: none; animation: enter .2s var(--ease); }
.remove-btn { pointer-events: auto; width: min(460px, 100%); box-shadow: 0 10px 30px rgb(0 0 0 / .35); }

/* ---- Activity ---- */
.heat-scroll { overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.heat-inner { display: flex; gap: 8px; width: max-content; margin: 0 auto; }
.heat-days { display: grid; grid-template-rows: 14px repeat(7, 14px); row-gap: 3px; font-size: 10px; color: var(--faint); padding-top: 3px; }
.heat-days span:first-child { margin-top: 14px; }
.heat-months { display: grid; grid-auto-flow: column; grid-auto-columns: 14px; column-gap: 3px; height: 14px; font-size: 10px; color: var(--faint); margin-bottom: 3px; }
.heat-months span { white-space: nowrap; overflow: visible; }
.heat-grid { display: flex; gap: 3px; border-radius: 4px; outline-offset: 4px; }
.heat-week { display: grid; grid-template-rows: repeat(7, 14px); gap: 3px; }
.heat-cell { width: 14px; height: 14px; border-radius: 3px; display: inline-block; cursor: pointer; transition: transform .1s ease; }
.heat-cell:hover { transform: scale(1.25); }
.heat-cell.lx { background: transparent; cursor: default; }
.heat-cell.lx:hover { transform: none; }
.l0 { background: var(--raised); } .l1 { background: rgb(var(--accent-rgb) / .25); } .l2 { background: rgb(var(--accent-rgb) / .45); }
.l3 { background: rgb(var(--accent-rgb) / .7); } .l4 { background: var(--accent); }
.heat-cell.picked { box-shadow: 0 0 0 1.5px var(--ink); }
.heat-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.heat-legend { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--faint); }
.heat-legend .heat-cell { width: 11px; height: 11px; cursor: default; }
.heat-legend .heat-cell:hover { transform: none; }
.week-grid { display: grid; gap: 3px; }
.week-row { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; align-items: center; }
.week-day { font-size: 10px; color: var(--faint); }
.week-cell { aspect-ratio: 1; border-radius: 3px; background: var(--raised); }
.week-hours span { font-size: 10px; color: var(--faint); white-space: nowrap; overflow: visible; }
.throwback { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--rail); }
.throwback-head { display: flex; align-items: baseline; gap: 8px; }
.throwback-head strong { font-size: 16px; }
.throwback .link-chip { justify-self: start; }
.throwback-tracks { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.throwback-track { display: grid; gap: 3px; width: 96px; flex: none; min-width: 0; border-radius: 10px; }
.throwback-track:hover .art { filter: brightness(1.1); }
.link-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; max-width: 100%; padding: 0 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line2); font-size: 14px; font-weight: 600; transition: background-color .12s ease;
}
.link-chip:hover { background: var(--raised); }

/* ---- Detail pages ---- */
.detail { display: grid; gap: 18px; }
.detail-hero { position: relative; display: flex; align-items: flex-end; gap: 28px; padding: 36px 32px 28px; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); min-height: 296px; }
.detail-glow { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(50px) saturate(1.2); opacity: .45; transform: scale(1.1); }
.detail-glow::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgb(var(--bg-rgb) / .1), rgb(var(--bg-rgb) / .85)); }
.detail-art { position: relative; box-shadow: 0 18px 50px rgb(var(--accent-rgb) / .18), 0 10px 30px rgb(0 0 0 / .35); }
.detail-hero.artist .detail-art { box-shadow: 0 0 0 2px rgb(var(--accent-rgb) / .8), 0 0 40px rgb(var(--accent-rgb) / .25); }
.detail-hero-text { position: relative; display: grid; gap: 10px; justify-items: start; min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.detail-title { font-size: clamp(30px, 3.6vw, 48px); font-weight: 700; line-height: 1.08; letter-spacing: -.015em; overflow-wrap: anywhere; }
.detail-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Stats ---- */
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; margin-bottom: 14px; scrollbar-width: thin; }
.chip { height: 36px; padding: 0 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; transition: background-color .12s ease; }
.chip:hover:not(.on) { background: var(--raised); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.year-rows { max-height: 330px; overflow: auto; padding-right: 6px; scrollbar-width: thin; }
.year-row { align-items: flex-start; }
.year-num { width: 54px; flex: none; font-weight: 700; font-size: 17px; color: var(--accent); font-variant-numeric: tabular-nums; }
.year-row .icon { margin-top: 4px; }
.hero-mini.static { cursor: default; }
.parts-bar { display: flex; gap: 2px; height: 14px; border-radius: 999px; overflow: hidden; }
.parts-bar span { min-width: 0; }
.parts-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; font-size: 13px; }
.parts-legend li { display: flex; align-items: center; gap: 8px; }
.parts-legend li .strong { margin-left: auto; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.decades { display: grid; gap: 10px; }
.decades li { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 10px; font-size: 14px; }
.decades li span:last-child { text-align: right; font-size: 13px; }
.repeat-count { font-size: 18px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.report { display: grid; grid-template-columns: minmax(0, 400px) minmax(200px, 280px); gap: 28px; align-items: start; }
.report-holder { min-height: 300px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.report-holder .loading-mark { min-height: 300px; }
.report-image { width: 100%; height: auto; display: block; }
.report-actions { display: grid; gap: 10px; }

/* ---- Settings ---- */
.kv { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; }
.kv-value { color: var(--ink); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.kv-value.amber { color: var(--amber); font-weight: 700; }
.renew { display: grid; gap: 8px; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); margin-bottom: -4px; }
.swatches { display: flex; justify-content: space-between; gap: 6px; }
.swatch-btn { padding: 4px; border-radius: 50%; border: 2px solid transparent; transition: border-color .15s ease, transform .1s ease; }
.swatch-btn:hover { transform: scale(1.06); }
.swatch-btn.on { border-color: var(--ink); }
.swatch-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--swatch); display: grid; place-items: center; color: var(--on-accent); }
.toggle-row { display: flex; align-items: center; gap: 16px; }
.toggle-row > div { flex: 1; display: grid; gap: 3px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; border-radius: 999px; background: var(--line2); transition: background-color .2s ease; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }

/* ---- Sign in ---- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card { width: min(440px, 100%); display: grid; gap: 16px; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; }
.signin-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.signin-brand img { border-radius: 13px; }
.signin-title { font-size: 30px; font-weight: 700; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input { height: 46px; padding: 0 14px; border-radius: 10px; background: var(--rail); border: 1px solid var(--line2); outline: none; transition: border-color .15s ease; }
.field input:focus { border-color: rgb(var(--accent-rgb) / .7); }
.signin-error { color: var(--loss); font-size: 14px; min-height: 20px; }

/* ---- Light mode tweaks ---- */
[data-theme="light"] .menu, [data-theme="light"] .dialog, [data-theme="light"] .toast { box-shadow: 0 18px 48px rgb(0 0 0 / .14), 0 2px 8px rgb(0 0 0 / .08); }
[data-theme="light"] .dialog::backdrop { background: rgb(0 0 0 / .25); }
[data-theme="light"] .detail-glow { opacity: .3; }

/* ---- Narrower windows ---- */
@media (max-width: 1240px) {
  .main { padding: 26px 28px 56px; }
  .span-4, .span-5 { grid-column: span 6; } .span-7, .span-8 { grid-column: span 6; }
  .clock.span-4 { grid-column: span 6; }
  .bubbles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
  :root { --sidebar: 76px; }
  .sidebar { padding: 22px 10px; align-items: center; }
  .sidebar-brand .wordmark { font-size: 10px !important; }
  .nav-link { width: 50px; justify-content: center; padding: 0; }
  .nav-label, .refresh-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sidebar-refresh { width: 50px; justify-content: center; padding: 0; }
  .sidebar-updated { display: none; }
  [class*="span-"], .clock.span-4 { grid-column: 1 / -1; }
  .hero { grid-template-columns: 1fr; gap: 16px; }
  .split, .report { grid-template-columns: 1fr; }
  .remove-bar { left: calc(var(--sidebar) + 24px); right: 24px; }
}

/* Phones: the sidebar becomes a bottom bar, like the iPhone app. */
@media (max-width: 759px) {
  :root { --sidebar: 0px; }
  body { font-size: 15px; }
  .sidebar {
    inset: auto 0 0 0; width: auto; height: auto; flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); gap: 0;
  }
  .sidebar-brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 0; }
  .nav-link { flex: 1; flex-direction: column; height: auto; gap: 3px; padding: 4px 0; width: auto; background: transparent !important; color: var(--faint); font-size: 10.5px; }
  .nav-link .icon { width: 46px; height: 32px; display: grid; place-items: center; border-radius: 11px; color: var(--muted); }
  .nav-link.on { color: var(--ink); }
  .nav-link.on .icon { background: var(--accent); color: var(--on-accent); }
  .nav-short { display: block; position: static; }
  .mobile-bar { display: flex; justify-content: flex-end; padding: 14px 16px 0; }
  .main { margin: 0; padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-header { min-height: 0; margin-bottom: 14px; }
  .page-title { font-size: 28px; }
  .range-bar { flex-basis: 100%; padding-top: 0; }
  .segmented button { padding: 0 6px; font-size: 13.5px; }
  .ov-grid { gap: 14px; }
  .card { padding: 16px; }
  .tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bubbles { display: flex; overflow-x: auto; gap: 12px; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .bubbles li { flex: none; width: 96px; scroll-snap-align: start; }
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-grid { grid-template-columns: 1fr; }
  .detail-hero { flex-direction: column; align-items: center; text-align: center; padding: 28px 16px 22px; }
  .detail-hero-text { justify-items: center; }
  .detail-links { justify-content: center; }
  .remove-bar { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .dialog:not(.anchored) { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .calendar-dialog, .confirm-dialog { width: 100%; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
.signin .forgot { justify-self: center; margin-top: -6px; }
.signin-error.ok { color: var(--accent); }
