:root {
  --bg: #f4f6f5; --panel: #ffffff; --text: #17201f; --muted: #5d6b69; --line: #dde3e1;
  --accent: #0f3d3e; --accent-2: #1d6b6c; --out: #d9efe8; --in: #ffffff; --danger: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1413; --panel: #161e1d; --text: #e6eeec; --muted: #93a3a0; --line: #26312f;
    --accent: #5fb3a4; --accent-2: #7cc8ba; --out: #1f3b36; --in: #1c2624; --danger: #f2b8b5; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
h1 { margin: 0 0 4px; font-size: 26px; } h2 { margin: 0; font-size: 18px; } h3 { margin: 20px 0 8px; font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
button { font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #fff; cursor: pointer; }
@media (prefers-color-scheme: dark) { button { color: #0e1413; } }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.ghost { background: transparent; color: var(--accent); padding: 6px 10px; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
input, textarea { font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); margin: 4px 0; }
textarea { resize: none; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.center { max-width: 440px; margin: 48px auto; }
.card button { width: 100%; margin-top: 6px; }
.profile-row { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.notice { background: var(--out); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.layout { display: grid; grid-template-columns: 320px 1fr; height: 100dvh; }
.side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.bar > div { display: flex; flex-direction: column; }
.net { font-size: 12px; color: var(--muted); } .net.ok::before { content: "● "; color: #2e9b5f; } .net.bad::before { content: "● "; color: var(--danger); }
.actions { display: grid; gap: 8px; padding: 12px 14px; }
.contacts { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.contact { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.contact.active, .contact:hover { background: var(--bg); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-2); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.cname { flex: 1; display: flex; flex-direction: column; min-width: 0; } .cname small { color: var(--muted); }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; }
.empty { padding: 14px; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.placeholder { margin: auto; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(560px, 80%); padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta { font-size: 11px; color: var(--muted); text-align: right; }
.msg.out { align-self: flex-end; background: var(--out); border-color: transparent; }
.msg.in { align-self: flex-start; background: var(--in); }
.msg.failed { border-color: var(--danger); }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.composer textarea { margin: 0; }
.back { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal { background: var(--panel); border-radius: 16px; padding: 20px; width: min(460px, 100%); max-height: 90dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.qr { width: 240px; height: 240px; align-self: center; image-rendering: pixelated; background: #fff; border-radius: 8px; }
.safety { font: 16px/1.6 ui-monospace, Menlo, monospace; background: var(--bg); padding: 12px; border-radius: 10px; white-space: pre-wrap; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: calc(100% - 32px); }
@media (max-width: 699px) {
  .layout { grid-template-columns: 1fr; }
  .chat { display: none; } body.in-chat .chat { display: flex; } body.in-chat .side { display: none; }
  .back { display: inline-block; font-size: 22px; }
  .center { margin: 16px; }
}
.attach { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: 10px; margin: 2px 0; }
a.file { color: inherit; }
.attach-btn { font-size: 20px; padding: 6px 8px; }
.row { display: flex; gap: 2px; }
.test-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 30; background: #b8860b; color: #fff; text-align: center; font-size: 12px; font-weight: 600; padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: max(3px, env(safe-area-inset-top)); }
body.has-test-banner #app { padding-top: 22px; }
body.has-test-banner .layout { height: calc(100dvh - 22px); }
