/* Captions are the hero. Dark base for auditorium phones, one warm "stage light" accent,
   Atkinson Hyperlegible for maximum readability at a glance. */
:root {
  --bg: #0f1a2b;
  --panel: #16233a;
  --line: #26354f;
  --text: #f3eee6;
  --muted: #8a98b0;
  --accent: #f2b544;
  --accent-ink: #1a1200;
  --live: #4fd1a1;
  --error: #f27e7e;
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent); }
button, select {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.bar .room { color: var(--text); font-weight: 700; }
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}
.live-pill::before {
  content: '';
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--muted);
}
.live-pill.is-live { color: var(--live); }
.live-pill.is-live::before { background: var(--live); box-shadow: 0 0 0 4px rgba(79, 209, 161, 0.18); }

/* ---------- audience page ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.captions {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { .captions { scroll-behavior: auto; } }
.captions ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.captions li {
  font-size: 1.5rem;
  line-height: 1.35;
  margin: 0 0 0.9rem;
  max-width: 34ch;
  color: var(--muted);
}
.captions li:nth-last-child(-n + 2) { color: var(--text); }
.captions li.pending { opacity: 0.55; font-style: italic; }
.partial {
  font-size: 1.5rem;
  line-height: 1.35;
  margin: 0 0 0.5rem;
  max-width: 34ch;
  color: var(--accent);
  min-height: 1.35em;
}
.partial.secondary { font-size: 1rem; color: var(--muted); }
.partial:not(:empty)::after {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 0.15em;
  vertical-align: text-bottom;
  background: var(--accent);
  opacity: 0.8;
}
.empty { color: var(--muted); max-width: 34ch; }

.controls {
  border-top: 1px solid var(--line);
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--panel);
}
.langs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}
.langs::-webkit-scrollbar { display: none; }
.lang {
  flex: 0 0 auto;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.lang.is-selected { background: var(--text); color: var(--bg); border-color: var(--text); }
.listen {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 1.05rem;
}
.listen[disabled] { background: var(--line); color: var(--muted); cursor: default; }
.listen.is-on { background: var(--live); }
.audio-status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.3em;
}

/* ---------- broadcaster page ---------- */
.broadcast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  padding: 1.25rem 1rem;
  max-width: 1200px;
}
@media (max-width: 860px) { .broadcast { grid-template-columns: 1fr; } }
.setup {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.setup label { display: flex; flex-direction: column; gap: 0.25rem; color: var(--muted); font-size: 0.9rem; min-width: 16rem; flex: 1; }
.setup select {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.primary {
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.primary.is-on { background: var(--error); color: var(--accent-ink); }
.meter {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.meter > div { height: 100%; width: 0; background: var(--live); transition: width 80ms linear; }
.transcript ol { list-style: none; margin: 0; padding: 0; }
.transcript li { margin: 0 0 0.6rem; max-width: 70ch; }
.transcript li small { color: var(--muted); margin-right: 0.5rem; }
.transcript .partial { font-size: 1.1rem; }
.side { display: flex; flex-direction: column; gap: 1rem; }
.stat { color: var(--muted); }
.stat b { color: var(--text); font-size: 1.4rem; margin-right: 0.3rem; }
.qr { background: #fff; padding: 0.75rem; border-radius: 10px; width: fit-content; }
.qr img, .qr canvas { display: block; }
.link { word-break: break-all; font-size: 0.9rem; }
.log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
  max-height: 14rem;
  overflow-y: auto;
}
.log li { padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
.log li.error { color: var(--error); }
.log li.warn { color: var(--accent); }

/* ---------- landing ---------- */
.landing { max-width: 48ch; padding: 2rem 1rem; }
.landing h1 { font-size: 1.6rem; margin: 0 0 0.5rem; }
.landing p { color: var(--muted); }
.landing ul { padding-left: 1.2rem; }
