:root { color-scheme: light dark; --bg:#f4f5f7; --fg:#1a1c20; --card:#fff; --me:#2563eb; --other:#e5e7eb; --muted:#6b7280; --line:#d8dbe0; }
@media (prefers-color-scheme: dark) { :root { --bg:#0f1115; --fg:#e8eaed; --card:#181b21; --me:#3b6ee8; --other:#262a32; --muted:#8b93a1; --line:#2a2f38; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.4 system-ui, sans-serif; }
.card { max-width: 340px; margin: 18vh auto 0; padding: 24px; background: var(--card); border-radius: 12px; }
.card h1 { margin: 0 0 16px; font-size: 1.3rem; }
form input, form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: inherit; font: inherit; }
button { padding: 10px 16px; border: 0; border-radius: 8px; background: var(--me); color: #fff; font: inherit; cursor: pointer; }
button:disabled { opacity: .6; }
.card input + input { margin-top: 8px; }
.card button { width: 100%; margin-top: 12px; }
.error { color: #dc2626; min-height: 1.4em; margin: 8px 0 0; font-size: .9rem; }
#chat { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; background: var(--card); }
header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
header .link { margin-left: auto; background: none; color: var(--muted); padding: 4px 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; }
.dot.on { background: #22c55e; }
#messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 14px; background: var(--other); }
.msg.me { align-self: flex-end; background: var(--me); color: #fff; }
.msg .who { font-size: .72rem; opacity: .7; margin-bottom: 2px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bad { font-style: italic; opacity: .6; }
.typing { padding: 0 16px 6px; color: var(--muted); font-size: .85rem; font-style: italic; }
#send-form { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); align-items: flex-end; }
#send-form textarea { resize: none; max-height: 140px; }
.msg .acts { display: flex; gap: 4px; margin-top: 4px; }
.msg .acts .link { background: none; color: inherit; opacity: .65; padding: 2px 6px; font-size: .75rem; }
.msg .acts .link:hover { opacity: 1; }
.msg.me .acts { justify-content: flex-end; }
.msg .edit-input { min-width: 240px; color: var(--fg); }
.msg .acts button:not(.link) { padding: 4px 10px; font-size: .8rem; background: #fff; color: var(--me); }
