:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #16202c; --muted: #647184; --line: #dde2e9;
  --accent: #0f5fd7; --accent-ink: #fff; --user: #e7f0ff; --ok: #1a8f4c; --warn: #b7791f; --bad: #c0392b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151c; --panel: #171e27; --ink: #e8edf3; --muted: #93a0b2; --line: #28323f;
    --accent: #5b9bff; --accent-ink: #0b1220; --user: #1d2c44;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.layout { display: flex; justify-content: center; height: 100dvh; }
.app {
  display: flex; flex-direction: column; height: 100dvh; width: 100%; max-width: 780px;
  background: var(--panel); border-inline: 1px solid var(--line);
}
/* the screen is 1280x800: beside the chat it gets all the remaining width, text stays readable */
.with-demo .app { flex: 0 0 400px; }
.demo { flex: 1 1 0; min-width: 0; max-width: 1312px; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.demo[hidden] { display: none; }
.demo-head { display: flex; align-items: center; gap: 12px; font-size: 0.92rem; }
.demo-state { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-state[data-state="running"] { color: var(--accent); }
.demo-state[data-state="running"]::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s steps(4, end) infinite; }
.demo-zoom { padding: 4px 10px; font-size: 0.82rem; background: var(--panel); border-color: var(--line); color: var(--ink); }
.demo-video { width: 100%; aspect-ratio: 1280 / 800; background: #000; border: 1px solid var(--line); border-radius: 8px; pointer-events: none; }
.demo-caption { margin: 0; color: var(--muted); font-size: 0.82rem; }
@media (max-width: 1100px) {
  .layout { flex-direction: column; height: auto; min-height: 100dvh; }
  .with-demo .app { flex: 1 1 auto; height: 60dvh; max-width: none; }
  .demo { order: -1; flex: 0 0 auto; }
}
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; }
.bar-end { display: flex; align-items: center; gap: 14px; }
.stt { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.stt select { font: inherit; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status[data-state="ready"]::before { background: var(--ok); }
.status[data-state="error"]::before { background: var(--bad); }

.messages { flex: 1; overflow-y: auto; margin: 0; padding: 20px; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.hint { color: var(--muted); font-size: 0.92rem; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; }
.signin { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 0 16px 12px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.signin[hidden] { display: none; }
.msg { max-width: 86%; display: flex; flex-direction: column; gap: 6px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.user .bubble { background: var(--user); border-bottom-right-radius: 4px; }
.assistant .bubble { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.error .bubble { border-color: var(--bad); color: var(--bad); }
.pending .bubble::after { content: "..."; color: var(--muted); animation: blink 1.2s steps(4, end) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.sources span { padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }

.composer { display: flex; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.composer input {
  flex: 1; min-width: 0; padding: 11px 14px; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.composer input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.send { padding: 0 18px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.mic, .speaker { display: grid; place-items: center; width: 46px; background: var(--bg); border-color: var(--line); color: var(--muted); }
.mic[hidden], .speaker[hidden] { display: none; }
.mic[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 520px) { .sub { display: none; } .msg { max-width: 94%; } }
.speaker[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
