:root {
  --bg: #f6f5f2; --surface: #ffffff; --border: #e3e1dc; --text: #1d1c1a; --muted: #6d6a64;
  --accent: #b5452f; --ok: #2f7d4f; --warn: #a86b00; --bad: #b3261e; --track: #ecebe7;
  --radius: 10px;
  --nav-h: 0px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --surface: #1f1e1c; --border: #33312e; --text: #ecebe7; --muted: #9b978f;
    --accent: #e0765f; --ok: #5cbf85; --warn: #e0a43a; --bad: #f07167; --track: #2c2a27;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
img { display: block; }
main { max-width: 1100px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) calc(48px + var(--nav-h)) max(16px, env(safe-area-inset-left)); }
.loading, .empty { color: var(--muted); padding: 16px 0; }
.hidden { display: none !important; }

/* Header and tabs: a top bar on desktop, a bottom bar on phones. */
header.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
header.top .inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; color: var(--text); text-decoration: none; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs a { display: flex; align-items: center; gap: 6px; padding: 14px 12px 12px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.offline { margin-left: auto; font-size: 12px; color: var(--warn); border: 1px solid currentColor; border-radius: 10px; padding: 1px 8px; }

/* Shared bits. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 4px 0 14px; }
input[type=search] { flex: 1 1 240px; max-width: 480px; font: inherit; font-size: 16px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.toolbar button { font: inherit; font-size: 16px; padding: 9px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.toolbar.key input { flex: 1 1 200px; max-width: 320px; font: inherit; font-size: 16px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.summary { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.muted { color: var(--muted); } .ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--track); white-space: nowrap; }
.facts { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0 0 8px; }
.prose { max-width: 72ch; margin: 0 0 10px; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 6px; overflow-wrap: anywhere; }
h2 { font-size: 17px; margin: 28px 0 12px; display: flex; align-items: baseline; gap: 10px; }
h2 small, h3 small { color: var(--muted); font-weight: normal; font-size: 13px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.pic { background: var(--track); color: var(--muted); display: flex; align-items: center; justify-content: center; overflow: hidden; flex: 0 0 auto; }
.pic img { width: 100%; height: 100%; object-fit: cover; }
.pic.round { border-radius: 50%; }
.pending { color: var(--muted); font-style: italic; }

/* Artist grid. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.card { color: var(--text); text-decoration: none; min-width: 0; }
.card .pic { width: 100%; aspect-ratio: 1; border-radius: 8px; font-size: 32px; }
.card .pic.round { border-radius: 50%; }
.card .title { font-weight: 600; margin-top: 8px; overflow-wrap: anywhere; line-height: 1.3; }
.card .meta { color: var(--muted); font-size: 13px; }
.card:hover .title { color: var(--accent); }

/* Lists of rows (search results, tracks). */
.rows { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-height: 52px; color: var(--text); text-decoration: none; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
a.row:hover { background: var(--bg); }
.row .pic { width: 40px; height: 40px; border-radius: 4px; }
.row .pic.round { border-radius: 50%; }
.row .main { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: 13px; }
.row .end { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Artist and album pages. */
.hero { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 8px; }
.hero .pic { width: 180px; height: 180px; border-radius: 8px; font-size: 48px; }
.hero .pic.round { border-radius: 50%; }
.hero .text { min-width: 0; flex: 1; }
.hero .kicker { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.hero .by { font-size: 16px; margin: 0 0 8px; }
.hero .by a { color: var(--text); font-weight: 600; text-decoration: none; }
.hero .by a:hover { color: var(--accent); }
.back { display: inline-block; margin: 0 0 12px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--accent); }

ol.tracks { list-style: none; margin: 0; padding: 0; }
ol.tracks > li { border-top: 1px solid var(--border); }
ol.tracks > li:first-child { border-top: 0; }
ol.tracks > li:target summary, ol.tracks > li.target summary { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.track > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-height: 48px; }
.track > summary::-webkit-details-marker { display: none; }
.track > summary:hover { background: var(--bg); }
.track .no { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 24px; text-align: right; }
.track .t-title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.track .dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.track .lyr { color: var(--muted); font-size: 12px; }
.track-body { padding: 4px 14px 14px 50px; font-size: 14px; }
.credit-groups { display: flex; flex-wrap: wrap; gap: 4px 32px; }
.credit-groups h4, .track-body h4 { margin: 8px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
ul.credits { list-style: none; margin: 0 0 6px; padding: 0; }
ul.credits li { padding: 1px 0; }
.lyrics { white-space: pre-wrap; max-height: 420px; overflow: auto; padding: 8px 12px; background: var(--bg); border-radius: 6px; max-width: 60ch; line-height: 1.55; margin: 0; font: inherit; }

/* Status tabs. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap > .empty { padding: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
td.name { min-width: 240px; overflow-wrap: anywhere; }
td.name a { color: var(--text); text-decoration: none; }
td.name a:hover { color: var(--accent); }
.when { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; white-space: nowrap; font-size: 13px; }
.bar { height: 6px; width: 120px; background: var(--track); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.error { color: var(--bad); font-size: 13px; margin-top: 4px; max-width: 420px; overflow-wrap: anywhere; }
.notes { font-style: italic; color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.disco { display: grid; gap: 10px; }
details.disco-artist { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
details.disco-artist > summary { cursor: pointer; list-style: none; padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
details.disco-artist > summary::-webkit-details-marker { display: none; }
details.disco-artist > summary::before { content: "▸"; color: var(--muted); }
details.disco-artist[open] > summary::before { content: "▾"; }
.disco-name { font-weight: 600; flex: 1 1 200px; overflow-wrap: anywhere; }
.disco-name small { font-weight: normal; }
.disco-progress { display: flex; align-items: center; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.disco-progress .bar { margin-top: 0; }
.st-present { color: var(--ok); } .st-downloading, .st-planned { color: var(--warn); } .st-failed { color: var(--bad); }
.st-missing, .st-unavailable { color: var(--muted); }
.disco-body { border-top: 1px solid var(--border); padding: 12px 14px 14px; }
.disco-body h3:first-child { margin-top: 0; }
.disco-body .table-wrap { border-radius: 8px; }
.disco-body td, .disco-body th { padding: 6px 10px; font-size: 13px; }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
details.more > summary { cursor: pointer; font-size: 14px; font-weight: 600; margin: 16px 0 8px; }
table.albums { table-layout: fixed; }
table.albums td { overflow-wrap: anywhere; }
table.albums td.name { min-width: 0; }
.c-thumb { width: 46px; } .c-year { width: 64px; } .c-type { width: 64px; } .c-status { width: 150px; } .c-library { width: 35%; }
td.thumb { width: 44px; padding-right: 0; }
td.thumb .pic { width: 36px; height: 36px; border-radius: 4px; }
.dir { color: var(--muted); overflow-wrap: anywhere; }

@media (max-width: 640px) {
  :root { --nav-h: calc(58px + env(safe-area-inset-bottom)); }
  header.top .inner { padding: 10px 16px; }
  .brand { font-size: 16px; }
  nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border); gap: 0; padding-bottom: env(safe-area-inset-bottom); }
  nav.tabs a { flex: 1; flex-direction: column; gap: 2px; padding: 8px 4px 6px; font-size: 11px; border-bottom: 0; border-top: 3px solid transparent; }
  nav.tabs a[aria-current="page"] { border-top-color: var(--accent); color: var(--accent); }
  nav.tabs svg { width: 22px; height: 22px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; }
  .card .title { font-size: 13px; }
  .card .meta { font-size: 12px; }
  .hero { gap: 14px; }
  .hero .pic { width: 112px; height: 112px; font-size: 32px; }
  h1 { font-size: 20px; }
  .row { padding: 8px 10px; }
  .track > summary { padding: 8px 10px; gap: 10px; }
  .track-body { padding: 4px 10px 12px 10px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 10px; }
  .stat b { font-size: 18px; }
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  tr:last-child { border-bottom: 0; }
  td { border: 0; padding: 2px 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; }
  td.name { min-width: 0; font-weight: 600; padding-bottom: 6px; }
  td[data-label]::before { content: attr(data-label); flex: 0 0 92px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
  td .bar, td .error { flex-basis: 100%; margin-left: 104px; }
  td.thumb { display: none; }
  .disco-body { padding: 10px; }
  .disco-body tr { padding: 8px 0; }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
