:root {
  --size: 24px;
  --gutter: 16px;
  --bar-h: 64px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: var(--brand-bg, #0e0f12);
  --surface: color-mix(in srgb, var(--bg) 88%, #ffffff);
  --border: color-mix(in srgb, var(--bg) 78%, #ffffff);
  --text: #f2f3f5;
  --muted: #9aa0ab;
  --accent: var(--brand-accent, #6cb4ff);
  --fresh: #ffffff;
  --live: #3ddc84;
  --warn: #ffb547;
  --off: #ff6b6b;
}

[data-theme="light"] {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --border: #e2e2df;
  --text: #16171a;
  --muted: #5d636e;
  --accent: var(--brand-accent-light, #0b62c4);
  --fresh: #000000;
  --live: #12823f;
  --warn: #a75d00;
  --off: #c62828;
}

[data-theme="contrast"] {
  --bg: #000000;
  --surface: #000000;
  --border: #ffe600;
  --text: #ffe600;
  --muted: #ffe600;
  --accent: #ffffff;
  --fresh: #ffffff;
  --live: #ffe600;
  --warn: #ffe600;
  --off: #ffe600;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ---- Top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.titles {
  flex: 1;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event[hidden] { display: none; }
.event img { display: block; height: 18px; width: auto; }

.logo-light { display: none !important; }
[data-theme="light"] .has-light-logo .logo-dark { display: none !important; }
[data-theme="light"] .has-light-logo .logo-light { display: block !important; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
}

.status .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status[data-state="live"] { color: var(--text); }
.status[data-state="live"] .dot { background: var(--live); animation: pulse 2s ease-in-out infinite; }
.status[data-state="soon"] .dot,
.status[data-state="connecting"] .dot { background: var(--warn); }
.status[data-state="offline"] .dot { background: var(--off); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

.stages-link {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: -8px;
  border-radius: 10px;
  color: var(--text);
}

.stages-link[hidden] { display: none; }

/* ---- Stage picker ---- */

[data-view="picker"] .status,
[data-view="picker"] main,
[data-view="picker"] .controls,
[data-view="picker"] .jump {
  display: none;
}

.picker {
  max-width: 34em;
  margin: 0 auto;
  padding: 24px var(--gutter) calc(32px + env(safe-area-inset-bottom));
}

.picker-brand {
  margin: 8px 0 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.picker-brand[hidden] { display: none; }

.picker-event {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.picker-event img { display: block; max-width: 260px; max-height: 64px; width: auto; }

.picker-tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.picker-tagline:empty { display: none; }

.picker-intro {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.stage-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 21px;
  font-weight: 700;
  text-decoration: none;
}

.stage-list a::after {
  content: "›";
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
}

.stage-list a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Captions ---- */

main {
  max-width: 46em;
  margin: 0 auto;
  padding: 20px var(--gutter) calc(var(--bar-h) + 40px + env(safe-area-inset-bottom));
}

.transcript {
  font-size: var(--size);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.transcript .seg {
  transition: color 1.2s ease;
}

.transcript .seg.fresh {
  color: var(--fresh);
  transition: none;
}

.transcript .spk {
  display: inline-block;
  margin-right: 0.3em;
  color: var(--accent);
  font-weight: 700;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 50dvh;
  text-align: center;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.5;
}

.empty[hidden] { display: none; }
.empty { align-content: center; gap: 14px; }

.backup a {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.backup[hidden] { display: none; }
.empty p { max-width: 22em; margin: 0; }

/* ---- Jump to live ---- */

.jump {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 11;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font: 700 15px/1 var(--font);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.jump[hidden] { display: none; }

/* ---- Bottom controls ---- */

.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--bar-h);
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.controls button,
.controls select {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 700 17px var(--font);
  cursor: pointer;
}

.controls button:focus-visible,
.controls select:focus-visible,
.jump:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.lang {
  flex: 1;
  min-width: 0;
}

.lang[hidden] { display: none; }

.lang select {
  width: 100%;
  padding: 0 36px 0 14px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 19px, calc(100% - 14px) 19px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.size {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.size button,
.theme {
  width: 48px;
  padding: 0;
}

.size sup { font-size: 0.65em; }
.theme span { font-size: 21px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The official SyncWords widget is loaded but never shown. */
#sw-widget,
#fw-widgetWrapper {
  display: none !important;
}

@media (min-width: 720px) {
  :root { --gutter: 28px; }
  .topbar h1 { font-size: 19px; }
  .controls { justify-content: center; }
  .lang { flex: 0 1 260px; }
  .size { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .status[data-state="live"] .dot { animation: none; }
  .transcript .seg { transition: none; }
}
