/* Gregular TV on the web.
 *
 * Mobile first: every rule below is for a phone held upright, and the
 * media queries at the end add to it for landscape, tablets, desktops and
 * TVs. Sizes are in rem, so the reader's own text size is respected.
 *
 * Accessibility: text contrast is at least WCAG AA (4.5:1) on every
 * surface; touch targets are at least 44 px; focus is always visible; and
 * motion, contrast and transparency follow the reader's settings.
 */

/* Tokens */

:root {
  color-scheme: dark;

  /* Surfaces, from the page up. A cool near-black, a touch of the brand's indigo. */
  --bg: #0b0c13;
  --surface: #13141d;
  --surface-2: #1b1d29;
  --surface-3: #252837;
  --scrim: rgba(6, 7, 12, 0.72);
  --glass: rgba(19, 20, 29, 0.82);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* Text: 17:1, 10:1 and 6.6:1 on --surface. */
  --text: #f5f6fa;
  --text-2: #b9bccb;
  --text-3: #8f93a6;

  /* One accent, and states. */
  --accent: #a4a8ff;
  --on-light: #0b0c13;
  --live: #ff4d4f;
  --warn: #ffd66b;
  --danger: #ff7a7a;
  --focus: #c7c9ff;

  /* The colour bars: the one decorative accent. */
  --bar-0: #c0c0c0; --bar-1: #c0c000; --bar-2: #00c0c0; --bar-3: #00c000;
  --bar-4: #c000c0; --bar-5: #c00000; --bar-6: #0000c0;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;

  /* Space, radius, depth, motion */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem; --space-7: 3rem;
  --gutter: max(1rem, env(safe-area-inset-left));
  --radius-sm: 0.5rem;
  --radius: 0.875rem;
  --radius-lg: 1.25rem;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 64px rgba(0, 0, 0, 0.55);
  --tap: 2.75rem;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --quick: 160ms;
  --slow: 320ms;
}

@media (prefers-contrast: more) {
  :root {
    --text-2: #e3e5ee; --text-3: #c9ccd8; --border: rgba(255, 255, 255, 0.28); --border-strong: rgba(255, 255, 255, 0.5);
    --glass: rgba(10, 11, 18, 0.96); --scrim: rgba(0, 0, 0, 0.9);
  }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--text-md)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.2; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.icon-play path { fill: currentColor; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Buttons */

.button, .buttons button, dialog button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 var(--space-5); border: 1px solid var(--border-strong); border-radius: var(--pill);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: var(--text-md);
  transition: background var(--quick) var(--ease), transform var(--quick) var(--ease), border-color var(--quick);
}
.button:hover, .buttons button:hover, dialog button:hover { background: var(--surface-3); }
.button:active, .buttons button:active { transform: scale(0.98); }
.button.primary, button.primary { background: var(--text); color: var(--on-light); border-color: var(--text); }
.button.primary:hover, button.primary:hover { background: #fff; }
.button.quiet, button.quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.button.quiet:hover, button.quiet:hover { color: var(--text); background: var(--surface-2); }
.button.destructive, button.destructive { color: var(--danger); }
button:disabled { opacity: 0.45; cursor: default; transform: none; }
.icon-button {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: var(--pill); background: transparent; color: var(--text);
  transition: background var(--quick) var(--ease);
}
.icon-button:hover { background: rgba(255, 255, 255, 0.1); }
.icon-button .icon { width: 1.4rem; height: 1.4rem; }
.buttons { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Notes */

.note { color: var(--text-2); font-size: var(--text-sm); }
.hint { color: var(--text-3); font-size: var(--text-xs); }
.callout { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius); font-size: var(--text-sm); background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); text-align: left; }
.callout .icon { margin-top: 0.1rem; }
.callout.warn { color: var(--warn); background: rgba(255, 214, 107, 0.08); border-color: rgba(255, 214, 107, 0.25); }
.callout.danger { color: var(--danger); background: rgba(255, 122, 122, 0.08); border-color: rgba(255, 122, 122, 0.3); }

.spinner { width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 3px solid var(--surface-3);
  border-top-color: var(--text); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* The brand */

.brand { display: inline-flex; flex-direction: column; gap: 0.35rem; }
.wordmark { font: 800 var(--text-xl)/1 var(--font-display); letter-spacing: -0.02em; }
.bars { display: flex; width: 4.5rem; height: 0.3rem; border-radius: var(--pill); overflow: hidden; }
.bars .bar { flex: 1; }
.bar-0 { background: var(--bar-0); } .bar-1 { background: var(--bar-1); } .bar-2 { background: var(--bar-2); }
.bar-3 { background: var(--bar-3); } .bar-4 { background: var(--bar-4); } .bar-5 { background: var(--bar-5); }
.bar-6 { background: var(--bar-6); }
.hero { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; }
.hero .wordmark { font-size: clamp(2.25rem, 9vw, 4rem); }
.hero .bars { width: clamp(8rem, 30vw, 14rem); height: 0.5rem; }
.hero .tagline { color: var(--text-2); font-size: var(--text-md); }

/* App shell: an app bar and a scrolling page */

#app { position: fixed; inset: 0; }
/* Live TV and the page over it each stack their own layers, so nothing in
   live TV (its dimming, its panels) can rise above the page. */
.live, .page-layer { position: absolute; inset: 0; }
.live { z-index: 0; }
.page-layer { z-index: 1; }
.page-layer:empty { display: none; }
.page {
  position: absolute; inset: 0; overflow-y: auto; display: flex; flex-direction: column;
  background: radial-gradient(120% 60% at 50% -10%, rgba(76, 80, 170, 0.28), transparent 60%), var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
.live:not(:empty) + .page-layer .page { background: var(--scrim); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.app-bar { position: sticky; top: 0; z-index: 2; flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); min-height: 3.5rem; padding: max(var(--space-3), env(safe-area-inset-top)) var(--gutter) var(--space-3); }
.content > div:empty { display: none; }
.content { width: 100%; max-width: 40rem; margin: 0 auto; padding: var(--space-5) var(--gutter) var(--space-7);
  display: flex; flex-direction: column; gap: var(--space-5); }
.content.wide { max-width: 72rem; }
.centred { flex: 1; justify-content: center; align-items: center; text-align: center; }
.page-title { font-size: var(--text-2xl); font-weight: 700; }
.page-lede { color: var(--text-2); }

/* Cards and forms */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-4); box-shadow: var(--shadow); text-align: left; }
.card h2 { font-size: var(--text-lg); font-weight: 650; }
.field { display: flex; flex-direction: column; gap: var(--space-2); text-align: left; }
.field label { font-size: var(--text-sm); font-weight: 600; color: var(--text-2); }
.field input, .code-field {
  width: 100%; min-height: 3rem; padding: 0 var(--space-4); border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font-size: var(--text-md);
  transition: border-color var(--quick), box-shadow var(--quick);
}
.field input:focus, .code-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(164, 168, 255, 0.25); outline: none; }
.field input::placeholder, .code-field::placeholder { color: var(--text-3); text-transform: none; }
form .button.primary { width: 100%; }

/* Sign-in */

.steps { display: flex; gap: var(--space-2); justify-content: center; }
.steps span { width: 2rem; height: 0.25rem; border-radius: var(--pill); background: var(--surface-3); }
.steps span.done { background: var(--text); }
.server-heading { display: flex; align-items: center; gap: var(--space-3); text-align: left; }
.server-heading .avatar { width: 2.75rem; height: 2.75rem; flex: none; border-radius: var(--radius); display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); }
.sign-in-ways { display: grid; gap: var(--space-4); }
.quick-code { font: 700 2.5rem/1.1 var(--font-mono); letter-spacing: 0.12em; text-align: center; padding: var(--space-3) 0; }
.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--text-3); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: 0.08em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* The main page: your servers */

.section-title { font-size: var(--text-xs); font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.server-list { display: grid; gap: var(--space-3); list-style: none; margin: 0; padding: 0; }
.server { position: relative; display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); transition: border-color var(--quick); }
.server:hover { border-color: var(--border-strong); }
.server.last { border-color: rgba(164, 168, 255, 0.35); }
.server-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4);
  border: 0; background: transparent; text-align: left; border-radius: var(--radius-lg); }
.server-main:focus-visible { outline-offset: -3px; }
.server-icon { width: 3rem; height: 3rem; flex: none; border-radius: var(--radius); display: grid; place-items: center;
  background: linear-gradient(160deg, #2c2f63, #171830); border: 1px solid var(--border-strong); }
.server-icon .icon { width: 1.5rem; height: 1.5rem; }
.server-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.server-title { font-weight: 650; font-size: var(--text-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-line { color: var(--text-2); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-badges { display: flex; gap: var(--space-2); margin-top: var(--space-1); }
.server-badges:empty { display: none; }
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.6rem; border-radius: var(--pill);
  font-size: var(--text-xs); font-weight: 600; color: var(--text-2); background: var(--surface-3); }
.badge.playing { color: var(--text); }
.badge.playing::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--live);
  animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.server-main .chevron { color: var(--text-3); }
.server-actions { display: flex; align-items: center; padding-right: var(--space-2); color: var(--text-2); }
.add-server { border-style: dashed; box-shadow: none; background: transparent; }
.add-server .server-icon { background: var(--surface-2); }
.keyboard-hint { display: none; }

/* Live TV — on a phone held upright: the picture at the top, then what's
   on and the controls, then every channel's now and next. */

.watch { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.stage { position: relative; flex: none; width: 100%; aspect-ratio: 16 / 9; background: #000; overflow: hidden;
  margin-top: env(safe-area-inset-top); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.decks { position: absolute; inset: 0; z-index: 0; transition: opacity 0.4s ease; }
.decks.hidden { opacity: 0; }
.deck { position: absolute; inset: 0; z-index: 0; }
.deck.active { z-index: 1; }
.deck video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; visibility: hidden; }
.deck video.current { visibility: visible; }
.cards, .curtain { position: absolute; inset: 0; pointer-events: none; }
.cards { z-index: 2; }
.curtain { z-index: 5; background: #000; opacity: 0; transition-property: opacity; }
.curtain.closed { opacity: 1; }
.cover-dim { position: absolute; inset: 0; z-index: 7; background: rgba(0, 0, 0, 0.7); }

.stage-bar { position: absolute; z-index: 4; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-2); background: linear-gradient(rgba(0, 0, 0, 0.55), transparent); opacity: 0; pointer-events: none;
  transition: opacity var(--slow) var(--ease); }
.stage-bar .group { display: flex; gap: var(--space-1); }
.watch.revealed .stage-bar, .stage-bar:focus-within { opacity: 1; pointer-events: auto; }

.break-badge { position: absolute; z-index: 3; left: var(--space-3); top: var(--space-3); display: inline-flex; align-items: center;
  gap: var(--space-2); padding: 0.3rem 0.75rem; border-radius: var(--pill); background: var(--glass); color: var(--text-2);
  font-size: var(--text-xs); font-weight: 600; opacity: 0; transition: opacity var(--slow); pointer-events: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.break-badge .icon { width: 1rem; height: 1rem; }
.break-badge.showing { opacity: 1; }
.number-entry { position: absolute; z-index: 4; right: var(--space-3); top: var(--space-3); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius); background: var(--glass); font: 800 var(--text-3xl)/1 var(--font-display); font-variant-numeric: tabular-nums;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.number-entry.notice { font-size: var(--text-lg); font-weight: 600; }
.sound-note { position: absolute; z-index: 6; left: 50%; bottom: var(--space-3); transform: translateX(-50%);
  min-height: var(--tap); padding: 0 var(--space-5); border: 0; border-radius: var(--pill); background: var(--text); color: var(--on-light);
  font-weight: 700; display: inline-flex; align-items: center; gap: var(--space-2); box-shadow: var(--shadow-lg); white-space: nowrap; }

.status-card { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-2); padding: var(--space-4); text-align: center; background: radial-gradient(circle at 50% 40%, #1f2145, #07080d); }
.status-card .heading { color: var(--text-2); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.status-card .title { font: 700 var(--text-xl)/1.2 var(--font-display); }
.status-card .when { color: var(--text-2); font-size: var(--text-sm); }
.status-card .icon { width: 2rem; height: 2rem; color: var(--warn); }

/* What's on: below the picture on a phone; a card over it in landscape. */
.now { position: relative; z-index: 3; display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4) var(--gutter); background: var(--surface); border-bottom: 1px solid var(--border); }
.now-head { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.channel-chip { display: inline-flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
.channel-number { font: 800 var(--text-xl)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.channel-name { color: var(--text-2); font-weight: 600; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock { margin-left: auto; color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; font-size: var(--text-sm); }
.programme-title { font: 700 var(--text-xl)/1.25 var(--font-display); overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.programme-subtitle { color: var(--text-2); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playhead { height: 0.3rem; border-radius: var(--pill); background: var(--surface-3); overflow: hidden; }
.playhead-fill { height: 100%; border-radius: var(--pill); background: var(--text); transition: width 1s linear; }
.times { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-xs); color: var(--text-3);
  font-variant-numeric: tabular-nums; }
.status { color: var(--warn); font-weight: 600; font-size: var(--text-sm); }
.status:empty { display: none; }
.transport { display: flex; align-items: center; justify-content: space-between; gap: var(--space-1); }
.transport .group { display: flex; align-items: center; gap: var(--space-1); }
.transport .main-button { width: 3.25rem; height: 3.25rem; background: var(--text); color: var(--on-light); }
.transport .main-button:hover { background: #fff; }
.now .hint { display: none; }
.diagnostics { font: var(--text-xs)/1.4 var(--font-mono); color: #ffb26b; word-break: break-word; }
.diagnostics:empty { display: none; }

/* Every channel's now and next: on a phone, under what's on. The rows (and
   the bars above lists) are `flex: none`: in a scrolling column a long list
   would otherwise squeeze each one to its min-height, over its text. */
.lineup { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--gutter) calc(var(--space-6) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--space-2); }
.lineup .section-title { padding: 0 var(--space-1) var(--space-1); }
.channel-row { flex: none; display: flex; gap: var(--space-4); align-items: center; width: 100%; min-height: 4rem; padding: var(--space-3) var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius); background: var(--surface); text-align: left; color: var(--text);
  transition: background var(--quick), border-color var(--quick); }
.channel-row:hover { background: var(--surface-2); }
.channel-row.current { border-color: rgba(164, 168, 255, 0.45); background: var(--surface-2); }
.channel-row:focus-visible { outline-offset: -3px; }
.row-number { min-width: 2.5rem; text-align: right; font: 800 var(--text-lg)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.row-lines { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; flex: 1; }
.row-name { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; }
.row-name .live-dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--live); }
.row-programme { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-when { font-size: var(--text-xs); color: var(--text-2); }
.row-progress { height: 0.2rem; border-radius: var(--pill); background: var(--surface-3); overflow: hidden; }
.row-progress .fill { display: block; height: 100%; background: var(--text-2); }
.row-progress.faint .fill { background: var(--text-3); }

/* Panels over live TV: full-screen sheets on a phone. */
.overlay { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.sheet { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--surface);
  padding-top: env(safe-area-inset-top); animation: sheet-in var(--slow) var(--ease); }
@keyframes sheet-in { from { transform: translateY(4%); opacity: 0; } }
.sheet-bar { flex: none; display: flex; align-items: center; gap: var(--space-3); min-height: 3.5rem; padding: var(--space-2) var(--space-2) var(--space-2) var(--gutter);
  border-bottom: 1px solid var(--border); }
.sheet-bar h2 { flex: 1; font-size: var(--text-lg); font-weight: 700; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--gutter) calc(var(--space-6) + env(safe-area-inset-bottom)); }
.sheet .hint { display: none; }
.channel-list .sheet-body { display: flex; flex-direction: column; gap: var(--space-2); }

/* The guide */
.guide .sheet-body { padding: 0; display: flex; flex-direction: column; }
.guide-details { padding: var(--space-4) var(--gutter); border-bottom: 1px solid var(--border); min-height: 6.5rem;
  display: flex; flex-direction: column; gap: 0.2rem; }
.guide-details h3 { font-size: var(--text-lg); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-details p { color: var(--text-2); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-details .eyebrow { color: var(--text-3); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.guide-grid { --channel: 4.25rem; --row: 4rem; position: relative; flex: 1; overflow: auto; overscroll-behavior: contain;
  scroll-padding: 2.25rem 0 0 var(--channel); }
.guide-row { display: flex; height: var(--row); width: max-content; border-bottom: 1px solid var(--border); }
.ruler-row { position: sticky; top: 0; z-index: 3; height: 2.25rem; background: var(--surface); }
.guide-channel { position: sticky; left: 0; z-index: 2; width: var(--channel); flex: none; display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 0.1rem; padding: 0 var(--space-1); background: var(--surface);
  border-right: 1px solid var(--border); text-align: center; }
.guide-channel.corner { z-index: 4; }
.guide-channel.current { box-shadow: inset 3px 0 0 var(--accent); }
.guide-number { font: 800 var(--text-md)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.guide-name { font-size: var(--text-xs); color: var(--text-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-ruler { position: relative; height: 100%; }
.guide-ruler span { position: absolute; top: 0.6rem; padding-left: var(--space-2); color: var(--text-3); font-size: var(--text-xs);
  font-weight: 600; white-space: nowrap; border-left: 1px solid var(--border); }
.guide-track { position: relative; height: 100%; flex: none; }
.guide-cell { position: absolute; top: 0.25rem; bottom: 0.25rem; padding: 0 var(--space-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); text-align: left; overflow: hidden; display: flex;
  flex-direction: column; justify-content: center; gap: 0.1rem; transition: background var(--quick); }
.guide-cell:hover { background: var(--surface-3); }
.guide-cell:focus, .guide-cell:focus-visible { background: var(--text); color: var(--on-light); outline: none; z-index: 1; }
.guide-cell:focus .cell-time { color: rgba(11, 12, 19, 0.7); }
.guide-cell.airing-now { border-color: rgba(164, 168, 255, 0.35); }
.cell-title { position: relative; font-size: var(--text-sm); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-time { position: relative; font-size: var(--text-xs); color: var(--text-3); }
.cell-break { position: absolute; right: 0; top: 0; bottom: 0;
  background: repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.32) 0 6px, rgba(0, 0, 0, 0.18) 6px 12px); }
.now-line { position: absolute; top: 0; width: 2px; margin-left: var(--channel); background: var(--live); z-index: 1; pointer-events: none; }
.now-line::before { content: ""; position: absolute; top: 1.85rem; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--live); }

/* Settings */
.settings .sheet-body { display: flex; flex-direction: column; gap: var(--space-6); }
.group-title { font-size: var(--text-xs); font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0 var(--space-4) var(--space-2); }
.rows { display: flex; flex-direction: column; }
.rows-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rows-box > * + * { border-top: 1px solid var(--border); }
.rows .note { padding: var(--space-2) var(--space-4) 0; font-size: var(--text-xs); color: var(--text-3); }
.row { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 3.25rem; padding: var(--space-3) var(--space-4);
  border: 0; background: transparent; text-align: left; color: var(--text); }
button.row:hover { background: var(--surface-3); }
button.row:focus-visible { outline-offset: -3px; }
.row-text { display: flex; flex-direction: column; gap: 0.1rem; flex: 1; min-width: 0; }
.row-title { font-weight: 500; }
.row-detail { font-size: var(--text-xs); color: var(--text-3); }
.row-value { color: var(--text-2); font-size: var(--text-sm); }
.row .check { color: var(--accent); }
.row.destructive { color: var(--danger); }
.row.info .row-value { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.switch { position: relative; width: 2.75rem; height: 1.6rem; flex: none; border-radius: var(--pill); background: var(--surface-3);
  border: 1px solid var(--border-strong); transition: background var(--quick); }
.switch::after { content: ""; position: absolute; top: 0.15rem; left: 0.15rem; width: 1.2rem; height: 1.2rem; border-radius: 50%;
  background: var(--text-2); transition: transform var(--quick) var(--ease), background var(--quick); }
[aria-checked="true"] > .switch { background: #4f55d6; border-color: transparent; }
[aria-checked="true"] > .switch::after { transform: translateX(1.15rem); background: #fff; }
.row.field { padding: var(--space-2) var(--space-4); }
.code-field { min-height: 2.75rem; text-transform: uppercase; font-family: var(--font-mono); letter-spacing: 0.06em; }

/* Dialogs: a bottom sheet on a phone. */

dialog.confirm { width: 100%; max-width: 100%; margin: auto 0 0; padding: var(--space-5) var(--gutter) calc(var(--space-5) + env(safe-area-inset-bottom));
  border: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--surface-2); color: var(--text);
  box-shadow: var(--shadow-lg); animation: sheet-in var(--slow) var(--ease); }
dialog.confirm::backdrop { background: var(--scrim); }
dialog.confirm h2 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
dialog.confirm p { color: var(--text-2); font-size: var(--text-sm); }
dialog.confirm .buttons { margin-top: var(--space-5); flex-direction: column-reverse; }
dialog.confirm .buttons button { width: 100%; }

/* The channel editor */

.channel-editor { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); }
.channel-editor iframe { flex: 1; width: 100%; border: 0; background: var(--bg); }

/* Starting up, and failures */

.wait { gap: var(--space-5); }
.failure { gap: var(--space-4); max-width: 32rem; margin: 0 auto; }
.failure .icon-large { width: 3rem; height: 3rem; color: var(--warn); }

/* The station card: the last 15 s of a break. Joined late, every
   animation starts as far in as the card is (--elapsed). */

.station-card {
  --elapsed: 0s;
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-2); padding: var(--space-4); text-align: center; overflow: hidden;
  background: radial-gradient(130% 90% at 50% 0%, #34377a, #0b0c1f 70%);
  animation: fade-in 0.35s ease both; animation-delay: calc(-1 * var(--elapsed));
}
.station-card p { position: relative; }
.station-card .intro { color: var(--text-2); letter-spacing: 0.4em; font-weight: 700; font-size: clamp(0.625rem, 1.6vw, 1rem); }
.station-wordmark { font: 900 clamp(1.75rem, 9vw, 7rem)/1 var(--font-display); letter-spacing: -0.02em;
  text-shadow: 0 0.3rem 1rem rgba(0, 0, 0, 0.5); animation: spring 1.2s ease-out both; animation-delay: calc(-1 * var(--elapsed)); }
.station-channel { font-weight: 700; font-size: clamp(0.875rem, 2.5vw, 1.5rem); }
.station-card .next { margin-top: clamp(0.5rem, 3vw, 2.5rem); display: flex; flex-direction: column; gap: 0.2rem;
  animation: fade-in 0.6s ease both; animation-delay: calc(0.8s - var(--elapsed)); }
.station-card .next .heading { color: var(--text-2); font-size: clamp(0.75rem, 2vw, 1.25rem); }
.station-card .next .title { font: 800 clamp(1rem, 4vw, 2.5rem)/1.15 var(--font-display); }
.station-card .next .when { font-size: clamp(0.75rem, 2vw, 1.25rem); }
.bars.hopping { gap: 0.3rem; height: auto; width: auto; overflow: visible; border-radius: 0; position: relative; }
.bars.hopping .bar { width: clamp(1rem, 4vw, 3rem); height: clamp(0.4rem, 1.2vw, 1rem); border-radius: 0.3rem; flex: none;
  animation: hop 0.577s ease-out infinite; animation-delay: calc(0.05s - var(--elapsed)); }
.bars.hopping .bar-1 { animation-delay: calc(0.09s - var(--elapsed)); }
.bars.hopping .bar-2 { animation-delay: calc(0.13s - var(--elapsed)); }
.bars.hopping .bar-3 { animation-delay: calc(0.17s - var(--elapsed)); }
.bars.hopping .bar-4 { animation-delay: calc(0.21s - var(--elapsed)); }
.bars.hopping .bar-5 { animation-delay: calc(0.25s - var(--elapsed)); }
.bars.hopping .bar-6 { animation-delay: calc(0.29s - var(--elapsed)); }
.station-dots { position: absolute; inset: 0; }
.station-dots .dot { position: absolute; bottom: -3rem; width: 2rem; height: 2rem; border-radius: 50%; opacity: 0.2;
  animation: drift 14s linear infinite; animation-delay: calc(-1 * var(--elapsed)); }
.dot-0 { left: 5%; background: var(--bar-0); } .dot-1 { left: 13%; background: var(--bar-1); }
.dot-2 { left: 21%; background: var(--bar-2); } .dot-3 { left: 29%; background: var(--bar-3); }
.dot-4 { left: 37%; background: var(--bar-4); } .dot-5 { left: 45%; background: var(--bar-5); }
.dot-6 { left: 53%; background: var(--bar-6); } .dot-7 { left: 61%; background: var(--bar-0); }
.dot-8 { left: 69%; background: var(--bar-1); } .dot-9 { left: 77%; background: var(--bar-2); }
.dot-10 { left: 85%; background: var(--bar-3); } .dot-11 { left: 93%; background: var(--bar-4); }
.dot-12 { left: 33%; background: var(--bar-5); } .dot-13 { left: 72%; background: var(--bar-6); }
.dot-1, .dot-5, .dot-9 { width: 1.1rem; height: 1.1rem; animation-duration: 11s; }
.dot-3, .dot-7, .dot-12 { width: 2.8rem; height: 2.8rem; animation-duration: 17s; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes spring { 0% { transform: scale(0.85); } 45% { transform: scale(1.05); } 70% { transform: scale(0.98); } 100% { transform: scale(1); } }
@keyframes hop { 0%, 30%, 100% { transform: none; } 15% { transform: translateY(-0.8rem); } }
@keyframes drift { to { transform: translate(1.5rem, -115vh); } }

/* Landscape, and wider screens: the picture fills the window, and what's
   on becomes a card over it, shown when asked for (or while surfing). */

@media (orientation: landscape), (min-width: 60rem) {
  .watch { display: block; background: #000; }
  .stage { position: absolute; inset: 0; aspect-ratio: auto; margin: 0; }
  .lineup { display: none; }
  .now {
    position: absolute; z-index: 6; left: max(var(--space-4), env(safe-area-inset-left)); right: max(var(--space-4), env(safe-area-inset-right));
    bottom: max(var(--space-4), env(safe-area-inset-bottom)); max-width: 64rem; margin: 0 auto;
    border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--glass); box-shadow: var(--shadow-lg);
    backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3);
    opacity: 0; transform: translateY(1rem); pointer-events: none; transition: opacity var(--slow) var(--ease), transform var(--slow) var(--ease);
  }
  .watch.revealed .now, .now.showing, .now:focus-within { opacity: 1; transform: none; pointer-events: auto; }
  .watch.covered .now, .watch.covered .stage-bar, .watch.panel-open .now, .watch.panel-open .stage-bar { display: none; }
}

/* Tablets and up */

@media (min-width: 48rem) {
  :root { --gutter: 2rem; }
  .card { padding: var(--space-6); }
  .sign-in-ways { grid-template-columns: 1fr 1fr; align-items: start; }
  .content { padding-top: var(--space-6); }
  .server-list { grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: var(--space-4); }
  .guide-grid { --channel: 11rem; --row: 4.5rem; }
  .guide-channel { flex-direction: row; justify-content: flex-start; gap: var(--space-3); padding: 0 var(--space-4); text-align: left; }
  .guide-name { font-size: var(--text-sm); color: var(--text-2); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; }
  .guide-number { min-width: 2rem; text-align: right; font-size: var(--text-lg); }
  .channel-list { right: auto; width: min(26rem, 100%); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
    animation: slide-in var(--slow) var(--ease); }
  .settings { left: auto; width: min(34rem, 100%); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    animation: slide-in-right var(--slow) var(--ease); }
  dialog.confirm { width: min(28rem, calc(100% - 2rem)); margin: auto; border-radius: var(--radius-lg); padding: var(--space-6); }
  dialog.confirm .buttons { flex-direction: row; justify-content: flex-end; }
  dialog.confirm .buttons button { width: auto; }
  .now { padding: var(--space-5) var(--space-6); }
  .programme-title { font-size: var(--text-2xl); }
}
@keyframes slide-in { from { transform: translateX(-100%); } }
@keyframes slide-in-right { from { transform: translateX(100%); } }

/* With a keyboard and mouse: show the keys. */

@media (hover: hover) and (pointer: fine) {
  .now .hint, .sheet .hint, .keyboard-hint { display: block; }
}

/* Large screens and TVs: everything a step bigger, to read from the sofa. */

@media (min-width: 100rem) {
  html { font-size: 112.5%; }
}
@media (min-width: 140rem) {
  html { font-size: 137.5%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .now, .break-badge, .number-entry, .page { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  :root { --glass: var(--surface); }
}
@media (forced-colors: active) {
  .switch, .playhead, .row-progress { border: 1px solid CanvasText; }
  .playhead-fill, .row-progress .fill { background: Highlight; }
}

/* The static pages (privacy.html, help.html): readable text. */

a { color: var(--accent); }
.brand { color: var(--text); text-decoration: none; }
a.button { text-decoration: none; }
.prose { gap: var(--space-4); line-height: 1.65; }
.prose h2 { font-size: var(--text-lg); margin-top: var(--space-4); }
.prose p, .prose li { color: var(--text-2); }
.prose ul { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: var(--space-2); }
.prose strong { color: var(--text); }
.prose code { font-family: var(--font-mono); font-size: 0.9em; color: var(--text); background: var(--surface-2);
  padding: 0.1em 0.35em; border-radius: 0.3em; }
.page-footer { margin-top: auto; display: flex; justify-content: center; gap: var(--space-5); padding: var(--space-5) var(--gutter)
  calc(var(--space-5) + env(safe-area-inset-bottom)); font-size: var(--text-sm); }
.page-footer a { color: var(--text-3); text-decoration: none; }
.page-footer a:hover { color: var(--text); text-decoration: underline; }
