:root {
  --bg: #10121c; --card: #1a1d2e; --text: #f2f3f8; --muted: #8d92a8; --line: rgba(141,146,168,.22);
  /* The pink is the brand: the play button, the cover, the glow. Text and filled buttons with white text use
     the deeper pink so both pass 4.5:1, and errors get their own colour */
  --accent: #ff4d6d; --accent-strong: #d6264a; --accent-text: #ff4d6d; --danger: #ff8566;
  /* Type: one family, five roles. rem, so a larger browser font size scales the whole app */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-meta: .75rem;     /* 12: times, the song in the bar, fine print, the small caps label */
  --fs-label: .875rem;   /* 14: status lines, notes, names, secondary buttons */
  --fs-body: 1rem;       /* 16: messages, the song, inputs (iPhones zoom on anything smaller), main buttons */
  --fs-title: clamp(1.375rem, 3.6dvh, 1.875rem);   /* 22-30: the station name on the player */
  /* Space: a 4px scale. Tight steps join things, wide steps separate groups */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --tap: 44px;   /* smallest touch target */
  /* Corners, by role */
  --r-sm: 10px;    /* controls: inputs, buttons */
  --r-md: 16px;    /* cards and bars: the mini player, popovers */
  --r-lg: 24px;    /* surfaces: the cover */
  --r-xl: 28px;    /* the cover art and the desktop player */
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #f4f5fa; --card: #fff; --text: #14172a; --muted: #666b83; --line: rgba(20,23,42,.12);
    --accent-text: #c41c42; --danger: #b3261e; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
/* The app: the tab's screen, the mini player and the tab bar, like a music app on a phone. The pink glow
   sits behind every tab */
body {
  color: var(--text); font-family: var(--font-ui); line-height: 1.4;
  height: 100dvh; overflow: hidden;
  background: radial-gradient(120% 55% at 50% 0%, color-mix(in srgb, var(--accent) 26%, var(--bg)), var(--bg) 72%) var(--bg) no-repeat;
}
.app {
  display: grid; grid-template-rows: minmax(0, 1fr) auto auto;
  width: 100%; max-width: 460px; height: 100%; margin: 0 auto;
}
.view { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.view[hidden] { display: none; }

/* Mini player: on Recent, play and what's on stay in reach */
.mini {
  display: flex; align-items: center; gap: var(--space-3);
  margin: 0 var(--space-2) var(--space-2); padding: var(--space-2) var(--space-4) var(--space-2) var(--space-2);
  border-radius: var(--r-md);
}
body[data-view="player"] .mini { display: none; }
.mini .play-btn {
  width: var(--tap); height: var(--tap); flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent; transition: transform .1s;
}
.mini .play-btn:active { transform: scale(.94); }
.mini .play-btn svg { width: 22px; height: 22px; fill: currentColor; }
.mini .play-btn.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { .mini .play-btn.live { animation: none; } }
.mini-title { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; min-height: var(--tap); color: var(--text); text-decoration: none; }
.mini-cover { width: 40px; height: 40px; flex: none; border-radius: var(--r-sm); object-fit: cover; }
.mini-cover[hidden] { display: none; }
.mini-text { display: flex; flex-direction: column; min-width: 0; font-weight: 700; font-size: var(--fs-body); line-height: 1.25; }
.mini-text .track { font-size: var(--fs-meta); font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-text .track:empty { display: none; }
.mini .status { flex: 0 1 auto; min-width: 0; max-width: 40%; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tab bar */
.tabbar {
  display: grid; grid-template-columns: repeat(2, 1fr);
  height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: var(--fs-meta); font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"] svg { color: var(--accent-text); stroke-width: 2.4; }
.tab:focus-visible { outline-offset: -4px; border-radius: var(--r-sm); }
@media (hover: hover) { .tab:hover { color: var(--text); } }

/* Computers and tablets: the whole app in a phone-sized card, centred */
@media (min-width: 700px) and (min-height: 700px) {
  .app {
    height: min(880px, calc(100dvh - 48px)); max-width: 440px; margin-top: max(24px, calc((100dvh - 880px) / 2));
    border-radius: var(--r-xl); overflow: hidden;
    background: color-mix(in srgb, var(--card) 70%, transparent); box-shadow: 0 20px 60px rgba(0,0,0,.35);
  }
}
/* Phones on their side: little height, lots of width. The app widens (clear of the notch), and the tab bar
   puts each label beside its icon to give the screen back 16px */
@media (orientation: landscape) and (max-height: 520px) {
  .app { max-width: 760px; padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
  .tabbar { height: calc(42px + env(safe-area-inset-bottom)); }
  .tab { flex-direction: row; gap: var(--space-2); font-size: var(--fs-label); }
  .tab svg { width: 20px; height: 20px; }
  .mini { padding-block: var(--space-1); }
}
.side-brand { display: none; }   /* the sidebar's station name, on a computer */

/* Computers: a desktop app. The sidebar (the station and Recent) down the left, Now always in the
   middle with the big cover, Recent beside it, and the player along the bottom in the brand's pink.
   Phones and tablets keep the bottom tabs */
@media (min-width: 1024px) and (min-height: 600px) {
  .app {
    grid-template-columns: 220px minmax(0, 1.15fr) minmax(380px, .85fr);
    grid-template-rows: 76px minmax(0, 1fr) 88px;
    max-width: 1440px; height: 100%; margin-top: 0;
    border-radius: 0; overflow: hidden; box-shadow: none;
    background: color-mix(in srgb, var(--bg) 35%, transparent);
  }

  .side-brand, .tabbar { grid-column: 1; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--card) 55%, transparent); }
  .side-brand {
    grid-row: 1; display: flex; align-items: center; gap: var(--space-3); margin: 0; padding: 0 var(--space-5);
    font-size: 1.125rem; font-weight: 800; letter-spacing: -.01em;
  }
  .side-brand img { width: 36px; height: 36px; border-radius: var(--r-sm); }

  .tabbar {
    grid-row: 2; display: flex; flex-direction: column; gap: var(--space-1);
    height: auto; padding: var(--space-2) var(--space-3); border-top: 0;
  }
  .tab[data-view="player"] { display: none; }   /* Now is always on screen */
  .tab {
    flex-direction: row; justify-content: flex-start; gap: var(--space-3);
    height: 48px; padding: 0 var(--space-3); border-radius: var(--r-sm); font-size: var(--fs-label);
    transition: background-color .15s, color .15s;
  }
  .tab svg { width: 22px; height: 22px; }
  .tab[aria-current="page"] { background: color-mix(in srgb, var(--text) 8%, transparent); }
  .tab:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
  .tab:focus-visible { outline-offset: -2px; }

  .player { grid-column: 2; grid-row: 1 / 3; }
  .recent {
    grid-column: 3; grid-row: 1 / 3;
    border-left: 1px solid var(--line); background: color-mix(in srgb, var(--card) 40%, transparent);
  }

  /* The player bar: full width, in the brand's pink, the song on the left, play in the middle, the status
     on the right. Inside it the accent is white, so the play button, its ring and the focus ring stay visible */
  body[data-view] .mini {
    --accent: #fff; --accent-text: #fff;
    grid-column: 1 / -1; grid-row: 3;
    display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--space-5);
    height: 88px; margin: 0; padding: 0 var(--space-6) 0 var(--space-5);
    border-radius: 0; box-shadow: none; background: var(--accent-strong); color: #fff;
  }
  .mini .play-btn { grid-column: 2; grid-row: 1; width: 56px; height: 56px; color: var(--accent-strong); }
  .mini .play-btn svg { width: 26px; height: 26px; }
  .mini-title { grid-column: 1; grid-row: 1; gap: var(--space-4); color: #fff; border-radius: var(--r-sm); }
  .mini-cover { width: 60px; height: 60px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
  .mini-text { font-size: 1.125rem; }
  .mini-text .track { font-size: var(--fs-label); color: #fff; }
  .mini .status, .mini .status.on, .mini .status.err {
    grid-column: 3; grid-row: 1; justify-self: end; max-width: 100%; color: #fff;
  }
  .mini .status:empty::before { content: "Tap play to listen"; }   /* the hint the Now column shows on a phone */
  @media (hover: hover) { .mini .play-btn:hover { transform: scale(1.05); } }
}
/* Wider than the app: a hairline on each side so its edge is drawn, not cut */
@media (min-width: 1441px) and (min-height: 600px) {
  .app { border-inline: 1px solid var(--line); }
}
.card {
  background: var(--card); border-radius: var(--r-lg);
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
h1 { font-size: var(--fs-title); font-weight: 700; line-height: 1.15; margin: 0 0 var(--space-1); }
button, input, textarea, select { font: inherit; }   /* form controls default to the browser's own font */
.status { font-size: var(--fs-label); color: var(--muted); }
.status.on { color: var(--accent-text); font-weight: 600; text-transform: uppercase; }
/* Connecting: a ring turns around the play button, which now reads Stop */
.play-btn { position: relative; }
.play-btn.connecting::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%; pointer-events: none;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent-text);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { rotate: 1turn; } }
@media (prefers-reduced-motion: reduce) { .play-btn.connecting::after { animation: none; border-color: var(--accent-text); opacity: .5; } }
.status.err { color: var(--danger); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
