:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1b1b1a;
  --muted: #6d6b66;
  --line: #e4e1da;
  --accent: #e8590c;
  --accent-soft: #fff1e6;
  --mark: #ffe58a;
  --live: #1aa35b;
  --paused: #e67700; /* a short gap in captions, usually an ad break */
  --stale: #b8b5ad;
  --size: 20px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1b1b1a;
    --text: #ecebe7;
    --muted: #96938b;
    --line: #2c2b29;
    --accent: #ff8a3d;
    --accent-soft: #2d1f15;
    --mark: #6b5310;
    --live: #3ccf7f;
    --paused: #ffa94d;
    --stale: #55534e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* beats display rules like .list { display: flex } */
html { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 56px;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-row {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 16px 8px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.logo {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}
.logo { display: inline-flex; align-items: center; gap: 8px; }
.logo img { flex: none; border-radius: 6px; }
.logo b { color: var(--accent); font-weight: inherit; }
.search { flex: 1; min-width: 0; }
.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 15px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.size { display: none; gap: 4px; }
.has-transcript .size { display: flex; } /* only where there's caption text to resize */
.size button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
}

.channels {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px 10px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.channels::-webkit-scrollbar { display: none; }
.chan {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.chan[aria-current="page"] {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}
.chan .pip { width: 7px; height: 7px; border-radius: 50%; background: var(--stale); }
.chan.live .pip { background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 25%, transparent); }
.chan.paused .pip { background: var(--paused); box-shadow: 0 0 0 3px color-mix(in srgb, var(--paused) 25%, transparent); }
.card.paused .state { color: var(--paused); font-weight: 700; }
.card.paused .state::before { content: "● "; }

/* Programme header */
main { max-width: 920px; margin: 0 auto; padding: 20px 16px 0; }
.program { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.program-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.program h1 { font-size: 26px; line-height: 1.2; letter-spacing: -0.02em; margin: 4px 0 6px; }
.program p { margin: 0; color: var(--muted); max-width: 70ch; }
.program-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
}
.pill:hover { border-color: var(--accent); }
.pill[aria-current] { border-color: var(--text); background: var(--text); color: var(--bg); }
.pill.date { font: inherit; font-size: 13px; font-weight: 600; color: inherit; padding: 3px 10px; }
.pill.date[aria-current] { color: var(--bg); }
.program-links .break { flex-basis: 100%; height: 0; }
.mode { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; font-size: 11px; }
.mode.live { color: var(--live); }

/* Transcript */
.transcript { font-size: var(--size); line-height: 1.6; }
.block { display: grid; grid-template-columns: 64px 1fr; gap: 0 14px; margin: 0 0 0.9em; }
.block .t {
  font: 12px/1 var(--mono);
  color: var(--muted);
  padding-top: 0.55em;
  text-align: right;
  text-decoration: none;
  white-space: nowrap;
}
.block .t:hover { color: var(--accent); }
.block .t:empty::before { content: ""; }
.block p { margin: 0; overflow-wrap: anywhere; }
.cap { transition: background-color 2s ease; border-radius: 3px; }
.cap.new { animation: arrive 1.2s ease-out; }
@keyframes arrive {
  from { background: var(--accent-soft); color: var(--accent); }
  to { background: transparent; }
}
.cap.hit { background: var(--mark); }
.gap { color: var(--muted); }

.frame { grid-column: 2; margin: 0.3em 0 0.6em; }
.frame img {
  display: block;
  width: min(320px, 100%);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--line);
}

.empty { color: var(--muted); text-align: center; padding: 48px 0; font-size: 16px; }
.more { display: block; margin: 0 auto 20px; }

/* Lists: search results, EPG */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
}
.row:hover { border-color: var(--accent); }
.row .when { color: var(--muted); font: 12px/1.5 var(--mono); }
.row .when b { display: block; font: 600 13px/1.4 var(--sans); color: var(--text); }
.row h3 { margin: 0 0 2px; font-size: 16px; }
.row p { margin: 0; color: var(--muted); font-size: 14px; }
.row mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.row.now { border-color: var(--live); }

/* Landing page */
.is-home .top .search { visibility: hidden; }
.home { padding-bottom: 32px; }
.hero { padding: 28px 0 24px; max-width: 720px; }
.hero h1 { font-size: clamp(30px, 6vw, 46px); line-height: 1.05; letter-spacing: -0.035em; margin: 0 0 14px; }
.hero > p { font-size: 18px; color: var(--muted); margin: 0 0 20px; max-width: 60ch; }
.hero-search { display: flex; gap: 8px; }
.hero-search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 17px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.hero-search input:focus { border-color: var(--accent); }
.hero-search button {
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  font-weight: 700;
  background: var(--text);
  color: var(--bg);
}
.hero .hero-status { font-size: 14px; margin: 12px 0 0; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent, var(--line));
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  min-height: 190px;
}
.card:hover { border-color: var(--accent, var(--line)); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 8px; }
.card h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.card .state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.card.live .state { color: var(--live); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.card.live .state::before { content: "● "; }
.card .now { margin: 0; font-size: 14px; font-weight: 600; }
.card .latest {
  margin: 0;
  flex: 1;
  font-size: 14px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.card .go { font-weight: 700; color: var(--text); }

.about { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 36px 0 20px; }
.about h2 { font-size: 15px; margin: 0 0 4px; }
.about p { margin: 0; color: var(--muted); font-size: 14px; }
.credit { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }

/* Footer status + jump */
.status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.status .viewers { margin-left: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stale); flex: none; }
.dot.on { background: var(--live); }
.dot.err { background: var(--accent); }
.jump {
  position: fixed;
  right: 16px;
  bottom: 56px;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

@media (max-width: 560px) {
  .size, .has-transcript .size { display: none; }
  .top-row { flex-wrap: wrap; }
  .logo { font-size: 17px; }
  .search { flex-basis: 100%; }
  .block { grid-template-columns: 1fr; }
  .block .t { text-align: left; padding: 0 0 2px; }
  .frame { grid-column: 1; }
  .row { grid-template-columns: 1fr; gap: 4px; }
  .program h1 { font-size: 22px; }
}

/* Quote and cite popover (shown over a caption text selection) */
.quote-pop {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  width: max-content;
  max-width: calc(100vw - 16px);
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font: 600 14px/1.2 var(--sans);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  user-select: none;
  -webkit-user-select: none;
}
.quote-pop[hidden] { display: none; }
.quote-pop .quote-meta {
  padding: 0 8px;
  font: 12px/1.2 var(--mono);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.quote-pop button {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 9px 12px; /* comfortable touch target */
  border-radius: 8px;
  white-space: nowrap;
}
.quote-pop button:hover, .quote-pop button:focus-visible { background: color-mix(in srgb, var(--bg) 18%, transparent); }
@media (max-width: 480px) { .quote-pop .quote-meta { display: none; } }

/* Account: header menu, sign-in, alerts, admin (public/account.js) */
.account { display: flex; align-items: center; gap: 6px; flex: none; }
.pill.solid { background: var(--text); border-color: var(--text); color: var(--bg); }
.pill.alert { border-color: var(--accent); color: var(--accent); }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 220px;
  display: flex; flex-direction: column; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 28px rgb(0 0 0 / 0.14);
}
.menu-panel a, .menu-panel button {
  text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px;
  font-size: 14px; text-decoration: none; color: var(--text);
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--bg); }
.menu-who { margin: 0 0 4px; padding: 6px 10px 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; font-size: 13px; }
.menu-who span { color: var(--muted); overflow-wrap: anywhere; }

.hero-alerts { margin: 14px 0 0; font-size: 15px; color: var(--muted); }
.hero-alerts a { color: var(--accent); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 30;
  max-width: min(520px, calc(100% - 32px)); padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: 0 8px 28px rgb(0 0 0 / 0.2);
}
.toast.err { background: #d63b2f; color: #fff; }
.toast[hidden] { display: none; }

.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; }
.panel h2, .panel h3 { margin: 0 0 6px; font-size: 17px; }
.panel > p { margin: 0 0 10px; }
.panel.auth { max-width: 480px; }
.field[hidden] { display: none; }
.panel.nudge { border-color: var(--accent); background: var(--accent-soft); }
.panel.nudge a { color: var(--accent); font-weight: 600; }
.list > form.panel, .list > .panel { margin-bottom: 4px; }
.section { font-size: 17px; margin: 22px 0 4px; }
.muted { color: var(--muted); font-size: 13px; }
.fine { color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.fine a { color: inherit; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field .label, .field legend { font-weight: 600; font-size: 14px; padding: 0; }
.field small { color: var(--muted); font-size: 13px; }
.input {
  font: inherit; font-size: 16px; padding: 8px 12px; border-radius: 8px; width: 100%; /* 16px: no zoom-on-focus in iOS Safari */
  border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none;
}
.input:focus { border-color: var(--accent); }
.input:disabled { color: var(--muted); }
.list > .input[type="search"] { margin: 16px 0 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin: 0 0 14px; }
.check input, .chans input { margin: 0; accent-color: var(--accent); }
.chans { display: flex; flex-wrap: wrap; gap: 6px; }
.chans label {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; cursor: pointer;
}
.btn {
  border: 1px solid var(--text); background: var(--text); color: var(--bg); border-radius: 999px;
  padding: 7px 16px; font-weight: 600; font-size: 14px;
}
.btn.quiet { border-color: var(--line); background: var(--surface); color: var(--text); padding: 4px 11px; font-size: 13px; }
.btn.quiet:hover { border-color: var(--accent); }
.btn.danger { border-color: #d63b2f; background: #d63b2f; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; }
.linkish { border: 0; background: none; padding: 0; text-decoration: underline; font-size: 14px; }
.msg { font-size: 14px; margin: 10px 0 0; min-height: 1.2em; }
.msg.err, .fail { color: #d63b2f; }
.tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 6px 10px 8px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.rule { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.rule h3 { overflow-wrap: anywhere; }
.rule .msg { flex-basis: 100%; margin: 0; min-height: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sent { display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.sent:hover { border-color: var(--accent); }
.sent q, .table .quote { quotes: "“" "”"; }
.sent mark { background: var(--mark); color: inherit; border-radius: 2px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; }
.stat b { font-size: 24px; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.off td { opacity: 0.55; }
.table .quote { display: block; max-width: 340px; text-decoration: none; }
.table .quote:hover { text-decoration: underline; }

@media (max-width: 560px) {
  /* Logo and account share the first row; search wraps below. */
  .top-row .account { order: 1; margin-left: auto; }
  .top-row .search { order: 2; }
  .top-row .size { order: 3; }
  .is-home .top .search { display: none; } /* the hero has its own search box */
  .menu-panel { right: 0; }
}

/* Legal pages and site footer (public/pages.js) */
.prose { max-width: 720px; font-size: 16px; line-height: 1.6; }
.prose h2 { font-size: 18px; margin: 22px 0 6px; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-left: 20px; }
.prose li { margin: 0 0 6px; }
.prose a, .credit a { color: var(--accent); }
.site-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.site-foot a { color: var(--muted); }
.site-foot { max-width: 920px; margin: 40px auto 0; padding: 16px; border-top: 1px solid var(--line); }
.site-foot span { flex-basis: 100%; }
textarea.input { resize: vertical; font: inherit; font-size: 16px; }
select.input { appearance: auto; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.table .message { white-space: pre-wrap; max-width: 460px; }

/* Advanced search */
.adv { margin-bottom: 12px; }
.adv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; }
.row-program { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.center { text-align: center; }
.hero-adv { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.hero-adv a { color: var(--accent); font-weight: 600; }

/* Channel picker (alerts, advanced search) */
.chan-picker { display: flex; flex-direction: column; gap: 6px; }
.chans label.all { border-color: var(--text); }
.chans label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.pick-summary { color: var(--muted); font-size: 13px; }
.pick-summary.err { color: #d63b2f; }
