:root {
  --bg: #0b0f14;
  --panel: #141a22;
  --text: #f4f7fa;
  --muted: #b7c5d3;
  --line: #2a3441;
  --green: #3ddc84;
  --amber: #f5b13d;
  --red: #ff5c5c;
  --blue: #6aa9ff;
  --focus: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

body {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 20px 48px;
  line-height: 1.45;
}

.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;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}

.brand { font-size: 1.5rem; letter-spacing: 0.02em; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.status { font-size: 1.05rem; font-weight: 600; }
.status-connecting { color: var(--amber); }
.status-live { color: var(--green); }
.status-down { color: var(--red); }

.chip {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

main { margin-top: 24px; display: grid; gap: 22px; }

.alert {
  background: var(--panel);
  border: 3px solid var(--blue);
  border-radius: 18px;
  padding: 24px;
}

.alert.u-green { border-color: var(--green); }
.alert.u-amber { border-color: var(--amber); }
.alert.u-red { border-color: var(--red); }
.alert.hidden { display: none; }

.hidden { display: none; }

.alert-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.clock { color: var(--muted); font-size: 1.15rem; }

.caption {
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 700;
  margin: 8px 0 6px;
}

.caption-sub {
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 12px;
  font-style: italic;
}

.caption-sub:empty {
  display: none;
}

.why { font-size: 1.3rem; color: var(--muted); margin-bottom: 12px; }

.meta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

.badge {
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
}

.badge:empty { display: none; }
.badge-latency { color: var(--blue); }

.evidence { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.evidence span {
  font-size: 1.05rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
}

.escalation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(255, 92, 92, 0.12);
  border: 2px solid var(--red);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 1.2rem;
}

.escalation.hidden { display: none; }

.replies { display: flex; flex-wrap: wrap; gap: 12px; }
.replies > button { flex-shrink: 0; }
.replies button:disabled { opacity: .55; cursor: not-allowed; }
button { min-width: 44px; }

.reply, .primary, .danger {
  min-height: 44px;
  font-size: 1.3rem;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  padding: 14px 22px;
  cursor: pointer;
  color: #06120a;
  background: var(--green);
}

.primary { background: var(--blue); color: #061019; }
.danger { background: var(--red); color: #1a0202; }

.reply:nth-child(2) { background: var(--amber); color: #1a1202; }
.reply:nth-child(3) { background: var(--muted); color: #0b0f14; }
.reply:nth-child(4) { background: var(--blue); color: #061019; }

.note { margin-top: 10px; font-size: 1.15rem; color: var(--muted); min-height: 1.4em; }
.note.warn { color: var(--amber); }
.banner { margin: 0 24px 8px; padding: 12px 16px; border: 1px solid var(--amber); border-radius: 12px; }

.panel h2 { font-size: 1.3rem; margin-bottom: 12px; color: var(--muted); }

.simulator {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

.list { list-style: none; display: grid; gap: 8px; }

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 1.1rem;
}

.grid { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center; margin-bottom: 14px; }
.grid label { color: var(--muted); font-size: 1.05rem; }
.grid button { grid-column: 1 / -1; justify-self: start; }

input, select {
  min-height: 44px;
  font-size: 1.1rem;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f151c;
  color: var(--text);
}

.check { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; margin: 10px 0; }
.check input { min-height: auto; width: 22px; height: 22px; }

.preview {
  white-space: pre-wrap;
  background: #0f151c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 1.05rem;
  color: var(--muted);
  margin: 10px 0;
  min-height: 1.5em;
}

.history { list-style: none; display: grid; gap: 8px; }

.history li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border-left: 6px solid var(--blue);
  padding: 12px 14px;
  border-radius: 10px;
}

.history li.u-green { border-left-color: var(--green); }
.history li.u-amber { border-left-color: var(--amber); }
.history li.u-red { border-left-color: var(--red); }

.history time { color: var(--muted); white-space: nowrap; font-size: 1.05rem; }
.history .h-caption { font-size: 1.2rem; font-weight: 600; }
.history .h-tag { color: var(--muted); font-size: 1.05rem; text-align: right; }

.demo.hidden { display: none; }

/* TV / kiosk presentation (?tv=1): the 10-foot caption surface a Fire TV would
   load. Same PWA, same events, one screen, large type, D-pad only. */
body.tv-mode { padding: 2vh 3vw; max-width: 1600px; }
body.tv-mode .topbar,
body.tv-mode #api-auth-note,
body.tv-mode main > section:not(#alert),
body.tv-mode #demo { display: none; }
body.tv-mode main { display: flex; justify-content: center; align-items: center; min-height: 96vh; }
body.tv-mode #alert { width: 100%; max-width: 1500px; padding: 24px 34px; }
body.tv-mode .caption { font-size: clamp(2.2rem, 5vw, 3.7rem); }
body.tv-mode .caption-sub { font-size: clamp(1.4rem, 2.8vw, 2.1rem); }
body.tv-mode .why { font-size: 1.25rem; margin-bottom: 8px; }
body.tv-mode .badge { font-size: 1.1rem; padding: 4px 14px; }
body.tv-mode .meta,
body.tv-mode .evidence { margin-bottom: 10px; gap: 8px; }
body.tv-mode .replies { gap: 14px; }
body.tv-mode .replies button { font-size: 1.4rem; min-height: 60px; padding: 10px 22px; }
body.tv-mode .evidence span { font-size: 1.05rem; padding: 4px 12px; }
.tv-note { display: none; }
body.tv-mode .tv-note { display: block; color: var(--blue); font-size: 1.2rem; }
.alexa-utterance { font-size: 1.35rem; color: var(--text); margin: 10px 0 12px; }
.alexa-transcript { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.alexa-transcript li {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.02rem;
  color: var(--muted);
}
.alexa-answer { margin-top: 12px; font-size: 1.3rem; color: var(--text); min-height: 1.4em; }
.demo .replies { margin-top: 8px; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}