/* OneTV Server — web page (ADR 0008).
   Design: onetvconnect.com « Cinema Noir » tokens (site/src/styles/global.css)
   for the dark appearance, the site's editorial light tokens for the light one.
   Every colour is a token; components only read tokens. No inline styles (CSP). */

/* ─── Fonts (self-hosted, SIL OFL — fonts/LICENSE-*.txt) ─── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 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: 'Sora';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('fonts/sora-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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Sora';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('fonts/sora-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;
}

/* ─── Tokens: Noir (dark, default) ─── */
:root {
  color-scheme: dark;
  --bg: #030308;
  --bg-elevated: #0a0a18;
  --bg-card: rgba(255, 255, 255, 0.035);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --bg-inset: rgba(255, 255, 255, 0.05);
  --bg-field: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-glow: rgba(59, 130, 246, 0.35);

  --text: #f0f2f8;
  --text-secondary: #a3abbd;
  --text-muted: #8891a5;
  --text-faint: #5f677a;

  --accent: #60a5fa;
  --accent-fill: #3b82f6;
  --accent-fill-2: #2563eb;
  --accent-vivid: #6366f1;
  --accent-on-fill: #fff;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-line: rgba(59, 130, 246, 0.3);
  --accent-glow: rgba(59, 130, 246, 0.18);

  --rec: #f2545b;
  --rec-soft: rgba(242, 84, 91, 0.14);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger-fill: #dc2626;

  --glass: rgba(10, 10, 28, 0.62);
  --glass-strong: rgba(10, 10, 26, 0.86);
  --glass-blur: blur(22px) saturate(180%);
  --scrim: rgba(2, 2, 8, 0.66);

  --thumb-1: color-mix(in srgb, #3b82f6 35%, #0a0a18);
  --thumb-2: color-mix(in srgb, #6366f1 25%, #0a0a18);
  --glow-1: rgba(59, 130, 246, 0.16);
  --glow-2: rgba(99, 102, 241, 0.12);
  --glow-3: rgba(139, 92, 246, 0.08);

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-pop: 0 30px 80px -20px rgba(0, 0, 0, 0.75), 0 0 60px -12px rgba(59, 130, 246, 0.16);
  --shadow-btn: 0 8px 28px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.16);

  --font-heading: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --max: 1120px;
  --header-h: 64px;
}

/* ─── Tokens: Clair (light, from the system) ─── */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f5f6f8;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fbfcfe;
    --bg-inset: #f1f4f8;
    --bg-field: #ffffff;
    --border: #e3e6ec;
    --border-strong: #cdd3df;
    --border-glow: #9cc0f4;

    --text: #17191d;
    --text-secondary: #4b525e;
    --text-muted: #5d6573;
    --text-faint: #8a92a0;

    --accent: #0964df;
    --accent-fill: #0964df;
    --accent-fill-2: #0754bd;
    --accent-vivid: #4f46e5;
    --accent-soft: #edf4ff;
    --accent-line: #cbdcf6;
    --accent-glow: rgba(9, 100, 223, 0.18);

    --rec: #d61f2c;
    --rec-soft: #fdecee;
    --ok: #157245;
    --ok-soft: #edf8f1;
    --warn: #9a5b00;
    --warn-soft: #fff6e5;
    --danger-fill: #c81e1e;

    --glass: rgba(255, 255, 255, 0.78);
    --glass-strong: rgba(255, 255, 255, 0.94);
    --scrim: rgba(23, 25, 29, 0.38);

    --thumb-1: #2f6fd6;
    --thumb-2: #5a4fd8;
    --glow-1: rgba(9, 100, 223, 0.08);
    --glow-2: rgba(79, 70, 229, 0.06);
    --glow-3: rgba(139, 92, 246, 0.04);

    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
    --shadow-pop: 0 30px 80px -24px rgba(16, 24, 40, 0.35);
    --shadow-btn: 0 6px 18px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  }
}

/* ─── Base ─── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: -20vh -10vw auto;
  height: 70vh;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 60% at 22% 30%, var(--glow-1), transparent 70%),
    radial-gradient(35% 55% at 70% 20%, var(--glow-2), transparent 70%),
    radial-gradient(30% 50% at 50% 60%, var(--glow-3), transparent 70%);
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: var(--font-heading); letter-spacing: -0.03em; line-height: 1.15; color: var(--text); }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--accent-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.94rem;
  white-space: nowrap;
  text-decoration: none;
  transition: transform 220ms var(--ease-out), background 200ms ease, box-shadow 300ms var(--ease-out), border-color 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.5; cursor: default; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary {
  color: var(--accent-on-fill);
  background: linear-gradient(135deg, var(--accent-fill) 0%, var(--accent-fill-2) 100%);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover:not([disabled]) { box-shadow: 0 12px 36px var(--accent-glow), 0 0 0 1px var(--accent-line), inset 0 1px 0 rgba(255, 255, 255, 0.16); }
.btn-ghost {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border);
}
.btn-ghost:hover:not([disabled]) { background: var(--bg-card-hover); border-color: var(--border-strong); }
.btn-danger { color: #fff; background: var(--danger-fill); }
.btn-danger-ghost { color: var(--rec); background: transparent; border-color: var(--border); }
.btn-danger-ghost:hover:not([disabled]) { background: var(--rec-soft); border-color: transparent; }
.btn-small { min-height: 36px; padding: 0 0.95rem; font-size: 0.86rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: background 200ms ease, border-color 200ms ease, transform 200ms var(--ease-out);
}
.icon-btn:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.plain { border-color: transparent; background: transparent; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.spinner {
  width: 18px; height: 18px; flex: none;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
.spinner.large { width: 34px; height: 34px; border-width: 3px; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Fields ─── */
.field { display: grid; gap: 0.4rem; }
.field > label, .field-label { font-size: 0.86rem; font-weight: 600; color: var(--text-secondary); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-field);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input[aria-invalid='true'] { border-color: var(--rec); }
.input.has-toggle { padding-inline-end: 5.5rem; }
.input.code { text-transform: uppercase; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; }
select.input { appearance: none; padding-inline-end: 2.4rem; background-image: none; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: '';
  position: absolute;
  inset-inline-end: 1rem;
  top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.toggle-vis {
  position: absolute;
  inset-inline-end: 6px;
  min-height: 36px;
  padding: 0 0.8rem;
  border-radius: 10px;
  border: 0;
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
}
.hint { font-size: 0.84rem; color: var(--text-muted); }
.error-text { font-size: 0.88rem; color: var(--rec); font-weight: 500; }
.check { display: flex; align-items: flex-start; gap: 0.7rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent-fill); flex: none; }
.check span { display: grid; gap: 0.05rem; }
.check small { color: var(--text-muted); font-size: 0.82rem; }

.strength { display: grid; gap: 0.35rem; }
.strength-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength-bar i { height: 5px; border-radius: 3px; background: var(--bg-inset); transition: background 200ms ease; }
.strength[data-score='1'] .strength-bar i:nth-child(-n+1) { background: var(--rec); }
.strength[data-score='2'] .strength-bar i:nth-child(-n+2) { background: var(--warn); }
.strength[data-score='3'] .strength-bar i:nth-child(-n+3) { background: var(--accent-fill); }
.strength[data-score='4'] .strength-bar i { background: var(--ok); }
.strength-text { font-size: 0.82rem; color: var(--text-muted); }

/* ─── Centered screens (landing, connecting, login, setup) ─── */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
}
.panel {
  width: min(100%, 440px);
  padding: 32px 28px;
  border-radius: var(--radius-xl);
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-pop);
  display: grid;
  gap: 1.15rem;
  animation: rise 520ms var(--ease-out) both;
}
.panel.wide { width: min(100%, 520px); }
.panel-head { display: grid; justify-items: center; gap: 0.8rem; text-align: center; }
.panel-head .logo { width: 76px; height: 76px; border-radius: 20px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35), 0 0 40px var(--accent-glow); }
.panel-head h1 { font-size: clamp(1.45rem, 5vw, 1.8rem); font-weight: 700; }
.panel-head p { color: var(--text-secondary); max-width: 34ch; }
.panel form, .sheet-body form { display: grid; gap: 1rem; }
.panel .foot { font-size: 0.84rem; color: var(--text-muted); text-align: center; }
.panel .center { display: grid; justify-items: center; gap: 1rem; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
}
.eyebrow svg { width: 14px; height: 14px; }
.notice {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: 0.88rem;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--accent); }
.notice.error { background: var(--rec-soft); color: var(--text); }
.notice.error svg { color: var(--rec); }
.notice.ok { background: var(--ok-soft); color: var(--text); }
.notice.ok svg { color: var(--ok); }
.server-status-list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.server-status-list li { display: flex; align-items: center; gap: 0.6rem; font-size: 0.88rem; color: var(--text-secondary); }

@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ─── Header ─── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand img { width: 38px; height: 38px; border-radius: 10px; flex: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); }
.brand-text { display: grid; min-width: 0; }
.brand-text strong { font-family: var(--font-heading); font-size: 1.02rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand-text span { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.server-switch select.input { min-height: 40px; border-radius: 999px; font-size: 0.9rem; font-weight: 600; max-width: 13rem; }
.pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 32px;
  padding: 0 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-faint); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--rec); box-shadow: 0 0 0 3px var(--rec-soft); }
.dot.rec { background: var(--rec); box-shadow: 0 0 0 4px var(--rec-soft); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }

.offline-bar {
  max-width: var(--max);
  margin: 12px auto 0;
  padding: 0 16px;
}
.offline-bar .notice { background: var(--warn-soft); color: var(--text); }
.offline-bar .notice svg { color: var(--warn); }

/* ─── Main ─── */
main.app-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 38px;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: background 200ms ease, color 200ms ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { background: var(--bg-elevated); color: var(--text); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18), 0 0 0 1px var(--border); }
.tab .count {
  min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  background: var(--bg-card-hover);
  font-size: 0.74rem; font-variant-numeric: tabular-nums;
}
.tab[aria-selected='true'] .count { background: var(--accent-soft); color: var(--accent); }
.tab .count.live { background: var(--rec-soft); color: var(--rec); }

.list { display: grid; gap: 14px; }
@media (min-width: 900px) { .list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.empty {
  display: grid; justify-items: center; gap: 0.8rem; text-align: center;
  padding: 56px 20px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}
.empty > svg { width: 40px; height: 40px; color: var(--text-faint); }
.empty strong { color: var(--text); font-family: var(--font-heading); font-size: 1.05rem; }

/* ─── Recording card ─── */
.rec-card {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transition: border-color 200ms ease, background 200ms ease;
  animation: rise 420ms var(--ease-out) both;
}
.rec-card:hover { border-color: var(--border-strong); }
.rec-card[data-state='recording'] { border-color: color-mix(in srgb, var(--rec) 30%, var(--border)); }
.thumb {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 16px;
  overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--thumb-1), var(--thumb-2));
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.rec-body { min-width: 0; display: grid; gap: 0.35rem; align-content: start; }
.rec-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 0.38rem;
  min-height: 24px; padding: 0 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em;
  background: var(--bg-inset); color: var(--text-secondary);
}
.badge .dot { width: 7px; height: 7px; }
.badge.recording { background: var(--rec-soft); color: var(--rec); }
.badge.scheduled { background: var(--accent-soft); color: var(--accent); }
.badge.conflict, .badge.partial { background: var(--warn-soft); color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--rec-soft); color: var(--rec); }
.badge.server { background: transparent; border: 1px solid var(--border); }
.rec-title { font-size: 1.06rem; font-weight: 650; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.rec-sub { font-size: 0.88rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.rec-meta { font-size: 0.84rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; }
.rec-meta span { white-space: nowrap; }
.progress { display: grid; gap: 0.35rem; margin-top: 0.3rem; }
.progress-track { height: 6px; border-radius: 3px; background: var(--bg-inset); overflow: hidden; }
.progress-fill {
  height: 100%;
  width: var(--pct, 0%);
  border-radius: 3px;
  background: linear-gradient(90deg, var(--rec), color-mix(in srgb, var(--rec) 60%, var(--accent-vivid)));
  transition: width 900ms var(--ease-out);
}
.progress-label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.3rem; }
.stat { display: grid; gap: 0; }
.stat dt { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.stat dd { margin: 0; font-size: 0.92rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.failure {
  display: flex; gap: 0.5rem; align-items: flex-start;
  margin-top: 0.3rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--rec-soft);
  font-size: 0.85rem;
}
.failure svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--rec); }
.failure.soft { background: var(--warn-soft); }
.failure.soft svg { color: var(--warn); }
.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0.55rem; }
@media (max-width: 420px) {
  .rec-card { grid-template-columns: 44px minmax(0, 1fr); padding: 14px; gap: 12px; }
  .thumb { width: 44px; height: 44px; border-radius: 12px; font-size: 0.85rem; }
  /* Under the thumbnail on recording cards only (Settings uses .rec-actions too). */
  .rec-card .rec-actions { margin-inline-start: -56px; }
}

/* ─── Dialogs (sheets) ─── */
dialog.sheet {
  width: min(100% - 32px, 560px);
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: rise 360ms var(--ease-out) both; }
dialog.sheet::backdrop { background: var(--scrim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog.sheet.small { width: min(100% - 32px, 420px); }
dialog.sheet.wide { width: min(100% - 32px, 720px); }
.sheet-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 12px 22px;
  border-bottom: 1px solid var(--border);
}
.sheet-head h2 { flex: 1; font-size: 1.15rem; font-weight: 700; }
.sheet-body { padding: 18px 22px 22px; overflow-y: auto; display: grid; gap: 1.1rem; overscroll-behavior: contain; }
.sheet-foot { padding: 14px 22px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.sheet-foot .btn { min-width: 7rem; }
@media (max-width: 600px) {
  dialog.sheet, dialog.sheet.small, dialog.sheet.wide {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: 0;
    max-height: 92vh;
    max-height: 92dvh;
  }
  .sheet-foot .btn { flex: 1; }
}
.confirm-body { padding: 26px 24px 10px; display: grid; gap: 0.6rem; }
.confirm-body h2 { font-size: 1.2rem; }
.confirm-body p { color: var(--text-secondary); }

.section { display: grid; gap: 0.75rem; }
.section + .section { padding-top: 1.1rem; border-top: 1px solid var(--border); }
.section h3 { font-size: 0.74rem; font-family: var(--font-body); font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1rem; margin: 0; font-size: 0.92rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; text-align: end; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row > div { min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { font-size: 0.84rem; color: var(--text-muted); }
.device-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.device-list li { padding: 10px 0; border-top: 1px solid var(--border); }
.device-list li:first-child { border-top: 0; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.8rem; word-break: break-all; color: var(--text-secondary); }
.server-block { display: grid; gap: 0.9rem; padding: 16px; border-radius: var(--radius-lg); background: var(--bg-inset); }
.server-block h4 { margin: 0; font-family: var(--font-heading); font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }

/* Switch */
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong);
  transition: background 200ms ease;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: transform 220ms var(--ease-out);
}
.switch input:checked + span { background: var(--accent-fill); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
[dir='rtl'] .switch span::after { left: auto; right: 3px; }
[dir='rtl'] .switch input:checked + span::after { transform: translateX(-20px); }

/* Channel picker */
/* Schedule search: programmes then channels. */
.channel-results { display: grid; gap: 10px; max-height: 320px; overflow-y: auto; }
.channel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.results-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); margin: 2px 10px 0; }
.channel-option > span:last-child { min-width: 0; }
.stack { display: grid; gap: 1.1rem; min-width: 0; }
.channel-option {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  text-align: start;
}
.channel-option:hover, .channel-option:focus-visible { background: var(--bg-inset); border-color: var(--border); }
.channel-logo {
  width: 40px; height: 40px; flex: none;
  border-radius: 10px;
  background: var(--bg-inset);
  display: grid; place-items: center;
  overflow: hidden;
  font-weight: 700; font-size: 0.8rem; color: var(--text-muted);
}
.channel-logo img { width: 100%; height: 100%; object-fit: contain; }
.channel-option .name { font-weight: 600; display: block; }
.channel-option .group { font-size: 0.8rem; color: var(--text-muted); display: block; }
.chosen-channel {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
}
.chosen-channel > div { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }
/* Date pickers have a wide intrinsic width (iOS Safari, Android Chrome) that
   pushed the sheet past the screen edge: let grid tracks shrink below it. */
.grid-2 > *, .sheet-body > *, .field { min-width: 0; }
input[type='datetime-local'].input {
  min-height: 48px; min-width: 0; max-width: 100%; display: block;
  -webkit-appearance: none; appearance: none; text-align: start;
}
input[type='datetime-local'].input::-webkit-date-and-time-value { text-align: start; }

/* ─── Player ─── */
dialog.player {
  width: min(100% - 32px, 1100px);
  /* The 16:9 video never pushes the controls below a short window (app window,
     small laptop screen): the width also follows the height left for the video. */
  width: min(100% - 32px, 1100px, max(320px, (100vh - 230px) * 16 / 9));
  width: min(100% - 32px, 1100px, max(320px, (100dvh - 230px) * 16 / 9));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  max-width: 1100px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #000;
  color: #fff;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
dialog.player[open] { animation: rise 360ms var(--ease-out) both; }
dialog.player::backdrop { background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
@media (max-width: 600px) { dialog.player { width: 100%; max-width: 100%; border-radius: 0; border: 0; } }
.player-stage { position: relative; aspect-ratio: 16 / 9; background: #000; display: grid; }
.player-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; grid-area: 1 / 1; }
.player-stage:fullscreen { aspect-ratio: auto; }
.player-overlay {
  grid-area: 1 / 1;
  display: grid; place-items: center; align-content: center; gap: 12px;
  padding: 24px; text-align: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.95rem;
}
.player-overlay .spinner.large { color: #fff; }
.player-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 18px;
  background: #0b0b14;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.player-top .t { flex: 1; min-width: 0; display: grid; }
.player-top strong { font-family: var(--font-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-top span { font-size: 0.8rem; color: #a3abbd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-top .icon-btn { border-color: rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.06); color: #fff; }
.player-controls {
  display: grid; gap: 8px;
  padding: 10px 14px 14px;
  background: #0b0b14;
}
.player-row { display: flex; align-items: center; gap: 6px; }
.player-row .spacer { flex: 1; }
.player-row .icon-btn { width: 40px; height: 40px; border-color: transparent; background: transparent; color: #fff; }
.player-row .icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
.player-time { font-size: 0.82rem; font-variant-numeric: tabular-nums; color: #cfd5e2; white-space: nowrap; }
.seek {
  --pct: 0%;
  --buf: 0%;
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
.seek::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-fill) 0 var(--pct), rgba(255, 255, 255, 0.35) var(--pct) var(--buf), rgba(255, 255, 255, 0.16) var(--buf));
}
.seek::-moz-range-track { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); }
.seek::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent-fill); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5.5px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.seek::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; }
.player-note { font-size: 0.78rem; color: #8891a5; }
.live-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.74rem; font-weight: 700; color: #ff8a90; }

/* ─── Toasts & downloads ─── */
.toasts {
  position: fixed;
  z-index: 60;
  inset-inline: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: min(100%, 520px);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--glass-strong);
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-pop);
  font-size: 0.92rem;
  animation: rise 320ms var(--ease-out) both;
}
.toast svg { width: 18px; height: 18px; flex: none; color: var(--ok); }
.toast.error svg { color: var(--rec); }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity 240ms ease, transform 240ms ease; }
.dl-toast { display: grid; gap: 8px; min-width: min(100%, 360px); }
.dl-toast .row { gap: 10px; }
.dl-toast .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-toast .progress-fill { background: linear-gradient(90deg, var(--accent-fill), var(--accent-vivid)); }

.fab {
  position: fixed;
  z-index: 15;
  inset-inline-end: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: none;
}
@media (max-width: 600px) {
  .fab { display: inline-flex; min-height: 54px; padding: 0 1.4rem; }
  .toolbar .schedule-btn { display: none; }
  .header-actions .pill { display: none; }
  .brand-text span { max-width: 40vw; }
  /* Several servers: the switcher takes the place of the name. */
  .header-inner:has(.server-switch:not([hidden])) .brand-text { display: none; }
  .tabs { display: flex; width: 100%; }
  .tab { flex: 1 1 0; justify-content: center; padding: 0 0.5rem; }
  .rec-actions .btn { flex: 1 1 calc(50% - 4px); }
  .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .brand-text strong { font-size: 0.95rem; }
  .server-switch select.input { max-width: 11rem; font-size: 0.86rem; }
  .tab { padding: 0 0.3rem; gap: 0.3rem; font-size: 0.84rem; }
  .tab .count { min-width: 18px; height: 18px; padding: 0 4px; font-size: 0.68rem; }
}

/* ─── Landing ─── */
.landing-steps { display: grid; gap: 0.7rem; margin: 0; padding: 0; list-style: none; }
.landing-steps li { display: flex; gap: 0.7rem; align-items: flex-start; font-size: 0.92rem; color: var(--text-secondary); }
.landing-steps svg { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 3px; }
footer.site-foot { text-align: center; color: var(--text-faint); font-size: 0.78rem; margin-top: 1.4rem; }
footer.site-foot a { color: inherit; }

/* Music away from home (gateway.js) */
.gw-form { display: grid; gap: 0.75rem; padding: 0.9rem; border: 1px solid var(--border); border-radius: 14px; }
.gw-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.gw-actions.start { justify-content: flex-start; }
.gw-row { align-items: flex-start; flex-wrap: wrap; }
.gw-row .title { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.gw-warn { color: var(--warn); }
/* Toast host raised to the top layer while a sheet is open (ui.js raiseToasts): keep its own box. */
.toasts:popover-open { top: auto; margin: 0; border: 0; background: transparent; color: inherit; overflow: visible; width: auto; height: auto; }
