:root {
  --bg: #f6f5f2; --surface: #ffffff; --ink: #1b1b1a; --muted: #5f5d58; --line: #dedbd4;
  --mine: #1f4f8f; --mine-ink: #ffffff; --theirs: #ffffff; --accent: #1f4f8f;
  --warn: #8a4b00; --bad: #a3261b; --ok: #2d6a3e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1f1f1d; --ink: #f1efe9; --muted: #b0ada5; --line: #33322f;
    --mine: #3a6fb5; --mine-ink: #ffffff; --theirs: #262624; --accent: #7fa8e0;
    --warn: #f0b062; --bad: #ff8a7d; --ok: #8fd19e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1f1f1d; --ink: #f1efe9; --muted: #b0ada5; --line: #33322f;
  --mine: #3a6fb5; --mine-ink: #ffffff; --theirs: #262624; --accent: #7fa8e0;
  --warn: #f0b062; --bad: #ff8a7d; --ok: #8fd19e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; cursor: pointer; }
button.primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 14px 20px; font-weight: 600; min-height: 52px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.primary { color: #10131a; } }
button.primary:disabled { opacity: .55; cursor: default; }
button.quiet { background: none; border: 0; color: var(--muted); padding: 10px 12px; font-size: 16px; }

.screen { max-width: 30rem; margin: 0 auto; padding: 18vh 16px 32px; }
.screen h1 { font-size: 30px; margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 28px; }
.screen .primary { width: 100%; }
.msg { min-height: 1.5em; margin-top: 16px; color: var(--muted); }
.msg.bad { color: var(--bad); }

.chat { display: flex; flex-direction: column; height: 100dvh; max-width: 44rem; margin: 0 auto; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.seats { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seats button {
  position: relative; border: 0; background: none; color: var(--muted); padding: 10px 18px; border-radius: 9px; font-weight: 600; min-height: 44px;
}
.seats button[aria-selected="true"] { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seats button[aria-selected="true"] { color: #10131a; } }
.dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
.banner { margin: 0; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); color: var(--warn); font-size: 16px; }

.thread { flex: 1; overflow-y: auto; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.empty { color: var(--muted); text-align: center; margin: auto 16px; }
.turn { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.bubble.mine { align-self: flex-end; background: var(--mine); color: var(--mine-ink); border-bottom-right-radius: 6px; }
.bubble.theirs { align-self: flex-start; background: var(--theirs); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.who { align-self: flex-start; font-size: 14px; color: var(--muted); margin: 6px 4px 0; }
.state { align-self: flex-end; max-width: 86%; text-align: right; font-size: 14px; color: var(--muted); padding: 0 4px; }
.state.blocked, .state.failed { color: var(--bad); }
.state.closed, .state.passed { color: var(--muted); }
.state.uncertain { color: var(--warn); }
.state.answered { color: var(--ok); }
.state button { margin-left: 6px; background: none; border: 1px solid currentColor; color: inherit; border-radius: 8px; padding: 2px 10px; font-size: 14px; }
.quote { font-size: 14px; color: var(--muted); margin: 0 4px; align-self: flex-start; max-width: 86%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
}
.composer textarea {
  flex: 1; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; resize: none; max-height: 40vh; min-height: 52px;
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
