/* The fonts, served from this site (Google Fonts' latin and latin-ext
   files, OFL): no third-party request before the first paint, and the
   service worker keeps them for offline. A browser only downloads the
   latin-ext file when a song title needs one of its letters. Browsers
   keep them for a year (firebase.json): to change a font, give the new
   file a new name. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 900;
  font-display: swap;
  src: url('../fonts/inter-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 900;
  font-display: swap;
  src: url('../fonts/inter-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --primary: #38f916;            /* NOSTALJI green: live and selected state */
  --bg-color: #020202;
  --panel: #070707;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --muted: #a1a1aa;              /* 8.4:1 on the ground */
  --dim: #8b8b94;                /* 5.9:1 */
  --error: #fca5a5;
  --text-soft: #e4e4e7;
  --surface: #18181b;            /* behind a cover while it loads */
  --edge: rgba(255, 255, 255, 0.1); /* the hairline round covers and boxes */
  --hover: rgba(255, 255, 255, 0.04);
  --selected: rgba(255, 255, 255, 0.06);
  /* See-through grounds over the blurred cover, from most to least see-through */
  --glass: rgba(2, 2, 2, 0.6);           /* the app column, the top bar */
  --glass-panel: rgba(7, 7, 7, 0.6);     /* Log and Signal beside Now (computer) */
  --glass-side: rgba(5, 5, 5, 0.75);     /* the sidebar (computer) */
  --glass-raised: rgba(10, 10, 10, 0.92); /* the mini player, a shade above the tabs */
  --glass-bar: rgba(2, 2, 2, 0.94);      /* the tab bar */
  /* The play bar takes the cover's colour; script.js sets both */
  --btn-bg: #ffffff;
  --btn-ink: #000000;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg-color); }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-color);
  color: var(--text);
  height: 100vh;
  /* The visible height: 100vh is the height without the mobile toolbar,
     which would hide the tab bar behind it */
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--primary); color: #000; }

.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
}

[hidden] { display: none !important; }

/* Keyboard focus, visible on every control */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
.screen:focus-visible { outline: none; }

/* ------------------------------------------------------------ backdrop */

#dynamic-bg {
  position: fixed;
  inset: -60px;
  z-index: 0;
  background-size: cover;
  background-position: center;
  filter: blur(60px) brightness(0.32) saturate(1.5);
  opacity: 0.7;
  transition: background-image 1.5s ease-in-out;
}

#dynamic-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, transparent 0%, var(--bg-color) 80%);
}

.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
              linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 3px 100%;
  opacity: 0.4;
}

/* ------------------------------------------------------------ app shell */

#app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr) auto auto;
  width: 100%;
  max-width: 460px;
  height: 100%;
  margin: 0 auto;
}

/* On a computer the app sits as a phone-width column over the cover */
@media (min-width: 600px) {
  #app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    background: var(--glass);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  margin: 0;
  font-weight: 900;
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  cursor: default;
}
.brand span { color: var(--primary); }
@media (hover: hover) {
  .brand:hover { text-shadow: 2px 0 #ff00c1, -2px 0 #00fff9; }
}

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(56, 249, 22, 0.5);
  animation: live-pulse 2.4s ease-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 249, 22, 0.55); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(56, 249, 22, 0); }
}

/* ------------------------------------------------------------ screens */

.screens {
  position: relative;
  min-height: 0;
}

.screen {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  animation: screen-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.screen::-webkit-scrollbar { width: 4px; }
.screen::-webkit-scrollbar-thumb { background: var(--line-strong); }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.screen-title {
  margin: 4px 0 6px;
  font-weight: 900;
  font-style: italic;
  font-size: 2rem;
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}

.screen-sub {
  margin: 0 0 20px;
  color: var(--dim);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ------------------------------------------------------------ now */

.screen-now {
  display: flex;
  flex-direction: column;
}

.cover {
  position: relative;
  margin: 0 auto;
  /* Short phones keep the title and PLAY above the tab bar */
  width: min(100%, calc(100dvh - 420px));
  min-width: 200px;
  flex: none;
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--edge);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  container-type: inline-size;   /* the facts label fits itself to the cover */
}

/* With a sponsor credit at the foot of Now, the cover gives up a little
   height so the whole screen still fits a phone like a Pixel 8 in the
   app (412×839), credit included, instead of the tab bar cutting it */
@media (orientation: portrait) and (max-width: 1023px) {
  body[data-sponsor] .cover { width: min(100%, calc(100dvh - 500px)); }
}

.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
}
.cover img.is-loading { opacity: 0.35; }

.cover-facts {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 7px 11px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--edge);
  color: var(--text-soft);
  max-width: calc(100% - 20px);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cover-facts > span { white-space: nowrap; }
.cover-facts b { font-weight: 700; color: var(--primary); }
.cover-facts > span:not([hidden]) ~ span { padding-left: 12px; border-left: 1px solid var(--edge); }
/* A small cover (a 320px phone, a short laptop): Year and Format one
   above the other, without the divider, instead of running off the edge */
@container (max-width: 240px) {
  .cover-facts { flex-direction: column; gap: 4px; }
  .cover-facts > span:not([hidden]) ~ span { padding-left: 0; border-left: 0; }
}

/* Title and artist on the left, Share beside them */
.meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  margin-top: 20px;
}
.meta > * { grid-column: 1; }
.meta .meta-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  margin-top: -2px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  position: relative;
  min-height: 36px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.share svg { width: 16px; height: 16px; fill: currentColor; }
/* The pills are drawn 36px tall but take a 44px tap; Share and Like sit
   8px apart, so their tap areas meet without overlapping */
.share::after,
.sleep::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}

/* Like: an outlined heart, filled green once liked */
.like svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.like[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }
.like[aria-pressed="true"] svg { fill: currentColor; }

.title {
  margin: 0;
  font-weight: 900;
  font-style: italic;
  font-size: 1.875rem;
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  text-wrap: balance;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-right: 0.08em; /* the italic's overhang */
}

@media (max-width: 380px) {
  .title { font-size: 1.625rem; }
}

.artist {
  margin: 10px 0 0;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-note { margin: 10px 0 0; color: var(--dim); }

/* The play bar: cover-coloured, the station's one big control */
.play-wrap { margin-top: 20px; }

.play-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: 60px;
  padding: 0 18px;
  border: 0;
  border-radius: 2px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: background-color 0.6s ease, color 0.6s ease, transform 0.12s ease;
}
.play-btn:active { transform: scale(0.985); }
@media (hover: hover) {
  .play-btn:hover { filter: brightness(1.06); }
}

.play-icon { width: 24px; height: 24px; flex: none; fill: currentColor; }
.play-icon .i-stop,
.play-icon .i-retry { display: none; }
/* Failed: a retry arrow, so the bar itself says something went wrong */
body[data-state="error"] .play-icon .i-play { display: none; }
body[data-state="error"] .play-icon .i-retry { display: inline; }
body[data-state="playing"] .play-icon .i-play,
body[data-state="connecting"] .play-icon .i-play { display: none; }
body[data-state="playing"] .play-icon .i-stop,
body[data-state="connecting"] .play-icon .i-stop { display: inline; }

.play-label { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.play-word {
  font-weight: 900;
  font-style: italic;
  font-size: 1.75rem;
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-transform: uppercase;
}
.play-word::before { content: "Play"; }
body[data-state="playing"] .play-word::before,
body[data-state="connecting"] .play-word::before { content: "Stop"; }

.play-status {
  margin-top: 5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visualizer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 24px;
}
/* Only while there's something to show: idle dots read as a spinner */
body[data-state="idle"] .visualizer,
body[data-state="error"] .visualizer { visibility: hidden; }
.visualizer i {
  width: 3px;
  height: 24px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.5;
  /* Scale, not height: it runs on the compositor, so HLS work and
     song-info updates on the main thread can't make the wave stutter */
  transform: scaleY(0.1667);
  transform-origin: bottom;
}
/* One animation for both states, so a buffering blip (playing ->
   connecting -> playing) doesn't restart the wave from frame 0.
   Connecting just shrinks and dims it. */
body[data-state="playing"] .visualizer i,
body[data-state="connecting"] .visualizer i {
  animation: v-bounce 0.8s infinite ease-in-out;
  animation-delay: calc(var(--i) * 0.1s - 0.8s);
}
.visualizer {
  transform-origin: bottom;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
body[data-state="connecting"] .visualizer { transform: scaleY(0.42); opacity: 0.75; }
/* Negative delays start every bar mid-cycle: the full wave from the
   first frame instead of bars kicking in one after another */
.visualizer i:nth-child(1) { --i: 1; }
.visualizer i:nth-child(2) { --i: 2; }
.visualizer i:nth-child(3) { --i: 3; }
.visualizer i:nth-child(4) { --i: 4; }
.visualizer i:nth-child(5) { --i: 5; }
.visualizer i:nth-child(6) { --i: 6; }
.visualizer i:nth-child(7) { --i: 7; }

@keyframes v-bounce {
  0%, 100% { transform: scaleY(0.1667); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

.status-note {
  margin: 12px 0 0;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--error);
}

.volume {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  color: var(--muted);
}
.volume label { flex: none; }

/* Sleep timer: a pill like Share, green while it counts down */
.sleep {
  position: relative;
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
}
.sleep[data-on="true"],
.sleep[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }
.saver-block .sleep { margin-top: 12px; }
@media (hover: hover) {
  .share:hover,
  .sleep:hover { border-color: var(--primary); color: var(--primary); }
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 44px; /* touch target; the track is drawn below */
  margin: 0;
  background: transparent;
  cursor: pointer;
  --fill: 80%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(to right, var(--text) var(--fill), var(--line-strong) var(--fill));
}
input[type="range"]::-moz-range-track { height: 3px; background: var(--line-strong); }
input[type="range"]::-moz-range-progress { height: 3px; background: var(--text); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: 0;
}

.lyrics {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}
.lyrics summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.lyrics summary::-webkit-details-marker { display: none; }
.lyrics summary::after { content: "+"; font-size: 16px; }
.lyrics[open] summary::after { content: "–"; }
.lyrics-body {
  padding: 4px 0 8px;
  white-space: pre-line;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-soft);
}

/* ------------------------------------------------------------ sponsor */

/* The server's sponsor (sponsor.json): a credit, not an ad. A mono
   label, the name in the title's black italic, a hairline above, the
   same weight as the volume row: there when you look, never in the way.
   It sits at the foot of Now, so a short song pushes it down, not up. */
.sponsor-slot {
  margin-top: auto;
  padding-top: 20px;
}

.sponsor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  row-gap: 6px;
  min-height: 44px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}
.sponsor-label { grid-column: 1 / -1; color: var(--dim); }
/* At the foot of Now: label and name on one line, to stay short */
.sponsor-slot .sponsor {
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 12px;
  padding-top: 12px;
}
.sponsor-slot .sponsor-label { grid-column: auto; }
.sponsor-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
/* Logos come in every shape: held to the name's height, never wider
   than a short word, and drawn as they are (no tint, no frame) */
.sponsor-logo {
  flex: none;
  height: 24px;
  width: auto;
  max-width: 96px;
  object-fit: contain;
}
.sponsor-name {
  font-weight: 900;
  font-style: italic;
  font-size: 1rem;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.08em; /* the italic's overhang */
}
.sponsor-arrow {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--muted);
  transition: color 0.18s ease, transform 0.18s ease;
}

/* Signal: the sponsor with its one line, between hairlines like the readout */
.sponsor-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}
.sponsor-card .sponsor-logo { height: 40px; max-width: 120px; }
.sponsor-card .sponsor-logo[hidden] + .sponsor-text { grid-column: 1 / 3; }
.sponsor-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sponsor-card .sponsor-name {
  font-size: 1.375rem;
  line-height: 1;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sponsor-line { color: var(--muted); font-size: 0.9375rem; line-height: 1.45; }
.sponsor-line:empty { display: none; }
.sponsor-ask-link { color: var(--primary); }
/* A sponsor with just a name: one line on Signal too, like the foot of
   Now, instead of a name boxed between two rules */
.sponsor-block.is-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.sponsor-block.is-compact .block-label { margin: 0; }
.sponsor-block.is-compact .sponsor-card {
  display: flex;
  min-height: 0;
  padding: 0;
  border: 0;
}
.sponsor-block.is-compact .sponsor-name { font-size: 1rem; }

@media (hover: hover) {
  /* Only a sponsor with a website is a link, and only a link lights up */
  .sponsor[href]:hover .sponsor-name,
  .sponsor-card[href]:hover .sponsor-name { color: var(--primary); }
  .sponsor[href]:hover .sponsor-arrow,
  .sponsor-card[href]:hover .sponsor-arrow { color: var(--primary); transform: translate(2px, -2px); }
}

/* The sidebar's credit is for a computer only */
.sponsor-side { display: none; }

/* ------------------------------------------------------------ log */

.log-list { list-style: none; margin: 0; padding: 0; }

.log-item {
  display: grid;
  grid-template-columns: 26px 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.log-item:last-child { border-bottom: 1px solid var(--line); }

.log-item .n { color: var(--dim); }
.log-item img {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid var(--edge);
  background: var(--surface);
}
.log-item .song {
  display: block;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-item .by {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-item .at { color: var(--dim); font-variant-numeric: tabular-nums; }

.log-item.is-live { padding: 14px 0; }
.log-item.is-live .n { color: var(--primary); }
.log-item.is-live img { width: 48px; height: 48px; outline: 2px solid var(--primary); outline-offset: 2px; }
.log-item.is-live .song { font-weight: 900; font-style: italic; font-size: 1rem; letter-spacing: -0.02em; }
.log-item.is-live .at { color: var(--primary); }

.empty { color: var(--muted); font-size: 0.9375rem; line-height: 1.5; }
.block .empty { margin: 0; }

/* Liked songs, under the log: cover, song, then Find and remove */
.liked .block-label { margin-bottom: 12px; font-weight: 500; }
.liked .empty { margin: 0; }
.log-item.liked-item { grid-template-columns: 48px minmax(0, 1fr) auto auto; }
.log-item .find,
.liked-item .unlike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
}
@media (hover: hover) {
  .log-item .find:hover { color: var(--primary); }
  .liked-item .unlike:hover { color: var(--error); }
}
.liked-item .unlike svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ------------------------------------------------------------ signal */

.block { margin-top: 22px; }
.block-label { margin: 0 0 8px; color: var(--muted); }

.big-number {
  margin: 0;
  font-weight: 900;
  font-style: italic;
  font-size: 4.5rem;
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 88px;
  margin-top: 6px;
  border-bottom: 1px solid var(--line-strong);
}
.chart i {
  flex: 1;
  max-width: 14px;
  min-height: 2px;
  background: var(--primary);
  opacity: 0.8;
}
.chart i:last-child { opacity: 1; }
.chart i.is-empty { height: 2px; min-height: 0; background: var(--line-strong); opacity: 1; }

.chart-peak { margin: 14px 0 0; text-align: right; color: var(--dim); }

.chart-axis {
  display: flex;
  justify-content: space-between;
  margin: 8px 0 0;
  color: var(--dim);
}

.readout { margin: 26px 0 0; }
.readout div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
}
.readout div:last-child { border-bottom: 1px solid var(--line); }
.readout dt { color: var(--muted); }
.readout dd {
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.readout dd[data-tone="live"] { color: var(--primary); }
.readout dd[data-tone="error"] { color: var(--error); }

.top-artists { list-style: none; margin: 0; padding: 0; }
.top-artists li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 22px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
}
.top-artists .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-artists .bar { height: 6px; background: var(--line); }
.top-artists .bar i { display: block; height: 100%; background: var(--text); }
.top-artists .count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* ------------------------------------------------------------ mini player */

.mini {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--mini-h);
  height: var(--mini-h);
  border-top: 1px solid var(--line);
  background: var(--glass-raised);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
body[data-tab="now"] .mini { display: none; }

.mini-open {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 12px 0 10px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mini-open img {
  flex: none;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--edge);
  background: var(--surface);
}
.mini-text { display: flex; flex-direction: column; min-width: 0; }
.mini-title {
  font-weight: 900;
  font-style: italic;
  font-size: 0.9375rem;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-artist {
  margin-top: 3px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-play {
  display: grid;
  place-items: center;
  border: 0;
  background: var(--btn-bg);
  color: var(--btn-ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.6s ease, color 0.6s ease;
}
.mini-play .play-icon { width: 26px; height: 26px; }

/* ------------------------------------------------------------ tab bar */

.tabbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  border-top: 1px solid var(--line);
  background: var(--glass-bar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.18s ease;
}
.tab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
}
.tab .mono { font-weight: 700; }
@media (hover: hover) {
  .tab:hover { color: var(--text); }
}
.tab[aria-selected="true"] { color: var(--text); }
.tab::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 30%;
  right: 30%;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.tab[aria-selected="true"]::before { transform: scaleX(1); }
.tab:focus-visible { outline-offset: -4px; }

/* ------------------------------------------------------------ sideways */

/* A phone held sideways is too short for the cover above the title:
   the cover takes the left, sized to the height, and the title, PLAY
   and volume sit beside it, all above the tab bar */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 1023px) {
  #app { max-width: 820px; }
  .screen-now {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-auto-rows: min-content;
    column-gap: 24px;
    align-content: start;
  }
  .screen-now > * { grid-column: 2; }
  .screen-now .cover {
    grid-column: 1;
    grid-row: 1 / span 6;
    width: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - var(--safe-b) - 48px);
    min-width: 140px;
    margin: 0;
  }
  .meta { margin-top: 0; }
  .title { font-size: 1.5rem; -webkit-line-clamp: 2; }
  .artist { margin-top: 6px; font-size: 1rem; }
  .play-wrap { margin-top: 16px; }
  .volume { margin-top: 8px; }
}

/* ------------------------------------------------------------ computer */

/* A desktop app: the sidebar (brand, Log/Signal, listeners) down the
   left, Now in the middle with the big cover, the log or Signal beside
   it, and the player along the bottom in the cover's colour */
@media (min-width: 1024px) {
  #app {
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: var(--topbar-h) minmax(0, 1fr) 88px;
    max-width: 1440px;
    background: var(--glass);
  }

  .topbar {
    grid-column: 1;
    grid-row: 1;
    padding: 0 24px;
    border-right: 1px solid var(--line);
    background: var(--glass-side);
    backdrop-filter: none;   /* a blur layer would paint over the listener count */
    -webkit-backdrop-filter: none;
  }
  /* The listener count sits at the foot of the sidebar */
  .topbar .live {
    position: absolute;
    left: 24px;
    bottom: calc(88px + 24px);
    z-index: 2;
  }

  /* The sponsor at the foot of the sidebar, above the listener count;
     the line at the foot of Now gives way to it */
  .sponsor-slot,
  .sponsor-block { display: none !important; }   /* Signal's copy too: the sidebar's is always on screen */
  .sponsor-side:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    position: absolute;
    left: 24px;
    width: 172px;
    bottom: calc(88px + 24px + 36px);
    z-index: 2;
    padding-top: 12px;
  }
  /* The sidebar is narrow: a long name takes two lines, not an ellipsis */
  .sponsor-side .sponsor-name {
    font-size: 0.875rem;
    line-height: 1.1;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .sponsor-side .sponsor-logo { height: 20px; max-width: 72px; }

  .tabbar {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: auto;
    padding: 16px 12px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--glass-side);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  #tab-now { display: none; }   /* Now is always on screen */
  .tab {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    height: 48px;
    padding: 0 14px;
    border-radius: 2px;
  }
  @media (hover: hover) {
    .tab:hover { background: var(--hover); }
  }
  .tab[aria-selected="true"] { background: var(--selected); }
  .tab::before {
    top: 12px;
    bottom: 12px;
    left: 0;
    right: auto;
    width: 2px;
    height: auto;
    transform: scaleY(0);
  }
  .tab[aria-selected="true"]::before { transform: scaleY(1); }

  .screens {
    grid-column: 2;
    grid-row: 1 / 3;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  }
  .screens > .screen { height: 100%; min-height: 0; }

  .screen-now {
    --col: min(540px, calc(100dvh - 330px), 100%);
    justify-content: safe center;
    align-items: center;
    padding: 32px 48px;
  }
  /* The cover follows the screen height; the song text under it keeps
     at least 440px, so a short laptop screen doesn't break the title
     mid-word */
  .screen-now > * { width: min(max(var(--col), 440px), 100%); }
  .screen-now .cover { width: var(--col); min-width: 0; }
  .title { font-size: 2.5rem; }
  .play-wrap { display: none; }   /* PLAY lives in the bar along the bottom */

  #panel-log,
  #panel-signal {
    padding: 32px 36px;
    border-left: 1px solid var(--line);
    background: var(--glass-panel);
  }

  /* The player bar: the cover's colour, full width */
  body[data-tab] .mini {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 3;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    height: 88px;
    padding: 0 24px 0 14px;
    border-top: 0;
    background: var(--btn-bg);
    color: var(--btn-ink);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: background-color 0.6s ease, color 0.6s ease;
  }
  .mini-open { gap: 16px; padding: 0; }
  .mini-open img { width: 60px; height: 60px; border-color: rgba(0, 0, 0, 0.2); }
  .mini-title { font-size: 1.25rem; }
  .mini-artist { color: inherit; }
  .mini-play {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--btn-ink);
    color: var(--btn-bg);
  }
  .mini-play .play-icon { width: 26px; height: 26px; }
  .mini-play:focus-visible,
  .mini-open:focus-visible { outline-color: var(--btn-ink); }
}

/* ------------------------------------------------------------ motion */

/* Movement off when the system asks: no slides, pulses or bouncing
   bars. Colour fades stay (they don't move anything), and every state
   still shows: a still halo on the live dot, still bars while playing,
   short dim bars while connecting */
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .live-dot { animation: none; box-shadow: 0 0 0 3px rgba(56, 249, 22, 0.3); }
  .tab::before { transition: none; }
  .play-btn:active { transform: none; }
  .sponsor-arrow { transition: color 0.18s ease; transform: none !important; }
  .visualizer { transition: opacity 0.3s ease; }
  body[data-state] .visualizer i { animation: none; }
  body[data-state="playing"] .visualizer i { transform: scaleY(0.667); opacity: 1; }
}
