:root {
  color-scheme: light dark;
  --bg: #f4f5f8;
  --surface: #fff;
  --raised: #eceef4;
  --border: #dfe1e9;
  --text: #20212d;
  --muted: #626575;
  --accent: #5140a5;
  --tint: #eeeafb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --surface: #181a1f;
    --raised: #202329;
    --border: #30323b;
    --text: #f1f1f5;
    --muted: #a4a6b2;
    --accent: #b8afff;
    --tint: #28243d;
  }
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; min-width: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, sans-serif }
header, main { width: min(100%, 860px); margin: auto; padding: 12px 16px }
header { display: flex; align-items: center; gap: 16px; padding-top: calc(12px + env(safe-area-inset-top)) }
header a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); white-space: nowrap }
h1 { margin: 0; font-size: clamp(22px, 4vw, 32px); letter-spacing: -.03em }
main { padding-bottom: calc(12px + env(safe-area-inset-bottom)) }
#status { color: var(--muted); margin: 0 0 8px }
#status:empty { display: none }
#conversation { display: flex; flex-direction: column; height: min(760px, calc(100dvh - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); min-height: 230px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface) }
#history { flex: 1; min-height: 0; overflow: auto; padding: 12px; overflow-anchor: none }
#older { display: block; margin: 0 auto 12px }
#empty { color: var(--muted); text-align: center }
#messages { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none }
.message { background: var(--raised); padding: 8px 12px; border-radius: 4px 14px 14px; width: fit-content; max-width: 90%; overflow-wrap: anywhere }
.message.own { justify-self: end; background: var(--tint); border-radius: 14px 4px 14px 14px }
.message p { margin: 4px 0 0; white-space: pre-wrap }
.message strong { font-size: 13px; color: var(--accent) }
.message time { font-size: 12px; color: var(--muted); margin-inline-start: 8px }
.room-note { padding: 4px 12px; font-size: 12px; margin: 0; color: var(--muted) }
form { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--border) }
textarea, button { color: inherit; font: inherit; border: 1px solid var(--border); border-radius: 9px; min-height: 44px; padding: 8px 10px }
textarea { flex: 1; min-width: 0; background: var(--bg); resize: vertical; max-height: 25dvh }
button { background: var(--tint); color: var(--accent); cursor: pointer }
button:disabled, textarea:disabled { opacity: .6 }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden }
