:root {
  --accent: #3390ec;
  --accent-dark: #2a7fd4;
  --bg: #ffffff;
  --bg-2: #f4f4f5;
  --hover: #f4f4f5;
  --active: #3390ec;
  --text: #000000;
  --text-2: #707579;
  --border: #dfe1e5;
  --bubble-in: #ffffff;
  --bubble-out: #eeffde;
  --meta-out: #4fae4e;
  --meta-in: #a3abb2;
  --check-gray: #9aa5ad;
  --check-read: #3390ec;
  --link: #3390ec;
  --danger: #e53935;
  --shadow: 0 1px 2px rgba(16, 35, 47, .15);
  --chat-bg: linear-gradient(135deg, #dbddbb 0%, #6ba587 35%, #d5d88d 70%, #88b884 100%);
  --pattern-opacity: .22;
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-h: 100dvh;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --bg-2: #181818;
    --hover: #2c2c2c;
    --text: #ffffff;
    --text-2: #aaaaaa;
    --border: #303030;
    --bubble-in: #212121;
    --bubble-out: #766ac8;
    --meta-out: #ffffff;
    --meta-in: #8a8a8a;
    --check-gray: rgba(255,255,255,.55);
    --check-read: #9fe0ff;
    --link: #8774e1;
    --accent: #8774e1;
    --accent-dark: #7564d0;
    --active: #8774e1;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --chat-bg: linear-gradient(135deg, #2b3a2e 0%, #1f2b26 40%, #2e3324 75%, #1b2620 100%);
    --pattern-opacity: .12;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Roboto", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg { display: block; }
.hidden { display: none !important; }

/* ---------- кнопки-иконки ---------- */
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); flex: none; transition: background .15s; }
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- аватарки ---------- */
.avatar { --s: 54px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: calc(var(--s) * .4); background-size: cover; background-position: center; position: relative; user-select: none; }
.avatar.c0 { background-image: linear-gradient(#ff885e, #ff516a); }
.avatar.c1 { background-image: linear-gradient(#ffcd6a, #ffa85c); }
.avatar.c2 { background-image: linear-gradient(#82b1ff, #665fff); }
.avatar.c3 { background-image: linear-gradient(#a0de7e, #54cb68); }
.avatar.c4 { background-image: linear-gradient(#53edd6, #28c9b7); }
.avatar.c5 { background-image: linear-gradient(#72d5fd, #2a9ef1); }
.avatar.c6 { background-image: linear-gradient(#e0a2f3, #d669ed); }
.avatar.group { background-image: linear-gradient(#72d5fd, #2a9ef1); }
.avatar .dot { position: absolute; right: 1px; bottom: 1px; width: calc(var(--s) * .26); height: calc(var(--s) * .26);
  background: #0ac630; border: 2px solid var(--bg); border-radius: 50%; }
.avatar svg { width: 55%; height: 55%; }

/* ---------- раскладка ---------- */
#app { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h); display: flex; overflow: hidden; }
/* клавиатура открыта — нижний отступ под «полоску» iPhone не нужен */
.kb-open .composer-wrap { padding-bottom: 8px; }
.kb-open .chat-list { padding-bottom: 8px; }
.sidebar { width: 380px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--bg); position: relative; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.main::before { content: ""; position: absolute; inset: 0; opacity: var(--pattern-opacity); pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.18' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 22c4-6 12-6 16 0-4 6-12 6-16 0z'/%3E%3Ccircle cx='86' cy='20' r='6'/%3E%3Cpath d='M62 52l8 8m0-8l-8 8'/%3E%3Cpath d='M14 78h14v12H14zM16 78v-3a5 5 0 0110 0v3'/%3E%3Cpath d='M90 70c0-5 7-5 7 0 0-5 7-5 7 0 0 5-7 9-7 9s-7-4-7-9z'/%3E%3Cpath d='M44 100l6-10 6 10z'/%3E%3Cpath d='M96 104a6 6 0 1012 0 6 6 0 00-12 0'/%3E%3Cpath d='M40 30h10m-5-5v10'/%3E%3C/g%3E%3C/svg%3E"); }
.main > * { position: relative; }
.empty-main { margin: auto; background: rgba(0, 0, 0, .22); color: #fff; padding: 6px 14px; border-radius: 16px; font-size: 15px; }

@media (max-width: 767px) {
  .sidebar { width: 100%; border: 0; }
  .main { position: absolute; inset: 0; transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); z-index: 5; }
  #app.chat-open .main { transform: none; }
  #app.chat-open .sidebar { transform: translateX(-25%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  .sidebar { transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  .empty-main { display: none; }
}

/* ---------- шапки ---------- */
.topbar { height: calc(var(--header-h) + var(--safe-top)); padding: var(--safe-top) 8px 0; display: flex; align-items: center; gap: 6px; flex: none; background: var(--bg); }
.search { flex: 1; height: 40px; border-radius: 20px; background: var(--bg-2); display: flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--text-2); border: 2px solid transparent; }
.search:focus-within { border-color: var(--accent); background: var(--bg); }
.search svg { width: 20px; height: 20px; flex: none; }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; font-size: 16px; }

/* ---------- список чатов ---------- */
.chat-list { flex: 1; overflow-y: auto; padding: 0 8px calc(8px + var(--safe-bottom)); -webkit-overflow-scrolling: touch; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 9px; border-radius: 12px; cursor: pointer; user-select: none; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); color: #fff; }
.chat-item.active .ci-text, .chat-item.active .ci-time, .chat-item.active .ci-pin { color: rgba(255,255,255,.85); }
.chat-item.active .badge { background: #fff; color: var(--accent); }
.chat-item.active .avatar .dot { border-color: var(--active); }
.ci-body { flex: 1; min-width: 0; }
.ci-row { display: flex; align-items: center; gap: 6px; }
.ci-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 13px; color: var(--text-2); flex: none; display: flex; align-items: center; gap: 3px; }
.ci-time svg { width: 18px; height: 18px; color: var(--meta-out); }
.ci-text { flex: 1; min-width: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; margin-top: 2px; }
.ci-text b { color: var(--text); font-weight: 400; }
.chat-item.active .ci-text b { color: #fff; }
.ci-text .typing { color: var(--accent); }
.chat-item.active .ci-text .typing { color: #fff; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; display: grid; place-items: center; flex: none; }
.ci-pin { color: var(--text-2); width: 18px; height: 18px; flex: none; }

/* ---------- чат ---------- */
.chat-head { cursor: pointer; }
.chat-head .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-head .who-text { min-width: 0; }
.chat-head .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .status { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .status.on { color: var(--accent); }
.back-btn { display: none; }
@media (max-width: 767px) { .back-btn { display: grid; } }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 6px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.msgs-inner { max-width: 760px; margin: 0 auto; padding: 0 10px; display: flex; flex-direction: column; }
.day { align-self: center; margin: 10px 0 6px; background: rgba(0, 0, 0, .22); color: #fff; font-size: 14px; font-weight: 500; padding: 3px 10px; border-radius: 14px; position: sticky; top: 6px; z-index: 2; }

.row { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; }
.row.out { justify-content: flex-end; }
.row.gap { margin-top: 8px; }
.row .avatar { --s: 34px; visibility: hidden; }
.row.last .avatar { visibility: visible; }
.row.highlight .bubble { animation: hl 1.6s ease; }
@keyframes hl { 0%, 60% { filter: brightness(.82); } 100% { filter: none; } }

.bubble { position: relative; max-width: min(480px, 82%); background: var(--bubble-in); border-radius: 15px; padding: 6px 9px 7px 10px; box-shadow: var(--shadow);
  word-wrap: break-word; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; -webkit-touch-callout: none; }
.row.out .bubble { background: var(--bubble-out); }
.row.last.in .bubble { border-bottom-left-radius: 4px; }
.row.last.out .bubble { border-bottom-right-radius: 4px; }
.row.last .bubble::after { content: ""; position: absolute; bottom: 0; width: 11px; height: 17px; background: inherit;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 17'%3E%3Cpath d='M11 0v17H0c5 0 9-3 11-8z'/%3E%3C/svg%3E") no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 17'%3E%3Cpath d='M11 0v17H0c5 0 9-3 11-8z'/%3E%3C/svg%3E") no-repeat; }
.row.last.in .bubble::after { left: -10px; }
.row.last.out .bubble::after { right: -10px; transform: scaleX(-1); }
.sender { font-size: 14px; font-weight: 600; margin-bottom: 1px; }
.name-c0 { color: #e17076; } .name-c1 { color: #eda86c; } .name-c2 { color: #a695e7; } .name-c3 { color: #7bc862; }
.name-c4 { color: #4fbfb0; } .name-c5 { color: #4fa3e3; } .name-c6 { color: #ce67d6; }
.text { white-space: pre-wrap; }
.text a { color: var(--link); }
.row.out .text a { color: inherit; }
.text.big { font-size: 44px; line-height: 1.15; }
.meta { float: right; margin: 6px 0 -5px 10px; font-size: 12px; color: var(--meta-in); display: flex; align-items: center; gap: 2px; position: relative; top: 2px; user-select: none; }
.row.out .meta { color: var(--meta-out); }
.meta svg { width: 18px; height: 18px; }
.deleted { color: var(--text-2); font-style: italic; }

/* ответ */
.reply-quote { display: block; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 4px 6px 6px 4px; padding: 3px 8px; margin: 2px 0 5px; cursor: pointer; font-size: 14px; min-width: 120px; }
.row.out .reply-quote { border-color: var(--meta-out); background: color-mix(in srgb, var(--meta-out) 12%, transparent); }
.reply-quote .rq-name { font-weight: 600; color: var(--accent); }
.row.out .reply-quote .rq-name { color: var(--meta-out); }
.reply-quote .rq-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; color: var(--text); opacity: .85; }

/* медиа */
.bubble.media { padding: 3px; }
.bubble.media.has-caption { padding-bottom: 7px; }
.bubble.media .sender, .bubble.media .reply-quote { margin-left: 7px; margin-right: 7px; }
.bubble.media .sender { margin-top: 3px; }
.media-box { position: relative; border-radius: 12px; overflow: hidden; background: rgba(0,0,0,.08); cursor: pointer; display: block; }
.media-box img, .media-box video { display: block; width: 100%; height: 100%; object-fit: cover; }
.bubble.media .caption { padding: 5px 7px 0; }
.media-meta { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.45); color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 12px; display: flex; align-items: center; gap: 2px; float: none; margin: 0; top: auto; }
.media-meta svg { width: 16px; height: 16px; }
.row.out .media-meta { color: #fff; }
.vid-dur { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.45); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; }
.play-big { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(0,0,0,.45); display: grid; place-items: center; color: #fff; }
.play-big svg { width: 28px; height: 28px; margin-left: 3px; }
.progress-ring { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.25); }
.progress-ring svg { width: 52px; height: 52px; }
.progress-ring circle { fill: rgba(0,0,0,.4); }
.progress-ring circle.p { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .2s; }

/* голосовые */
.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; padding: 2px 0; }
.voice-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.row.out .voice-btn { background: var(--meta-out); color: var(--bubble-out); }
.voice-btn svg { width: 22px; height: 22px; }
.voice-body { flex: 1; min-width: 0; }
.wave { display: flex; align-items: center; gap: 2px; height: 26px; cursor: pointer; }
.wave i { flex: 1; min-width: 2px; max-width: 3px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.row.out .wave i { background: color-mix(in srgb, var(--meta-out) 40%, transparent); }
.wave i.on { background: var(--accent); }
.row.out .wave i.on { background: var(--meta-out); }
.voice-time { font-size: 13px; color: var(--meta-in); margin-top: 2px; }
.row.out .voice-time { color: var(--meta-out); }

/* файлы */
.file { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 200px; }
.file-ico { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.row.out .file-ico { background: var(--meta-out); color: var(--bubble-out); }
.file-ico svg { width: 24px; height: 24px; }
.file-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file-size { font-size: 13px; color: var(--meta-in); }

/* ---------- поле ввода ---------- */
.composer-wrap { flex: none; padding: 6px 8px calc(8px + var(--safe-bottom)); }
.composer-inner { max-width: 760px; margin: 0 auto; }
.reply-bar { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 14px 14px 0 0; padding: 6px 6px 2px 12px; margin-right: 56px; }
.reply-bar svg.ic { width: 22px; height: 22px; color: var(--accent); flex: none; }
.reply-bar .rb-body { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 8px; font-size: 14px; }
.reply-bar .rb-name { color: var(--accent); font-weight: 600; }
.reply-bar .rb-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.reply-bar + .composer .input-box { border-top-left-radius: 0; border-top-right-radius: 0; }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.input-box { flex: 1; min-width: 0; background: var(--bg); border-radius: 22px; display: flex; align-items: flex-end; box-shadow: var(--shadow); min-height: 48px; padding: 4px; }
.input-box textarea { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: none; padding: 10px 6px 10px 10px; max-height: 160px; line-height: 1.35; font-size: 16px; height: 41px; }
.input-box .icon-btn { width: 40px; height: 40px; }
.send-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--bg); color: var(--accent); box-shadow: var(--shadow); display: grid; place-items: center; flex: none; transition: background .2s, color .2s, transform .1s; }
.send-btn:active { transform: scale(.94); }
.send-btn svg { width: 26px; height: 26px; }
.send-btn.send { background: var(--accent); color: #fff; }
.send-btn.rec { background: var(--accent); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
.rec-box { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 14px; height: 40px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; flex: none; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; min-width: 48px; }
.rec-cancel { margin-left: auto; color: var(--danger); font-weight: 500; padding: 8px; }

.typing-dots { display: inline-flex; gap: 2px; margin-right: 4px; vertical-align: middle; }
.typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: td 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; } .typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes td { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.scroll-down { position: absolute; right: 14px; bottom: 84px; width: 48px; height: 48px; border-radius: 50%; background: var(--bg); color: var(--text-2); box-shadow: var(--shadow); display: grid; place-items: center; z-index: 3; }
.scroll-down svg { width: 26px; height: 26px; }
.scroll-down .badge { position: absolute; top: -6px; right: -2px; }

/* ---------- меню сообщения ---------- */
.ctx { position: fixed; z-index: 50; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.22); padding: 6px 0; min-width: 200px; animation: pop .14s ease; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.ctx button { display: flex; align-items: center; gap: 16px; width: 100%; padding: 9px 18px; font-size: 15px; }
.ctx button:hover { background: var(--hover); }
.ctx button svg { width: 22px; height: 22px; color: var(--text-2); }
.ctx button.danger, .ctx button.danger svg { color: var(--danger); }
.backdrop { position: fixed; inset: 0; z-index: 49; }

/* ---------- панели (профиль) ---------- */
.panel { position: absolute; inset: 0; background: var(--bg-2); z-index: 20; display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.panel.right { transform: translateX(100%); }
.panel.open { transform: none; }
.panel .topbar { gap: 8px; }
.panel .topbar h2 { font-size: 20px; font-weight: 600; margin: 0; flex: 1; }
.panel-body { flex: 1; overflow-y: auto; padding-bottom: calc(24px + var(--safe-bottom)); }
.prof-head { background: var(--bg); padding: 18px 16px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.prof-head .avatar { --s: 120px; }
.prof-head .pname { font-size: 22px; font-weight: 600; margin-top: 6px; }
.prof-head .pstatus { color: var(--text-2); font-size: 15px; }
.prof-head .pstatus.on { color: var(--accent); }
.av-edit { position: relative; cursor: pointer; }
.av-edit .cam { position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,.35); display: grid; place-items: center; color: #fff; opacity: 0; transition: opacity .2s; }
.av-edit:hover .cam { opacity: 1; }
.av-edit .cam-badge { position: absolute; right: 2px; bottom: 2px; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 3px solid var(--bg); }
.av-edit .cam-badge svg { width: 18px; height: 18px; }
.section { background: var(--bg); margin-top: 10px; padding: 6px 0; }
.section-title { color: var(--accent); font-weight: 600; font-size: 15px; padding: 10px 18px 4px; }
.field { padding: 8px 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 4px 2px; }
.field input, .field textarea, .login-card input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--bg); outline: 0; font-size: 16px; resize: none; }
.field input:focus, .field textarea:focus, .login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.hint { font-size: 13px; color: var(--text-2); padding: 0 18px 8px; }
.list-btn { display: flex; align-items: center; gap: 22px; width: 100%; padding: 13px 18px; text-align: left; font-size: 16px; }
.list-btn:hover { background: var(--hover); }
.list-btn svg { width: 24px; height: 24px; color: var(--text-2); flex: none; }
.list-btn .sub { display: block; font-size: 13px; color: var(--text-2); }
.list-btn.danger, .list-btn.danger svg { color: var(--danger); }
.info-row { display: flex; gap: 22px; padding: 10px 18px; align-items: flex-start; }
.info-row svg { width: 24px; height: 24px; color: var(--text-2); flex: none; margin-top: 2px; }
.info-row .k { font-size: 13px; color: var(--text-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 48px; padding: 0 22px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; width: 100%; }
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; color: var(--accent); }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; }
.media-grid > div { aspect-ratio: 1; background-size: cover; background-position: center; cursor: pointer; background-color: var(--hover); position: relative; }
.media-grid > div video { width: 100%; height: 100%; object-fit: cover; }

/* ---------- вход ---------- */
.login { position: fixed; inset: 0; overflow-y: auto; background: var(--bg); display: flex; flex-direction: column; align-items: center; padding: calc(40px + var(--safe-top)) 16px 40px; }
.login-logo { width: 120px; height: 120px; border-radius: 50%; background: linear-gradient(#37aee2, #1e96c8); display: grid; place-items: center; color: #fff; }
.login-logo svg { width: 64px; height: 64px; }
.login h1 { font-size: 28px; margin: 22px 0 6px; }
.login p { color: var(--text-2); margin: 0 0 22px; text-align: center; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.login-card .avatar { --s: 96px; }
.login-card .who { font-size: 22px; font-weight: 600; }
.login-err { color: var(--danger); font-size: 14px; min-height: 18px; }

/* ---------- просмотр медиа ---------- */
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: flex; flex-direction: column; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-top)) 10px 8px; color: #fff; }
.viewer-top .icon-btn { color: #fff; }
.viewer-top .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer-top .vt-who { flex: 1; min-width: 0; font-size: 15px; }
.viewer-top .vt-who small { display: block; opacity: .7; font-size: 13px; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 0 calc(10px + var(--safe-bottom)); }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- плашки ---------- */
.banner { margin: 4px 8px 8px; padding: 12px 14px; background: color-mix(in srgb, var(--accent) 10%, var(--bg)); border-radius: 12px; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.banner svg { width: 26px; height: 26px; color: var(--accent); flex: none; }
.banner .b-text { flex: 1; }
.banner .b-text b { display: block; font-size: 15px; }
.banner .b-act { color: var(--accent); font-weight: 600; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 80; animation: fade .2s; max-width: 90vw; text-align: center; }
.conn { position: absolute; top: calc(var(--header-h) + var(--safe-top) + 4px); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6); color: #fff; font-size: 13px; padding: 3px 12px; border-radius: 12px; z-index: 4; }

.ios-guide { display: flex; flex-direction: column; gap: 10px; padding: 8px 18px 14px; font-size: 15px; }
.ios-guide .step { display: flex; gap: 12px; align-items: center; }
.ios-guide .num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 600; display: grid; place-items: center; flex: none; font-size: 14px; }
.ios-guide svg { width: 20px; height: 20px; display: inline-block; vertical-align: -4px; color: var(--accent); }

/* ---------- галочки: одна серая — отправлено, две серые — доставлено, две синие — прочитано ---------- */
.st { display: inline-flex; color: var(--check-gray); }
.st.read { color: var(--check-read); }
.media-meta .st { color: rgba(255,255,255,.75); }
.media-meta .st.read { color: #8fd3ff; }
.chat-item.active .st, .chat-item.active .st.read { color: #fff; }
.ci-time .st svg { width: 18px; height: 18px; }
.proc { color: #fff; font-size: 13px; background: rgba(0,0,0,.45); padding: 4px 10px; border-radius: 12px; }

/* ---------- сообщения о звонках ---------- */
.call-msg { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 2px 0; min-width: 190px; }
.call-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.row.out .call-ico { background: var(--meta-out); color: var(--bubble-out); }
.call-ico svg { width: 22px; height: 22px; }
.call-msg b { display: block; font-weight: 500; }
.call-msg.missed b { color: var(--danger); }
.call-sub { font-size: 13px; color: var(--meta-in); }
.row.out .call-sub { color: var(--meta-out); }

/* ---------- экран звонка ---------- */
.call { position: fixed; inset: 0; z-index: 70; background: linear-gradient(160deg, #3b4a5c, #1b232c); color: #fff; display: flex; flex-direction: column; align-items: center; overflow: hidden; animation: fade .2s; }
.call video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.call video.local { position: absolute; right: 14px; top: calc(14px + var(--safe-top)); width: 104px; height: 150px; object-fit: cover; border-radius: 14px; background: #222; box-shadow: 0 4px 16px rgba(0,0,0,.4); transform: scaleX(-1); z-index: 2; }
.call video.local.back { transform: none; }
.call .c-info { position: relative; z-index: 1; margin-top: calc(70px + var(--safe-top)); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 0 20px; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.call .c-info .avatar { --s: 120px; }
.call .c-name { font-size: 26px; font-weight: 600; }
.call .c-status { font-size: 16px; opacity: .85; }
.call.has-video .c-info { margin-top: calc(24px + var(--safe-top)); }
.call.has-video .c-info .avatar { display: none; }
.call .c-btns { position: absolute; z-index: 3; left: 0; right: 0; bottom: calc(36px + var(--safe-bottom)); display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; padding: 0 12px; }
.c-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: #fff; }
.c-btn span.b { width: 62px; height: 62px; border-radius: 50%; background: rgba(255,255,255,.18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: grid; place-items: center; transition: transform .1s; }
.c-btn:active span.b { transform: scale(.92); }
.c-btn svg { width: 28px; height: 28px; }
.c-btn.off span.b { background: #fff; color: #222; }
.c-btn.red span.b { background: #e53935; }
.c-btn.green span.b { background: #2fbf4a; animation: ring 1.2s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(47,191,74,.6); } 100% { box-shadow: 0 0 0 18px rgba(47,191,74,0); } }
.call-mini { position: fixed; left: 50%; transform: translateX(-50%); top: calc(8px + var(--safe-top)); z-index: 65; background: #2fbf4a; color: #fff; border-radius: 18px; padding: 6px 14px; font-size: 14px; font-weight: 500; box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer; }
