:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #ebe8e2;
  --ink: #17161b;
  --muted: #6d6b76;
  --faint: #a3a0aa;
  --line: #e1ddd6;
  --accent: #e8401c;
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgb(20 18 30 / .06), 0 4px 16px rgb(20 18 30 / .05);
  --radius: 16px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', var(--font);
  --tint: 16%;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11;
    --surface: #17171c;
    --surface-2: #222229;
    --ink: #f2f0ea;
    --muted: #9c9aa6;
    --faint: #686673;
    --line: #2a2a32;
    --accent: #ff5a36;
    --accent-ink: #120a07;
    --shadow: none;
    --tint: 24%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e11; --surface: #17171c; --surface-2: #222229; --ink: #f2f0ea; --muted: #9c9aa6;
  --faint: #686673; --line: #2a2a32; --accent: #ff5a36; --accent-ink: #120a07; --shadow: none; --tint: 24%;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
a { color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

/* ---------- header & tabs ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) var(--gutter) 10px;
  max-width: 1200px; margin: 0 auto;
}
/* Installed on iOS: the system blurs a strip under the status bar, so start the header a little lower. */
@media (display-mode: standalone) {
  .top { padding-top: calc(env(safe-area-inset-top) + 28px); }
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; flex: none; }
.brand h1 { font: 700 22px/1 var(--display); letter-spacing: -.02em; margin: 0; white-space: nowrap; }
.brand h1 span { font-weight: 500; color: var(--muted); }
@media (max-width: 420px) { .brand { gap: 8px; } .brand-mark { width: 28px; height: 28px; } .brand h1 { font-size: 19px; } }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.clock span { font: 700 20px/1 var(--display); font-variant-numeric: tabular-nums; }
.clock small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.icon-btn svg { width: 22px; height: 22px; }

.tabs {
  display: flex; gap: 4px; margin: 4px auto 0; padding: 4px;
  width: calc(100% - 2 * var(--gutter)); max-width: 420px;
  background: var(--surface-2); border-radius: 14px;
}
.tabs button { flex: 1; text-align: center; padding: 9px 10px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

main { max-width: 1200px; margin: 0 auto; padding: 14px var(--gutter) 24px; }

/* ---------- badges & shared ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.logo { width: var(--lg, 24px); height: var(--lg, 24px); border-radius: calc(var(--lg, 24px) * .24); flex: none; box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 12%, transparent); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font: 600 10.5px/1 var(--font); letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.live { background: var(--accent); color: var(--accent-ink); }
.badge.live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
.badge.onair { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .badge.live::before { animation: none; } }

.thumb {
  width: var(--size, 64px); height: var(--size, 64px); flex: none; border-radius: 12px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 30%, var(--surface-2));
  display: grid; place-items: center; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.thumb.has-logo { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 10%, transparent); }
.thumb span { font: 700 calc(var(--size, 64px) * .3)/1 var(--display); color: color-mix(in srgb, var(--c) 60%, var(--ink)); letter-spacing: -.03em; }

/* ---------- Now view ---------- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
@media (max-width: 400px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card.quiet { background: color-mix(in srgb, var(--surface) 55%, var(--bg)); box-shadow: none; }
.card.quiet .card-main .title { color: var(--muted); }
.card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-head .st-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-head .st-city { color: var(--muted); font-size: 13px; white-space: nowrap; }
.card-head .badge { margin-left: auto; }
.card-main { display: flex; gap: 12px; align-items: center; width: 100%; min-width: 0; }
.card-text { min-width: 0; flex: 1; }
.title { font: 700 17px/1.2 var(--display); letter-spacing: -.01em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.time { color: var(--muted); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.progress { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--c); border-radius: 4px; }
.next { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.next li { min-width: 0; }
.next button { display: flex; gap: 10px; width: 100%; font-size: 13.5px; min-width: 0; align-items: baseline; }
.next time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; min-width: 3.1em; white-space: nowrap; }
.next .n-title { flex: 1; min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.next .empty { color: var(--faint); font-size: 13px; }
.card .note { color: var(--muted); font-size: 13px; margin: 0; }
.card .note a { color: var(--ink); }

.about { display: grid; gap: 8px; }
.blurb { margin: 0; font-size: 13.5px; line-height: 1.45; color: color-mix(in srgb, var(--ink) 78%, var(--muted)); }
.genres { display: flex; flex-wrap: wrap; gap: 5px; }
.genres span { font-size: 11.5px; line-height: 1; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.li .genres { margin-top: 6px; }
.li-blurb {
  margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.sort-set { display: grid; gap: 8px; }
.sort-set h3 { font: 700 17px/1.2 var(--display); margin: 0; }
.sortbar { display: flex; }
.sortbar > span { display: none; }
.sortbar .seg { width: 100%; }
.sortbar .seg button { flex: 1; justify-content: center; text-align: center; padding: 9px 12px; }
.seg.seg-text button { width: auto; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- Guide toolbar ---------- */
.toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.days { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter); }
.days::-webkit-scrollbar { display: none; }
.days button {
  flex: none; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; min-width: 58px; line-height: 1.1;
}
.days button small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.days button b { font: 700 17px/1.2 var(--display); }
.days button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.days button[aria-pressed="true"] small { color: inherit; opacity: .7; }
.days.dim button[aria-pressed="true"] { background: var(--surface); color: var(--ink); border-color: var(--line); }
.toolbar-row { display: flex; gap: 8px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; min-width: 0; }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); font: inherit; font-size: 16px; padding: 10px 0; outline: none; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { width: 40px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); }
.seg button svg { width: 20px; height: 20px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Guide grid ---------- */
/* Phones, grid view: the page doesn't scroll; the grid is sized in JS (sizeGrid) to fill the space
   between the toolbar and the player bar, so it's the only scroller. */
@media (max-width: 640px) {
  /* Don't set overflow: hidden on html/body here: in iOS home-screen apps that lifts the fixed player bar. The grid is sized to fit, so the page has nothing to scroll; just stop the bounce. */
  html:has(body.grid-mode), body.grid-mode { overscroll-behavior: none; }
  /* iOS home-screen apps only extend the viewport behind the home indicator when the page is taller than the
     screen; otherwise the fixed player bar floats above a grey strip. So keep the page 1px taller than the screen. */
  body.grid-mode { min-height: calc(100lvh + 1px); }
  body.grid-mode .grid-wrap { max-height: none; overscroll-behavior: contain; }
  body.grid-mode, body.grid-mode.has-bar, body.grid-mode.has-bar.bar-mini { padding-bottom: 0; }
  body.grid-mode main { padding-bottom: 0; }
}

.grid-wrap {
  --label: 116px; --pxh: 180px; --lane: 64px;
  overflow: auto; overscroll-behavior-x: contain;
  max-height: calc(100dvh - 210px); min-height: 320px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  margin: 0 calc(-1 * var(--gutter) + 0px);
}
@media (max-width: 640px) {
  .grid-wrap { --label: 92px; --pxh: 140px; --lane: 62px; border-radius: 0; border-left: 0; border-right: 0; }
}
@media (min-width: 641px) { .grid-wrap { margin: 0; } }
.grid { position: relative; display: grid; grid-template-columns: var(--label) var(--w); width: calc(var(--label) + var(--w)); }
.g-corner, .g-hours { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); height: 34px; }
.g-corner { left: 0; z-index: 4; display: grid; place-items: center; }
.g-full { display: none; width: 30px; height: 30px; border-radius: 8px; place-items: center; color: var(--muted); }
.g-full svg { width: 18px; height: 18px; }
.g-full[aria-pressed="true"] { color: var(--ink); background: var(--surface-2); }
@media (max-width: 640px) {
  .g-full { display: grid; }
  /* Full-screen grid: hide everything above it; the player bar is forced to its slim version in JS. */
  body.grid-full .top, body.grid-full .tabs, body.grid-full .toolbar { display: none; }
  body.grid-full main { padding-top: calc(env(safe-area-inset-top, 0px) + 6px); }
}
@media (max-width: 640px) and (display-mode: standalone) {
  body.grid-full main { padding-top: calc(env(safe-area-inset-top, 0px) + 20px); }
}
.g-hours { position: sticky; }
.g-hours span { position: absolute; top: 9px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; transform: translateX(6px); }
.g-label {
  position: sticky; left: 0; z-index: 2; background: var(--surface);
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  padding: 8px 10px; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0;
}
.g-label b { font-weight: 600; font-size: 13px; line-height: 1.15; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.g-label b > span:last-child { min-width: 0; }
@media (max-width: 640px) {
  .g-label { padding: 6px 6px 6px 8px; }
  .g-label b { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 11.5px; overflow-wrap: normal; }
  .g-label b .logo { --lg: 22px !important; }
  .g-label small { display: none; }
}
.g-label small { color: var(--muted); font-size: 11px; }
.g-row {
  position: relative; border-bottom: 1px solid var(--line);
  background-image: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px var(--pxh));
  background-size: var(--pxh) 100%;
}
.g-row > .g-empty { position: sticky; left: calc(var(--label) + 12px); display: inline-block; margin-top: calc(var(--lane) / 2 - 9px); color: var(--faint); font-size: 12.5px; }
.blk {
  position: absolute; height: calc(var(--lane) - 8px); margin-top: 4px;
  padding: 0; border-radius: 9px; overflow: hidden; overflow: clip;
  background: color-mix(in srgb, var(--c) var(--tint), var(--surface));
  border-left: 3px solid var(--c);
  display: flex; align-items: center; min-width: 0;
}
.blk .b-in {
  position: sticky; left: calc(var(--label) + 4px);
  display: flex; flex-direction: column; gap: 1px; min-width: 0; max-width: 100%;
  padding: 4px 8px;
}
.blk:hover { background: color-mix(in srgb, var(--c) calc(var(--tint) + 10%), var(--surface)); }
.blk .b-time { font-size: 10.5px; line-height: 1.25; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.blk .b-title { font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk .b-sub { font-size: 11px; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk.filler, .blk.stream {
  background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c) 9%, transparent) 6px 12px), var(--surface);
  border-left-color: color-mix(in srgb, var(--c) 45%, transparent);
}
.blk.filler .b-title { color: var(--muted); font-weight: 500; }
.blk.past { opacity: .55; }
.blk.now:not(.filler) { box-shadow: inset 0 0 0 2px var(--c); }
.mini-live { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 5px; vertical-align: 1px; box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: onsonos 1.8s ease-out infinite; }
@keyframes onsonos { 70% { box-shadow: 0 0 0 5px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .mini-live { animation: none; } }
.li-st .mini-live { margin: 0 0 0 4px; }
.on-sonos { color: var(--accent); font-weight: 600; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 1; pointer-events: none; }
.now-line::before { content: ''; position: absolute; top: 28px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* ---------- Guide list ---------- */
.list { display: grid; gap: 4px; }
.list h3 { font: 700 13px/1 var(--display); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin: 16px 0 6px; }
.list h3:first-child { margin-top: 4px; }
.li {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: start; width: 100%;
  padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.li + .li { margin-top: 2px; }
.li.past { opacity: .5; }
.li-time { padding-top: 2px; font: 600 15px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.li-time span { display: block; font: 400 12px/1.3 var(--font); color: var(--muted); }
.li-body { min-width: 0; }
.li-st { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.li-st .logo { --lg: 18px; }
.li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: inherit; border-radius: 3px; }
.more-btn { justify-self: start; color: var(--muted); font-size: 13.5px; padding: 8px 4px; text-decoration: underline; text-underline-offset: 3px; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- sheet ---------- */
.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--ink);
  width: min(560px, 100%); max-height: min(86dvh, 760px); border-radius: 20px;
  box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
.sheet::backdrop { background: rgb(10 10 14 / .55); backdrop-filter: blur(2px); }
@media (max-width: 640px) {
  .sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.sheet-inner { padding: 20px; display: grid; gap: 14px; outline: none; position: relative; }
.sheet-head { display: flex; gap: 14px; align-items: flex-start; }
.sheet-head .thumb { --size: 88px; }
.sheet h2 { font: 700 22px/1.15 var(--display); letter-spacing: -.015em; margin: 4px 0 2px; overflow-wrap: anywhere; text-wrap: balance; }
.sheet .meta { color: var(--muted); font-size: 14px; }
.sheet .st-line { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.sheet h3 + .chips { margin-top: 2px; }
.sheet .desc { white-space: pre-wrap; font-size: 14.5px; line-height: 1.5; margin: 0; max-height: 36dvh; overflow: auto; }
.orig summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.orig[open] summary { margin-bottom: 8px; }
.orig .desc { color: var(--muted); }
.sheet .actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.sheet .actions .btn {
  min-height: 48px; padding: 0 16px; border-radius: 14px; font-size: 15px; font-weight: 600; line-height: 1.2; text-align: center;
  background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line);
}
.sheet .actions .btn.primary { background: var(--ink); color: var(--bg); box-shadow: none; }
.sheet .actions .btn svg { width: 12px; height: 12px; flex: none; }
.sheet .actions .btn .eq { height: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px; font-weight: 600; text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--bg); }
.close-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); }
.close-x svg { width: 16px; height: 16px; }
.st-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.order-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-row .more-btn { padding: 4px; }
.st-row { display: flex; align-items: center; gap: 2px; position: relative; }
.st-row > label { flex: 1; min-width: 0; }
.drag { flex: none; width: 34px; height: 44px; display: grid; place-items: center; color: var(--faint); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 8px; }
.drag svg { width: 16px; height: 16px; fill: currentColor; }
.drag:hover, .drag:focus-visible { color: var(--ink); }
.st-row.dragging { z-index: 2; background: var(--surface-2); box-shadow: 0 8px 24px rgb(0 0 0 / .35); border-radius: 10px; }
.st-row.dragging .drag { cursor: grabbing; color: var(--ink); }
.st-list label { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.st-list label span.nm { flex: 1; font-weight: 500; }
.st-list small { color: var(--muted); }
.st-list .err { color: var(--accent); }
.st-list input, .opt input { width: 20px; height: 20px; accent-color: var(--accent); }
.opt { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

/* ---------- add station ---------- */
.st-list .rm { font-size: 12.5px; color: var(--muted); padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); margin-left: 4px; }
.add { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.add h3 { font: 700 17px/1.2 var(--display); margin: 0; }
.hint { margin: 0; color: var(--muted); font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; font-weight: 500; }
.chip small { color: var(--muted); font-weight: 400; margin-left: 2px; }
.add-row { display: flex; gap: 8px; }
.add input, .add select {
  width: 100%; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
.add-row input { flex: 1; }
.find { margin: 0; font-size: 14px; padding: 12px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.find p { margin: 0; }
.find.err, .hint.err, small.err { color: var(--accent); }
.find ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; }
.find time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.find-fields, .manual-form { display: grid; gap: 10px; }
@media (min-width: 480px) { .find-fields { grid-template-columns: 1fr 1fr; } }
.find label, .manual-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.manual summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }
.manual[open] summary { margin-bottom: 10px; }
.manual-form .btn, .find .btn { justify-self: start; }

/* ---------- sonos ---------- */
.sonos-play {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start; align-self: flex-start;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: var(--ink); background: transparent; border: 1px solid var(--line);
}
.sonos-play:hover { background: var(--surface-2); }
.sonos-play svg { width: 10px; height: 10px; color: var(--muted); }
.sonos-play.on { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); background: color-mix(in srgb, var(--c) 10%, transparent); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { width: 3px; background: currentColor; border-radius: 1px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.35s; } .eq i:nth-child(3) { animation-delay: -.7s; }
.eq.paused i { animation: none; height: 4px; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }
@media (prefers-reduced-motion: reduce) { .eq i { animation: none; height: 8px; } }
/* Player bar modelled on the Sonos app's: slate panel, artwork, speakers badge, round play button, volume row. */
.sonos-bar {
  --sb-bg: #3b4148; --sb-ink: #f4f5f6; --sb-muted: #b3b9c0; --sb-track: #5a6169;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--sb-bg); color: var(--sb-ink);
  border-radius: 20px 20px 0 0; box-shadow: 0 -6px 24px rgb(0 0 0 / .18);
}
@media (min-width: 700px) { .sonos-bar { left: 50%; right: auto; width: min(640px, calc(100% - 32px)); transform: translateX(-50%); bottom: 12px; border-radius: 20px; padding-bottom: 12px; } }
body.has-bar { padding-bottom: calc(170px + env(safe-area-inset-bottom, 0px)); }
body.has-bar.bar-mini { padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px)); }
.sonos-bar { padding-top: 4px; row-gap: 8px; }
.sb-handle { justify-self: center; width: 64px; height: 22px; display: grid; place-items: center; color: var(--sb-muted); border-radius: 11px; }
.sb-handle:hover { color: var(--sb-ink); background: color-mix(in srgb, var(--sb-ink) 8%, transparent); }
.sb-handle svg { width: 24px; height: 12px; }
/* Minimised: the player tucks away into a small floating pill with the up arrow (same on phone and desktop). */
.sonos-bar.mini {
  left: 50%; right: auto; width: 76px !important; transform: translateX(-50%);
  bottom: max(10px, calc(env(safe-area-inset-bottom, 0px) - 6px));
  padding: 2px 0; row-gap: 0; border-radius: 16px;
  box-shadow: 0 4px 16px rgb(0 0 0 / .22);
}
.sonos-bar.mini > :not(.sb-handle) { height: 0; min-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; overflow: hidden; pointer-events: none; }
.sonos-bar.mini .sb-handle { width: 76px; height: 28px; color: var(--sb-ink); }
@media (min-width: 700px) { .sonos-bar.mini { bottom: 12px; } }
.sb-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sb-art { width: 48px; height: 48px; border-radius: 10px; flex: none; background: #5a6169; display: grid; place-items: center; overflow: hidden; position: relative; color: var(--sb-muted); }
.sb-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sb-art svg { width: 24px; height: 24px; }
.sb-text { flex: 1; min-width: 0; display: grid; gap: 1px; color: inherit; line-height: 1.25; }
.sb-text small { font-size: 12.5px; color: var(--sb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-text b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-text span { font-size: 13px; color: var(--sb-muted); display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-text span .logo { --lg: 14px; box-shadow: none; }
.sb-spk { position: relative; width: 40px; height: 40px; display: grid; place-items: center; color: inherit; flex: none; }
.sb-spk svg { width: 26px; height: 26px; }
.sb-spk i { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #6c737b; color: #fff; font: 600 11px/17px var(--font); font-style: normal; text-align: center; }
.sb-pp { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; color: var(--sb-ink); border: 2px solid color-mix(in srgb, var(--sb-ink) 55%, transparent); }
.sb-pp svg { width: 16px; height: 16px; }
.sb-pp:disabled { opacity: .5; }
.sb-volrow { display: flex; align-items: center; gap: 12px; }
.sb-volrow > svg { width: 20px; height: 20px; flex: none; }
.sb-volrow output { min-width: 2.2ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--sb-muted); font-size: 14px; }
/* Range sliders: filled track up to the thumb (--v), used in the bar and the speakers panel. */
.sonos-bar input[type=range], .spk-vol input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 8px; border-radius: 4px; margin: 0;
  background: linear-gradient(to right, var(--fill) 0 var(--v, 0%), var(--track) var(--v, 0%) 100%);
  --fill: var(--sb-ink); --track: var(--sb-track);
}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .35); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .35); }
input[type=range]:disabled { opacity: .4; }
/* Speakers panel */
.spk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.spk { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.spk-main { flex: 1; min-width: 0; display: grid; gap: 8px; }
.spk-main b { font-weight: 600; }
.spk-main small { color: var(--muted); }
.spk-vol { display: flex; align-items: center; gap: 10px; }
.spk-vol svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.spk-vol input[type=range] { --fill: var(--ink); --track: color-mix(in srgb, var(--ink) 15%, transparent); height: 6px; }
.spk-vol output { min-width: 2.2ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.spk-check input { position: absolute; opacity: 0; pointer-events: none; }
.spk-check span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); cursor: pointer; }
.spk-check input:checked + span { background: var(--ink); border-color: var(--ink); }
.spk-check input:checked + span::after { content: ''; width: 10px; height: 6px; border: 2.5px solid var(--bg); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.spk-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sheet .spk-actions { display: grid; grid-template-columns: auto 1fr; }
.spk-actions .btn { justify-content: center; }
.home-net { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.home-net .actions-row { display: flex; gap: 8px; }
.add .opt input[type=checkbox] { width: 20px; height: 20px; flex: none; padding: 0; }
.spk-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spk-row .btn { margin-left: auto; padding: 8px 12px; }
.spk-list small { color: var(--muted); }
.sonos-set .btn { justify-self: start; }
.toast {
  position: fixed; left: 50%; bottom: calc(180px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer & states ---------- */
.skeleton { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); height: 176px; position: relative; overflow: hidden; }
.skeleton::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 5%, transparent), transparent); animation: shimmer 1.3s infinite; transform: translateX(-100%); }
@keyframes shimmer { to { transform: translateX(100%); } }
.error-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--muted); }

/* Track ID */
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.id-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: var(--muted); background: transparent; border: 1px solid var(--line);
}
.id-btn:hover { background: var(--surface-2); color: var(--ink); }
.id-btn svg { width: 12px; height: 12px; }
.id-btn[disabled] { opacity: 1; color: var(--ink); }
.track-id {
  display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows .36s cubic-bezier(.22, .8, .2, 1), opacity .28s ease;
}
.track-id.in { grid-template-rows: 1fr; opacity: 1; }
.track-id > .tid-inner { min-height: 0; overflow: hidden; }
.tid-inner.swap { animation: tidswap .3s ease; }
@keyframes tidswap { from { opacity: .25; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.track-id:empty { display: none; }
@media (prefers-reduced-motion: reduce) {
  .track-id { transition: none; }
  .tid-inner.swap { animation: none; }
}
.tid {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 8px; border-radius: 10px; background: var(--surface-2); color: inherit; text-decoration: none;
}
.tid-art { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: none; }
.tid-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.tid-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tid-text span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tid-text small { font-size: 11px; color: var(--muted); opacity: .8; }
.tid-note { font-size: 13px; color: var(--muted); margin: 0; }
.tid-earlier { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.tid-earlier li { font-size: 12px; color: var(--muted); display: flex; gap: 8px; min-width: 0; }
.tid-earlier time { flex: none; font-variant-numeric: tabular-nums; opacity: .7; }
.sb-id { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); flex: none; }
.sb-id svg { width: 16px; height: 16px; }
.sb-id:hover { color: var(--ink); background: var(--surface-2); }
.id-wave { display: inline-flex; align-items: center; gap: 2.5px; height: 13px; }
.id-wave i { width: 2.5px; height: 100%; border-radius: 2px; background: currentColor; animation: idwave 1.15s cubic-bezier(.4, 0, .6, 1) infinite; }
/* negative delays spread the bars through one cycle, so the wave is already travelling */
.id-wave i:nth-child(1) { animation-delay: -.86s; }
.id-wave i:nth-child(2) { animation-delay: -.57s; }
.id-wave i:nth-child(3) { animation-delay: -.29s; }
.id-wave i:nth-child(4) { animation-delay: 0s; }
@keyframes idwave { 0%, 100% { transform: scaleY(.26); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .id-wave i { animation: none; transform: scaleY(.6); } }
/* Saved track IDs */
.ids-set { display: grid; gap: 8px; }
.tid-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tid-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.tid-list li { border-left: 3px solid var(--c); border-radius: 10px; overflow: hidden; }
.tid-list .tid { border-radius: 0 10px 10px 0; padding: 8px 10px; }
.tid-list .tid time { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.tid-art.blank { background: var(--surface-2); }
.more-btn.back { margin-bottom: 12px; }

/* Launch animation: the radios cut in frame by frame, like a hand-made title card */
.splash {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--bg); transition: opacity .4s steps(2, end);
}
.splash.done { opacity: 0; pointer-events: none; }
.splash-mark { will-change: transform; animation: signal-lock .4s steps(1, end) .64s; }
.splash svg { display: block; width: min(40vw, 168px); height: auto; }
/* no fade on the plate — it is just there, hard cut */
.splash .r {
  opacity: 0; transform-box: fill-box; transform-origin: 50% 50%;
  animation: tune-in .6s steps(1, end) forwards;   /* four discrete frames, no interpolation */
}
.splash .r1 { animation-delay: .06s; }
.splash .r2 { animation-delay: .18s; }
.splash .r3 { animation-delay: .30s; }
.splash .r4 { animation-delay: .44s; }   /* the orange one lands last */
.splash .ping {
  opacity: 0; transform-box: fill-box; transform-origin: 50% 50%;
  animation: ping-out 1s steps(6, end) forwards;
}
.splash .ping1 { animation-delay: .6s; }
.splash .ping2 { animation-delay: .84s; }
.splash-word {
  margin: 0; font: 700 19px/1 var(--display); letter-spacing: -.02em; color: var(--ink);
  opacity: 0; animation: word-cut .4s steps(4, end) .72s forwards;
}
.splash-word span { color: var(--green); }
.splash.done .splash-word { opacity: 0; transition: opacity .2s steps(2, end); animation: none; }

/* lands hot and crooked, jitters, then sits straight */
@keyframes tune-in {
  0% { opacity: 0; transform: scale(.55) rotate(-16deg); }
  25% { opacity: 1; transform: scale(1.16) rotate(7deg); }
  50% { opacity: 1; transform: scale(.93) rotate(-3deg); }
  75% { opacity: 1; transform: scale(1.04) rotate(1.5deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes signal-lock { 0%, 100% { opacity: 1; } 25% { opacity: .3; } 50% { opacity: 1; } 75% { opacity: .65; } }
@keyframes ping-out { 0% { opacity: .8; transform: scale(.5); } 100% { opacity: 0; transform: scale(5); } }
@keyframes word-cut {
  from { opacity: 1; clip-path: inset(0 100% 0 0); }
  to { opacity: 1; clip-path: inset(0 0 0 0); }
}

@media (prefers-reduced-motion: reduce) {
  .splash .r, .splash-word { animation: none; opacity: 1; clip-path: none; }
  .splash-mark { animation: none; }
  .splash .ping { animation: none; opacity: 0; }
}

/* Station health */
.health-set { display: grid; gap: 8px; }
.health-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.health-list li { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.health-list li span { color: var(--muted); }

/* About & credits */
.about-set p { margin: 0 0 12px; }
.about-set h3 { margin: 18px 0 6px; }
.credit-list { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 4px; }
.credit-list li { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; border-left: 3px solid var(--c); border-radius: 0 8px 8px 0; background: var(--surface-2); font-size: 14px; }
.credit-list li small { color: var(--muted); font-size: 12px; margin-left: auto; }
.credit-list a { color: var(--ink); text-decoration: none; }
.credit-list a:hover { text-decoration: underline; }
.about-row { margin-top: 20px; }

/* Open a track ID in Spotify — their own icon, kept quiet in grey */
.tid-wrap { position: relative; }
.tid-wrap > .tid { padding-right: 88px; }
.tid-links {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 2px;
}
.tid-link {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  color: var(--muted); transition: color .15s ease, background-color .15s ease;
}
.tid-link svg { width: 22px; height: 22px; display: block; }
.tid-link.bandcamp svg { width: 24px; height: 14px; }
.tid-link:hover, .tid-link:focus-visible { color: var(--ink); background: var(--surface-2); }

/* Alerts */
.alerts-set { display: grid; gap: 8px; }
.alerts-set .opt small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.alerts-set .opt input:disabled + * { opacity: .5; }

/* Where Listen plays at home */
.sortbar.play-on { display: grid; gap: 6px; }
.sortbar.play-on > span { display: block; color: var(--muted); font-size: 13px; }
