:root {
  color-scheme: light dark;
  --page: #f5f6f5;
  --surface: #fdfefd;
  --subtle: #eef1ef;
  --text: #222a26;
  --muted: #56625b;
  --line: #7c8b81;
  --accent: #286147;
  --accent-hover: #204e39;
  --on-accent: #fdfefd;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #181c1a;
    --surface: #202622;
    --subtle: #29322c;
    --text: #e8eee9;
    --muted: #b0bdb3;
    --line: #6a7e70;
    --accent: #a0cbb1;
    --accent-hover: #b8dbc5;
    --on-accent: #18271e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--text); min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select, textarea { border: 1px solid var(--line); border-radius: 8px; }
button { min-height: 44px; padding: 9px 15px; background: var(--surface); cursor: pointer; line-height: 1.3; }
button:hover:not(:disabled) { background: var(--subtle); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.quiet { background: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
input, select, textarea { background: var(--surface); padding: 10px 12px; width: 100%; min-height: 44px; }
textarea { resize: vertical; min-height: 96px; max-height: 50dvh; }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 1; }
label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -.025em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
.shell { max-width: 1000px; margin: 0 auto; padding: 28px 32px; }
.page-header { display: flex; gap: 24px; justify-content: space-between; align-items: center; padding-bottom: 24px; }
.subtitle { color: var(--muted); margin-top: 3px; font-size: .9rem; }
.connection-tools { text-align: right; font-size: .85rem; color: var(--muted); max-width: 340px; }
.connection-tools button { margin-top: 8px; }
.login-panel { max-width: 420px; margin: 64px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 28px; }
.login-panel h2 { font-size: 1.25rem; }
.login-panel .muted { margin-top: 8px; }
.login-panel form { margin: 24px 0; }
.login-panel button { margin-top: 16px; width: 100%; }
.muted, .fine-print { color: var(--muted); }
.fine-print { font-size: .8rem; line-height: 1.55; }
.room-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding: 18px 0; }
.room-actions { display: flex; gap: 8px; }
.agents { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.agents li { min-width: 0; display: grid; gap: 2px; }
.agents strong { font-size: .9rem; font-weight: 600; }
.agents span { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.presence-help { margin-top: 8px; }
.exchange-state { margin: 18px 0; padding: 12px 16px; border-radius: 8px; background: var(--subtle); }
#exchange-status { font-size: .9rem; font-weight: 600; margin-bottom: 4px; }
.error { border: 1px solid var(--line); border-left: 3px solid var(--text); background: var(--subtle); border-radius: 8px; padding: 12px; font-size: .9rem; margin: 12px 0; overflow-wrap: anywhere; }
.transcript { min-height: 260px; height: clamp(280px, 43dvh, 620px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.empty-state { padding: 72px 24px; text-align: center; }
.empty-state p { margin-top: 6px; color: var(--muted); font-size: .9rem; }
#message-list { list-style: none; padding: 0; margin: 0; }
.message { padding: 20px 24px; }
.message + .message { border-top: 1px solid var(--line); }
.message-header { display: flex; align-items: baseline; gap: 8px 14px; flex-wrap: wrap; font-size: .85rem; }
.message-author { font-weight: 650; }
.message-recipient, .message-time { color: var(--muted); font-size: .8rem; }
.message-time { margin-left: auto; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 9px; unicode-bidi: plaintext; }
.message-delivery { color: var(--muted); font-size: .72rem; margin-top: 10px; }
.new-messages { display: block; margin: 10px auto 0; color: var(--accent); }
.composer { padding-top: 20px; }
.recipient-field { max-width: 240px; margin-bottom: 14px; }
.composer-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 10px; }
.composer-footer button { min-width: 130px; }
.privacy-note { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.privacy-note p + p { margin-top: 6px; }
.skip-link { position: fixed; top: 10px; left: 10px; transform: translateY(-200%); background: var(--surface); color: var(--text); padding: 12px; border: 1px solid var(--line); border-radius: 8px; z-index: 1; }
.skip-link:focus { transform: none; }
@media (max-width: 640px) {
  .shell { padding: 20px 16px; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 10px; padding-bottom: 18px; }
  .connection-tools { text-align: left; max-width: none; }
  .login-panel { margin: 24px auto; padding: 22px; }
  .room-toolbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .room-actions { width: 100%; }
  .room-actions button:first-child { flex: 1; }
  .agents { grid-template-columns: 1fr; gap: 10px; }
  .agents li { grid-template-columns: 100px 1fr; gap: 8px; }
  .transcript { height: 44dvh; min-height: 240px; }
  .message { padding: 16px; }
  .message-time { margin-left: 0; }
  .composer-footer { gap: 12px; align-items: flex-start; }
  .composer-footer button { min-width: auto; }
  .recipient-field { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled) { transform: none; }
}
