:root {
  --bg: #0e1116; --panel: #161b22; --line: #262d36; --text: #e8edf2; --muted: #8b96a3;
  --accent: #3ddc97; --accent-ink: #062a1b; --mine: #1f6f52; --theirs: #222a33; --danger: #ff6b6b;
  --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { height: 100%; display: flex; flex-direction: column; }
button { font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--panel); color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { background: none; color: var(--accent); padding: 8px 0; }
button:disabled { opacity: .5; }
input, textarea { font: inherit; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); outline: none; }
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: none; }
label { display: block; color: var(--muted); font-size: 14px; margin: 14px 0 6px; }
.page { flex: 1; overflow-y: auto; padding: calc(16px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); max-width: 640px; width: 100%; margin: 0 auto; }
.page h1 { font-size: 26px; margin: 8px 0 6px; }
.page p.sub { color: var(--muted); margin: 0 0 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; }
.err { color: var(--danger); min-height: 1.2em; margin: 10px 0; }
.note { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--muted); font-size: 14px; }
.code { font-family: ui-monospace, Menlo, monospace; word-break: break-all; background: #0a0d11; border: 1px dashed var(--line);
  border-radius: 12px; padding: 14px; font-size: 15px; letter-spacing: .5px; user-select: all; -webkit-user-select: all; }
.code.small { font-size: 12px; max-height: 120px; overflow: auto; }
.safety { font-family: ui-monospace, Menlo, monospace; font-size: 20px; letter-spacing: 2px; text-align: center; }
.top { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-top)) 12px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.top h2 { flex: 1; margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top button { padding: 8px 12px; background: none; }
.list { flex: 1; overflow-y: auto; }
.item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item .avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #2a3440; flex: none; }
.item .meta { flex: 1; min-width: 0; }
.item .name { font-weight: 600; }
.item .last { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.empty { color: var(--muted); text-align: center; padding: 48px 24px; }
.status { font-size: 12px; color: var(--muted); padding: 4px 16px; text-align: center; }
.status.off { color: #f0b429; }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 16px; background: var(--theirs); word-wrap: break-word; white-space: pre-wrap; }
.bubble.mine { align-self: flex-end; background: var(--mine); }
.bubble .who { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.bubble .time { font-size: 11px; color: rgba(255,255,255,.55); text-align: right; margin-top: 2px; }
.bubble img, .bubble video { max-width: 100%; border-radius: 10px; display: block; }
.bubble audio { width: 230px; max-width: 100%; }
.bubble .load { color: var(--accent); cursor: pointer; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.composer textarea { max-height: 120px; padding: 10px 12px; }
.composer button { padding: 10px 12px; flex: none; }
.composer button.rec { background: var(--danger); color: #fff; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; color: var(--text); font-size: 16px; margin: 0; }
.check input { width: 22px; height: 22px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); background: #2a3440;
  padding: 10px 16px; border-radius: 12px; z-index: 9; max-width: 90%; }
.hidden { display: none !important; }
.mt { margin-top: 12px; }
