/*
 * Mobile-first, one stylesheet, no framework (§3.7). Large tap targets throughout: AC-24 has
 * several people sharing one handset and tapping between voice profiles mid-conversation, so a
 * 44 px minimum is a requirement here rather than a guideline.
 *
 * Dark by default. The room this runs in is a dim evening event, and a white phone screen held at
 * chest height is a light source pointed at everybody else's face.
 */

:root {
  --bg: #101215;
  --panel: #181b20;
  --line: #2a2f37;
  --text: #e8eaed;
  --muted: #9aa3ad;
  --accent: #4da3ff;
  --good: #47c07a;
  --warn: #e0a33e;
  --bad: #e2564d;
  --radius: 10px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.lede {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.note {
  color: var(--muted);
  font-size: 0.85rem;
}

.error {
  color: var(--bad);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

/*
 * No `.token` rule. It existed for exactly one element — the admin token that `index.html`'s Step 1
 * scaffold painted onto the landing page — and that element is gone. A style whose only purpose was
 * rendering a credential is an invitation to render one again, so it goes with the markup rather
 * than surviving as dead CSS somebody later finds a use for (§4.16).
 */

button.primary {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #06121f;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

button.tap {
  min-height: 64px;
  font-size: 1.1rem;
}

button.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.panel {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.35rem 0;
}

.row span {
  color: var(--muted);
}

.row strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
}

/* The level meter draws three things at once: level, noise floor, and start threshold. Seeing the
   threshold is what turns "it isn't picking me up" from a complaint into a diagnosis. */
.meter {
  position: relative;
  height: 22px;
  margin-bottom: 0.75rem;
  background: #0b0d10;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--good), var(--warn) 78%, var(--bad));
  transition: width 60ms linear;
}

.meter-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
}

.meter-floor {
  background: var(--muted);
}

.meter-threshold {
  background: var(--accent);
}

#gate-state[data-open="yes"] {
  color: var(--good);
}

#gate-state[data-open="no"] {
  color: var(--muted);
}

a {
  color: var(--accent);
}

/* ── Admin console (§5 Step 2: transcript + metrics) ───────────────────────────────────────── */

/* The console is read on a laptop beside the room; the join page is read on a phone in it. */
.page-wide {
  max-width: 52rem;
}

.banner:empty {
  display: none;
}

.banner {
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  color: var(--warn);
  background: #241d10;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
}

/* Bounded height with its own scroll: the transcript grows all evening and must not push the
   metrics panel off the screen an operator is watching. */
.captions {
  max-height: 24rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.caption {
  padding: 0.55rem 0.7rem;
  background: #12151a;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.caption-head {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--muted);
}

.caption-speaker {
  font-weight: 600;
  color: var(--text);
}

.caption-time {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.caption-source,
.caption-translated {
  margin: 0.35rem 0 0;
}

.caption-translated {
  color: var(--accent);
}

.caption-pending {
  color: var(--muted);
}

.caption-noaudio {
  margin: 0.35rem 0 0;
  color: var(--warn);
}

/* ── Step 5: readiness, tap-to-switch, QR, roster, ladder, live tier ───────────────────────── */

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

button.danger {
  background: transparent;
  color: var(--bad);
  border: 1px solid var(--bad);
}

button:disabled {
  opacity: 0.45;
}

input[type="text"],
input[type="number"],
select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  font: inherit;
  min-height: 44px;
}

.row.consent {
  align-items: flex-start;
  gap: 0.6rem;
}

.row.consent input {
  /* R11's checkbox is the gate on a legal obligation; it has to be hittable with a thumb. */
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

/* AC-24: one large button per registered person, wrapping rather than scrolling — a button you
   have to scroll to find is one that gets tapped late, and late is the whole failure mode. */
.profile-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

button.profile {
  flex: 1 1 45%;
  min-height: 56px;
}

.qr {
  display: block;
  width: 100%;
  max-width: 16rem;
  margin: 0.75rem auto 0;
  background: #fff;
  border-radius: var(--radius);
  padding: 0.5rem;
}

.roster-row {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
}

.roster-row[data-green="yes"] {
  border-left-color: var(--good);
}

.roster-row[data-green="no"] {
  border-left-color: var(--line);
}

.roster-row[data-muted="yes"] {
  opacity: 0.6;
}

.roster-row .controls {
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.readiness-dot {
  color: var(--muted);
}

.roster-row[data-green="yes"] .readiness-dot {
  color: var(--good);
}

.languages,
.active-profile {
  color: var(--accent);
}

.health-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.health-dot {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.health-dot[data-tone="green"] {
  color: var(--good);
  border-color: var(--good);
}

.health-dot[data-tone="red"] {
  color: var(--bad);
  border-color: var(--bad);
}

.health-dot[data-tone="grey"] {
  color: var(--muted);
}

/* R§4.9: in realtime mode this row IS the pipeline and the ladder beside it is the fallback, so it
   must not read as an eighth interchangeable dot. The tone still carries health — this only says
   which half of the build the row belongs to. */
.health-dot[data-kind="realtime"] {
  border-width: 2px;
  font-weight: 600;
}

/* §4.20's indicator. Deliberately unlike the health dots in size, position and shape: it answers a
   different question, and an operator who reads it as a fourth dot has learned nothing. */
.live-tier {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  margin-bottom: 1rem;
}

.live-tier[data-tone="amber"] {
  border-color: var(--warn);
  background: #241d10;
}

.live-tier[data-tone="red"] {
  border-color: var(--bad);
  background: #24140f;
}

.tier-headline {
  font-size: 1.05rem;
}

.live-tier[data-tone="amber"] .tier-headline {
  color: var(--warn);
}

.live-tier[data-tone="red"] .tier-headline {
  color: var(--bad);
}

.tier-detail {
  color: var(--muted);
}

.ladder-row select {
  flex: 1 1 auto;
  margin: 0 0.5rem;
}

.tunables {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.row.tunable input {
  width: 8rem;
}

.row[data-verdict="over"] strong {
  color: var(--warn);
}

.row[data-verdict="under"] strong {
  color: var(--good);
}

@media (min-width: 40rem) {
  .tunables {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── The operator gate and the console's first run (§4.16 extended) ────────────────────────── */

/* The unlock page's one field. `password` was missing from the input list above because until the
   gate existed no page had one. */
input[type="password"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  font: inherit;
  min-height: 44px;
}

.field {
  width: 100%;
}

/*
 * First run. Before a room exists every panel that depends on one shows its heading and its
 * `waiting` line and nothing else — an empty panel and a panel that is waiting look identical on
 * screen and mean different things, and the operator who reported "I could not find the QR code"
 * was reading an empty one.
 */
[data-room="none"] .needs-room > :not(h2):not(.waiting) {
  display: none;
}

[data-room="live"] .waiting {
  display: none;
}

[data-room="live"] #first-run {
  display: none;
}

.waiting {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.first-run {
  border-color: var(--accent);
}

/* The QR is how everybody in the room gets in, so it is the largest thing on the page and it is
   first. `.qr` above sizes it for the join page's tighter column; here it gets the room. */
.needs-room .qr {
  max-width: 22rem;
  margin-top: 0;
}

.qr-caption {
  text-align: center;
  margin: 0.5rem 0 1rem;
}

/* The join URL, as text somebody can select — the complaint this answers is that it was impossible
   to type off a screen. `user-select: all` makes one tap take the whole thing, and the button
   beside it removes the need to select at all. */
.join-url {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.join-link {
  flex: 1 1 12rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  user-select: all;
  -webkit-user-select: all;
}

button.copy {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
}

/* ── Realtime mode shows only what realtime uses (docs/DEFERRED.md §12.5) ──────────────────── */

/*
 * `hidden` is how both pages remove a panel that has no subject in the current pipeline mode. The
 * declaration is explicit rather than left to the UA stylesheet because `.panel` and `.row` set
 * layout on the same elements, and a future `display` rule on either would otherwise win on
 * specificity and quietly bring a hidden panel back — visibly, on a phone, mid-event.
 */
[hidden] {
  display: none !important;
}

/* AC-18's refusal line now sits at the top of the console, above the first-run panel, so it must
   take no room when there is nothing to refuse. Same rule `.banner` has, for the same reason. */
#config-error:empty {
  display: none;
}

/*
 * The console's one disclosure. It holds the modular chain — providers, the voice ladder, §4.20's
 * tier indicator, segmentation and the cross-talk gate — and `admin/main.ts` decides whether it
 * stands open: yes in modular mode, where those controls are the live path, and yes again the
 * moment realtime stops being available and they become the live path once more.
 *
 * The summary is a real target rather than a text link: it is pressed on a laptop beside a room,
 * sometimes in a hurry, and it is the only route to controls the operator may need at 19:50.
 */
.fallback {
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #14171c;
}

.fallback > summary {
  min-height: 44px;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style-position: inside;
}

.fallback > summary::marker {
  color: var(--muted);
}

.fallback[open] > summary {
  border-bottom: 1px solid var(--line);
}

.fallback-note {
  margin: 0.75rem 1rem 0;
}

/* The panels inside sit in the disclosure's own padding, so they do not read as a second page. */
.fallback > .panel {
  margin: 1rem;
}
