:root { color-scheme: dark; --bg:#111216; --panel:#1a1c22; --line:#2a2d36; --text:#e8e8ee; --muted:#8b8e9a; --accent:#6e8cff; --me:#2b3a78; --them:#23252d; --ok:#3ecf8e; --bad:#ff6b6b; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }

.card { max-width: 360px; margin: 18vh auto 0; padding: 28px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.card h1 { margin: 0 0 18px; font-size: 1.25rem; font-weight: 600; }
#loginForm { display: grid; gap: 12px; }
input[type=password] { width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 12px 16px; background: var(--accent); color: #0b0d14; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; color: var(--muted); padding: 4px 8px; font-weight: 400; }
button.link:hover { color: var(--text); }
.error { min-height: 1.2em; margin: 0; color: var(--bad); font-size: .9rem; }
.muted { color: var(--muted); font-size: .85rem; }

#chat { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 10px; }
.right { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }

#messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; background: var(--them); word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--me); }
.msg .meta { display: block; margin-bottom: 2px; color: var(--muted); font-size: .72rem; }
.sys { align-self: center; color: var(--muted); font-size: .8rem; }

#sendForm { display: flex; gap: 8px; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
#input { flex: 1; resize: none; max-height: 40vh; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
