:root {
  --bg: #14161a; --panel: #1c1f25; --panel2: #242830; --line: #2e333c;
  --text: #e8eaed; --dim: #9aa0a9; --acc: #e87828; --acc2: #ffa85c; --ok: #4caf7d; --bad: #e5534b;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#app { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; cursor: pointer; }
button:hover { border-color: var(--acc); }
button.primary { background: var(--acc); border-color: var(--acc); color: #1a0e02; font-weight: 600; }
button.danger { color: var(--bad); }
button.small { padding: 4px 10px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--acc); border-color: transparent; }
a { color: var(--acc2); }
h1, h2, h3 { margin: 0 0 8px; }
.dim { color: var(--dim); } .small { font-size: 14px; } .ok { color: var(--ok); } .bad { color: var(--bad); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

.center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; width: 100%; max-width: 440px; }
.card > * + * { margin-top: 12px; }
.consent { max-height: 38vh; overflow: auto; white-space: pre-wrap; background: var(--panel2); border-radius: 10px; padding: 12px; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: auto; margin-top: 4px; }
.qr { background: #fff; border-radius: 10px; padding: 8px; width: 220px; height: 220px; display: block; margin: 0 auto; }
.code { text-align: center; font-size: 26px; letter-spacing: 3px; }
.err { color: var(--bad); min-height: 1.2em; }

.shell { display: grid; grid-template-columns: 340px 1fr; height: 100%; }
.side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.head .me { font-weight: 600; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 10px 4px; font-size: 14px; border-bottom: 2px solid transparent; position: relative; }
.tabs button.on { border-bottom-color: var(--acc); color: var(--acc2); }
.badge { background: var(--acc); color: #1a0e02; border-radius: 10px; font-size: 12px; padding: 0 6px; margin-left: 4px; font-weight: 700; }
.list { overflow: auto; flex: 1; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover, .row.on { background: var(--panel2); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--dim); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--acc); color: #1a0e02; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.pad { padding: 14px; } .pad > * + * { margin-top: 12px; }
.sect { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; padding: 14px 14px 4px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.main { display: flex; flex-direction: column; min-height: 0; }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; background: var(--panel); }
.back { display: none; }
.msgs { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; background: var(--panel2); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.out { align-self: flex-end; background: var(--acc); color: #1a0e02; }
.bubble .t { display: block; font-size: 11px; opacity: .65; margin-top: 2px; text-align: right; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.composer textarea { resize: none; max-height: 120px; }
.empty { margin: auto; color: var(--dim); text-align: center; padding: 20px; }
.video { width: 100%; border-radius: 10px; background: #000; max-height: 260px; }
.banner { background: #3a2a14; color: var(--acc2); padding: 8px 14px; font-size: 14px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .shell .main { display: none; }
  .shell.open .side { display: none; }
  .shell.open .main { display: flex; }
  .back { display: inline-block; }
}

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; } .toast.bad { border-color: var(--bad); color: var(--bad); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 40; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
label { display: block; } label > input, label > select { margin-top: 4px; }
