:root { --bg:#111827; --panel:#1f2937; --me:#2563eb; --them:#374151; --text:#f3f4f6; --muted:#9ca3af; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
#auth { height: 100%; display: grid; place-items: center; padding: 16px; }
#authForm { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
input, textarea { background: var(--panel); border: 1px solid #374151; border-radius: 10px; padding: 12px; }
button[type=submit] { background: var(--me); border: 0; border-radius: 10px; padding: 12px; cursor: pointer; }
#toggle { color: var(--muted); text-align: center; font-size: 14px; }
.err { color: #f87171; min-height: 1.2em; margin: 0; text-align: center; }
#app { height: 100dvh; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--panel); }
header div { flex: 1; display: flex; flex-direction: column; }
header small { color: var(--muted); }
header button { background: none; border: 0; font-size: 20px; cursor: pointer; }
#contacts { padding: 8px; overflow: auto; }
.contact { padding: 14px; border-radius: 10px; background: var(--panel); margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; }
.dot { color: #4ade80; }
#chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#messages { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 14px; background: var(--them); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--me); }
.msg time { display: block; font-size: 11px; color: #d1d5db99; text-align: right; }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 6px 0; }
#composer { display: flex; gap: 8px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--panel); }
#composer textarea { flex: 1; resize: none; max-height: 120px; }
#composer button { width: 48px; }
