/* «Тихо» — оформление. Анимируются только transform и opacity: так браузер
   рисует их на видеокарте и держит частоту экрана (120–144 Гц) без рывков. */
:root {
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f0f1f6; --line: rgba(15, 20, 40, .08);
  --text: #12141c; --muted: #737a8c; --accent: #6c5cff; --accent-2: #3d8bff;
  --grad: linear-gradient(135deg, #7b61ff 0%, #4a8dff 100%);
  --in: #ffffff; --in-text: #12141c; --out-text: #ffffff; --out-meta: rgba(255,255,255,.78);
  --chat-bg: #eceff6; --dot: rgba(108, 92, 255, .07);
  --glass: rgba(255, 255, 255, .72); --hover: rgba(15, 20, 40, .045);
  --danger: #ef4458; --ok: #19b56b; --warn: #c27a00; --warn-bg: #fff4dc;
  --secret: #19b56b;
  --shadow-s: 0 1px 2px rgba(20, 24, 40, .08);
  --shadow-m: 0 8px 30px rgba(20, 24, 40, .12);
  --shadow-l: 0 24px 60px rgba(20, 24, 40, .22);
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --surface: #161922; --surface-2: #1d212d; --line: rgba(255,255,255,.07);
    --text: #eef0f6; --muted: #8b92a6; --accent: #8b7bff; --accent-2: #5b9dff;
    --in: #1d212d; --in-text: #eef0f6; --chat-bg: #0b0d12; --dot: rgba(139, 123, 255, .06);
    --glass: rgba(22, 25, 34, .72); --hover: rgba(255,255,255,.05);
    --warn-bg: #2e2412; --warn: #f2b84b;
    --shadow-s: 0 1px 2px rgba(0,0,0,.4); --shadow-m: 0 8px 30px rgba(0,0,0,.4); --shadow-l: 0 24px 60px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; transition: transform .14s var(--ease), background-color .18s, opacity .18s, color .18s; }
button:active:not(:disabled) { transform: scale(.95); }
.ic { width: 22px; height: 22px; flex: none; vertical-align: middle; }
.sprite { position: absolute; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.danger { color: var(--danger) !important; }
.small-t { font-size: 13px; }
.center { text-align: center; }
.insecure { background: var(--danger); color: #fff; text-align: center; padding: 6px; font-size: 13px; }
#app { display: flex; height: 100dvh; position: relative; overflow: hidden; }
.glass { background: var(--glass); backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .7s linear infinite; vertical-align: -3px; opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.card-in { animation: cardIn .5s var(--ease) both; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pop { animation: pop .35s var(--spring) both; }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }
.shake { animation: shake .45s; }

/* ---------- вход ---------- */
body.auth-mode #app { overflow: auto; }
.auth-wrap { min-height: 100%; width: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 500px at 10% -10%, rgba(123, 97, 255, .28), transparent 60%),
  radial-gradient(800px 500px at 110% 110%, rgba(74, 141, 255, .25), transparent 60%), var(--bg); }
.auth { width: min(400px, 100%); background: var(--surface); border-radius: 28px; padding: 32px 24px 24px; box-shadow: var(--shadow-l); border: 1px solid var(--line); }
.logo { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 24px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 12px 30px rgba(108, 92, 255, .4); }
.logo .ic { width: 38px; height: 38px; }
.auth h1 { text-align: center; margin: 0; font-size: 28px; letter-spacing: -.5px; }
.auth .sub { text-align: center; color: var(--muted); margin: 4px 0 22px; }
.seg { position: relative; display: flex; background: var(--surface-2); padding: 4px; border-radius: 14px; margin-bottom: 18px; isolation: isolate; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 4px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 4px; transition: color .25s; }
.seg button .ic { width: 18px; height: 18px; }
.seg button.on { color: var(--text); }
.seg-pill { position: absolute; z-index: -1; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-s); transition: transform .35s var(--ease); }
.seg-pill.r { transform: translateX(100%); }
.small-seg { margin-bottom: 8px; }
form, .sheet-body { display: flex; flex-direction: column; gap: 12px; }
.field { position: relative; }
.field input, .field select { width: 100%; background: var(--surface-2); border: 1.5px solid transparent; border-radius: 14px; padding: 22px 14px 8px; outline: none; transition: border-color .2s, background-color .2s; }
.field select { appearance: none; }
.field label { position: absolute; left: 15px; top: 15px; color: var(--muted); pointer-events: none; transition: transform .2s var(--ease), color .2s; transform-origin: left top; }
.field input:focus, .field select:focus { border-color: var(--accent); background: var(--surface); }
.field input:focus + label, .field input:not(:placeholder-shown) + label, .field.sel label { transform: translateY(-9px) scale(.78); color: var(--accent); }
.field.sel label { color: var(--muted); }
input, select, textarea { outline: none; }
.primary { background: var(--grad); color: #fff; border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 650; box-shadow: 0 6px 18px rgba(108, 92, 255, .32); }
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: .6; }
.primary.big { padding: 15px; font-size: 16px; }
.primary.loading { color: transparent; position: relative; }
.primary.loading::after { content: ''; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid #fff; border-right-color: transparent; animation: spin .7s linear infinite; }
.danger-bg { background: var(--danger); box-shadow: 0 6px 18px rgba(239, 68, 88, .3); }
.ghost { background: none; border: 0; color: var(--accent); padding: 12px; font-weight: 600; border-radius: 12px; }
.ghost:hover { background: var(--hover); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error { background: rgba(239, 68, 88, .12); color: var(--danger); padding: 11px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 14px; }

/* ---------- раскладка ---------- */
#side { width: 380px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); position: relative; z-index: 2; }
#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background-color: var(--chat-bg);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.2px), radial-gradient(700px 400px at 100% 0%, rgba(123, 97, 255, .08), transparent 60%), radial-gradient(600px 400px at 0% 100%, rgba(74, 141, 255, .08), transparent 60%);
  background-size: 22px 22px, auto, auto; }
.side-top { display: flex; gap: 6px; padding: 10px 12px; align-items: center; position: sticky; top: 0; z-index: 2; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 14px; padding: 0 12px; transition: box-shadow .2s, background-color .2s; }
.search .ic { color: var(--muted); width: 20px; height: 20px; }
.search input { flex: 1; border: 0; background: none; padding: 10px 0; min-width: 0; }
.search:focus-within { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.search.inset { margin-bottom: 4px; }
.icon-btn { border: 0; background: none; color: var(--muted); width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.conn { display: none; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 4px; }
body.offline .conn { display: flex; }
#list { flex: 1; overflow-y: auto; padding: 2px 8px 90px; contain: content; }
.row { display: flex; gap: 12px; padding: 9px 10px; border-radius: 16px; cursor: pointer; align-items: center; transition: background-color .18s; position: relative; }
.row:hover { background: var(--hover); }
.row:active { transform: scale(.985); transition: transform .12s; }
.row.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(108, 92, 255, .28); }
.row.active .row-text, .row.active .row-time, .row.active .muted, .row.active .you, .row.active .accent, .row.active .secret-ic, .row.active .grp-ic, .row.active .tick { color: rgba(255, 255, 255, .85) !important; }
.row-main { flex: 1; min-width: 0; }
.row-top, .row-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.row-title { font-weight: 620; display: flex; align-items: center; gap: 5px; min-width: 0; }
.row-time { font-size: 12.5px; color: var(--muted); flex: none; display: flex; align-items: center; gap: 3px; }
.row-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.you { color: var(--text); }
.secret-ic { color: var(--secret); width: 16px; height: 16px; }
.grp-ic { width: 17px; height: 17px; color: var(--muted); }
.ttl-mini { display: inline-flex; align-items: center; font-size: 11px; margin-right: 3px; }
.ttl-mini .ic { width: 13px; height: 13px; }
.tick { width: 17px; height: 17px; color: var(--muted); transition: color .3s; }
.tick.read { color: var(--accent); }
.badge { background: var(--accent); color: #fff; border-radius: 12px; min-width: 22px; height: 22px; padding: 0 7px; font-size: 12.5px; font-weight: 700; display: grid; place-items: center; flex: none; }
.row.active .badge { background: #fff; color: var(--accent); }
.section { padding: 14px 10px 4px; color: var(--muted); font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .4px; }
.list-empty { color: var(--muted); text-align: center; padding: 60px 24px; font-size: 14.5px; line-height: 1.6; }
.empty-ic { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--grad); color: #fff; box-shadow: 0 10px 26px rgba(108, 92, 255, .35); }
.empty-ic .ic { width: 34px; height: 34px; }
.empty-ic.sm { width: 56px; height: 56px; border-radius: 18px; }
.avatar { --s: 44px; width: var(--s); height: var(--s); font-size: calc(var(--s) * .38); border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 650; position: relative; user-select: none;
  background: linear-gradient(140deg, hsl(var(--h) 80% 66%), hsl(calc(var(--h) + 35) 70% 52%)); }
.avatar.online::after { content: ''; position: absolute; right: 1px; bottom: 1px; width: calc(var(--s) * .26); height: calc(var(--s) * .26); max-width: 14px; max-height: 14px; border-radius: 50%; background: var(--ok); border: 2.5px solid var(--surface); animation: pop .3s var(--spring); }
.fab { position: absolute; right: 22px; bottom: max(22px, env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 20px; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 26px rgba(108, 92, 255, .45); }
.fab:hover { transform: translateY(-2px) scale(1.04); }

/* ---------- чат ---------- */
.empty { flex: 1; display: grid; place-items: center; animation: fadeIn .4s var(--ease); }
.empty-card { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); }
.empty-card b { color: var(--text); font-size: 17px; margin-top: 4px; }
@keyframes fadeIn { from { opacity: 0; } }
#chat-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); min-height: 62px; position: relative; z-index: 3; animation: fadeIn .25s; }
.head-click { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; cursor: pointer; padding: 2px 4px; border-radius: 12px; }
.head-text { min-width: 0; }
.head-title { font-weight: 650; display: flex; gap: 5px; align-items: center; font-size: 16px; }
.head-sub { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key-emoji { font-size: 14px; letter-spacing: 1px; padding: 5px 8px; border-radius: 10px; background: var(--surface-2); cursor: pointer; flex: none; }
.chip-ttl { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 650; color: var(--accent); background: var(--surface-2); padding: 4px 8px; border-radius: 10px; flex: none; }
.chip-ttl .ic { width: 15px; height: 15px; }
.back { display: none; }
.dots { display: inline-flex; gap: 2px; margin-left: 3px; vertical-align: middle; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
#banner { position: relative; z-index: 2; }
.alert { background: var(--warn-bg); color: var(--warn); padding: 11px 14px; font-size: 13.5px; border-radius: 14px; }
#banner .alert, #banner .note { border-radius: 0; animation: slideDown .3s var(--ease); }
.note { background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: var(--muted); padding: 8px 14px; font-size: 13px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.note .ic { width: 16px; height: 16px; }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } }
#msgs { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px max(12px, calc((100% - 780px) / 2)) 8px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; scroll-behavior: auto; }
.loading { margin: auto; color: var(--muted); }
.intro { align-self: center; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); padding: 14px 18px; border-radius: 18px; max-width: 340px; margin: 10px 0 6px; font-size: 13px; color: var(--muted); animation: cardIn .45s var(--ease); }
.intro .ic { width: 26px; height: 26px; color: var(--accent); margin-bottom: 2px; }
.intro b { color: var(--text); font-size: 14px; }
.day { align-self: center; position: sticky; top: 4px; z-index: 1; margin: 10px 0 6px; pointer-events: none; }
.day span { display: inline-block; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 4px 11px; border-radius: 12px; border: 1px solid var(--line); }
.sys { align-self: center; display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; padding: 4px 12px; border-radius: 12px; background: var(--glass); margin: 4px 0; animation: msgIn .3s var(--ease) both; }
.sys .ic { width: 14px; height: 14px; color: var(--accent); }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: min(560px, 82%); margin-top: 6px; transform-origin: 0% 100%; animation: msgIn .32s var(--ease) both; will-change: transform; }
.msg.cont { margin-top: 1px; }
.msg.mine { align-self: flex-end; transform-origin: 100% 100%; }
@keyframes msgIn { from { opacity: 0; transform: translateY(12px) scale(.94); } }
.no-anim .msg, .no-anim .sys, .no-anim .intro { animation: none; }
.msg.leave { animation: msgOut .3s var(--ease) forwards; }
@keyframes msgOut { 0% { max-height: var(--hgt); } 60% { opacity: 0; transform: scale(.9); } 100% { opacity: 0; transform: scale(.9); max-height: 0; margin: 0; } }
.av-space { width: 34px; flex: none; }
.bubble { background: var(--in); color: var(--in-text); border-radius: var(--r); padding: 7px 12px 7px; box-shadow: var(--shadow-s); position: relative; min-width: 70px; overflow-wrap: anywhere; }
.msg:not(.mine):not(.cont) .bubble { border-top-left-radius: 6px; }
.mine .bubble { background: var(--grad); color: var(--out-text); box-shadow: 0 4px 14px rgba(108, 92, 255, .22); }
.mine:not(.cont) .bubble { border-top-right-radius: 6px; }
.msg.pending .bubble { opacity: .85; }
.bubble.broken { opacity: .8; }
.author { font-weight: 650; font-size: 13.5px; color: hsl(var(--h) 65% 55%); margin-bottom: 1px; }
.text { white-space: pre-wrap; }
.text.jumbo { font-size: 42px; line-height: 1.15; }
.text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.meta { float: right; display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted); margin: 7px 0 -5px 12px; user-select: none; cursor: pointer; font-variant-numeric: tabular-nums; }
.mine .meta, .mine .meta .tick { color: var(--out-meta); }
.mine .meta .tick.read { color: #fff; }
.meta .tick { width: 16px; height: 16px; }
.tick.pending { animation: spin 2s linear infinite; }
.ttl { font-variant-numeric: tabular-nums; }
.err { color: var(--danger); font-size: 14px; display: flex; align-items: center; gap: 4px; }
.mine .err { color: #fff; }
.err .ic { width: 16px; height: 16px; }
.err.pad { padding: 20px; }
.photo-bubble { padding: 4px; }
.photo-bubble .meta { position: absolute; right: 10px; bottom: 10px; margin: 0; background: rgba(0,0,0,.45); color: #fff !important; padding: 2px 7px; border-radius: 10px; }
.photo-bubble .meta .tick { color: #fff !important; }
.photo-bubble .text { padding: 4px 8px 2px; }
.photo-wrap { border-radius: 16px; overflow: hidden; min-height: 80px; min-width: 160px; }
.shimmer { background: linear-gradient(100deg, var(--surface-2) 30%, var(--hover) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; height: 200px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.photo { display: block; max-width: 100%; max-height: 380px; cursor: zoom-in; animation: fadeIn .3s; }
.file { display: flex; gap: 12px; align-items: center; padding: 2px 0; }
.file-ic { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; flex: none; }
.mine .file-ic { background: rgba(255,255,255,.22); }
.file-name { font-weight: 600; word-break: break-all; }
.file-size { font-size: 12.5px; opacity: .7; }
.down-btn { position: absolute; right: 18px; bottom: 86px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); display: grid; place-items: center; box-shadow: var(--shadow-m); opacity: 0; transform: scale(.6) translateY(10px); pointer-events: none; transition: opacity .25s, transform .3s var(--spring); z-index: 3; }
.down-btn.show { opacity: 1; transform: none; pointer-events: auto; }
#bottom { position: relative; z-index: 3; }
#composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px max(12px, calc((100% - 780px) / 2)) max(10px, env(safe-area-inset-bottom)); flex-direction: row; animation: fadeIn .25s; }
.compose-box { flex: 1; display: flex; align-items: flex-end; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-m); border: 1px solid var(--line); padding: 3px; transition: box-shadow .2s; }
.compose-box:focus-within { box-shadow: var(--shadow-m), 0 0 0 2px rgba(108, 92, 255, .35); }
.compose-box textarea { flex: 1; resize: none; border: 0; background: none; padding: 10px 8px; max-height: 180px; line-height: 1.4; min-width: 0; }
.attach { cursor: pointer; }
.send { width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 6px 18px rgba(108, 92, 255, .4); transform: scale(.86); opacity: .55; transition: transform .3s var(--spring), opacity .2s; }
#composer.has-text .send { transform: scale(1); opacity: 1; }
.send .ic { transform: translateX(1px); }
.wait-bar { margin: 10px auto max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); padding: 10px 16px; border-radius: 16px; width: fit-content; max-width: calc(100% - 24px); }
.accept { margin: auto; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 26px 22px 16px; box-shadow: var(--shadow-l); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.accept-ic { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto; display: grid; place-items: center; background: linear-gradient(135deg, #2fd38a, #19a568); color: #fff; box-shadow: 0 10px 24px rgba(25, 181, 107, .35); }
.accept-ic .ic { width: 30px; height: 30px; }
.accept h3 { margin: 4px 0 0; font-size: 20px; }
.accept p { margin: 0; color: var(--muted); }
.accept ul { text-align: left; margin: 4px 0 6px; padding-left: 20px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- контекстное меню, просмотр фото ---------- */
#ctx-back { position: fixed; inset: 0; z-index: 60; }
.ctx { position: fixed; z-index: 61; background: var(--glass); backdrop-filter: blur(26px) saturate(180%); -webkit-backdrop-filter: blur(26px) saturate(180%); border: 1px solid var(--line); border-radius: 16px; padding: 6px; min-width: 200px; box-shadow: var(--shadow-l); opacity: 0; transform: scale(.85); transform-origin: top left; transition: opacity .18s, transform .28s var(--spring); }
.ctx.open { opacity: 1; transform: none; }
.ctx button { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: none; padding: 10px 12px; border-radius: 10px; text-align: left; font-weight: 500; }
.ctx button:hover { background: var(--hover); }
.ctx .ic { width: 20px; height: 20px; color: var(--muted); }
.ctx .danger .ic { color: var(--danger); }
.viewer { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0); display: grid; place-items: center; padding: 20px; cursor: zoom-out; transition: background-color .3s; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 12px; transform: scale(.85); opacity: 0; transition: transform .4s var(--ease), opacity .25s; }
.viewer.open { background: rgba(0,0,0,.88); }
.viewer.open img { transform: none; opacity: 1; }

/* ---------- листы ---------- */
#modal, #modal-closing { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8, 10, 20, 0); transition: background-color .32s var(--ease); }
#modal.open { background: rgba(8, 10, 20, .45); }
#modal-closing { pointer-events: none; }
.sheet { background: var(--surface); border-radius: 26px; padding: 6px 20px 22px; width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: var(--shadow-l); border: 1px solid var(--line); opacity: 0; transform: translateY(18px) scale(.96); transition: opacity .22s, transform .38s var(--ease); overscroll-behavior: contain; }
#modal.open .sheet { opacity: 1; transform: none; }
.sheet.swap .sheet-body { animation: swapIn .3s var(--ease); }
@keyframes swapIn { from { opacity: 0; transform: translateX(16px); } }
.grabber { display: none; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 6px; position: sticky; top: -6px; background: var(--surface); z-index: 2; }
.sheet-head h2 { margin: 0; font-size: 20px; letter-spacing: -.3px; }
.group-list { background: var(--surface-2); border-radius: 18px; padding: 4px; display: flex; flex-direction: column; }
.menu-item { display: flex; gap: 12px; align-items: center; border: 0; background: none; padding: 10px 10px; border-radius: 14px; text-align: left; width: 100%; font-weight: 500; }
.menu-item:hover { background: var(--hover); }
.menu-item > span:nth-child(2) { flex: 1; }
.mi-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--grad); color: #fff; flex: none; }
.mi-ic .ic { width: 18px; height: 18px; }
.menu-item.danger .mi-ic { background: var(--danger); }
.chev { color: var(--muted); width: 20px; height: 20px; opacity: .6; }
.profile { display: flex; gap: 14px; align-items: center; padding: 2px 0 4px; }
.center-col { flex-direction: column; text-align: center; gap: 6px; }
.p-name { font-weight: 700; font-size: 19px; }
.kind-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 10px; background: var(--surface-2); }
.kind-chip .ic { width: 16px; height: 16px; }
.kind-chip.secret { color: var(--secret); }
.kind-chip.cloud { color: var(--accent); }
.keybox { background: var(--surface-2); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.keybox code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; letter-spacing: .6px; color: var(--muted); }
.keybox .emoji { font-size: 28px; letter-spacing: 3px; line-height: 1.3; }
.label { font-size: 12.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .4px; }
.pad-top { padding-top: 6px; }
.member, .sess { display: flex; gap: 12px; align-items: center; padding: 6px 2px; }
.member-main { flex: 1; min-width: 0; }
.sess-ic { width: 42px; height: 42px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); flex: none; }
.sess.cur .sess-ic { background: var(--grad); color: #fff; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 7px; background: var(--surface-2); color: var(--muted); margin-left: 6px; flex: none; }
.tag.ok { color: var(--ok); } .tag.warn { color: var(--warn); }
.small { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 600; align-self: flex-start; flex: none; }
.small:hover { background: var(--hover); }
.info-row { display: flex; gap: 14px; align-items: center; padding: 6px 0; }
.info-row .ic { color: var(--muted); }
.info-row .ic.read { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip { background: var(--grad); color: #fff; border-radius: 12px; padding: 5px 11px; font-size: 13px; font-weight: 600; cursor: pointer; }
.pick-list { max-height: 300px; overflow-y: auto; }
.add-members summary { cursor: pointer; color: var(--accent); padding: 6px 0; font-weight: 600; list-style: none; }
.add-members[open] > div { margin: 8px 0; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--surface-2); padding: 10px 12px; border-radius: 14px; }
.linkbox code { flex: 1; word-break: break-all; font-size: 13px; }
.steps { display: flex; flex-direction: column; gap: 8px; }
.steps > div { display: flex; flex-direction: column; background: var(--surface-2); padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.steps span { color: var(--muted); }
.doc { font-size: 14.5px; }
.doc h4 { margin: 10px 0 2px; font-size: 15px; }
.doc p { margin: 0; color: var(--muted); }
ol.doc { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.toast { position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translate(-50%, 24px) scale(.96); opacity: 0; background: rgba(22, 24, 34, .92); backdrop-filter: blur(12px); color: #fff; padding: 11px 18px; border-radius: 16px; z-index: 100; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow-l); transition: transform .4s var(--spring), opacity .25s; display: flex; gap: 8px; align-items: center; }
.toast.in { transform: translate(-50%, 0); opacity: 1; }
.toast.bad { background: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------- телефоны: экраны скользят, как в нативном приложении ---------- */
@media (max-width: 799px) {
  #side, #chat { position: absolute; inset: 0; width: 100%; transition: transform .42s var(--ease), filter .42s; will-change: transform; }
  #side { border: 0; }
  #side .side-top { padding-top: max(10px, env(safe-area-inset-top)); }
  #chat { transform: translateX(100%); z-index: 3; box-shadow: -10px 0 40px rgba(0,0,0,.15); }
  body.in-chat #chat { transform: none; }
  body.in-chat #side { transform: translateX(-28%); filter: brightness(.85); }
  .back { display: grid; }
  .msg { max-width: 86%; }
  #modal, #modal-closing { place-items: end center; padding: 0; }
  .sheet { width: 100%; border-radius: 26px 26px 0 0; padding-bottom: max(22px, env(safe-area-inset-bottom)); transform: translateY(100%); opacity: 1; transition: transform .42s var(--ease); max-height: 92dvh; border-bottom: 0; }
  .grabber { display: block; }
  .key-emoji { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- аватарки ---------- */
.avatar { overflow: visible; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; animation: fadeIn .3s; }
.avatar.online::after { z-index: 1; }
.profile.clickable { cursor: pointer; border-radius: 16px; padding: 6px; margin: -6px; transition: background-color .18s; }
.profile.clickable:hover { background: var(--hover); }
.photo-pick { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.photo-pick-av { position: relative; cursor: pointer; border-radius: 50%; }
.photo-pick-av .cam { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.42); color: #fff; opacity: 0; transition: opacity .2s; z-index: 2; }
.photo-pick-av:hover .cam, .photo-pick.busy .cam { opacity: 1; }
.photo-pick.busy .cam .ic { animation: spin 1s linear infinite; }
.photo-pick-av .cam .ic { width: 30px; height: 30px; }
.photo-pick-btns { display: flex; gap: 8px; }
.photo-pick-btns .small { display: inline-flex; align-items: center; gap: 4px; align-self: auto; }
.photo-pick-btns .ic { width: 17px; height: 17px; }
@media (hover: none) { .photo-pick-av .cam { opacity: .85; background: rgba(0,0,0,.3); } }
.get-app { display: block; text-align: center; color: var(--accent); font-weight: 600; text-decoration: none; padding: 12px; margin-top: 4px; border-radius: 12px; transition: background-color .2s; }
.get-app:hover { background: var(--hover); }
