:root {
  --bg: #0d1020;
  --bg2: #121734;
  --panel: #171c36;
  --panel2: #202750;
  --line: #2a3360;
  --text: #eef0ff;
  --muted: #8e97c6;
  --accent: #7c6cff;
  --accent2: #b05cf6;
  --good: #34d399;
  --bad: #ff5d6c;
  --bubble-them: #202750;
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
  --radius: 16px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fc;
    --bg2: #e9ebfa;
    --panel: #ffffff;
    --panel2: #eef0fb;
    --line: #dadef2;
    --text: #15182e;
    --muted: #666e9a;
    --bubble-them: #eceffb;
    --shadow: 0 20px 60px rgba(60, 70, 140, .18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.sprite { position: absolute; }
.i { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── shared bits ── */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; letter-spacing: -.01em; }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.logo.big { width: 72px; height: 72px; border-radius: 22px; font-size: 1.8rem; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: .92rem; }
.err { color: var(--bad); font-size: .9rem; min-height: 1.2em; }
.err:empty { min-height: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); }
input, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-weight: 400; color: var(--text);
}
#encTimerSelect { font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.35rem; letter-spacing: .18em; text-align: center; text-transform: uppercase; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; background: var(--panel2); }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; align-self: center; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--panel2); color: var(--text); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }

.avatar {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 1rem; position: relative; text-transform: uppercase;
}
.avatar.xl { width: 96px; height: 96px; font-size: 2.2rem; }

/* ── landing ── */
.landing {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 440px); gap: 56px; align-items: center;
  max-width: 1120px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 24px 40px;
}
body:has(#landing:not([hidden])) {
  background:
    radial-gradient(700px 500px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(600px 500px at 100% 100%, color-mix(in srgb, var(--accent2) 18%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
.hero { display: flex; flex-direction: column; gap: 20px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; letter-spacing: -.03em; }
.grad { background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); font-size: 1.1rem; max-width: 34ch; }

.locked { position: relative; margin-top: 12px; max-width: 420px; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); user-select: none; pointer-events: none; }
.mock { display: flex; flex-direction: column; gap: 10px; padding: 16px; filter: blur(5px); transition: filter .6s ease; }
.mock-head { display: flex; align-items: center; gap: 10px; font-weight: 600; padding-bottom: 6px; }
.mock-av { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.veil {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent); transition: opacity .5s ease;
}
.veil .lock-icon { width: 44px; height: 44px; padding: 10px; box-sizing: content-box; border-radius: 50%; background: var(--panel2); margin-bottom: 6px; }
.veil span { color: var(--muted); font-size: .9rem; }
.locked.open .mock { filter: none; transition-delay: .9s; }
.locked.open .veil { opacity: 0; transition-delay: .9s; }
.locked.open .lock-icon { color: var(--good); }

.bubble { max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: .95rem; overflow-wrap: anywhere; }
.bubble.them { background: var(--bubble-them); align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.me { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }

.access { padding: 24px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 22px; background: var(--bg); border-radius: 14px; }
.tab { border: 0; background: transparent; padding: 10px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--panel2); color: var(--text); }
.access h2 { font-size: 1.3rem; letter-spacing: -.01em; }
.chip { align-self: flex-start; padding: 5px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }

.how { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.how h2 { font-size: 1.3rem; letter-spacing: -.01em; }
.how-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.how .card { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.how h3 { font-size: 1.05rem; margin: 0; }
.how .card p { color: var(--muted); font-size: .95rem; margin: 0; }
.how-note { color: var(--muted); font-size: .88rem; max-width: 70ch; }
.how-note a { color: var(--accent); }

@media (max-width: 860px) {
  .how-grid { grid-template-columns: minmax(0, 1fr); }
  .landing { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 24px 16px 40px; align-items: start; }
  .sub { max-width: none; }
  .locked { max-width: none; }
  .mock .bubble:nth-child(n + 4) { display: none; } /* keep the login card near the top on phones */
  .access { padding: 18px; }
}

/* ── app shell ── */
.app { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 4px; padding: calc(14px + env(safe-area-inset-top)) 12px 14px 16px; border-bottom: 1px solid var(--line); }
.me .avatar { margin-right: 8px; }
.me-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.me-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); text-align: center; font-size: .85rem; padding: 6px; }

.banner { display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 10px 6px 10px 14px; border-radius: 14px; font-size: .88rem; background: color-mix(in srgb, var(--accent) 16%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.banner span { flex: 1; }
.banner .icon-btn { width: 30px; height: 30px; }
.offline { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 24px; }

.contacts { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.contact { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: 14px; background: transparent; text-align: left; }
.contact:hover { background: var(--panel2); }
.contact.active { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.contact .mid { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.contact .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.contact .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact .time { color: var(--muted); font-size: .75rem; flex: none; }
.contact .name-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.space-tag { flex: none; font-size: .66rem; font-weight: 700; letter-spacing: .02em; padding: 1px 7px; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.space-tag.ending, .space-tag.lapsed { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.space-bar.lapsed { color: var(--text); background: color-mix(in srgb, var(--bad) 10%, var(--panel)); }
.contact .last { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact .badge { flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: #fff; background: var(--accent); }
.contact .last-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--good); border: 2px solid var(--panel); }

.empty { padding: 32px 24px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty p:first-child { font-weight: 600; }

.chat { min-width: 0; min-height: 0; display: flex; background:
  radial-gradient(500px 300px at 90% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%), var(--bg); }
.placeholder { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px; }
.thread { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.thead { display: flex; align-items: center; gap: 6px; padding: calc(12px + env(safe-area-inset-top)) 12px 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.thead .avatar { margin-right: 6px; }
.thead .back { display: none; }
#tStatus.on { color: var(--good); }

.msgs { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; margin: 12px 0 6px; padding: 3px 12px; border-radius: 999px; font-size: .75rem; color: var(--muted); background: var(--panel); border: 1px solid var(--line); }
.msg { max-width: min(560px, 78%); padding: 8px 12px 6px; border-radius: 18px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.them { align-self: flex-start; background: var(--bubble-them); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-bottom-right-radius: 6px; }
.msg .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; font-size: .68rem; opacity: .7; }
.msg .meta .i { width: 13px; height: 13px; }
.ticks { display: inline-flex; }
.ticks .i + .i { margin-left: -8px; }
.ticks.read { color: #bff3e0; }
.msgs .none { margin: auto; color: var(--muted); font-size: .9rem; }

.composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; max-height: 140px; border-radius: 20px; padding: 11px 16px; line-height: 1.35; }
.send { width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.send:hover { filter: brightness(1.1); }

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .chat { display: none; }
  .app.show-chat .sidebar { display: none; }
  .app.show-chat .chat { display: flex; }
  .thead .back { display: grid; }
  .msgs { padding: 14px 12px; }
  .msg { max-width: 86%; }
}

/* ── calls ── */
.call { position: fixed; inset: 0; z-index: 50; background: #05060f; color: #fff; display: grid; place-items: center; }
.call #remoteVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05060f; }
.call.audio-only #remoteVideo { visibility: hidden; }
.call.audio-only { background: radial-gradient(600px 500px at 50% 30%, #2a2270, #05060f 70%); }
.call-info { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-shadow: 0 2px 12px rgba(0, 0, 0, .6); transition: opacity .3s; }
.call-info strong { font-size: 1.5rem; }
.call-info span:last-child { opacity: .85; font-variant-numeric: tabular-nums; }
.call.live.video .call-info { position: absolute; top: max(20px, env(safe-area-inset-top)); left: 0; right: 0; }
.call.live.video .call-info .avatar { display: none; }
#localVideo { position: absolute; right: 16px; top: 16px; width: 130px; aspect-ratio: 3/4; object-fit: cover; border-radius: 16px; background: #1b1f3b; transform: scaleX(-1); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .15); }
.call.audio-only #localVideo, .call.no-cam #localVideo { display: none; }
.call-bar { position: absolute; bottom: max(28px, env(safe-area-inset-bottom)); left: 0; right: 0; display: flex; justify-content: center; gap: 18px; }
.round { width: 62px; height: 62px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, .16); backdrop-filter: blur(10px); }
.round .i { width: 26px; height: 26px; }
.round:hover { background: rgba(255, 255, 255, .26); }
.round.off, .round.on { background: #fff; color: #111; }
.round.hang { background: var(--bad); }
.round.hang .i { transform: rotate(135deg); }
.round.accept { background: var(--good); }
.call.audio-only #btnCam { display: none; }

.incoming {
  position: fixed; z-index: 60; top: 16px; left: 50%; transform: translateX(-50%); width: min(440px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: drop .3s ease;
}
.incoming .avatar { width: 52px; height: 52px; font-size: 1.2rem; }
.inc-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.inc-text span { color: var(--muted); font-size: .88rem; }
.incoming .round { width: 50px; height: 50px; }
.incoming .round .i { width: 22px; height: 22px; }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -20px); } }

@media (max-width: 760px) {
  #localVideo { width: 96px; top: 12px; right: 12px; }
}

/* ── dialogs & toasts ── */
dialog { width: min(440px, calc(100vw - 24px)); padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5, 6, 15, .6); backdrop-filter: blur(3px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.quota { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 6px; font-weight: 600; }
.invite-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.invite { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.invite .inv-email { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite .state { color: var(--muted); font-size: .82rem; flex: none; }
.invite.joined .state { color: var(--good); }
.invite.joined .inv-email { opacity: .7; }
.invite.expired .inv-email, .invite.expired .state { opacity: .5; text-decoration: line-through; }
.invite .icon-btn { width: 34px; height: 34px; }
.invite-form { display: flex; gap: 8px; margin: 4px 0; }
.invite-form input { flex: 1; min-width: 0; }
.ok { color: var(--good); font-size: .9rem; min-height: 1.2em; }
.ok:empty { min-height: 0; }
#friendDlg h3, #invitesDlg h3, #tokensDlg h3 { margin: 16px 0 8px; font-size: .95rem; }
.balance { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.invite-form select { flex: 1; min-width: 0; }
.invite-form .amount { flex: none; width: 5.5em; }
.space-row .who small { white-space: normal; }
.space-row .btn { flex: none; }
.ledger-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px; font-size: .88rem; color: var(--muted); }
.ledger-row .plus { color: var(--good); font-weight: 600; }
.tabs.small { margin-bottom: 16px; }

.toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: .92rem; box-shadow: var(--shadow); animation: drop2 .25s ease; }
@keyframes drop2 { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── groups, attachments ── */
.thread { position: relative; }
.avatar.group { border-radius: 14px; }
.thead.group .me-text { cursor: pointer; }
.btn.danger { color: #fff; background: var(--bad); }
.btn.danger:hover { filter: brightness(1.08); }
.opt { font-weight: 400; opacity: .7; }
.avail { display: block; min-height: 1.1em; margin-top: 2px; font-size: .8rem; color: var(--muted); }
.avail.good { color: var(--good); }
.avail.bad { color: var(--bad); }

.has-badge { position: relative; }
.dotbadge { position: absolute; top: 3px; right: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); border: 2px solid var(--panel); }

.chip.info { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.center { text-align: center; }

.qr { display: block; margin: 14px auto 10px; width: 210px; height: 210px; background: #fff; padding: 12px; border-radius: 18px; box-sizing: border-box; box-shadow: 0 0 0 1px var(--line); }
.mycode { margin: 0; text-align: center; }
.mycode code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.4rem; letter-spacing: .18em; font-weight: 700; }

.scanner { position: relative; margin: 14px auto; max-width: 280px; aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 14%; border: 3px solid #fff; border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .4); pointer-events: none; }

.attach { position: relative; align-self: flex-end; }
.attach .icon-btn { width: 46px; height: 46px; border-radius: 50%; }
.menu { position: absolute; bottom: 54px; left: 0; z-index: 6; min-width: 200px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--panel2); }
.drop { position: absolute; inset: 10px; z-index: 8; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; pointer-events: none; border: 3px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--bg) 82%, transparent); }

.msg .sender { font-size: .78rem; font-weight: 700; margin-bottom: 2px; }
.system { align-self: center; max-width: 84%; margin: 6px 0; padding: 4px 12px; text-align: center; font-size: .8rem; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; overflow-wrap: anywhere; }
.att-img { display: block; max-width: min(300px, 100%); height: auto; margin: -2px -6px 4px; border-radius: 14px; cursor: zoom-in; background: var(--panel2); }
.att-video { display: block; max-width: min(320px, 100%); margin: -2px -6px 4px; border-radius: 14px; background: #000; }
.att-file { display: flex; align-items: center; gap: 10px; min-width: min(220px, 100%); padding: 4px 0; color: inherit; text-decoration: none; }
.att-file .att-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.att-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.att-file .att-meta span { font-size: .76rem; opacity: .75; }
.att-file > .i:first-child { box-sizing: content-box; width: 22px; height: 22px; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, .2); }
.msg.them .att-file > .i:first-child { background: var(--panel); }
.msg.pending { opacity: .85; }
.msg.pending progress { display: block; width: 200px; max-width: 100%; height: 6px; margin-top: 6px; accent-color: #fff; }
.msg.failed { outline: 2px solid var(--bad); }

.picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.picker legend { padding: 0; margin-bottom: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 32vh; overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 12px; }
.pick-list .none { padding: 10px; color: var(--muted); font-size: .9rem; }
label.pick { flex-direction: row; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; font-size: 1rem; font-weight: 500; color: var(--text); }
label.pick:hover { background: var(--panel2); }
label.pick input { flex: none; width: 20px; height: 20px; padding: 0; accent-color: var(--accent); }
label.pick .avatar, .member .avatar { width: 36px; height: 36px; font-size: .85rem; }
label.pick small, .member small { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }

#infoDlg h3 { margin: 16px 0 8px; font-size: .95rem; }
#infoDlg .btn.danger { width: 100%; margin-top: 16px; }
.rename { display: flex; gap: 8px; margin-top: 12px; }
.rename input { flex: 1; min-width: 0; }
.member-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 34vh; overflow-y: auto; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.member .who { flex: 1; min-width: 0; line-height: 1.25; }
.member .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .tag { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.member .btn.small { padding: 5px 10px; font-size: .78rem; }

.send-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.send-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; background: var(--bg); }
.send-item img, .send-item .thumb { flex: none; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.send-item .thumb { display: grid; place-items: center; background: var(--panel2); color: var(--muted); }
.send-item .nm { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.send-item .nm strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.send-item .nm span { font-size: .8rem; color: var(--muted); }
.send-item .nm span.bad { color: var(--bad); }

.lightbox { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(5, 6, 15, .93); }
.lightbox img { max-width: 96vw; max-height: 90vh; object-fit: contain; }
.lb-bar { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; display: flex; gap: 12px; }
.lb-bar .round { width: 46px; height: 46px; color: #fff; text-decoration: none; }
.lb-bar .round .i { width: 22px; height: 22px; }

/* ── safety: terms, blocking, reporting, account ── */
dialog { max-height: 90dvh; overflow-y: auto; }
/* ── end-to-end encryption ── */
.lock-tag { flex: none; display: inline-flex; align-items: center; color: var(--good); }
.lock-tag .i { width: 13px; height: 13px; }
.me-text .enc-chip { display: flex; align-items: center; gap: 4px; width: fit-content; margin-top: 2px; padding: 1px 9px; border: 0; border-radius: 999px; font-size: .7rem; font-weight: 600; cursor: pointer;
  color: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.me-text .enc-chip .i { width: 12px; height: 12px; }
.me-text .enc-chip.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.me-text .enc-chip.verified { color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); }
.me-text .enc-chip.warn { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.enc-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 16px; font-size: .85rem; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 9%, var(--panel)); }
.enc-bar.warn { background: color-mix(in srgb, var(--bad) 12%, var(--panel)); }
.enc-bar .btn { flex: none; }
.msg.locked .text { font-style: italic; opacity: .75; }
.msg.unverified { outline: 1px dashed color-mix(in srgb, var(--muted) 60%, transparent); outline-offset: 2px; }
.enc-status { font-weight: 600; margin: 10px 0 4px; }
.safety { margin: 8px 0; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); text-align: center; user-select: all;
  font: 600 1.1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; word-spacing: .6em; white-space: pre-line; line-height: 1.6; }
#encDlg h3 { margin: 16px 0 8px; font-size: .95rem; }
#encDlg .btn { margin-top: 6px; }
.member .tag.good { color: var(--good); background: color-mix(in srgb, var(--good) 16%, transparent); }
.member .tag.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-size: .88rem; font-weight: 400; color: var(--text); }
label.check input { flex: none; width: 18px; height: 18px; margin-top: 2px; padding: 0; accent-color: var(--accent); }
label.check a, .legal-links a, .links a, #termsDlg a { color: var(--accent); }
.legal-links { margin: 18px 0 0; text-align: center; font-size: .82rem; color: var(--muted); }
.blocked-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: .92rem; }
.msg .meta .more { display: inline-grid; place-items: center; width: 24px; height: 18px; padding: 0; border: 0; background: transparent; color: inherit; opacity: .6; cursor: pointer; }
.msg .meta .more:hover, .msg .meta .more:focus-visible { opacity: 1; }
.msg .meta .more .i { width: 15px; height: 15px; }
.btn.wide { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
#accountDlg h3 { margin: 20px 0 8px; font-size: .95rem; }
#accountDlg .danger-title { color: var(--bad); }
#accountDlg .btn.danger { width: 100%; }
#accountDlg .links { margin: 0 0 12px; font-size: .92rem; }
.person-actions .btn { display: flex; align-items: center; gap: 10px; justify-content: flex-start; }
#personDlg .hint { margin-top: 12px; }
.member .btn.small.icon-only { display: inline-grid; place-items: center; padding: 6px 8px; }