/* Call — стили приложения (подключаются из index.html) */
/* Только системные шрифты и свои файлы: никаких запросов на сторонние серверы */
:root {
  --accent: #2f7fd1; --accent-text: #fff; --danger: #e5484d; --ok: #2fb75a;
  --side: #ffffff; --line: #e6e9ee; --text: #17212b; --muted: #707a86; --hover: #f2f5f8; --active: #2f7fd1;
  --chat-bg: #d7e2d2; --dots: rgba(255,255,255,.35);
  --theirs: #ffffff; --mine: #e1f7cf; --mine-text: #17212b; --meta-mine: #4f9a48; --link-mine: #23772e; --input: #ffffff;
  --tick-read: #2f9cf1; --tick-mine: var(--meta-mine); --tick-mine-read: #2f9cf1;
  --head: #ffffff; --pill: rgba(0,0,0,.18); --pill-text: #fff; --seg-on: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); font-size: 15px;
}
/* тема: системная (по умолчанию), светлая или тёмная — выбирается в настройках */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #5aa7f2; --side: #17212b; --line: #0f1720; --text: #e8edf2; --muted: #7f8b97; --hover: #202b36; --active: #2b5278;
    --chat-bg: #0e1621; --dots: rgba(255,255,255,.03);
    --theirs: #182533; --mine: #2b5278; --mine-text: #e8edf2; --meta-mine: #8fbce6; --link-mine: #a5d6ff; --input: #17212b;
    --tick-read: #4db8ff; --tick-mine: rgba(232,237,242,.45); --tick-mine-read: #5ce6ff;
    --head: #17212b; --pill: rgba(0,0,0,.35); color-scheme: dark; --seg-on: #34475a;
  }
}
:root[data-theme="dark"] {
    --accent: #5aa7f2; --side: #17212b; --line: #0f1720; --text: #e8edf2; --muted: #7f8b97; --hover: #202b36; --active: #2b5278;
    --chat-bg: #0e1621; --dots: rgba(255,255,255,.03);
    --theirs: #182533; --mine: #2b5278; --mine-text: #e8edf2; --meta-mine: #8fbce6; --link-mine: #a5d6ff; --input: #17212b;
    --tick-read: #4db8ff; --tick-mine: rgba(232,237,242,.45); --tick-mine-read: #5ce6ff;
    --head: #17212b; --pill: rgba(0,0,0,.35); color-scheme: dark; --seg-on: #34475a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* как в приложении: двойное касание не увеличивает страницу (масштаб двумя пальцами остаётся) */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, label, input, select, textarea, .item, .msg { touch-action: manipulation; }
.pin-pad, .pin-pad button, .cbtn, .icon-btn, .send { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* iPhone увеличивает страницу при нажатии на поле, если шрифт в нём меньше 16px */
@media (max-width: 760px) { html input, html textarea, html select, html .ta-hl { font-size: max(16px, 1rem); } }
/* --app-h и --app-top: видимая часть экрана над клавиатурой телефона (см. «клавиатура на телефоне») */
html, body { margin: 0; height: var(--app-h, 100%); background: var(--side); }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); overflow: hidden; display: flex; flex-direction: column; position: relative; top: var(--app-top, 0); }
body.kb-open { padding-bottom: 0; } /* клавиатура закрывает полоску «домой», отступ под ней не нужен */
body > section#app, body > section#auth, body > section#guest { flex: 1; min-height: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; cursor: pointer; }
@media (hover: hover) { .icon-btn:hover { background: var(--hover); color: var(--accent); } }
/* наведение — только для мыши: на телефоне подсветка оставалась после касания. Там отклик — пока палец на кнопке */
@media (hover: none) {
  .icon-btn:active, .menu button:active, .small-btn:active, .ctx-list button:active, .chat-menu button:active, .list-ctx button:active,
  .ep-list button:active, .lst-pick label:active, .srv-sug button:active, .pw-eye:active, .meet-lobby .lrow:active { background: var(--hover); }
}
/* кнопки: нажатие видно и при коротком касании (было лишь чуть темнее — «нажалось или нет?»), мышь — подсветка */
.btn { transition: filter .12s, scale .12s; }
.btn:active:not(:disabled) { filter: brightness(.85); scale: .96; }
@media (hover: hover) { .btn:hover:not(:disabled) { filter: brightness(1.08); } .btn:active:not(:disabled) { filter: brightness(.9); } }
.btn { background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 11px 16px; font-weight: 600; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; }
.field { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--input); outline: none; }
.field:focus { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.error { color: var(--danger); min-height: 1.2em; font-size: .9rem; }

/* ---------- аватарки ---------- */
.avatar { flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; user-select: none; }
.av-48 { width: 48px; height: 48px; font-size: 1.05rem; }
.av-40 { width: 40px; height: 40px; font-size: .95rem; }
.av-42 { width: 42px; height: 42px; font-size: .98rem; }
.av-110 { width: 110px; height: 110px; font-size: 2.4rem; }

/* ---------- вход ---------- */
#auth, #guest { display: grid; place-items: center; padding: 20px; background: var(--chat-bg); overflow-y: auto; }
/* вход и гость встречи: тот же фон и под часами, и под полоской «Домой» (отступы body на iPhone) */
html:has(body > #auth:not(.hidden)), html:has(body > #guest:not(.hidden)),
body:has(> #auth:not(.hidden)), body:has(> #guest:not(.hidden)) { background: var(--chat-bg); }
.auth-box { width: 100%; max-width: 380px; background: var(--side); border-radius: 18px; padding: 30px 26px; position: relative; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
/* Скачать приложение: значки в правом верхнем углу окна входа, напротив логотипа — для компьютера и для телефона */
.auth-apps { position: absolute; top: 30px; right: 26px; display: flex; gap: 14px; }
.auth-apps-group { display: grid; justify-items: center; gap: 7px; }
.auth-apps-group + .auth-apps-group { border-left: 1px solid var(--line); padding-left: 14px; }
.auth-apps small { font-size: .9rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 460px) { .auth-apps { position: static; justify-content: center; margin-bottom: 18px; } } /* телефон: пять значков не помещаются рядом с логотипом */
.auth-apps-row { display: flex; gap: 7px; }
.auth-apps-row a { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); color: var(--text); display: grid; place-items: center; transition: background .15s, color .15s, border-color .15s; }
.auth-apps-row a:hover { background: var(--hover); color: var(--accent); border-color: var(--accent); }
.auth-apps-row svg { width: 23px; height: 23px; fill: currentColor; stroke: none; }
.auth-apps-row svg .ic-line { fill: none; stroke: currentColor; stroke-width: 1.5; }
.auth-apps-row a.apk { font-size: .78rem; font-weight: 700; letter-spacing: .02em; text-decoration: none; } /* APK файлом, мимо Google Play */
.logo { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }
.logo svg { width: 32px; height: 32px; }
.auth-box h1 { margin: 0 0 4px; font-size: 1.6rem; }
.auth-box p.sub { margin: 0 0 20px; color: var(--muted); }
.auth-box form { display: grid; gap: 12px; }
.auth-box label { font-size: .85rem; color: var(--muted); display: grid; gap: 5px; }
/* подписи полей — заметнее текста в поле: светлее, крупнее и жирнее; в поле — обычный текст 16 px (iPhone не увеличивает страницу) */
.auth-box form label:not(.reg-terms) { font-size: .95rem; font-weight: 600; color: var(--text); gap: 7px; }
.auth-box form label .field { font-size: 1rem; font-weight: 400; }
/* подсказка под заголовком поля — мелко и серым */
.auth-box .field-head { display: grid; gap: 2px; }
.auth-box .field-hint { font-size: .8rem; font-weight: 400; color: var(--muted); }
#installFirst { display: grid; gap: 12px; }
#installFirst h2 { margin: 0; font-size: 1.15rem; }
#installFirst p, #installFirst ol { margin: 0; color: var(--muted); line-height: 1.5; }
#installFirst ol { padding-left: 20px; display: grid; gap: 4px; }
#installFirst a.btn { text-align: center; text-decoration: none; }
#installFirst .install-code { font-size: 1.5rem; font-weight: 700; letter-spacing: .06em; text-align: center; user-select: all; -webkit-user-select: all; }
.switch { margin-top: 12px; text-align: center; }

/* ---------- раскладка ---------- */
#app { display: grid; grid-template-columns: var(--side-w, minmax(300px, 380px)) minmax(0, 1fr); }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; position: relative; }
/* объём: список чуть «над» чатом — мягкая тень от края в сторону переписки (только когда стоят рядом) */
@media (min-width: 761px) { .side { z-index: 2; box-shadow: 6px 0 16px -10px rgba(0,0,0,.22); } }
@media (min-width: 761px) { :root[data-theme="dark"] .side { box-shadow: 6px 0 18px -10px rgba(0,0,0,.6); } }
@media (min-width: 761px) and (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side { box-shadow: 6px 0 18px -10px rgba(0,0,0,.6); } }
/* край списка чатов: потянуть — шире или уже, двойной щелчок — как было */
/* ручка ширины — целиком по ту сторону границы, над чатом: раньше половиной лежала на полосе прокрутки списка, и у края
   вместо полосы ловилась ручка */
.side-resize { position: absolute; top: 0; bottom: 0; right: -8px; width: 8px; cursor: col-resize; z-index: 17; touch-action: none; outline: none; }
.side-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 2px; transition: background .15s; }
.side-resize:hover::after, .side-resize:focus-visible::after, .side-resize.drag::after { background: var(--accent); }
body.side-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
.side-top { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.search { flex: 1; position: relative; }
.search input { width: 100%; border: 0; border-radius: 22px; padding: 10px 14px 10px 40px; background: var(--hover); outline: none; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
#status { font-size: .78rem; color: var(--muted); padding: 0 18px 6px; display: flex; align-items: center; gap: 8px; }
#status.online { display: none; }
/* подключение и обновление (setStatus в js/06-live.js), как в Telegram: крутится значок у строки и бежит полоска сверху */
body.net-busy #status::before { content: ""; flex: none; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: netSpin .8s linear infinite; }
@keyframes netSpin { to { transform: rotate(360deg); } }
#netBar { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 2px; z-index: 9000; overflow: hidden;
  pointer-events: none; opacity: 0; transition: opacity .3s; }
body.net-busy #netBar { opacity: 1; }
#netBar::after { content: ""; position: absolute; top: 0; bottom: 0; left: -35%; width: 35%; background: var(--accent); border-radius: 2px;
  animation: netSlide 1.3s ease-in-out infinite; }
@keyframes netSlide { to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { body.net-busy #status::before, #netBar::after { animation-duration: 3s; } }
.menu { position: absolute; top: 54px; left: 10px; z-index: 20; background: var(--side); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 6px; min-width: 230px; }
.menu button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px; border-radius: 8px; text-align: left; }
@media (hover: hover) { .menu button:hover { background: var(--hover); } }
.menu svg { width: 20px; height: 20px; color: var(--muted); }
.menu .me { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; gap: 12px; align-items: center; }
.menu .me small { color: var(--muted); display: block; }

#chatList { list-style: none; margin: 0; padding: 0 6px 10px; overflow-y: auto; flex: 1; }
/* фильтры списка, как в WhatsApp: одна узкая строка, при нехватке места прокручивается вбок */
.chat-filters { display: flex; align-items: center; gap: 6px; padding: 4px 10px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.chat-filters::-webkit-scrollbar { display: none; }
.chat-filters button { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 16px;
                       background: var(--hover); color: var(--text); font-size: .86rem; line-height: 1.2; font-weight: 500;
                       transition: background-color .18s, color .18s, box-shadow .18s, scale .12s; }
.chat-filters button:active { scale: .95; }
.chat-filters .f-seg { display: inline-flex; flex: none; gap: 2px; padding: 2px; border-radius: 16px; background: var(--hover); }
.chat-filters .f-seg button { position: relative; background: transparent; padding: 4px 10px; }
.chat-filters .f-seg button.on { background: var(--seg-on); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.chat-filters .f-seg svg { width: 17px; height: 17px; }
.chat-filters .f-seg .fc, .chat-filters .f-list.compact .fc { position: absolute; top: -3px; right: -3px; min-width: 15px; height: 15px; padding: 0 3px;
                       font-size: .62rem; line-height: 15px; border-radius: 8px; box-shadow: 0 0 0 1.5px var(--side); }
.chat-filters .f-list { position: relative; }
.chat-filters .f-list .lst-nm { display: inline-block; overflow: hidden; white-space: nowrap; max-width: 160px; text-overflow: ellipsis; }
.chat-filters .f-list.compact { padding: 4px 5px; gap: 0; }
.chat-filters .f-list .lst-tag { width: 18px; height: 18px; font-size: .68rem; }
.chat-filters .f-list.compact .lst-tag { width: 22px; height: 22px; font-size: .78rem; border-radius: 7px; }
.chat-filters .f-list.compact .pin-ic { display: none; }
.chat-filters .f-list.compact:not(.on) .lst-nm { max-width: 0; }
.chat-filters .f-list.compact.on { padding-right: 10px; }
.chat-filters .f-list.compact.on .lst-nm { margin-left: 6px; }
.chat-filters .f-list.compact.on.grow .lst-nm { animation: lstGrow .22s ease-out; }
@keyframes lstGrow { from { max-width: 0; opacity: 0; } }
.chat-filters .f-sep { flex: none; align-self: center; width: 1px; height: 18px; margin: 0 2px; background: color-mix(in srgb, var(--muted) 40%, transparent); }
.chat-filters .f-list.on { background: color-mix(in srgb, var(--lst) 22%, var(--side)); color: var(--text); }
/* мини-анимации: меню и окна мягко появляются, список при смене фильтра и лента при смене чата — проявляются.
   Используем свойства scale/translate, а не transform: у части меню transform уже занят центровкой */
@keyframes uiPop { from { opacity: 0; scale: .94; } }
@keyframes uiFade { from { opacity: 0; } }
@keyframes uiRise { from { opacity: 0; translate: 0 6px; } }
.menu:not(.hidden), .chat-menu:not(.hidden), .ctx:not(.hidden), .list-ctx:not(.hidden), .out-menu:not(.hidden),
.hang-menu:not(.hidden), .peer-menu:not(.hidden) { animation: uiPop .14s cubic-bezier(.2, .8, .3, 1); }
.menu, .ctx, .list-ctx, .peer-menu { transform-origin: top left; }
.chat-menu { transform-origin: top right; }
.out-menu, .hang-menu { transform-origin: bottom center; }
dialog[open] { animation: uiPop .16s cubic-bezier(.2, .8, .3, 1); }
dialog[open]::backdrop { animation: uiFade .16s; }
#chatList.swap > * { animation: uiRise .2s ease-out both; }
#chatList.swap > :nth-child(2) { animation-delay: 15ms; } #chatList.swap > :nth-child(3) { animation-delay: 30ms; }
#chatList.swap > :nth-child(4) { animation-delay: 45ms; } #chatList.swap > :nth-child(5) { animation-delay: 60ms; }
#chatList.swap > :nth-child(n+6) { animation-delay: 75ms; }
#messages.swap { animation: uiFade .18s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .menu, .chat-menu, .ctx, .list-ctx, .out-menu, .hang-menu, .peer-menu, dialog[open], dialog[open]::backdrop,
  #chatList.swap > *, #messages.swap { animation: none !important; }
  .chat-filters button { transition: none; }
  .chat-filters .f-list.compact.on.grow .lst-nm { animation: none; }
}
.chat-filters .f-list .pin-ic svg { width: 12px; height: 12px; }
.chat-filters .f-add { padding: 5px 9px; color: var(--muted); }
.chat-filters .f-add svg { width: 15px; height: 15px; }
.chat-filters button.on { background: color-mix(in srgb, var(--accent) 22%, var(--side)); color: var(--accent); }
.chat-filters .fc { font-size: .75rem; min-width: 18px; padding: 1px 5px; border-radius: 9px; background: var(--ok); color: #fff; text-align: center; }
.chat-filters .fc.muted { background: var(--muted); }
.chat-filters svg { width: 14px; height: 14px; }
.fav-ic { color: #f5b301; display: inline-flex; vertical-align: -2px; margin-left: 4px; }
.fav-ic svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.section { padding: 10px 12px 4px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.lst-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; background: var(--lst); }
/* буква списка: первая буква названия цветом списка на его бледном фоне — у чата и во вкладках */
.lst-tag { display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; border-radius: 5px; font-size: .62rem;
           font-weight: 700; line-height: 1; color: var(--lst); background: color-mix(in srgb, var(--lst) 16%, transparent); }
.item-name .lst-tags { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: 1px; }
.item.active .lst-tag { color: #fff; background: rgba(255,255,255,.22); }
.lst-colors { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
.lst-colors button { width: 30px; height: 30px; border-radius: 50%; background: var(--lst); }
.lst-colors button.on { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--lst); }
.lst-pick { max-height: 38vh; overflow: auto; margin: 8px -6px 12px; }
.lst-pick label { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; cursor: pointer; }
@media (hover: hover) { .lst-pick label:hover { background: var(--hover); } }
.lst-pick .avatar { width: 32px; height: 32px; font-size: .8rem; }
.lst-pick span.nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lst-pick input { width: 18px; height: 18px; accent-color: var(--lst); flex: none; }
.lst-sub { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
dialog label.lst-compact { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; color: var(--text); font-size: .95rem; cursor: pointer; }
.lst-compact input { width: 18px; height: 18px; accent-color: var(--lst); flex: none; }
.lst-compact small { display: block; color: var(--muted); font-size: .8rem; }
.list-ctx .lst-tag { width: 20px; height: 20px; font-size: .72rem; }
.list-ctx button .lst-check { margin-left: auto; color: var(--accent); font-weight: 700; }
.btn.danger-text { color: var(--danger); margin-right: auto; }
/* «Помощь» — возможности Call: группы, в каждой — карточки «что это, пример, где найти» */
dialog.help-dialog { max-width: 560px; display: none; }
dialog.help-dialog[open] { display: flex; flex-direction: column; max-height: min(720px, calc(100dvh - 40px)); }
.netdiag-list { overflow-y: auto; margin: 0 0 6px; font-size: .9rem; }
/* длинный результат (адрес IPv6) уходит на свою строку справа, а не растягивает окно */
.netdiag-row { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--line); }
.netdiag-row > span:first-child { flex: 1 1 auto; }
.netdiag-row .nd-res { color: var(--muted); font-size: .8rem; text-align: right; margin-left: auto; overflow-wrap: anywhere; }
#netDiagDialog h2 { margin-bottom: 6px; }
#netDiagNote { margin: 4px 0 0; }
#netDiagDialog .row { margin-top: 8px; gap: 6px; flex-wrap: nowrap; }
#netDiagDialog .row .btn { padding-left: 12px; padding-right: 12px; white-space: nowrap; }
.netdiag-row.ok .nd-res { color: var(--ok); }
.netdiag-row.bad .nd-res { color: var(--danger); }
.help-list { flex: 1; overflow-y: auto; margin: 10px -6px 12px; padding: 0 6px; }
.help-group { margin: 12px 2px 6px; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.help-group:first-child { margin-top: 2px; }
.help-item { display: flex; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--hover); margin-bottom: 6px; }
.help-item .hi-ic { font-size: 1.3rem; line-height: 1.5rem; flex: none; width: 1.6rem; text-align: center; }
.help-item b { display: block; margin-bottom: 2px; }
.help-item p { margin: 0; color: var(--text); font-size: .9rem; line-height: 1.4; }
.help-item .hi-ex { color: var(--muted); margin-top: 4px; }
.help-item .hi-where { color: var(--accent); margin-top: 4px; font-size: .85rem; }
.item { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 12px; cursor: pointer; }
@media (hover: hover) { .item:hover { background: var(--hover); } }
.item.active { background: var(--active); color: #fff; }
.item.active .preview, .item.active .ltime { color: rgba(255,255,255,.8); }
.item-main { flex: 1; min-width: 0; }
.item-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ltime { font-size: .76rem; color: var(--muted); flex: none; display: inline-flex; align-items: center; gap: 4px; }
.preview { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
/* список чатов: имя обычным шрифтом, полужирным — только у непрочитанных; превью без прозрачности;
   тонкая линия между чатами (под текстом, не под аватаром) */
:is(#chatList, #inShareList) .item { gap: 10px; padding: 7px 8px; }
:is(#chatList, #inShareList) .item-name { font-weight: 400; font-size: 1.07rem; } /* имя в списке чуть крупнее текста сообщений */
:is(#chatList, #inShareList) .item.unread .item-name { font-weight: 600; }
:is(#chatList, #inShareList) .preview { opacity: 1; }
:is(#chatList, #inShareList) .item-main { align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 1px;
                       margin: -7px 0; padding: 7px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
:is(#chatList, #inShareList) .item:last-child .item-main, :is(#chatList, #inShareList) .item.active .item-main, :is(#chatList, #inShareList) .item:has(+ .item.active) .item-main,
@media (hover: hover) { :is(#chatList, #inShareList) .item:hover .item-main, :is(#chatList, #inShareList) .item:has(+ .item:hover) .item-main { border-bottom-color: transparent; } }
:is(#chatList, #inShareList) .ltime .fav-ic, :is(#chatList, #inShareList) .ltime .mute-ic { margin-left: 0; vertical-align: 0; }
/* непрочитанные — заметнее: жирное имя, тёмный текст, время цветом */
.item.unread .item-name { font-weight: 600; }
.item.unread .preview { color: var(--text); opacity: 1; }
.item.unread .ltime { color: var(--accent); font-weight: 600; }
/* свои сообщения в списке: галочки вместо «Вы:» */
.ltime .tick { display: inline-flex; color: var(--muted); }
.list-mode-btn { width: 36px; height: 36px; flex: none; color: var(--muted); }
.list-mode-btn svg { width: 20px; height: 20px; }
/* «только у новых»: у прочитанного чата убираем вторую строку, высота и аватар — как у всех; точки списков — у времени */
body.list-new :is(#chatList, #inShareList) .item.quiet .item-row + .item-row { display: none; }
.ltime .tick svg { width: 15px; height: 15px; }
.ltime .tick svg.dbl { width: 19px; }
.ltime .tick.read { color: var(--tick-read); }
.item.active .ltime { color: rgba(255,255,255,.85); }
/* у выбранного чата фон синий: доставлено — бледные, прочитано — яркие голубые и жирнее */
.item.active .ltime .tick { color: rgba(255,255,255,.5); }
.item.active .ltime .tick.read { color: #8ff4ff; }
.item.active .ltime .tick.read svg { stroke-width: 2.6; }
/* «Только имена»: без последнего сообщения, строки ниже, счётчик в той же строке */
body.list-names :is(#chatList, #inShareList) .item { padding: 5px 10px; }
body.list-names :is(#chatList, #inShareList) .item > .avatar { width: 38px; height: 38px; font-size: .88rem; }
body.list-names :is(#chatList, #inShareList) .item-main { display: flex; flex-direction: row; align-items: center; gap: 8px; }
body.list-names :is(#chatList, #inShareList) .item-main > .item-row:first-child { flex: 1; min-width: 0; }
body.list-names :is(#chatList, #inShareList) .preview { display: none; }
.preview .draft-l { color: var(--danger); }
.chat-head .subtitle.online, .profile-card .pc-head .pc-seen.online { color: var(--accent); }
.preview.typing, .chat-head .subtitle.typing { color: var(--accent); }
.item.active .preview.typing { color: #fff; }
/* «печатает» и три точки волной; --t0 — общая фаза, чтобы при перерисовке строки точки не начинали заново */
.tdots { display: inline-flex; align-items: flex-end; gap: 2px; margin-left: 3px; height: .9em; }
.tdots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: tdot 1.2s ease-in-out infinite; animation-delay: var(--t0, 0ms); }
.tdots i:nth-child(2) { animation-delay: calc(var(--t0, 0ms) + .2s); }
.tdots i:nth-child(3) { animation-delay: calc(var(--t0, 0ms) + .4s); }
@keyframes tdot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .tdots i { animation: none; opacity: .8; } }
.item.active .preview .draft-l { color: #ffd2d2; }
.badge { background: var(--ok); color: #fff; border-radius: 999px; font-size: .78rem; min-width: 22px; padding: 2px 7px; text-align: center; flex: none; }
.empty { color: var(--muted); padding: 28px 18px; text-align: center; line-height: 1.5; }

/* ---------- окно чата ---------- */
/* фон переписки: обычный — точки; выбранный в настройках узор (--wall, applyWall в 07-settings.js) — поверх градиента */
.chat { display: flex; flex-direction: column; min-height: 0;
        background: var(--wall, radial-gradient(var(--dots) 1.2px, transparent 1.3px) 0 0 / 22px 22px, var(--chat-bg)); }
.chat-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 12px; background: var(--head); border-bottom: 1px solid var(--line); min-height: 58px; }
.chat-head .who-box { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; }
.chat-head .who-box.clickable { cursor: pointer; }
.chat-head .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* бегущая строка у длинного названия группы (setChatTitle в 03-chats.js): стоит, уезжает к концу, стоит, возвращается;
   края мягко гаснут */
.chat-head .name.marquee { text-overflow: clip;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 12px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 12px), transparent); }
.chat-head .name.marquee .mq { display: inline-block; padding-left: 4px; animation: chatTitleMq var(--mq-dur, 8s) ease-in-out infinite alternate; }
@keyframes chatTitleMq { 0%, 20% { transform: translateX(0); } 80%, 100% { transform: translateX(var(--mq-shift, 0)); } }
@media (prefers-reduced-motion: reduce) {
  .chat-head .name.marquee { text-overflow: ellipsis; -webkit-mask-image: none; mask-image: none; }
  .chat-head .name.marquee .mq { display: inline; padding: 0; animation: none; }
}
.chat-head .subtitle { font-size: .82rem; color: var(--muted); }
#back { display: none; }
/* на широком экране лента — колонкой ~880px по центру, как в Telegram: свои и чужие сообщения рядом, голову не крутить
   (--lane: проценты в padding считаются от ширины окна чата; на узком экране выходит 0) */
#messages { --lane: max(0px, calc((100% - 880px) / 2));
            flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px calc(var(--pr, var(--pl)) + var(--lane)) 14px calc(var(--pl) + var(--lane)); display: flex; flex-direction: column;
            --pl: 7px; container-type: inline-size; transition: padding-right .18s ease; }
.day { align-self: center; background: var(--pill); color: var(--pill-text); font-size: .8rem; padding: 4px 12px; border-radius: 12px; margin: 10px 0 4px; }
/* служебная строка чата: «Иван добавил(а) Петра» */
.sys { align-self: center; max-width: 85%; text-align: center; overflow-wrap: anywhere; background: var(--pill); color: var(--pill-text); font-size: .8rem; padding: 4px 12px; border-radius: 12px; margin: 6px 0; }
/* текст сообщений растёт с «Размером текста» мягче остального интерфейса: на обычном размере — как всё остальное,
   крупнее — примерно на 70% шага; иначе при крупном интерфейсе облачка становились огромными */
.msg { font-size: calc(5px + .7rem); position: relative; max-width: min(78%, 44em); /* ~660px при обычном шрифте, растёт вместе с размером текста */ padding: 6px 10px; border-radius: 14px; background: var(--theirs); align-self: flex-start;
       white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--bubble-shadow); margin-top: 8px; line-height: 1.38; }
.msg.cont { margin-top: 2px; }
.msg.mine { background: var(--mine); color: var(--mine-text); align-self: flex-end; }
.msg.mine:not(.cont) { border-bottom-right-radius: 4px; }
.tr-badge { display: inline-flex; vertical-align: -2px; padding: 0; margin-right: 5px; background: none; border: 0; color: inherit; opacity: .55; cursor: pointer; }
.tr-badge svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tr-badge.orig { opacity: .3; }
.msg.tr-wait .msg-text { animation: trPulse 1.4s ease-in-out infinite; }
.tr-wait-label { margin-right: 6px; opacity: .7; font-style: italic; }
@keyframes trPulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .msg.tr-wait .msg-text { animation: none; opacity: .6; } }
.tr-on { font-size: 1rem; margin-left: 6px; flex: none; }
.msg.failed { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 55%, transparent), var(--bubble-shadow); }
.tick.failed { color: var(--danger) !important; font-weight: 800; }
.fail-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; font-size: .82rem; color: var(--danger); white-space: normal; }
.fail-bar button { padding: 4px 8px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font-weight: 600; font-size: .82rem; }
.msg:not(.mine):not(.cont) { border-bottom-left-radius: 4px; }
.msg .who { font-size: .85rem; font-weight: 600; margin-bottom: 1px; display: flex; align-items: center; gap: 6px; }
.msg .who .mav { flex: none; }
/* аватарки в группах, как в Telegram: место слева у чужих сообщений, сама аватарка — у последнего в серии */
.av-26 { width: 26px; height: 26px; font-size: .62rem; }
.msg.with-av { margin-left: 32px; }
.msg.with-av:not(.cont) { border-bottom-left-radius: 14px; }
.msg.with-av.tail { border-bottom-left-radius: 4px; }

.msg.with-av .mav, .msg .who:not(.bot) { cursor: pointer; }
/* ответ на сообщение: цитата в начале пузыря, нажатие — к исходному сообщению */
.msg .reply-q { display: block; border-left: 3px solid var(--rq, var(--accent)); background: color-mix(in srgb, var(--rq, var(--accent)) 12%, transparent);
                border-radius: 6px; padding: 3px 8px; margin: 2px 0 4px; cursor: pointer; font-size: .86rem; white-space: normal; }
.msg .reply-q b { display: block; color: var(--rq, var(--accent)); font-size: .8rem; }
.msg .reply-q span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.msg.mine .reply-q { --rq: var(--mine-text); background: rgba(255,255,255,.14); }
.msg .reply-q.gone { cursor: default; }
.msg .reply-q.gone span { font-style: italic; opacity: .6; }
/* мини-профиль по нажатию на аватарку или имя автора */
dialog.profile-card { max-width: 320px; }
.profile-card .pc-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; padding-top: 4px; }
.profile-card .pc-head .avatar { margin-bottom: 8px; }
.profile-card .pc-head b { font-size: 1.15rem; overflow-wrap: anywhere; }
.profile-card .pc-real { color: var(--muted); overflow-wrap: anywhere; }
.profile-card #pcRename, .profile-card #pcBlock, .profile-card #pcReport { width: 100%; margin-top: 10px; }
.profile-card #pcBlock, .profile-card #pcReport { margin-top: 2px; }
#reportReason { appearance: none; -webkit-appearance: none; padding-right: 38px; background-repeat: no-repeat; background-position: right 14px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238a96a3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
#reportComment { resize: none; }
.profile-card .pc-alias { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.profile-card .pc-alias .row { justify-content: flex-end; margin: 0; }
.profile-card .pc-head small { color: var(--muted); }
.profile-card .pc-head .pc-role { color: var(--accent); }
.profile-card .row { flex-direction: column; align-items: stretch; margin-top: 18px; }
.meta { float: right; margin: 6px 0 -4px 10px; font-size: .72rem; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; user-select: none; }
.msg.mine .meta { color: var(--meta-mine); }
.meta .unverified { color: var(--danger, #e5484d); font-size: .9rem; cursor: help; }
.meta svg { width: 15px; height: 15px; stroke-width: 2.2; }
.msg.broken { font-style: italic; opacity: .75; }
/* только смайлики (emojiCount): один — крупно и без облачка, два-три — помельче, больше — чуть крупнее текста */
.msg.jumbo .msg-text, .msg.emoji-only .msg-text { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.msg.jumbo .msg-text { display: block; line-height: 1.12; letter-spacing: .04em; }
.msg.jumbo-1 .msg-text { font-size: 3.6em; }
.msg.jumbo-2 .msg-text { font-size: 2.6em; }
.msg.jumbo-3 .msg-text { font-size: 2.2em; }
.msg.emoji-only .msg-text { font-size: 1.4em; line-height: 1.25; }
.msg.jumbo:not(.jumbo-box) { background: none; padding: 0 2px; }
.msg.jumbo:not(.jumbo-box):not(.failed) { box-shadow: none; }
.msg.jumbo:not(.jumbo-box) > .meta, .msg.jumbo:not(.jumbo-box) > .reacts > .meta { float: none; display: flex; width: fit-content; margin: 2px 0 0 auto;
    padding: 1px 7px; border-radius: 10px; background: var(--pill); color: var(--pill-text); }
/* ссылки в тексте сообщения и подписи */
.msg a.link, .lb-caption a.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.msg.mine a.link { color: var(--link-mine); }
.msg .mention { color: var(--accent); font-weight: 600; cursor: pointer; }
.msg.mine .mention { color: var(--link-mine); }
.msg .mention.me { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 4px; padding: 0 2px; }
/* подсказка «@»: участники группы над полем ввода */
.mention-box { background: var(--head); border-top: 1px solid var(--line); max-height: 228px; overflow-y: auto; padding: 4px 6px; }
.mention-box .item { padding: 6px 8px; gap: 10px; }
.mention-box .item.on { background: var(--hover); }
.mention-box .item-name { font-weight: 600; }
.badge.at { background: var(--accent); min-width: 22px; padding: 2px 6px; }
.msg img { display: block; max-width: 100%; max-height: 340px; border-radius: 10px; margin-top: 2px; cursor: zoom-in; }
.msg img.sized, .img-ph.sized { height: auto; max-height: none; object-fit: cover; }
.img-ph { display: grid; place-items: center; min-width: 140px; min-height: 90px; margin-top: 2px; border-radius: 10px; background: var(--hover); }
.file { display: flex; gap: 10px; align-items: center; cursor: pointer; text-align: left; min-width: 200px; }
.file .ficon { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.file .fname { font-weight: 600; word-break: break-all; }
.fsize { font-size: .8rem; color: var(--muted); }
.callmsg { display: flex; gap: 10px; align-items: center; }
.callmsg .cicon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); flex: none; }
.callmsg.redial { cursor: pointer; }
.callmsg .cdone { margin-left: 6px; color: var(--muted); font-size: .82rem; }
.callmsg .ctext { display: flex; flex-direction: column; min-width: 0; }
.callmsg .cend { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.callmsg .cend:empty { display: none; }
.callmsg .join { margin-left: 6px; background: var(--ok); color: #fff; border-radius: 16px; padding: 5px 12px; font-size: .85rem; font-weight: 600; }
.placeholder { flex: 1; display: grid; place-items: center; }
.placeholder span { background: var(--pill); color: var(--pill-text); padding: 6px 14px; border-radius: 14px; font-size: .9rem; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px max(10px, calc((100% - 900px) / 2)); background: var(--head); position: relative;
            box-shadow: 0 -1px 0 color-mix(in srgb, var(--text) 7%, transparent), 0 -6px 14px -8px rgba(0,0,0,.18); }
body.kb-open .composer { padding-bottom: 6px; } /* над клавиатурой — плотнее */
.bot-gate { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
            background: var(--head); color: var(--muted); text-align: center; border-top: 1px solid var(--line); }
.composer .ta-wrap { flex: 1; min-width: 0; position: relative; display: flex; background: var(--hover); border-radius: 21px; }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; background: transparent; border-radius: 21px; padding: 10px 4px 10px 16px; max-height: 140px; line-height: 1.35;
                     position: relative; z-index: 1; scrollbar-width: none; }
.composer textarea::-webkit-scrollbar { display: none; } /* без полосы прокрутки: иначе слой подсветки съедет */
/* слой подсветки ошибок под прозрачным полем: тот же текст, тот же шрифт и отступы */
.ta-hl { font: inherit; line-height: 1.35; /* font сбрасывает line-height — поэтому сначала font */
         position: absolute; inset: 0 38px 0 0; padding: 10px 4px 10px 16px; white-space: pre-wrap; overflow-wrap: break-word;
         color: transparent; overflow: hidden; pointer-events: none; border-radius: 21px; }
.ta-hl mark { background: rgba(229,57,53,.09); border-radius: 3px; color: transparent; text-decoration: underline wavy rgba(229,57,53,.8);
              text-decoration-thickness: 1.5px; text-decoration-skip-ink: none; text-underline-offset: 4px; }
/* карточка с вариантами — всплывает над полем ввода и не сдвигает ленту */
.spell-bar { position: fixed; z-index: 40; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; max-width: min(460px, calc(100vw - 16px));
             background: var(--side); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.18);
             font-size: .9rem; animation: uiPop .14s cubic-bezier(.2, .8, .3, 1); }
.spell-bar .sb-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.spell-bar .sb-word { color: var(--danger); font-weight: 600; font-size: .92rem; text-decoration: line-through rgba(229,57,53,.5); }
.spell-bar .sb-head .sb-n { margin-left: auto; }
.spell-bar .sb-sugs { display: flex; flex-wrap: wrap; gap: 6px; }
.spell-bar .sb-acts { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.spell-bar button { padding: 6px 13px; border-radius: 16px; background: var(--hover); color: var(--text); font-size: .9rem; }
.spell-bar button.sug { color: var(--accent); font-weight: 600; }
.spell-bar button.sug.best { background: var(--accent); color: #fff; }
.spell-bar button.act { background: none; color: var(--muted); padding: 4px 8px; font-size: .84rem; }
.spell-bar button.act.next { margin-left: auto; color: var(--accent); }
@media (hover: hover) { .spell-bar button:hover { filter: brightness(.95); } .spell-bar button.act:hover { color: var(--text); background: var(--hover); } }
.spell-bar .sb-none { color: var(--muted); }
.spell-bar kbd { font: inherit; font-size: .72rem; opacity: .7; margin-left: 4px; }
/* сколько ошибок в набранном: нажатие ведёт к следующей */
.spell-count { position: absolute; top: -9px; right: 44px; z-index: 2; display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 10px;
               background: #e53935; color: #fff; font-size: .72rem; font-weight: 600; line-height: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.18); cursor: pointer; }
.emoji-btn { width: 38px; height: 42px; flex: none; align-self: flex-end; display: grid; place-items: center; color: var(--muted); border-radius: 0 21px 21px 0; position: relative; z-index: 1; }
.emoji-btn.on { color: var(--accent); }
@media (hover: hover) { .emoji-btn:hover { color: var(--accent); } }
.emoji-btn svg { width: 23px; height: 23px; }
/* заготовленные фразы: ⚡ у поля ввода и список над ним */
.phr-btn { width: 32px; border-radius: 0; }
.phr-btn svg { width: 21px; height: 21px; }
.phr-pop { position: fixed; z-index: 41; background: var(--side); border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
           display: flex; flex-direction: column; overflow: hidden; min-height: 160px; }
.phr-pop .phr-q { margin: 8px 8px 4px; width: auto; }
.phr-list { flex: 1; overflow-y: auto; padding: 0 6px 6px; overscroll-behavior: contain; }
.phr-sec { position: sticky; top: 0; background: var(--side); color: var(--muted); font-size: .78rem; font-weight: 600; padding: 8px 6px 4px; }
.phr-item { display: flex; align-items: flex-start; gap: 4px; border-radius: 9px; }
.phr-item > button.phr-t { flex: 1; min-width: 0; text-align: start; padding: 7px 8px; border-radius: 9px; color: var(--text); white-space: pre-wrap;
                           overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (hover: hover) { .phr-item > button.phr-t:hover { background: var(--hover); } }
.phr-del { flex: none; width: 30px; height: 32px; color: var(--muted); border-radius: 8px; display: grid; place-items: center; }
.phr-del svg { width: 15px; height: 15px; }
@media (hover: hover) { .phr-del:hover { color: var(--danger); background: var(--hover); } }
.phr-empty { color: var(--muted); font-size: .86rem; padding: 6px 8px; }
.phr-back { display: block; width: 100%; text-align: start; color: var(--accent); }
.phr-foot { border-top: 1px solid var(--border, rgba(127,127,127,.2)); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.phr-foot textarea { resize: vertical; min-height: 60px; }
.phr-foot .seg button { font-size: .82rem; padding: 6px 4px; }
.phr-foot .row { display: flex; gap: 8px; justify-content: flex-end; margin: 0; }
.phr-warn { color: var(--muted); font-size: .76rem; margin: 0; }
.tk-cm-line .tk-phr svg { width: 21px; height: 21px; }
/* камера в поле сообщения: пока поле пустое (начали писать — прячется, как у мессенджеров) */
.cam-btn { width: 34px; height: 42px; flex: none; align-self: flex-end; display: grid; place-items: center; color: var(--muted); position: relative; z-index: 1; }
.cam-btn svg { width: 22px; height: 22px; }
@media (hover: hover) { .cam-btn:hover { color: var(--accent); } }
.ta-wrap:has(textarea:not(:placeholder-shown)) .cam-btn { display: none; }
.cam-dialog { width: min(640px, calc(100vw - 24px)); }
.cam-dialog video { width: 100%; max-height: 62vh; border-radius: 12px; background: #000; display: block; object-fit: contain; }
.cam-dialog .cam-msg { min-height: 1.2em; margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
/* смайлики: панель над полем ввода (и над сообщением — для реакции) */
.emoji-panel { position: fixed; z-index: 41; width: 352px; height: 330px; max-width: calc(100vw - 16px); background: var(--side); border-radius: 14px;
               box-shadow: 0 8px 30px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden; }
.ep-grid { flex: 1; overflow-y: auto; padding: 4px 8px 8px; overscroll-behavior: contain; }
.ep-sec { position: sticky; top: -4px; background: var(--side); color: var(--muted); font-size: .78rem; font-weight: 600; padding: 8px 4px 4px; }
.ep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); content-visibility: auto; contain-intrinsic-size: auto 300px; } /* темы вне экрана не рисуются */
.ep-list button { height: 38px; font-size: 25px; line-height: 1; border-radius: 8px; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
@media (hover: hover) { .ep-list button:hover { background: var(--hover); } }
/* вкладки панели: смайлики, поиск GIF, «Мои мемы» (для реакции — только смайлики) */
.ep-modes { display: flex; gap: 4px; padding: 6px 8px 2px; flex: none; }
.ep-modes button { flex: 1; padding: 5px 0; border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.ep-modes button.on { background: var(--hover); color: var(--text); }
.emoji-panel.pick .ep-modes { display: none; }
.ep-gif { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 4px 8px 8px; gap: 6px; }
.ep-gif .field { flex: none; }
.mine-bar { flex: none; display: flex; align-items: center; gap: 8px; }
.mine-bar .btn { padding: 5px 12px; font-size: .88rem; }
.mine-hint { font-size: .78rem; color: var(--muted); }
@media (pointer: coarse) { .mine-hint { display: none; } }
.gif-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 4px; align-content: start; overscroll-behavior: contain; }
.gif-grid > button { position: relative; height: 104px; /* высота числом: в Safari квадрат через aspect-ratio сплющивался */ border-radius: 8px; overflow: hidden; background: var(--hover); padding: 0; }
.gif-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-grid .g-del { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
                   font-size: 11px; display: grid; place-items: center; }
.gif-grid .g-add { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
                   font-size: 16px; line-height: 1; display: grid; place-items: center; }
.gif-grid .g-add.done { background: var(--accent); }
/* эффекты на весь экран: кнопки в панели, плашка в чате, холст поверх всего */
.fx-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; align-content: start; }
.fx-grid button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px; background: var(--hover); font-size: .8rem; color: var(--text); }
.fx-grid button span { font-size: 30px; line-height: 1; }
@media (hover: hover) { .fx-grid button:hover { background: color-mix(in srgb, var(--accent) 15%, var(--hover)); } }
.msg.fx-msg { align-self: center; background: var(--pill); color: var(--pill-text); box-shadow: none; padding: 5px 12px; border-radius: 14px;
              font-size: .85rem; cursor: pointer; white-space: normal; }
.msg.fx-msg .fx-ic { font-size: 1.15rem; margin-right: 4px; vertical-align: -2px; }
.msg.fx-msg .meta { color: inherit; opacity: .75; }
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 70; pointer-events: none; }
.gif-note { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; padding: 14px 6px; text-align: center; line-height: 1.4; }
.gif-sec { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; font-weight: 600; padding: 6px 2px 0; }
.ep-tabs { display: flex; border-top: 1px solid var(--line); padding: 4px; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: none; }
.ep-tabs button { flex: 1; min-width: 34px; height: 34px; border-radius: 8px; font-size: 19px; filter: grayscale(1); opacity: .7; }
.ep-tabs button.on { filter: none; opacity: 1; background: var(--hover); }
@media (hover: hover) { .ep-tabs button:hover { filter: none; opacity: 1; background: var(--hover); } }
/* голосовые: кнопка-микрофон, полоса записи, плеер в сообщении */
.composer .rec-bar { display: none; }
.composer.recording > label.icon-btn, .composer.recording > .ta-wrap { display: none; }
.composer.recording .rec-bar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 14px 0 2px; background: var(--hover); border-radius: 21px; }
.rec-bar .rec-cancel { width: 38px; height: 38px; color: var(--danger); }
.rec-bar .rec-cancel svg { width: 20px; height: 20px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; animation: blink 1s ease-in-out infinite; }
.rec-time { font-variant-numeric: tabular-nums; min-width: 38px; }
.rec-wave { flex: 1; min-width: 0; height: 28px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.rec-wave span { flex: none; width: 3px; min-height: 3px; border-radius: 2px; background: var(--accent); transition: height .14s ease-out; }
.rec-wave .rw-lane { flex: none; display: flex; align-items: center; gap: 2px; height: 100%; will-change: transform; }
/* во время записи кнопка «дышит» в такт голосу (--lvl 0–1 из startVoice), как в Telegram */
.composer.recording .send { box-shadow: 0 0 0 calc(var(--lvl, 0) * 14px) color-mix(in srgb, var(--accent) 24%, transparent); scale: calc(1 + var(--lvl, 0) * .08); }
.send.mic svg { margin-left: 0; width: 22px; height: 22px; }
.voice { display: flex; align-items: center; gap: 10px; width: min(300px, 62vw); padding: 2px 0; white-space: normal; }
.voice .vplay { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.voice .vplay svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.voice:not(.playing) .vplay svg { margin-left: 3px; }
.voice.loading .vplay { opacity: .6; }
.voice .vmain { flex: 1; min-width: 0; }
.voice .vwave { position: relative; height: 28px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.voice .vwave-on { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; pointer-events: none; clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0); }
.voice .vwave span { flex: 1; max-width: 3px; min-height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.voice .vwave .vwave-on span { background: var(--accent); }
/* текст голосового: под плеером ссылка «Показать текстом», после распознавания — сам текст (и перевод) */
.voice .vinfo { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; }
.voice .vrate { font-size: .72rem; font-weight: 700; padding: 0 6px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.msg.mine .voice .vplay { background: var(--meta-mine); color: var(--mine); }
.msg.mine .voice .vwave span { background: color-mix(in srgb, var(--meta-mine) 35%, transparent); }
.msg.mine .voice .vwave .vwave-on span { background: var(--meta-mine); }
.msg.mine .voice .vinfo { color: var(--meta-mine); }
.msg.mine .voice .vrate { background: color-mix(in srgb, var(--meta-mine) 18%, transparent); color: var(--meta-mine); }
.send { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.send svg { width: 20px; height: 20px; margin-left: -2px; }

/* ---------- диалоги ---------- */
dialog { border: 0; border-radius: 16px; padding: 22px; max-width: 440px; width: calc(100% - 28px); background: var(--side); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog:focus { outline: none; } /* на телефоне фокус — на самом окне, а не в поле */
dialog h2 { margin: 0 0 6px; font-size: 1.2rem; }
dialog p { color: var(--muted); margin: 0 0 14px; }
dialog form { display: grid; gap: 10px; }
dialog label { font-size: .85rem; color: var(--muted); display: grid; gap: 5px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 14px; }
.picker-results { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.picker-results .item { padding: 6px 8px; }
/* пересылка: кружок у чата — выбрать несколько, внизу подпись и «Отправить (N)» */
.muted.small.fwd-hint { margin: 6px 0 0; }
#fwdList .item { cursor: pointer; }
/* «Кому отправить?» — поделились из другого приложения: на телефоне на весь экран, список чатов с отметками,
   внизу карточка — что, кому, подпись и круглая кнопка со счётчиком */
dialog.in-share { max-width: 480px; display: none; padding: 0; overflow: hidden; }
dialog.in-share[open] { display: flex; flex-direction: column; height: min(780px, calc(100dvh - 40px)); }
@media (max-width: 760px) {
  dialog.in-share { max-width: none; width: 100%; margin: 0; border-radius: 0; }
  dialog.in-share[open] { height: 100dvh; max-height: none; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); box-sizing: border-box; }
}
.in-share-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; flex: none; }
.in-share-head h2 { margin: 0; font-size: 1.2rem; }
.in-share-back { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0; background: none; flex: none; }
.in-share-back:hover { background: var(--hover); }
.in-share-back svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.in-share-search { flex: none; margin: 2px 10px 6px; }
.in-share-list { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0 6px 130px; }
.in-share-list .item { cursor: pointer; }
.in-share-list .item.on { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 12px; }
.in-share-none { text-align: center; margin-top: 24px; }
.in-share-check { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 2px solid var(--side);
  display: grid; place-items: center; transform: scale(0); transition: transform .15s; }
.in-share-check svg { width: 13px; height: 13px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.in-share-list .item.on .in-share-check { transform: scale(1); }
.in-share-card { flex: none; margin: -122px 10px 10px; position: relative; background: var(--side); border-radius: 18px; padding: 10px 10px 10px 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.16), 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 8px; }
.in-share-what { display: flex; align-items: center; gap: 10px; min-width: 0; }
.in-share-thumb { position: relative; width: 44px; height: 44px; border-radius: 9px; overflow: hidden; flex: none; background: var(--hover);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--accent); }
.in-share-thumb img, .in-share-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.in-share-thumb svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.in-share-thumb.vid::after { content: ""; position: absolute; left: 50%; top: 50%; margin: -6px 0 0 -3px; border: 6px solid transparent; border-left: 9px solid #fff; border-right: 0; }
.in-share-count { position: absolute; right: 2px; bottom: 2px; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px; box-sizing: border-box;
  background: rgba(0,0,0,.6); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.in-share-label { display: flex; flex-direction: column; min-width: 0; }
.in-share-label b { color: var(--accent); font-weight: 600; }
.in-share-label span { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.in-share-send-row { display: flex; align-items: center; gap: 8px; }
.in-share-cap { flex: 1; min-width: 0; position: relative; }
.in-share-cap .field { width: 100%; margin: 0; border-radius: 20px; padding-right: 44px; box-sizing: border-box; }
.in-share-cap .emoji-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); height: 40px; border-radius: 20px; }
.in-share-send { position: relative; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); flex: none; display: grid; place-items: center; padding: 0; transition: opacity .15s; }
.in-share-send:disabled { opacity: .4; }
.in-share-send svg { width: 22px; height: 22px; fill: #fff; stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; margin-left: -2px; }
.in-share-n { position: absolute; top: -5px; left: -5px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px; box-sizing: border-box;
  background: var(--accent); color: #fff; border: 2px solid var(--side); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
#fwdList .item-name { flex: 1; min-width: 0; }
.fwd-check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; margin-left: auto; padding: 0; }
.fwd-check svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
#fwdList .item.on .fwd-check { background: var(--accent); border-color: var(--accent); }
#fwdList .item.on .fwd-check svg { opacity: 1; }
.fwd-foot { margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--hover); border-radius: 16px; padding: 4px 6px 4px 10px; font-size: .9rem; }
.chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.chip svg { width: 14px; height: 14px; }
.members { list-style: none; margin: 8px 0 12px; padding: 0; max-height: 45vh; overflow-y: auto; }
.members .item { cursor: default; }
.members .item.open { cursor: pointer; }
.members .preview.online { color: var(--accent); }
/* в сети — зелёная точка на аватаре, как в Telegram */
.members .avatar.on::after { content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--side); }
.role { font-size: .78rem; color: var(--accent); }
.small-btn { color: var(--danger); font-size: .88rem; padding: 6px 8px; border-radius: 8px; }
@media (hover: hover) { .small-btn:hover { background: var(--hover); } }
.small-btn.accent { color: var(--accent); }
.member-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; flex: none; max-width: 52%; }

/* ---------- звонок ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: #0d141c; color: #fff; display: flex; flex-direction: column;
           padding: calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 18px); }
.call-top { text-align: center; padding: 6px 0 12px; }
.call-top .cname { font-size: 1.2rem; font-weight: 600; }
.call-top .cstatus { color: #9fb0c0; font-size: .9rem; margin-top: 3px; }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); grid-auto-rows: 1fr; position: relative; }
.tile { position: relative; background: #1b2633; border-radius: 16px; overflow: hidden; display: grid; place-items: center; min-height: 140px; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile video.mirror { transform: scaleX(-1); }
.tile.screen { background: #0b1118; }
.tile.screen video { object-fit: contain; } /* экран целиком, без обрезки */
.call-grid.has-screen .tile:not(.screen) { min-height: 0; }
.cbtn.on { background: var(--accent); color: #fff; }
.tile.has-video .avatar { display: none; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--ok); }
.tile .tname { position: absolute; left: 10px; bottom: 8px; font-size: .85rem; background: rgba(0,0,0,.45); padding: 3px 9px; border-radius: 10px; }
.call-grid[data-count="2"] { grid-template-columns: 1fr; }
.call-grid[data-count="2"] .tile.local { position: absolute; right: 12px; bottom: 12px; width: 26%; max-width: 170px; aspect-ratio: 3/4; min-height: 0; z-index: 2; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
.call-grid[data-count="2"] .tile.local .avatar { width: 56px; height: 56px; font-size: 1.2rem; }
.controls { display: flex; justify-content: center; gap: 22px; padding-top: 18px; }
.cbtn { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; }
.cbtn.off { background: #fff; color: #0d141c; }
.cbtn.lit { background: #fff; color: #0d141c; }
.cbtn.hang { background: var(--danger); }
.cbtn.accept { background: var(--ok); }
.cbtn svg { width: 28px; height: 28px; }
.cbtn.busy { animation: routeBusy .7s ease-in-out infinite alternate; } /* динамик переключается: звук придёт через мгновение */
@keyframes routeBusy { to { box-shadow: 0 0 0 6px rgba(255,255,255,.35); opacity: .75; } }
.incoming { justify-content: space-between; align-items: center; text-align: center; padding-top: 12vh; }
.incoming .avatar { margin: 0 auto 18px; }
.incoming .cname { font-size: 1.5rem; font-weight: 600; }
.incoming .ckind { color: #9fb0c0; margin-top: 6px; }
.incoming .controls { gap: 70px; padding-bottom: 6vh; }
.incoming .clabel { font-size: .85rem; color: #c6d2dd; margin-top: 8px; }
/* аватарки-фото */
.avatar { background-size: cover; background-position: center; }
.avatar.has-img { color: transparent; }
/* объём аватарок: мягкая тень и тонкая обводка — светлые картинки не сливаются с фоном */
/* объём: аватарки и облачка сообщений — мягкая тень (в тёмной теме глубже) */
:root { --avatar-shadow: 0 2px 6px rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.12), inset 0 0 0 1px rgba(0,0,0,.07);
        --bubble-shadow: 0 1px 2px rgba(0,0,0,.1), 0 3px 8px rgba(0,0,0,.08); }
:root[data-theme="dark"] { --avatar-shadow: 0 2px 7px rgba(0,0,0,.55), 0 1px 2px rgba(0,0,0,.4), inset 0 0 0 1px rgba(255,255,255,.08);
        --bubble-shadow: 0 1px 2px rgba(0,0,0,.35), 0 3px 9px rgba(0,0,0,.28); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --avatar-shadow: 0 2px 7px rgba(0,0,0,.55), 0 1px 2px rgba(0,0,0,.4), inset 0 0 0 1px rgba(255,255,255,.08);
  --bubble-shadow: 0 1px 2px rgba(0,0,0,.35), 0 3px 9px rgba(0,0,0,.28); } }
.avatar { box-shadow: var(--avatar-shadow); }
.avatar.has-img > svg { display: none; }
.avatar-edit { position: relative; border-radius: 50%; }
.avatar-edit .cam { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--side); }
.avatar-edit .cam svg { width: 16px; height: 16px; }
.av-88 { width: 88px; height: 88px; font-size: 2rem; }
.av-28 { width: 28px; height: 28px; font-size: .7rem; }

/* плашка уведомлений / установки */
.auth-hint { margin: 14px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }
.auth-hint.legal-links a, .terms-links a, .legal-row a { color: var(--accent); }
.reg-terms { display: flex !important; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--muted); margin: 4px 0 6px; }
.reg-terms input { width: auto; margin: 3px 0 0; flex: none; }
.reg-terms a { color: var(--accent); }
.legal-row { gap: 18px; justify-content: flex-start; flex-wrap: wrap; font-size: .9rem; }
/* высота окна задана: иначе Safari на iPhone сжимает тело с flex: 1 и прокруткой до нуля — пустое окно с одной кнопкой */
dialog.legal-dialog[open] { height: min(720px, calc(100dvh - 40px)); }
.legal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: -4px -6px 12px; padding: 0 6px; font-size: .93rem; line-height: 1.5; }
.legal-body h1 { font-size: 1.25rem; margin: 0 0 4px; }
.legal-body h2 { font-size: 1.02rem; margin: 18px 0 4px; }
.legal-body h3 { font-size: .95rem; margin: 14px 0 2px; }
.legal-body .lg-date { color: var(--muted); margin-top: 0; }
.legal-body p { color: var(--text); margin: 6px 0; }
.legal-body ul { padding-left: 20px; margin: 6px 0; }
.legal-body a { color: var(--accent); }
.legal-body .lg-wrap { overflow-x: auto; }
.legal-body table { border-collapse: collapse; width: 100%; font-size: .86rem; margin: 6px 0; }
.legal-body td, .legal-body th { border: 1px solid var(--line); padding: 5px 7px; text-align: left; vertical-align: top; }
.banner { margin: 0 10px 8px; padding: 10px 8px 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, var(--side)); display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.banner span { flex: 1; }
.banner-acts { display: flex; gap: 6px; flex: none; }
/* две кнопки (Google Play и APK): текст — строкой во всю ширину, кнопки под ним, крестик — справа сверху */
.banner.two { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; column-gap: 8px; }
.banner.two span { grid-column: 1; grid-row: 1; align-self: center; }
.banner.two #bannerClose { grid-column: 2; grid-row: 1; }
.banner.two .banner-acts { grid-column: 1 / -1; grid-row: 2; display: flex; gap: 6px; }
.btn.small { padding: 7px 12px; font-size: .88rem; }
/* «Завод залов»: кнопки вместо поля ввода, шторка с формами, карточка итога */
.srv-panel { background: var(--head); padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; border-top: 1px solid var(--line); }
.srv-left { font-size: .8rem; color: var(--muted); min-height: 1em; }
.srv-acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.srv-acts button { min-height: 52px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); font-weight: 600; font-size: .85rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.srv-acts button.main { background: var(--accent); color: var(--accent-text); }
.srv-acts svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.srv-acts button:not(.main) svg { stroke: var(--accent); }
dialog.srv-sheet { max-width: 480px; padding: 16px 18px 18px; }
dialog.srv-sheet.in-chat { margin: 0; inset: auto; transform: translate(-50%, -50%); width: min(480px, calc(100vw - 28px)); }
.srv-sheet .field { outline: none; color: var(--text); font-weight: 600; }
.srv-sheet .field::placeholder { color: var(--muted); opacity: .55; font-weight: 400; }
.srv-sheet .field:focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
@media (max-width: 760px) { dialog.srv-sheet { margin: auto 0 0; width: 100%; max-width: none; border-radius: 18px 18px 0 0; max-height: 92dvh; padding-bottom: calc(18px + env(safe-area-inset-bottom)); } }
/* на телефоне лист прижат к низу — оттуда и выезжает (как в iOS), а не проявляется из центра */
@keyframes sheetUp { from { translate: 0 100%; } }
@media (max-width: 760px) { dialog.srv-sheet[open] { animation: sheetUp .4s cubic-bezier(.32, .72, 0, 1); } }
.srv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.srv-head h2 { margin: 0; }
.srv-body { display: grid; gap: 12px; max-height: min(62dvh, 560px); overflow: auto; padding: 2px 0; }
.srv-foot { display: grid; gap: 8px; margin-top: 12px; }
.srv-foot:empty { display: none; }
.srv-field { display: grid; gap: 8px; }
.srv-sug-wrap { position: relative; }
.srv-sug { margin-top: 6px; background: var(--side); border: 1px solid var(--line); border-radius: 12px;
           box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 240px; overflow: auto; padding: 4px; }
.srv-item.srv-sug-wrap { flex-wrap: wrap; }
.srv-item.srv-sug-wrap .srv-sug { flex-basis: 100%; }
.srv-sug button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; background: transparent; color: var(--text);
                  font-family: ui-monospace, monospace; font-size: .95rem; }
.srv-sug button:focus-visible { background: var(--hover); }
@media (hover: hover) { .srv-sug button:hover { background: var(--hover); } }
.srv-sug b { color: var(--accent); }
.srv-sheet label { font-size: .85rem; color: var(--muted); display: grid; gap: 6px; }
.srv-path { background: color-mix(in srgb, var(--accent) 9%, var(--side)); border-radius: 12px; padding: 9px 12px; display: grid; gap: 4px; font-size: .92rem; overflow-wrap: anywhere; }
.srv-path small { color: var(--muted); font-size: .8rem; }
.srv-err { color: var(--danger); font-size: .86rem; }
.srv-steps { border: 1px solid var(--line); border-radius: 12px; }
.srv-step { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; }
.srv-step + .srv-step { border-top: 1px solid var(--line); }
.srv-step .stp { display: flex; align-items: center; gap: 10px; }
.srv-step button { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--side); color: var(--text); font-size: 1.25rem; }
.srv-step button:disabled { opacity: .35; }
.srv-step b { min-width: 22px; text-align: center; font-size: 1.1rem; display: inline-block; }
.srv-step b.bump { animation: srv-bump .18s ease-out; }
@keyframes srv-bump { 40% { transform: scale(1.35); color: var(--accent); } }
.srv-step.srv-fold { max-height: 64px; overflow: hidden; transition: max-height .22s ease, opacity .18s ease, padding .22s ease, border-color .22s ease; }
.srv-step.srv-fold.shut { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; border-top-color: transparent; }
dialog.srv-sheet.tall[open] { display: flex; flex-direction: column; height: min(640px, calc(100dvh - 40px)); }
dialog.srv-sheet.tall .srv-body { flex: 1; max-height: none; align-content: start; }
@media (max-width: 760px) { dialog.srv-sheet.tall[open] { height: 88dvh; } }
@media (prefers-reduced-motion: reduce) { .srv-step b.bump { animation: none; } .srv-step.srv-fold { transition: none; } }
.srv-preview { display: grid; gap: 6px; }
.srv-preview:empty { display: none; }
.srv-pre { font-family: ui-monospace, monospace; font-size: .84rem; line-height: 1.55; background: var(--hover); border-radius: 10px; padding: 9px 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.srv-go { width: 100%; min-height: 50px; font-size: 1rem; }
.srv-items { border: 1px solid var(--line); border-radius: 12px; }
.srv-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; }
.srv-item + .srv-item { border-top: 1px solid var(--line); }
.srv-item .field { border: 0; padding: 8px 2px; }
.srv-item .st { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.srv-item .st.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.srv-item .st.bad { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.srv-item .st.wait { background: var(--hover); color: var(--muted); }
.srv-item .im { flex: 1; min-width: 0; display: grid; gap: 1px; }
.srv-item small { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.srv-item.bad small { color: var(--danger); }
.srv-card { display: grid; gap: 8px; white-space: normal; }
/* API чата: сообщения от программ и окно ключей */
.msg.api-msg { border-left: 3px solid var(--accent); }
.msg .who.api { color: var(--accent); }
dialog.api-dialog { max-width: 560px; }
.api-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.api-new { display: flex !important; gap: 8px; margin: 12px 0 0; }
.api-new .field { flex: 1; min-width: 0; }
.api-new.hidden { display: none !important; }
.api-key { margin-top: 12px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 8%, var(--side)); display: grid; gap: 10px; }
.api-copy { display: grid; gap: 4px; }
.api-line { display: flex; gap: 8px; align-items: flex-start; }
.api-line code { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: .8rem; background: var(--side); border: 1px solid var(--line);
                 border-radius: 8px; padding: 7px 9px; overflow-wrap: anywhere; white-space: pre-wrap; user-select: all; }
.api-note { margin: 12px 0 0 !important; }
/* чат с «Заводом»: писать туда нельзя — итоги лентой по центру, без хвостика облачка */
#messages.srv-feed .msg { align-self: center; width: min(560px, 100%); max-width: 100%; box-sizing: border-box; padding: 12px 14px;
  border-radius: 14px; margin-top: 10px; }
#messages.srv-feed .msg.cont { margin-top: 10px; }
#messages.srv-feed .msg .who { display: none; }
.srv-card .ttl { font-weight: 700; }
.srv-card .mono { font-family: ui-monospace, monospace; }
.srv-card .btn.small { padding: 6px 8px; }
.srv-sec { font-family: ui-monospace, monospace; }
.banner .icon-btn { width: 32px; height: 32px; }
.banner .icon-btn svg { width: 18px; height: 18px; }

/* настройки */
.panel { position: absolute; inset: 0; z-index: 15; background: var(--side); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; min-height: 58px; font-size: 1.1rem; }
/* панели (настройки и т. п.) прокручиваются только по вертикали: на телефоне лишний пиксель ширины у любого элемента
   давал таскать весь экран пальцем вбок */
.panel-body { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; padding: 4px 18px 30px; }
.panel-body h3 { font-size: .9rem; color: var(--accent); margin: 26px 0 10px; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0 0; text-align: center; }
.profile small { color: var(--muted); display: block; }
.link { color: var(--accent); font-size: .9rem; }
.link.danger { color: var(--danger); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: default; }
.set-row small { color: var(--muted); font-size: .8rem; display: block; margin-top: 2px; line-height: 1.35; }
/* настройки: каждый раздел — карточка с цветным значком (собирает groupSettings) */
.panel-body .set-card { background: color-mix(in srgb, var(--text) 3.5%, var(--side)); border-radius: 14px; padding: 2px 14px 4px; margin: 14px 0; }
.panel-body .set-card > h3 { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; font-size: 1rem; color: var(--text); }
.set-card > h3 .sic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; }
.set-card > h3 .sic svg { width: 17px; height: 17px; }
.set-card .set-row { border-bottom-color: color-mix(in srgb, var(--text) 8%, transparent); }
.set-card .set-row:last-child, .set-card .set-row:has(+ :not(.set-row)) { border-bottom: 0; }
#passkeyList .set-row.set-row { border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent); } /* ключи — в своём блоке, а под ними «Добавить»: черта и под последним */
.set-card .set-form { padding-bottom: 10px; }
.set-danger { padding: 4px 0 10px; } /* «Удалить аккаунт» — последняя в карточке: отступ снизу, как у «Сохранить имя» */
.set-card .members { margin: 0 -6px 4px; }
.set-foot { margin-top: 18px; }
.bot-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: .7rem; font-weight: 600; vertical-align: 2px;
           background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.item.active .bot-tag { background: rgba(255,255,255,.25); color: #fff; }
#botsList .item { cursor: default; }
#botsList .btn { flex: none; }
.set-card .members > li:last-child { border-bottom: 0; }
.set-intro { color: var(--muted); font-size: .82rem; line-height: 1.4; margin: 0 0 6px; }
.set-sub { font-size: .95rem; margin: 16px 0 2px; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent); }
/* «Данные и память»: сколько занято — общая цифра, полоска по видам и строки с «Очистить» (renderCacheInfo в 10-panels.js) */
.su-head { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 8px; }
.su-head b { font-size: 1.5rem; }
.su-head small { color: var(--muted); }
.su-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: color-mix(in srgb, var(--text) 8%, transparent); margin-bottom: 4px; }
.su-bar span { height: 100%; min-width: 2px; }
.su-row .su-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.su-row small { margin-left: 18px; }
.set-row small.set-state { color: var(--ok); font-weight: 600; margin-top: 5px; }
.set-row small.set-state.warn-text { color: var(--danger); }
a.btn { text-decoration: none; }
.set-row .dev-select { max-width: 52%; min-width: 0; text-overflow: ellipsis; }
.set-row select { flex: none; max-width: 55%; } /* длинное описание слева не сжимает список до «6 m…» (у устройств — до 52%, с многоточием) */
.set-row .grow { flex: 1; min-width: 0; }
.mic-meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; max-width: 220px; }
.mic-meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
#micTestHint { margin-top: 6px; }
.set-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.set-row > .btn, .set-acts .btn { flex: none; white-space: nowrap; }
.set-row.stack { flex-direction: column; align-items: stretch; gap: 8px; } /* описание во всю ширину, кнопки под ним */
.set-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; } /* к правому краю, как кнопки остальных строк */ /* кнопка не переносится ("Google Play" в две строки) — переносится текст слева */
.set-form { display: grid; gap: 10px; }
.set-form label { font-size: .85rem; color: var(--muted); display: grid; gap: 5px; }
.muted.small { color: var(--muted); font-size: .82rem; line-height: 1.45; margin: 22px 0 0; }

/* меню сообщения */
.ctx { position: fixed; z-index: 40; background: var(--side); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.22); padding: 6px; min-width: 190px; }
.ctx-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 8px; text-align: left; }
@media (hover: hover) { .ctx-list button:hover { background: var(--hover); } }
.ctx-list button.danger { color: var(--danger); }
.ctx-list svg { width: 19px; height: 19px; color: var(--muted); }
.ctx-list button.danger svg { color: var(--danger); }
/* реакции: ряд в меню сообщения и значки под сообщением */
.ctx .ctx-reacts { display: flex; gap: 1px; padding: 0 0 5px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.ctx .ctx-reacts button { width: 36px; height: 36px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 22px; line-height: 1;
                          font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; transition: transform .1s; }
@media (hover: hover) { .ctx .ctx-reacts button:hover { transform: scale(1.18); background: var(--hover); } }
.ctx .ctx-reacts button.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.ctx .ctx-reacts button.more svg { width: 20px; height: 20px; color: var(--muted); }
.ctx-dim { display: none; }
/* на телефоне — как в Telegram: фон размыт, сообщение приподнято, реакции над ним, меню под ним.
   Сообщение — копия (.ctx-bubble), настоящее на это время скрыто (.lifted). Анимации — в liftOpen/liftClose */
@media (hover: none) {
  .msg { transition: scale .2s ease; }
  .msg.pressing { scale: .96; transition-duration: .35s; }
}
.msg.lifted { visibility: hidden; }
.ctx.lift, .ctx.lift:not(.hidden) { inset: 0; padding: 0; min-width: 0; background: none; box-shadow: none; border-radius: 0; animation: none; }
.ctx.lift .ctx-dim { display: block; position: absolute; inset: 0; background: var(--pill); touch-action: none;
                     -webkit-backdrop-filter: blur(14px) saturate(1.15); backdrop-filter: blur(14px) saturate(1.15); }
.ctx-bubble { position: absolute; display: flex; flex-direction: column; transform-origin: center; }
.ctx-bubble.scroll { overflow-y: auto; overscroll-behavior: contain; border-radius: 14px; }
.ctx-bubble.scroll .mav { display: none; }
.ctx .ctx-bubble > .msg { margin: 0; max-width: none; width: 100%; align-self: stretch; box-shadow: 0 6px 24px rgba(0,0,0,.18), var(--bubble-shadow);
                          -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.ctx.hold .ctx-bubble, .ctx.hold .ctx-bubble * { -webkit-user-select: none !important; user-select: none !important; -webkit-touch-callout: none !important; }
.ctx.lift .ctx-list, .ctx.lift .ctx-reacts { position: absolute; border-radius: 16px; box-shadow: 0 10px 34px rgba(0,0,0,.25);
    background: color-mix(in srgb, var(--side) 92%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.ctx.lift .ctx-list { min-width: 230px; max-width: calc(100vw - 24px); padding: 6px; overflow-y: auto; overscroll-behavior: contain; }
.ctx.lift .ctx-list button { padding: 11px 14px; gap: 14px; font-size: 1.02rem; border-radius: 10px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ctx.lift .ctx-list button.hot, .ctx.lift .ctx-list button:active { background: var(--hover); }
.ctx.lift .ctx-list svg { width: 21px; height: 21px; }
/* 8 реакций и «+» помещаются в ширину экрана целиком: на узком телефоне кнопки мельче, а не обрезаются рамкой;
   рамка не обрезает и увеличенную под пальцем реакцию */
.ctx.lift .ctx-reacts { --rb: min(39px, calc((100vw - 28px) / 9)); padding: 4px 6px; margin: 0; border: 0; border-radius: 999px; gap: 0; max-width: calc(100vw - 16px); }
.ctx.lift .ctx-reacts button { flex: none; width: var(--rb); height: var(--rb); font-size: calc(var(--rb) * .68); animation: ctxReactIn .32s cubic-bezier(.3, 1.5, .5, 1) backwards;
                               animation-delay: calc(40ms + var(--i, 0) * 22ms); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ctx.lift .ctx-reacts button.hot { transform: scale(1.25); background: var(--hover); }
@keyframes ctxReactIn { from { opacity: 0; transform: scale(.3); } }
@media (prefers-reduced-motion: reduce) { .ctx.lift .ctx-reacts button { animation: none; } }
.reacts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px; margin-top: 5px; white-space: normal; }
.rc { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 5px; border-radius: 13px; font-size: .8rem; font-weight: 700; line-height: 1.6;
      background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.rc .rc-e { font-size: 1.05rem; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.rc.mine { background: var(--accent); color: #fff; }
.msg.mine .rc { background: color-mix(in srgb, var(--meta-mine) 20%, transparent); color: var(--meta-mine); }
.msg.mine .rc.mine { background: var(--meta-mine); color: var(--mine); }
.rc.pending { opacity: .6; }
.reacts .meta { float: none; margin: 0 0 -3px auto; padding-left: 8px; }
.msg .fwd { font-size: .82rem; color: var(--accent); margin-bottom: 2px; font-style: italic; }
.msg.mine .fwd { color: var(--meta-mine); }
.msg.selected { outline: 2px solid var(--accent); }
/* выбор нескольких сообщений: кружок слева сверху у каждого, отмеченные — с галочкой и рамкой */
.sel-bar { position: absolute; inset: 0; z-index: 22; display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 4px; background: var(--head); }
.sel-bar b { flex: 1; min-width: 0; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.sel-bar .btn.small { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; }
.sel-bar .btn svg { width: 18px; height: 18px; }
.sel-bar #selDelete { color: var(--danger); }
.sel-bar .btn:disabled { opacity: .35; }
/* как в Telegram: лента сдвигается влево, справа — колонка кружков, выбранная строка подсвечена целиком.
   Лента — контейнер (container-type), 100cqw — ширина её содержимого: так кружки встают в одну колонку
   и у левых, и у правых пузырей. --ml — отступ под аватарку слева у сообщений в группе */
#messages.picking { --pr: calc(var(--pl) + 40px); }
#messages.picking .msg[data-id] { cursor: pointer; -webkit-user-select: none; user-select: none; z-index: 0; }
#messages.picking .msg.with-av { --ml: 32px; }
#messages.picking .msg[data-id]::before { content: ""; position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    left: calc(100cqw + 9px - var(--ml, 0px)); width: 22px; height: 22px; border-radius: 50%; box-sizing: border-box;
    border: 2px solid var(--muted); background: var(--side); }
#messages.picking .msg.mine[data-id]::before { left: calc(100% + 9px); }
#messages.picking .msg.picked::after { content: ""; position: absolute; z-index: -1; top: -1px; bottom: -1px; pointer-events: none; /* стык в стык у соседних */
    left: calc(-1 * (var(--ml, 0px) + var(--pl))); width: calc(100cqw + 2 * var(--pl) + 40px);
    background: color-mix(in srgb, var(--accent) 16%, transparent); }
#messages.picking .msg.mine.picked::after { left: calc(100% - 100cqw - var(--pl)); }
#messages.picking .msg.picked::before { border-color: var(--accent); background: var(--accent) no-repeat center / 14px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
/* свайп влево на телефоне — «Ответить»: стрелка выезжает справа от сообщения */
.msg .swipe-ic { position: absolute; right: -44px; top: 50%; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%;
                 background: var(--pill); color: #fff; display: grid; place-items: center; opacity: var(--sw, 0); transform: scale(calc(.6 + var(--sw, 0) * .4)); }
.msg .swipe-ic svg { width: 18px; height: 18px; }
.msg.swipe-armed .swipe-ic { background: var(--accent); transform: scale(1.12); transition: transform .25s cubic-bezier(.2, .9, .3, 1.3), background .15s; }
@media (hover: none) { .msg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } }
/* на телефоне долгое нажатие открывает меню — выделять текст можно в отдельном окне */
.sel-text { max-height: 55vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--hover); border-radius: 12px;
            padding: 12px 14px; margin: 8px 0 12px; line-height: 1.45; -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

/* редактирование */
.edit-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px 0; background: var(--head); }
/* вложения над полем ввода: превью, кружок загрузки, крестик */
.attach-tray { display: flex; gap: 8px; padding: 10px 12px 2px; background: var(--head); overflow-x: auto; }
.attach-tray.sending { opacity: .6; pointer-events: none; }
.att { position: relative; flex: none; width: 68px; height: 68px; border-radius: 12px; overflow: hidden; background: var(--hover); display: grid; place-items: center; }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att.image, .att.video { cursor: zoom-in; }
.att.doc { width: 170px; display: flex; align-items: center; gap: 8px; padding: 8px 26px 8px 10px; }
.att.doc .ficon { flex: none; }
.att-name { min-width: 0; display: grid; font-size: .8rem; line-height: 1.25; text-align: left; }
.att-name b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-name small { color: var(--muted); }
.att-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%;
            background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; pointer-events: none; }
.att-play svg { width: 13px; height: 13px; fill: currentColor; stroke: none; margin-left: 2px; }
.att-wait { position: absolute; inset: 0; background: rgba(0,0,0,.38); display: grid; place-items: center; }
.att.doc .att-wait { inset: auto; left: 8px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%; background: var(--accent); }
.att.doc .att-wait .ring { width: 28px; height: 28px; }
.att .ring { width: 34px; height: 34px; transform: rotate(-90deg); }
.att .ring circle { fill: none; stroke-width: 3; }
.att .ring .bg { stroke: rgba(255,255,255,.3); }
.att .ring .fg { stroke: #fff; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 75; transition: stroke-dashoffset .25s; }
.att.wait .ring, .att.encrypting .ring, .att.compress .ring { animation: attSpin 1s linear infinite; }
.att-q { position: absolute; left: 3px; bottom: 3px; z-index: 2; font-size: .66rem; font-weight: 700; line-height: 1; padding: 4px 5px;
         border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; }
.att-q.orig { background: var(--accent); }
@keyframes attSpin { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
.att-retry { position: absolute; inset: 0; background: rgba(229,72,77,.55); color: #fff; font-size: 1.4rem; font-weight: 700; }
.att-rm { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff;
          display: grid; place-items: center; z-index: 2; }
.att-rm svg { width: 12px; height: 12px; stroke-width: 2.6; }
@media (hover: hover) { .att-rm:hover { background: var(--danger); } }
/* несколько фото и видео в сообщении — плиткой */
.album { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; width: min(340px, 64vw); border-radius: 10px; overflow: hidden; margin-top: 2px; }
.album.n3 .al-tile:first-child { grid-column: span 2; aspect-ratio: 2; }
.al-tile { position: relative; aspect-ratio: 1; background: #10171f center / cover no-repeat; cursor: zoom-in; }
.al-tile.loading { background-color: var(--hover); }
.al-tile.broken { display: grid; place-items: center; }
/* номер файла в чате «#15» (03-chats.js, fnoBadge): в правом нижнем углу картинки, видео и плитки альбома; у документа — после размера */
.fno-host { position: relative; }
.fno { position: absolute; right: 6px; bottom: 6px; z-index: 1; font-size: .72rem; line-height: 1.5; color: #fff; background: rgba(0,0,0,.5);
       padding: 0 6px; border-radius: 8px; font-variant-numeric: tabular-nums; cursor: pointer; -webkit-user-select: none; user-select: none; }
.fno:empty { display: none; }
.vtile .fno { right: 8px; bottom: 8px; }
.fno.doc { position: static; background: none; color: inherit; padding: 0; margin-left: 6px; }
.fno.doc::before { content: "· "; }
.fref { color: var(--accent); cursor: pointer; font-variant-numeric: tabular-nums; }
.msg.mine .fref { color: var(--link-mine); }
@media (hover: hover) { .fref:hover, .fno:hover { text-decoration: underline; } }
.al-dur { position: absolute; left: 6px; bottom: 6px; font-size: .74rem; color: #fff; background: rgba(0,0,0,.55); padding: 1px 6px; border-radius: 8px; }
.files-body .file + .file, .files-body .album + div { margin-top: 6px; }
.msg .caption { margin-top: 5px; }
/* разметка текста */
.msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.md-ic { font: .88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: rgba(127,127,127,.16); padding: 1px 5px; border-radius: 5px; }
.md-code { position: relative; margin: 4px 0; background: rgba(127,127,127,.13); border-radius: 9px; min-width: 0; }
.md-code pre { margin: 0; padding: 25px 11px 9px; overflow-x: auto; white-space: pre; font: .84em/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.md-code .md-lang { position: absolute; left: 11px; top: 4px; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.md-copy { position: absolute; right: 6px; top: 4px; font-size: .72rem; padding: 2px 8px; border-radius: 6px; background: rgba(127,127,127,.2); color: inherit; opacity: .75; }
@media (hover: hover) { .md-copy:hover { opacity: 1; } }
.md-table { overflow-x: auto; margin: 4px 0; max-width: 100%; }
.md-table table { border-collapse: collapse; font-size: .92em; white-space: normal; }
.md-table th, .md-table td { border: 1px solid rgba(127,127,127,.35); padding: 4px 8px; text-align: left; vertical-align: top; }
.md-table th { background: rgba(127,127,127,.12); font-weight: 600; }
.md-h { font-weight: 700; margin: 4px 0 2px; }
.md-h1 { font-size: 1.22em; } .md-h2 { font-size: 1.12em; } .md-h3 { font-size: 1.04em; }
.md-quote { border-left: 3px solid currentColor; opacity: .85; padding-left: 9px; margin: 3px 0; }
.md-list { margin: 3px 0; padding-left: 22px; white-space: normal; }
.md-list li { white-space: pre-wrap; }
.md-list li + li { margin-top: 1px; }
.edit-bar .eb-line { width: 3px; align-self: stretch; background: var(--accent); border-radius: 2px; }
.edit-bar .eb-text { flex: 1; min-width: 0; font-size: .88rem; }
.edit-bar .eb-text b { color: var(--accent); display: block; font-size: .82rem; }
.edit-bar .eb-text span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

/* информация о группе: как раньше (фото, название, участники, кнопки), но плотнее; длинное название — в несколько строк */
dialog.group-info { padding: 16px 16px 14px; }
.ginfo { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 6px; }
.ginfo .avatar-edit .cam { width: 26px; height: 26px; }
.ginfo .avatar-edit .cam svg { width: 14px; height: 14px; }
.ginfo .gtitle { font-size: 1.1rem; font-weight: 600; line-height: 1.3; text-align: center; overflow-wrap: anywhere; }
.ginfo .link { font-size: .85rem; }
.rename { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
.rename .field { flex: 1; min-width: 0; resize: none; overflow: hidden; line-height: 1.3; padding: 8px 11px; font-weight: 600; }
.rename .btn { padding: 9px 12px; font-size: .92rem; flex: none; }
.group-info h2 { font-size: 1rem; margin: 10px 0 6px; }
.group-info .members { margin: 6px -6px 6px; }
.group-info .members .item { padding: 6px; gap: 10px; }
.group-info .error:empty { display: none; }
.group-info .row { margin-top: 8px; gap: 4px; }
.group-info .row .btn { padding: 9px 12px; font-size: .92rem; }
.av-64 { width: 64px; height: 64px; font-size: 1.45rem; }
@media (max-width: 760px) {
  dialog.group-info { width: calc(100% - 16px); padding: 14px 12px 12px; }
  .ginfo .av-64 { width: 56px; height: 56px; font-size: 1.3rem; }
  .ginfo .gtitle { font-size: 1.04rem; }
  .rename .field { font-size: max(16px, 1rem); } /* меньше 16px — iPhone увеличивает страницу при вводе */
  .group-info .members { max-height: 50dvh; }
  .group-info .member-acts .small-btn { font-size: .8rem; padding: 5px 6px; }
  .group-info .row { flex-wrap: nowrap; gap: 0; }
  .group-info .row .btn { padding: 8px 8px; font-size: .86rem; white-space: nowrap; }
  .group-info .row .btn:last-child { margin-left: 4px; }
}

/* анимации звонка */
.pulse { position: relative; width: 110px; height: 110px; margin: 22px auto 20px; }
.pulse .avatar { position: relative; z-index: 1; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); animation: ring 2.2s ease-out infinite; }
.pulse::after { animation-delay: 1.1s; }
@keyframes ring { from { transform: scale(1); opacity: .85; } to { transform: scale(2.1); opacity: 0; } }
.wiggle { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%, 55%, 100% { transform: rotate(0); } 8%, 24%, 40% { transform: rotate(-16deg); } 16%, 32%, 48% { transform: rotate(16deg); } }
.in-label { color: #9fb0c0; font-size: .95rem; letter-spacing: .01em; }
.call-wait { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.call-wait .cw-text { color: #9fb0c0; }
/* исходящий видеовызов, пока не ответили: своя камера на весь экран под затемнением, поверх — аватар и «Видеовызов…» */
#callView.previewing .call-grid { position: absolute; inset: 0; z-index: 0; display: block; }
#callView.previewing .call-grid:not(:has(.tile.local.has-video)) { display: none; }
#callView.previewing .call-grid .tile.local { position: absolute; inset: 0; border-radius: 0; min-height: 0; }
#callView.previewing .call-grid .tile .tname { display: none; }
#callView.previewing .call-grid::after { content: ""; position: absolute; inset: 0; background: rgba(8,12,17,.35); }
#callView.previewing .call-head, #callView.previewing .call-wait, #callView.previewing .controls { position: relative; z-index: 1; }
#callView.previewing .call-wait .cw-text { color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.wait-banner { position: absolute; top: calc(env(safe-area-inset-top) + 10px); left: 50%; transform: translateX(-50%); z-index: 5; width: min(420px, calc(100% - 20px));
               background: #24313f; border-radius: 16px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.wait-banner .wb-text { flex: 1; min-width: 0; }
.wait-banner small { color: #9fb0c0; display: block; }
.cbtn.sm { width: 42px; height: 42px; }
.cbtn.sm svg { width: 22px; height: 22px; }
@media (prefers-reduced-motion: reduce) { .pulse::before, .pulse::after, .wiggle { animation: none; } }

.nh-body p { color: var(--text); margin: 0 0 10px; line-height: 1.45; }
.nh-body ol { margin: 0 0 10px; padding-left: 20px; line-height: 1.55; }
.nh-body .hint { color: var(--muted); font-size: .88rem; }
/* поле пароля: глаз, раскладка, Caps Lock */
.pw-wrap { position: relative; display: block; }
.pw-wrap .field { padding-right: 84px; }
.pw-tools { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 2px; }
.pw-lang { font-size: .72rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; letter-spacing: .03em; }
.pw-lang.ru { color: #c26a00; border-color: #e7a64f; }
.pw-eye { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
@media (hover: hover) { .pw-eye:hover { color: var(--accent); background: var(--hover); } }
.pw-eye svg { width: 20px; height: 20px; }
.pw-hint { font-size: .82rem; color: #c26a00; min-height: 0; }
.pw-hint:empty { display: none; }
.audio-unlock.mic-resume { top: 60%; background: var(--danger); }
.audio-unlock { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 6; background: var(--ok); color: #fff;
                font-weight: 600; font-size: 1.05rem; padding: 16px 22px; border-radius: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.45); }
.live-call { color: var(--ok); display: inline-flex; vertical-align: -3px; margin-left: 4px; }
/* трубка в шапке чата, где идёт звонок: зелёная и мягко «дышит» — нажатие подключает к идущему звонку */
#audioCallBtn.live, #audioCallBtn.live:active { background: var(--ok); color: #fff; animation: liveCall 1.8s ease-out infinite; }
@media (hover: hover) { #audioCallBtn.live:hover { background: var(--ok); color: #fff; filter: brightness(1.08); } }
@keyframes liveCall { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } to { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { #audioCallBtn.live { animation: none; } }
.live-call svg { width: 16px; height: 16px; }
.item.active .live-call { color: #fff; }
/* верхняя полоса: свёрнутый звонок или идущий звонок, в который можно войти */
.gbar { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--ok); color: #fff; cursor: pointer; font-size: .93rem; flex: none; }
.gbar .gdot { width: 9px; height: 9px; border-radius: 50%; background: #fff; flex: none; animation: blink 1.4s ease-in-out infinite; }
.gbar span.gtext { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gbar button { background: #fff; color: var(--ok); border-radius: 14px; padding: 5px 13px; font-weight: 700; flex: none; }
/* ---------- встречи по ссылке ---------- */
body.guest-mode #addToCall { display: none !important; }
/* карточка «гость хочет войти»: одна на весь экран, видна и поверх звонка */
.lobby-card { position: relative; z-index: 55; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 10px 0;
              padding: 10px 12px; background: var(--side); color: var(--text); border-radius: 14px; border-left: 4px solid var(--accent);
              box-shadow: 0 6px 24px rgba(0,0,0,.18); flex: none; }
.lobby-card .lc-ic { width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); display: grid; place-items: center; flex: none; }
.lobby-card .lc-ic svg { width: 20px; height: 20px; }
.lobby-card .lc-text { flex: 1; min-width: 150px; cursor: pointer; line-height: 1.3; }
.lobby-card .lc-text b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby-card .lc-text small { display: block; color: var(--muted); font-size: .84rem; }
.lobby-card .lc-btns { display: flex; gap: 8px; margin-left: auto; }
.meet-ic { color: var(--accent); display: inline-flex; vertical-align: -3px; margin-left: 4px; }
.meet-ic svg { width: 16px; height: 16px; }
.meet-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 7px 14px; background: color-mix(in srgb, var(--accent) 12%, var(--head)); font-size: .88rem; position: relative; }
.meet-bar .mb-text { flex: 1; min-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meet-bar .mb-text small { display: block; color: var(--muted); white-space: normal; }
/* гостей может быть много: список выпадает поверх ленты и прокручивается, место под сообщения не съедает */
.meet-lobby { position: absolute; top: calc(100% + 4px); right: 10px; width: min(380px, calc(100% - 20px)); max-height: min(60vh, 420px); overflow-y: auto;
              z-index: 12; background: var(--side); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.22); padding: 6px; display: grid; gap: 2px; }
.meet-lobby .lempty { color: var(--muted); padding: 8px 10px; }
.meet-lobby .lhead { color: var(--muted); font-size: .8rem; font-weight: 600; padding: 6px 10px 2px; }
.meet-lobby .lrow { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border-radius: 8px; }
@media (hover: hover) { .meet-lobby .lrow:hover { background: var(--hover); } }
.meet-lobby .lrow span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* «Передать файл по ссылке» (10-panels.js, xf…) */
.xf-dialog { max-width: 520px; }
.xf-dialog .xf-pick { display: flex; justify-content: center; cursor: pointer; margin-bottom: 12px; }
.xf-dialog.drop { outline: 2px dashed var(--accent); outline-offset: -8px; }
.xf-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; max-height: 55vh; overflow-y: auto; }
.xf-item { background: var(--hover); border-radius: 12px; padding: 10px 12px; }
.xf-name { font-weight: 600; word-break: break-word; }
.xf-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.xf-sub.err { color: var(--danger); }
.xf-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.xf-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.xf-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.xf-acts button { background: none; border: 0; color: var(--accent); font: inherit; font-size: .88rem; padding: 4px 6px; cursor: pointer; border-radius: 8px; }
.xf-acts button:hover { background: var(--side); }
.xf-acts button.danger { color: var(--danger); }
.xf-empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 6px 0; }
/* карточка ссылки на файл в сообщении */
.xf-card { display: flex; gap: 10px; align-items: center; margin-top: 6px; padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, currentColor 8%, transparent); text-decoration: none; color: inherit; max-width: 340px; cursor: pointer; }
.xf-card .xf-ico { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.xf-card .xf-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.xf-card .xf-t { min-width: 0; }
.xf-card .xf-name { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xf-card .xf-sub { font-size: .8rem; opacity: .85; color: inherit; }
.xf-card.gone { cursor: default; opacity: .7; }
.xf-card.gone .xf-ico { background: var(--muted); }
.meet-link { word-break: break-all; background: var(--hover); border-radius: 10px; padding: 10px 12px; font-size: .9rem; -webkit-user-select: all; user-select: all; }
#guest .note { font-size: .82rem; color: var(--muted); margin: 18px 0 0; }
#guest .gstate { margin: 0 0 14px; line-height: 1.45; }
#guest .gbtns { display: grid; gap: 8px; }
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .gbar .gdot { animation: none; } }
.call-head { display: flex; align-items: center; gap: 8px; }
.call-head .call-top { flex: 1; min-width: 0; }
/* кнопки не сжимаются (были овальными на узком телефоне), имя — в строку, статус — не больше двух строк */
.call-head .cbtn { width: 44px; height: 44px; flex: none; }
.call-head .cname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-head .cstatus { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
@media (max-width: 420px) { .call-head { gap: 4px; } .call-head .cbtn { width: 38px; height: 38px; } .call-head .cbtn svg { width: 20px; height: 20px; }
                            .call-head .cstatus { font-size: .85rem; } }
.call-head .cbtn svg { width: 22px; height: 22px; }
.call-head .spacer { width: 44px; }
.out-menu { position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: 8; background: #24313f; border-radius: 14px; padding: 6px; min-width: 240px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.out-menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 9px; color: #fff; text-align: left; }
.out-menu button.on { background: rgba(255,255,255,.12); }
@media (hover: hover) { .out-menu button:hover { background: rgba(255,255,255,.12); } }
.out-menu button.on::after { content: "✓"; margin-left: auto; color: var(--ok); }
/* реакции в звонке: меню, рука на плитке, всплывающие смайлики */
.react-menu { min-width: 0; width: min(330px, calc(100vw - 24px)); }
.react-menu .rm-ico { font-size: 1.3rem; line-height: 1; }
.react-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 4px 0; border-top: 1px solid rgba(255,255,255,.1); border-bottom: 1px solid rgba(255,255,255,.1); margin: 4px 0; }
.out-menu .react-grid button { flex-direction: column; justify-content: center; gap: 2px; padding: 8px 2px; font-size: .68rem; color: rgba(255,255,255,.75); text-align: center; line-height: 1.15; }
.react-grid button b { font-size: 1.7rem; line-height: 1; font-weight: normal; }
.tile .hand { font-size: 1.05rem; margin-right: 4px; }
.tile.hand-up { box-shadow: inset 0 0 0 3px #f5b83d; }
.react-layer { position: absolute; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
.react-fly { position: absolute; bottom: 120px; display: flex; flex-direction: column; align-items: center; animation: reactFly 3.2s cubic-bezier(.2, .7, .3, 1) forwards; }
.react-fly b { font-size: 48px; line-height: 1; font-weight: normal; }
.react-fly.mini b { font-size: 30px; }
.react-fly small { margin-top: 4px; font-size: .74rem; background: rgba(0,0,0,.55); color: #fff; padding: 2px 8px; border-radius: 9px; white-space: nowrap; }
@keyframes reactFly {
  0% { transform: translate(0, 30px) scale(.5); opacity: 0; }
  12% { transform: translate(0, 0) scale(1.15); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(var(--dx, 0), -52vh) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .react-fly { animation-duration: 2.2s; } }
@media (max-width: 420px) { #callView .controls { gap: 9px; } #callView .controls .cbtn { width: 52px; height: 52px; } }
/* рейтинг «кто больше говорит» — под шапкой звонка справа */
.talk-box { position: absolute; top: calc(env(safe-area-inset-top) + 70px); right: 12px; z-index: 7; width: min(320px, calc(100% - 24px));
            max-height: 50vh; display: flex; flex-direction: column; background: rgba(0,0,0,.62); color: #fff; border-radius: 14px;
            -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: uiFade .2s; }
.talk-list { overflow-y: auto; padding: 4px 12px 10px; }
.talk-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 2px 8px; align-items: center; padding: 5px 0; font-size: .88rem; }
.talk-row .tr-place { text-align: center; font-size: .95rem; color: rgba(255,255,255,.6); }
.talk-row .tr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.talk-row .tr-time { color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; font-size: .82rem; }
.talk-row .tr-bar { grid-column: 2 / 4; height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.talk-row .tr-bar i { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width .5s; }
.talk-row.now .tr-name::after { content: " 🎙"; }
/* участники группы в звонке — по нажатию на название, под шапкой слева */
.call-head .cname.link { cursor: pointer; }
.call-head .cname.link::after { content: " ›"; color: rgba(255,255,255,.55); }
.people-box { right: auto; left: 12px; }
.people-sec { padding: 8px 0 2px; font-size: .76rem; color: rgba(255,255,255,.6); }
.people-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: .9rem; }
.people-row .pr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-row.away .avatar { opacity: .55; }
.people-row small { color: rgba(255,255,255,.6); font-size: .78rem; }
.people-row button { color: #fff; padding: 3px 10px; border-radius: 8px; background: var(--ok); font-size: .78rem; }
.people-row button:disabled { opacity: .5; }
.talk-empty { padding: 8px 0 4px; font-size: .85rem; color: rgba(255,255,255,.65); }
.cc-head { display: flex; align-items: center; gap: 6px; padding: 7px 10px 4px 14px; font-size: .78rem; color: rgba(255,255,255,.7); }
.cc-head span { flex: 1; }
.cc-head button { color: #fff; padding: 3px 9px; border-radius: 8px; background: rgba(255,255,255,.13); font-size: .78rem; }
/* на компьютере входящий звонок — карточка в углу, а не весь экран */
@media (min-width: 761px) {
  .overlay.incoming { inset: auto 22px 22px auto; width: 340px; border-radius: 22px; padding: 22px 20px 20px; box-shadow: 0 12px 40px rgba(0,0,0,.45); gap: 8px; }
  .overlay.incoming .pulse { transform: scale(.75); margin: 0 auto; }
  .overlay.incoming .controls { gap: 60px; padding: 12px 0 0; }
  .overlay.incoming .cname { font-size: 1.25rem; }
}
.invite-code { font-size: 2.2rem; font-weight: 700; letter-spacing: .1em; text-align: center; margin: 4px 0 14px; font-variant-numeric: tabular-nums; }
/* «Напомнить…» (10-panels.js, напоминания) */
.remind-when { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.remind-when select { width: auto; flex: none; }
.remind-when #remindDay { flex: 1; min-width: 0; }
#remindText { width: 100%; resize: vertical; font: inherit; margin: 0 0 10px; }
.remind-have .ri { cursor: pointer; }
.remind-scope { margin: 12px 0; }
.remind-list { display: grid; gap: 6px; margin: 0 0 14px; max-height: 50vh; overflow-y: auto; }
.remind-list .ri { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--hover); cursor: pointer; }
.remind-list .ri > span { flex: 1; min-width: 0; }
.remind-list .ri b { display: block; font-weight: 600; font-size: .9rem; }
.remind-list .ri small { display: block; color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remind-list .ri button { color: var(--danger); font-size: .85rem; flex: none; }
.remind-list .empty { color: var(--muted); font-size: .9rem; }
.remind-have { font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
.remind-have div { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.remind-have button { color: var(--danger); font-size: .85rem; }
.meta .rbell { margin-right: 3px; font-size: .8em; cursor: pointer; }
/* сработавшее напоминание — карточкой, как сообщение (на светлой теме белый текст на сером читался плохо) */
.sys.remind { cursor: pointer; background: var(--side); color: var(--text); font-size: .86rem; font-weight: 600; padding: 6px 14px;
              box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.sys.remind.note { cursor: default; }
.sys.ghost { opacity: .55; font-style: italic; font-size: .8em; }
.sys.remind .rq { display: block; font-weight: 400; font-size: .95em; max-width: 340px; margin: 2px auto 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: flex; background: var(--hover); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 9px; font-size: .9rem; color: var(--text); }
.seg button.on { background: var(--side); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; color: var(--accent); }
/* значок группы поверх фото группы */
.avatar { position: relative; }
.gbadge { position: absolute; right: -2px; bottom: -2px; width: 48%; height: 48%; min-width: 20px; min-height: 20px; right: -3px; bottom: -3px; border-radius: 50%;
          background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--side); }
.gbadge svg { width: 62% !important; height: 62% !important; stroke-width: 2.4; }
.item.active .gbadge { border-color: var(--active); }
/* подтверждение входа и блокировка: полноэкранные панели */
/* экраны поверх приложения (подтверждение входа, блокировка, код): высота — видимая часть над клавиатурой,
   содержимое по центру через margin: auto — длинное не обрезается сверху, а прокручивается */
.gate { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100%); z-index: 44; background: var(--side);
        display: flex; padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; }
.gate-box { width: 100%; max-width: 400px; text-align: center; margin: auto; }
body.kb-open .gate { padding-top: 12px; padding-bottom: 12px; }
body.kb-open .gate .gate-icon { display: none; } /* клавиатура открыта — компактнее */
body.kb-open .gate-box h2 { margin-top: 0; font-size: 1.2rem; }
body.kb-open .gate-box p { font-size: .88rem; margin-bottom: 8px; }
body.kb-open .gate .big-code { font-size: 1.9rem; margin: 2px 0 10px; }
.gate-box h2 { margin: 14px 0 8px; font-size: 1.4rem; }
.gate-box p { color: var(--muted); line-height: 1.5; margin: 0 0 14px; }
.gate-box p.gate-lost { color: var(--text); background: var(--hover); border-radius: 12px; padding: 10px 12px; text-align: left; font-size: .9rem; }
.gate-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; margin: 0 auto; }
.gate-icon svg { width: 36px; height: 36px; }
.big-code { font-size: 2.4rem; font-weight: 700; letter-spacing: .1em; margin: 6px 0 18px; font-variant-numeric: tabular-nums; }
.gate-actions { display: grid; gap: 8px; margin-top: 10px; }
.link-danger { color: var(--danger); font-size: .88rem; margin-top: 18px; }
#lockView { z-index: 46; }
.pin-dots { font-size: 1.6rem; letter-spacing: .45em; margin: 18px 0 6px; color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px; justify-content: center; margin: 18px 0 8px; }
.pin-pad button { width: 72px; height: 72px; border-radius: 50%; background: var(--hover); font-size: 1.6rem; font-weight: 600; }
.pin-pad button:active { background: var(--line); }
.key-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: color-mix(in srgb, var(--danger) 14%, var(--head)); font-size: .88rem; }
.key-banner span { flex: 1; }
.key-banner button { background: var(--danger); color: #fff; border-radius: 10px; padding: 7px 12px; font-weight: 600; flex: none; }
.chat-head { position: relative; }
.chat-menu { position: absolute; right: 8px; top: 54px; z-index: 20; background: var(--side); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.2); padding: 6px; min-width: 240px; }
.chat-menu button.danger { color: var(--danger); }
.chat-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 8px; text-align: left; }
@media (hover: hover) { .chat-menu button:hover { background: var(--hover); } }
.chat-menu svg { width: 20px; height: 20px; color: var(--muted); }
.chat-menu button.danger svg { color: var(--danger); }
.device-item { cursor: default; padding: 10px 0; border-bottom: 1px solid var(--line); border-radius: 0; flex-wrap: wrap; }
@media (hover: hover) { .device-item:hover { background: none; } }
.dev-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--hover); color: var(--accent); display: grid; place-items: center; flex: none; }
.dev-ic.archive { color: var(--ok); }
.dev-acts { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.device-item { flex-wrap: wrap; row-gap: 6px; }
.device-item .item-main { flex: 1 1 140px; min-width: 0; }
.device-item .item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn-text { color: var(--danger) !important; }
.recovery-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.25rem; font-weight: 700; letter-spacing: .06em; text-align: center;
                 background: var(--hover); border-radius: 12px; padding: 14px; word-break: break-all; margin: 8px 0 12px; user-select: all; }
.check-row { display: flex; gap: 10px; align-items: center; font-size: .92rem; color: var(--text); margin: 10px 0 0; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.set-row select { font: inherit; padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--input); color: var(--text);
                  min-width: 0; max-width: 60%; text-overflow: ellipsis; } /* длинный пункт не выталкивает список за край карточки */
.progress-toast { bottom: 80px; }
/* переключатель как в iOS */
.set-row input[type=checkbox].switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px;
               background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .2s; margin: 0; }
.set-row input[type=checkbox].switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
                      background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .25s cubic-bezier(.2, .8, .3, 1), width .2s; }
.set-row input[type=checkbox].switch:checked { background: var(--ok); }
.set-row input[type=checkbox].switch:checked::after { transform: translateX(20px); }
/* пока палец на переключателе, ручка вытягивается в сторону хода, как в iOS */
.set-row input[type=checkbox].switch:active:not(:disabled)::after { width: 30px; }
.set-row input[type=checkbox].switch:checked:active:not(:disabled)::after { transform: translateX(14px); }
.set-row input[type=checkbox].switch:disabled { opacity: .45; cursor: default; }
#pinSheet { z-index: 47; }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.text-size { margin-top: 14px; }
.ts-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ts-head small { color: var(--muted); }
.ts-row { display: flex; align-items: center; gap: 12px; }
.ts-row input[type=range] { flex: 1; accent-color: var(--accent); height: 28px; }
.ts-row span { color: var(--muted); font-weight: 600; line-height: 1; }
.ts-preview { margin: 12px 0 6px; padding: 12px 10px; border-radius: 14px; display: flex; flex-direction: column;
              background: var(--wall, radial-gradient(var(--dots) 1.2px, transparent 1.3px) 0 0 / 22px 22px, var(--chat-bg)); }
.wall-head { margin: 16px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.wall-head small { color: var(--muted); }
/* фоны — одна полоса маленьких образцов, листается вбок (пальцем, колесом мыши) */
.wall-grid { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 8px; margin: 0 -4px; scroll-snap-type: x proximity;
             -webkit-overflow-scrolling: touch; }
.wall-sw { flex: none; width: 52px; height: 52px; padding: 0; border-radius: 13px; scroll-snap-align: center;
           box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: transform .12s; }
.wall-sw:active { transform: scale(.94); }
.wall-sw.classic { background: radial-gradient(var(--dots) 1.2px, transparent 1.3px) 0 0 / 10px 10px, #d7e2d2; }
:root[data-theme="dark"] .wall-sw.classic { background-color: #0e1621; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wall-sw.classic { background-color: #0e1621; } }
.wall-sw.on { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--accent); }
.ts-preview .msg { max-width: 85%; }
/* «Фон чата» из меню чата: сетка образцов (как везде, своё фото, обычный, узоры). Затемнение лёгкое — новый фон
   сразу виден за окном; на телефоне окно — шторка снизу, переписка над ней видна */
dialog.chat-wall { max-width: 460px; padding: 14px 14px 16px; display: none; }
dialog.chat-wall[open] { display: flex; flex-direction: column; max-height: min(640px, calc(100dvh - 40px)); }
dialog.chat-wall::backdrop { background: rgba(0,0,0,.18); }
.cw-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; }
.cw-head h2 { margin: 0; }
.cw-head .icon-btn { width: 36px; height: 36px; margin-right: -4px; }
.cw-head .icon-btn svg { width: 20px; height: 20px; }
dialog.chat-wall .cw-note { font-size: .85rem; margin: 2px 0 12px; flex: none; }
.cw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px 8px; overflow-y: auto; min-height: 0;
           margin: 0 -4px; padding: 4px; }
.cw-tile { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cw-sw { display: grid; place-items: center; aspect-ratio: 3 / 4; border-radius: 12px; color: var(--muted);
         box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: transform .12s; }
.cw-sw.classic { background: radial-gradient(var(--dots) 1.2px, transparent 1.3px) 0 0 / 10px 10px, #d7e2d2; }
:root[data-theme="dark"] .cw-sw.classic { background-color: #0e1621; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cw-sw.classic { background-color: #0e1621; } }
.cw-tile.photo .cw-sw.classic { background: var(--hover); }
.cw-tile:active .cw-sw { transform: scale(.95); }
.cw-tile.on .cw-sw { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px var(--accent); }
.cw-cap { font-size: .78rem; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-tile.on .cw-cap { color: var(--accent); font-weight: 600; }
@media (max-width: 760px) {
  dialog.chat-wall { margin: auto 0 0; width: 100%; max-width: none; border-radius: 18px 18px 0 0;
                     padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  dialog.chat-wall[open] { max-height: 58dvh; animation: sheetUp .4s cubic-bezier(.32, .72, 0, 1); }
  .cw-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}
/* панели «Файлы и фото» и «Поиск» поверх переписки */
.chat { position: relative; }
.side-panel { position: absolute; inset: 0; z-index: 16; background: var(--side); display: flex; flex-direction: column; }
.side-panel .panel-head { gap: 8px; }
.side-panel .panel-head b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-panel .panel-head .field { flex: 1; }
.panel-tools { padding: 0 12px 10px; display: grid; gap: 8px; }
.files-list { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.files-list.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; align-content: start; }
/* «Файлы и фото» — окно поверх переписки: фото и видео превью, файлы — значком, по месяцам */
.files-pop { position: absolute; inset: 0; z-index: 16; display: flex; justify-content: center; align-items: flex-start;
             padding: 66px 14px 14px; background: rgba(0,0,0,.28); }
.files-pop:not(.hidden) { animation: uiFade .16s; }
.files-card { width: min(720px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; background: var(--side);
              border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3); animation: uiPop .18s cubic-bezier(.2, .8, .3, 1); transform-origin: top center; }
.files-card .panel-head { min-height: 52px; padding: 8px 8px 8px 16px; }
.files-card .panel-head b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .files-pop { padding: 60px 6px 6px; } }
.files-month { grid-column: 1 / -1; padding: 10px 2px 2px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.files-month:first-child { padding-top: 2px; }
.media-tile, .file-tile { position: relative; overflow: hidden; border-radius: 10px; }
.media-tile.video.thumb { background-size: cover; background-position: center; }
.media-tile.video.thumb svg { width: 38px; height: 38px; padding: 9px; border-radius: 50%; background: rgba(0,0,0,.45); }
.file-tile { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px;
             background: var(--hover); color: var(--text); text-align: center; }
.file-tile .file-ext { width: 40px; height: 40px; border-radius: 9px; font-size: .66rem; }
.file-tile .ft-name { max-width: 100%; font-size: .74rem; line-height: 1.2; overflow: hidden; word-break: break-word;
                      display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.file-tile .ft-size { font-size: .68rem; color: var(--muted); }
.file-tile.gone, .media-tile.gone { opacity: .5; }
@media (hover: hover) { .file-tile:hover, .media-tile:hover { filter: brightness(.96); } }
@media (prefers-reduced-motion: reduce) { .files-pop:not(.hidden), .files-card { animation: none; } }
.media-grid .empty { grid-column: 1 / -1; }
.media-tile { aspect-ratio: 1; background-color: var(--hover); background-size: cover; background-position: center; border-radius: 6px; color: var(--muted); font-size: .8rem; }
.media-tile.gone { display: grid; place-items: center; }
.file-ext { width: 44px; height: 44px; border-radius: 10px; color: #fff; font-weight: 700; font-size: .7rem; display: grid; place-items: center; flex: none; letter-spacing: .02em; }
.file-acts { display: flex; flex: none; }
.file-acts .icon-btn { width: 38px; height: 38px; }
.icon-btn.danger-ic { color: var(--danger); }
.panel-foot { padding: 8px 14px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }
.search-info { padding: 0 18px 6px; color: var(--muted); font-size: .85rem; min-height: 1.2em; }
.search-hit { width: 100%; text-align: left; }
/* «Поиск по чату» — окно поверх переписки, найденное — карточками, как в «Избранном» */
.files-card .pop-search { flex: 1; min-width: 0; margin-right: 4px; }
.files-card .search-info { padding: 0 16px 8px; }
/* «@имя» в поиске по чату: подходящие участники кнопками под полем */
.search-who { display: flex; gap: 6px; overflow-x: auto; padding: 0 14px 8px; scrollbar-width: none; }
.search-who::-webkit-scrollbar { display: none; }
.sw-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 16px;
           background: var(--hover); font-size: .88rem; max-width: 180px; }
.sw-chip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-chip:active { filter: brightness(.92); }
.av-22 { width: 22px; height: 22px; font-size: .55rem; }
.star-card.search-hit { display: block; color: var(--text); font: inherit; }
.star-card .sc-text mark { background: color-mix(in srgb, #f5b301 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.msg.starred .meta::before { content: "★"; color: #f5b301; font-size: .95em; margin-right: 1px; }
.msg.note-card, .msg.mine.note-card { align-self: center; width: min(100%, 720px); max-width: 100%; background: var(--theirs); color: inherit;
          border-radius: 12px; border-left: 3px solid #f0a03c; padding: 8px 12px; }
.msg.note-card .meta { color: var(--muted); }
.msg.note-card .meta .tick { display: none; }
.note-src { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 4px; max-width: 100%;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-src svg { width: 15px; height: 15px; flex: none; }
button.note-src { background: none; border: 0; padding: 0; font: inherit; font-size: .82rem; cursor: pointer; color: var(--accent); text-align: left; }
@media (hover: hover) { button.note-src:hover span { text-decoration: underline; } }
.note-src span { overflow: hidden; text-overflow: ellipsis; }
.note-c { margin-top: 6px; padding: 5px 9px; border-left: 3px solid var(--accent); border-radius: 6px;
          background: color-mix(in srgb, var(--accent) 9%, transparent); font-size: .92em; white-space: pre-wrap; overflow-wrap: anywhere; }
#noteDialog textarea { width: 100%; resize: vertical; font: inherit; }
.note-prev { color: var(--muted); font-size: .9rem; margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere;
             max-height: 4.5em; overflow: hidden; }
.stars-empty { padding: 18px; color: var(--muted); line-height: 1.5; font-size: .92rem; }
.star-hit { cursor: pointer; }
/* «Избранные сообщения» — окно поверх переписки, как «Файлы и фото»: каждое сообщение — карточкой */
.files-card .panel-head .stars-count { flex: none; color: var(--muted); font-size: .85rem; }
.stars-list { flex: 1; overflow-y: auto; display: grid; gap: 8px; align-content: start; padding: 2px 12px 14px; }
.star-card { background: var(--hover); border-radius: 12px; padding: 9px 10px 10px 12px; cursor: pointer; }
@media (hover: hover) { .star-card:hover { filter: brightness(.98); } }
.sc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.sc-head .sc-name { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-head .star-off { width: 30px; height: 30px; margin: -4px -4px -4px 0; }
.sc-head .star-off svg { width: 18px; height: 18px; }
.sc-text { font-size: .93rem; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; overflow: hidden;
           display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; }
.star-card .star-thumbs { margin-top: 8px; }
.star-thumbs { display: flex; gap: 4px; flex: none; }
.star-thumb { width: 52px; height: 52px; border-radius: 8px; background: var(--line) center / cover no-repeat; flex: none; position: relative; }
.star-thumb .att-play { transform: scale(.6); }
.star-off { flex: none; color: #f5b301; }
.star-off svg { fill: currentColor; }
.snippet { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: color-mix(in srgb, var(--accent) 32%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
/* закреплённое сообщение: полоска над лентой; нажатие — к сообщению и к следующему закреплённому */
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 5px 4px 5px 14px; background: var(--head); border-bottom: 1px solid var(--line); cursor: pointer; flex: none; }
.pin-bar .pb-line { width: 3px; align-self: stretch; background: var(--accent); border-radius: 2px; }
.pin-bar .pb-text { flex: 1; min-width: 0; font-size: .88rem; line-height: 1.3; }
.pin-bar .pb-text b { display: block; color: var(--accent); font-size: .8rem; }
.pin-bar .pb-text span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-bar .icon-btn { width: 36px; height: 36px; }
.pin-bar .icon-btn svg { width: 18px; height: 18px; }
/* кнопка «вниз»: видна, когда ленту отлистали вверх; цифра — новые сообщения ниже края экрана */
.to-bottom { position: absolute; right: 14px; bottom: var(--tb-bottom, 76px); z-index: 6; width: 44px; height: 44px; border-radius: 50%;
             background: var(--side); color: var(--muted); box-shadow: 0 2px 10px rgba(0,0,0,.22); display: grid; place-items: center; }
@media (hover: hover) { .to-bottom:hover { color: var(--accent); } }
.to-bottom .tb-count { position: absolute; top: -7px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff;
                       font-size: .72rem; font-weight: 700; line-height: 1.35; min-width: 20px; padding: 1px 6px; border-radius: 10px; text-align: center; }
/* плашка перед первым непрочитанным при открытии чата */
.unread-mark { align-self: stretch; text-align: center; margin: 10px 0 2px; padding: 4px 10px; border-radius: 10px; font-size: .82rem; font-weight: 600;
               color: var(--accent); background: color-mix(in srgb, var(--side) 82%, transparent); }
.msg.flash { animation: flash 2.2s ease; }
@keyframes flash { 0%, 45% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--bubble-shadow); } }
.lightbox { position: fixed; inset: 0; z-index: 48; background: rgba(8,12,17,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
            display: flex; flex-direction: column; color: #fff; animation: lbIn .16s ease; }
@keyframes lbIn { from { opacity: 0; } }
.lb-top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px 14px; }
.lb-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.lb-who > div { min-width: 0; }
.lb-who b { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-who small { display: block; color: rgba(255,255,255,.6); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-count { color: rgba(255,255,255,.7); font-size: .88rem; white-space: nowrap; }
.lb-top .icon-btn { color: #fff; }
@media (hover: hover) { .lb-top .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; } }
.lb-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 0 72px; }
.lb-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lb-media img, .lb-media video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: 0 12px 48px rgba(0,0,0,.55); background: #000; }
.lb-media video { width: min(100%, 1100px); }
/* увеличение фото: двойной клик или касание, колесо, два пальца; увеличенное перетаскивается */
.lb-media img { cursor: zoom-in; touch-action: none; user-select: none; will-change: transform; }
.lightbox.zoomed .lb-stage { overflow: hidden; } /* верхняя полоса с «Закрыть» и подпись остаются видны */
.lightbox.zoomed .lb-media img { cursor: grab; -webkit-user-drag: none; box-shadow: none; border-radius: 0; }
.lightbox.zoomed .lb-media img.dragging { cursor: grabbing; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff;
          display: grid; place-items: center; }
@media (hover: hover) { .lb-nav:hover { background: rgba(255,255,255,.2); } }
.lb-nav.prev { left: 12px; } .lb-nav.next { right: 12px; }
.lb-nav svg { width: 26px; height: 26px; stroke-width: 2.2; }
.lb-spin { position: absolute; width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
           animation: lbSpin .8s linear infinite; pointer-events: none; }
@keyframes lbSpin { to { transform: rotate(360deg); } }
.lb-caption { padding: 10px 16px calc(env(safe-area-inset-bottom) + 14px); text-align: center; font-size: .95rem; max-height: 22vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 760px) { .lb-stage { padding: 0 4px; } .lb-nav { display: none; } .lb-media img, .lb-media video { border-radius: 0; } }
/* телефон: у документа до семи кнопок — подписи «кто и когда» не оставалось места; увеличивают щипком, «−» и «+» не нужны */
@media (max-width: 760px) { .lb-top { gap: 2px; padding-left: 10px; } .lb-who { margin-right: 4px; } }
@media (pointer: coarse) and (hover: none) { #lbZoomOut, #lbZoomIn { display: none; } }
/* документ (PDF, текст) в том же окне: страницы листаются прокруткой, увеличение — своё (браузер страницу не увеличивает) */
.lightbox.doc .lb-stage { padding: 0; align-items: stretch; }
.lightbox.doc .lb-media { display: block; }
.lightbox.doc .lb-count { font-variant-numeric: tabular-nums; }
.doc-view { width: 100%; height: 100%; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y; outline: none;
            padding: 6px 16px calc(env(safe-area-inset-bottom) + 20px); }
.doc-sheet { --z: 1; width: calc(min(100%, 920px) * var(--z)); margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.doc-sheet.text { width: min(100%, 920px); }
.doc-page { width: 100%; background: #fff; box-shadow: 0 6px 28px rgba(0,0,0,.5); border-radius: 2px; overflow: hidden; }
.doc-page canvas { display: block; width: 100%; height: 100%; }
.doc-text { margin: 0; padding: 18px 20px; background: #fff; color: #1b1f24; border-radius: 6px; box-shadow: 0 6px 28px rgba(0,0,0,.5);
            font: calc(13.5px * var(--z)) / 1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
            user-select: text; -webkit-user-select: text; }
.doc-fail { display: grid; justify-items: center; gap: 16px; padding: 48px 16px; text-align: center; color: rgba(255,255,255,.85); }
@media (max-width: 760px) {
  .doc-view { padding-left: 0; padding-right: 0; }
  .doc-sheet { gap: 6px; }
  .doc-page, .doc-text { border-radius: 0; }
  .doc-text { padding: 14px; }
}
/* видео в сообщении: обложка с кнопкой, нажатие открывает плеер */
.vtile { position: relative; display: block; width: min(320px, 64vw); max-height: 360px; aspect-ratio: var(--ar, 16 / 9); border-radius: 10px; margin-top: 2px;
         background: #10171f center / cover no-repeat; cursor: pointer; overflow: hidden; }
.vtile .att-play { width: 52px; height: 52px; }
.vtile .att-play svg { width: 22px; height: 22px; margin-left: 4px; }
.vtile .al-dur { left: 8px; bottom: 8px; }
@media (hover: hover) { .vtile:hover .att-play { background: var(--accent); } }
.drop-zone { position: absolute; inset: 10px; z-index: 17; border: 3px dashed var(--accent); border-radius: 18px;
             background: color-mix(in srgb, var(--accent) 14%, var(--side)); display: grid; place-items: center; text-align: center;
             pointer-events: none; padding: 20px; }
.drop-zone .dz-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; margin: 0 auto 12px; }
.drop-zone .dz-icon svg { width: 36px; height: 36px; }
.drop-zone b { font-size: 1.2rem; display: block; margin-bottom: 4px; }
.drop-zone span { color: var(--muted); }
@media (max-width: 760px) { .chat-head .icon-btn { width: 38px; height: 38px; } .chat-head { gap: 0; padding-left: 4px; } }
/* видео и аудио в переписке */
.media-box { min-width: 220px; max-width: 100%; }
.media-box video { display: block; width: 100%; max-height: 360px; border-radius: 10px; background: #000; margin-top: 2px; }
.media-box audio { display: block; width: 260px; max-width: 100%; margin: 4px 0 2px; }
.play-card { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 4px 0; }
.play-card .play { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.play-card .play svg { width: 22px; height: 22px; fill: currentColor; stroke: none; margin-left: 3px; }
.media-tile.video { background: #1b2633; color: #fff; display: grid; place-items: center; position: relative; }
.media-tile.video svg { width: 34px; height: 34px; fill: currentColor; stroke: none; }
.media-tile.video small { position: absolute; left: 6px; right: 6px; bottom: 5px; font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
/* закреплённые чаты */
.pin-ic { color: var(--muted); display: inline-flex; flex: none; }
.pin-ic svg { width: 15px; height: 15px; transform: rotate(40deg); }
.item.active .pin-ic { color: rgba(255,255,255,.85); }
.list-ctx { position: fixed; z-index: 40; background: var(--side); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.22); padding: 6px; min-width: 210px; }
.list-ctx button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 8px; text-align: left; }
@media (hover: hover) { .list-ctx button:hover { background: var(--hover); } }
.list-ctx svg { width: 19px; height: 19px; color: var(--muted); }
/* «без звука» */
#muteMenu { z-index: 42; min-width: 200px; }
#muteMenu .mm-head { padding: 8px 12px 4px; color: var(--muted); font-size: .8rem; font-weight: 600; }
.mute-ic { color: var(--muted); display: inline-flex; vertical-align: -2px; margin-left: 4px; }
.mute-ic svg { width: 14px; height: 14px; }
.item.active .mute-ic { color: rgba(255,255,255,.8); }
.badge.muted { background: var(--muted); }
.tile .tname { display: inline-flex; align-items: center; gap: 5px; }
.tile .mic-off { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); }
.tile .mic-off svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 2.4; }
.tile .tmenu { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: -5px; border-radius: 50%; color: #fff; flex: none; }
.tile .tmenu:focus-visible { background: rgba(255,255,255,.18); }
@media (hover: hover) { .tile .tmenu:hover { background: rgba(255,255,255,.18); } }
.tile .tmenu svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
/* на весь экран: кнопка на плитке с чужим экраном; двойной клик/касание — на любой плитке с видео */
.tile .tfull { position: absolute; top: 8px; right: 8px; z-index: 2; width: 38px; height: 38px; border-radius: 10px; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; }
.tile .tfull svg { width: 20px; height: 20px; }
@media (hover: hover) { .tile .tfull:hover { background: rgba(0,0,0,.72); } }
/* на весь экран уходит окно звонка: плитка — на всё место, снизу только кнопки звонка */
#callView.tile-full { padding: 0 0 env(safe-area-inset-bottom); background: #000; }
#callView.tile-full .call-head, #callView.tile-full .call-wait { display: none; }
#callView.tile-full .call-grid { display: block; overflow: hidden; }
#callView.tile-full .call-grid > .tile:not(.full) { display: none; }
#callView.tile-full .call-grid .tile.full { position: absolute; inset: 0; width: auto; height: auto; max-width: none; aspect-ratio: auto; min-height: 0; z-index: auto; border-radius: 0; background: #000; box-shadow: none; }
#callView.tile-full .tile.full video { object-fit: contain; transform-origin: 50% 50%; }
#callView.tile-full .tile.full { touch-action: none; } /* щипок и перетаскивание — наши, страница не масштабируется */
#callView.tile-full .tile.full.zoomed video { cursor: grab; }
#callView.tile-full .tile.full.zoomed video.dragging { cursor: grabbing; }
.call-grid .tile.screen { touch-action: pan-x pan-y; } /* щипок по экрану собеседника — развернуть и увеличить его */
#callView.tile-full .controls { padding: 10px 0; }
.call-grid.tiny .tile .tmenu { width: 18px; height: 18px; margin-left: -3px; }
.peer-menu { position: fixed; z-index: 9; background: #24313f; color: #fff; border-radius: 14px; padding: 6px; width: 270px; max-width: calc(100vw - 16px); box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.peer-menu .pm-head { padding: 8px 12px 6px; font-weight: 600; overflow-wrap: anywhere; }
.peer-menu .pm-head small { display: block; font-weight: 400; color: #9fb0c0; margin-top: 1px; }
.peer-menu .pm-vol { padding: 4px 12px 10px; }
.peer-menu .pm-row { display: flex; justify-content: space-between; font-size: .9rem; color: #c9d4de; margin-bottom: 6px; }
.peer-menu .pm-vol input { width: 100%; accent-color: #5aa7f2; }
.peer-menu .pm-vol small { display: block; color: #9fb0c0; font-size: .78rem; margin-top: 4px; }
.peer-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px; border-radius: 9px; color: #fff; font-weight: 600; }
@media (hover: hover) { .peer-menu button:hover:not(:disabled) { background: rgba(255,255,255,.1); } }
.peer-menu button:disabled { opacity: .5; }
.peer-menu button svg { width: 19px; height: 19px; flex: none; }
.peer-menu button.danger { color: #ff6b6b; }
.hang-menu.bot-menu { top: 64px; bottom: auto; left: auto; right: 12px; transform: none; }
.msg .who.bot { font-style: italic; }
.inv-label { font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
.inv-h { font-size: .9rem; color: var(--accent); margin: 20px 0 4px; }
.inv-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.inv-item .inv-code { font-weight: 700; letter-spacing: .05em; font-variant-numeric: tabular-nums; }
.inv-item .item-main { min-width: 0; }
/* групповой звонок: всё помещается над кнопками, кнопки всегда видны */
#callView .controls { flex: none; }
.call-grid.fit .tile { min-height: 0; }
.call-grid.scroll { overflow-y: auto; align-content: start; -webkit-overflow-scrolling: touch; }
.call-grid.dense .tile .avatar { width: 72px !important; height: 72px !important; font-size: 1.6rem !important; }
.call-grid.tiny .tile .avatar { width: 50px !important; height: 50px !important; font-size: 1.15rem !important; }
.call-grid.tiny .tile .tname { font-size: .74rem; left: 6px; bottom: 5px; padding: 2px 7px; max-width: calc(100% - 12px); }
.call-grid.tiny .tile .tname, .call-grid.dense .tile .tname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-grid.tiny .tile .mic-off { width: 16px; height: 16px; flex: none; }
.call-grid.tiny .tile .mic-off svg { width: 10px; height: 10px; }
/* отметки отправки: ✓ отправлено, ✓✓ доставлено, синие ✓✓ прочитано */
.msg .meta .tick { display: inline-flex; }
.msg .meta .tick svg.dbl { width: 20px; stroke-width: 2.2; }
/* в тёмной теме своё облачко синее: доставлено — серые, прочитано — яркие голубые, иначе не различить */
.msg .meta .tick.read { color: var(--tick-read); }
.msg.mine .meta .tick { color: var(--tick-mine); }
.msg.mine .meta .tick.read { color: var(--tick-mine-read); }
.receipt-list { list-style: none; margin: 0; padding: 0; }
.receipt-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.receipt-h { font-size: .85rem; color: var(--muted); margin: 14px 0 2px; display: flex; align-items: center; gap: 6px; }
.receipt-h svg { width: 18px; height: 18px; }
.receipt-h.read { color: var(--tick-read); }
/* группа: мини-аватарки тех, кто дочитал до этого места */
.av-18 { width: 18px; height: 18px; font-size: .5rem; font-weight: 700; }
.seen-row { display: flex; justify-content: flex-end; align-items: center; gap: 2px; margin: 1px 8px 5px; cursor: pointer; align-self: flex-end; }
.seen-row .avatar { box-shadow: 0 0 0 2px var(--chat-bg); transition: transform .15s; }
@media (hover: hover) { .seen-row:hover .avatar { transform: scale(1.15); } }
.seen-row .more { font-size: .7rem; color: var(--muted); margin-left: 3px; }
/* запись звонка: кнопка в шапке и метка «Идёт запись» для всех участников */
#recBtn .rec-core { fill: currentColor; stroke: none; }
#recBtn.on { background: #e5484d; color: #fff; }
.rec-banner { position: absolute; left: 50%; top: 62px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 8px;
              background: rgba(20,28,38,.88); color: #fff; padding: 6px 12px; border-radius: 16px; font-size: .85rem; white-space: nowrap; max-width: 92%; }
.rec-banner span:last-child { overflow: hidden; text-overflow: ellipsis; }
.recb-dot { width: 9px; height: 9px; border-radius: 50%; background: #e5484d; flex: none; animation: recPulse 1.2s ease-in-out infinite; }
@keyframes recPulse { 50% { opacity: .35; } }
.alone-banner { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); z-index: 6; background: rgba(36,49,63,.96);
                border-radius: 14px; padding: 10px 12px 10px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
                font-size: .92rem; width: min(440px, calc(100% - 28px)); }
.alone-banner span { flex: 1; line-height: 1.35; }
.alone-banner button { background: #fff; color: #0d141c; border-radius: 10px; padding: 7px 12px; font-weight: 700; flex: none; }
.hang-menu { position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: 8; background: #24313f; border-radius: 14px; padding: 6px; min-width: 250px; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.hang-menu button { display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: 9px; color: #fff; font-weight: 600; }
@media (hover: hover) { .hang-menu button:hover { background: rgba(255,255,255,.1); } }
.hang-menu button.danger { color: #ff6b6b; }
.hang-menu small { display: block; font-weight: 400; color: #9fb0c0; margin-top: 2px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: rgba(20,28,38,.92); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 60; font-size: .92rem; max-width: 90%; text-align: center; pointer-events: none; } /* не закрывает кнопки под собой (например, микрофон в звонке) */
/* удаление с отменой: круговой отсчёт, текст, «Отменить» */
.undo-toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 61; display: flex; align-items: center; gap: 12px;
              background: rgba(20,28,38,.94); color: #fff; padding: 8px 8px 8px 12px; border-radius: 14px; font-size: .92rem; width: max-content; max-width: min(460px, calc(100% - 28px));
              box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: utIn .2s ease-out; }
@keyframes utIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.ut-ring { position: relative; width: 28px; height: 28px; flex: none; display: grid; place-items: center; }
.ut-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round;
               stroke-dasharray: 62.84; animation: utRing 5s linear forwards; }
@keyframes utRing { to { stroke-dashoffset: 62.84; } }
.ut-ring b { font-size: .85rem; font-variant-numeric: tabular-nums; }
.ut-text { flex: 1; min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.ut-undo { flex: none; color: #7cc4ff; font-weight: 700; padding: 8px 10px; border-radius: 9px; }
@media (hover: hover) { .ut-undo:hover { background: rgba(255,255,255,.1); } }
@media (prefers-reduced-motion: reduce) { .undo-toast, .ut-ring svg { animation: none; } }
#messages.undo-clear > * { visibility: hidden; }

@media (max-width: 760px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .side-resize { display: none; }
  #app.in-chat .side { display: none; }
  #app:not(.in-chat) .chat { display: none; }
  /* свайп вправо по чату — назад: под чатом виден список, чуть сдвинутый и затемнённый */
  #app.swipe-back { position: relative; }
  #app.swipe-back .side { display: flex; position: absolute; inset: 0; transform: translateX(calc((var(--bk, 0) - 1) * 28%)); }
  #app.swipe-back .side::after { content: ""; position: absolute; inset: 0; z-index: 30; pointer-events: none; background: rgba(0,0,0,calc(.3 - .3 * var(--bk, 0))); }
  #app.swipe-back .chat { z-index: 1; box-shadow: -6px 0 24px rgba(0,0,0,.28); }
  #app.swipe-release .side, #app.swipe-release .side::after { transition: transform var(--rel, .2s) cubic-bezier(.2, .8, .3, 1), background var(--rel, .2s) ease-out; }
  #back { display: grid; position: relative; z-index: 1; }
  /* стрелка «назад» ловит нажатие шире, чем видна: на всю высоту шапки и чуть на аватар — промах открывал карточку
     собеседника */
  #back::before { content: ""; position: absolute; inset: -10px -14px -10px -4px; }
  #messages { padding-top: 8px; padding-bottom: 12px; --pl: 4px; }
  .msg { max-width: 86%; }
  .controls { gap: 16px; }
}
/* телефон: список чатов и фильтры крупнее (чат и меню — как есть), пальцем попадать и читать удобнее */
@media (max-width: 760px) {
  .chat-filters { gap: 8px; padding: 4px 10px 10px; }
  .chat-filters button { font-size: .92rem; padding: 7px 14px; border-radius: 18px; }
  .chat-filters .f-seg { border-radius: 18px; }
  .chat-filters .f-seg button { padding: 6px 13px; }
  .chat-filters .f-seg svg { width: 20px; height: 20px; }
  .chat-filters .f-list.compact { padding: 5px 6px; }
  .chat-filters .f-list.compact .lst-tag { width: 26px; height: 26px; font-size: .86rem; border-radius: 8px; }
  .chat-filters .f-sep { height: 22px; }
  :is(#chatList, #inShareList) .item { gap: 14px; padding: 10px 12px; }
  :is(#chatList, #inShareList) .item .av-42 { width: 52px; height: 52px; font-size: 1.12rem; }
  :is(#chatList, #inShareList) .item-name { font-size: 1.12rem; }
  :is(#chatList, #inShareList) .preview { font-size: .94rem; }
  :is(#chatList, #inShareList) .ltime { font-size: .84rem; }
}
/* Телефон: интерфейс чуть крупнее, меню — как меню сообщения (крупные строки) и с затемнением вокруг: белое меню
   на белом фоне сливалось с экраном. Нажатие мимо меню и так только закрывает его (POPUPS) */
@media (max-width: 760px) {
  .menu:not(.hidden), .chat-menu:not(.hidden), .list-ctx:not(.hidden), .ctx:not(.lift):not(.hidden) {
    border-radius: 16px; box-shadow: 0 10px 34px rgba(0,0,0,.25), 0 0 0 100vmax rgba(0,0,0,.32); }
  .menu, .chat-menu { min-width: 250px; }
  .menu button, .chat-menu button, .list-ctx button, .ctx-list button { padding: 12px 14px; gap: 14px; font-size: 1.02rem; border-radius: 10px; }
  .menu svg, .chat-menu svg, .list-ctx svg, .ctx-list svg { width: 22px; height: 22px; }
  .chat-head .icon-btn { width: 42px; height: 42px; }
}
/* Компьютер: полосы прокрутки — как на телефоне: тонкие, полупрозрачные, без стрелок и дорожки. Видны, когда мышь
   над прокручиваемой областью или её листают (.is-scrolling ставит 02-core.js), остальное время не мешают */
:root { --sb-thumb: rgba(0,0,0,.26); --sb-thumb-hover: rgba(0,0,0,.42); --sb-track: rgba(0,0,0,.045); }
:root[data-theme="dark"] { --sb-thumb: rgba(255,255,255,.22); --sb-thumb-hover: rgba(255,255,255,.38); --sb-track: rgba(255,255,255,.05); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sb-thumb: rgba(255,255,255,.22); --sb-thumb-hover: rgba(255,255,255,.38); --sb-track: rgba(255,255,255,.05); } }
@media (hover: hover) and (pointer: fine) {
  ::-webkit-scrollbar { width: 9px; height: 9px; background: transparent; }
  ::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb { background-color: transparent; border: 2px solid transparent; background-clip: padding-box; border-radius: 8px; min-height: 40px; }
  :hover::-webkit-scrollbar-thumb, .is-scrolling::-webkit-scrollbar-thumb { background-color: var(--sb-thumb); }
  /* направляющая — едва заметная, вместе с ползунком */
  :hover::-webkit-scrollbar-track, .is-scrolling::-webkit-scrollbar-track { background-color: var(--sb-track); border: 2px solid transparent; background-clip: padding-box; border-radius: 8px; }
  /* список чатов: место под полосу — всегда (список не сдвигается, когда она появляется), правый отступ — за счёт него:
     слева 7 px, справа 9 px полосы — поровну на глаз */
  #chatList { padding-left: 7px; padding-right: 0; scrollbar-gutter: stable; }
  ::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { background-color: var(--sb-thumb-hover); border-width: 1px; }
  @supports not selector(::-webkit-scrollbar) { /* Firefox: только тонкая полоса и цвет */
    * { scrollbar-width: thin; scrollbar-color: transparent transparent; }
    :hover, .is-scrolling { scrollbar-color: var(--sb-thumb) transparent; }
  }
}
/* настройки как в Telegram: на главной — профиль и список разделов (группами), раздел — своей страницей */
#settings:not([data-page]) .set-card { display: none; }
#settings[data-page] .profile, #settings[data-page] .set-menu, #settings[data-page] .set-foot,
#settings[data-page] .set-card:not(.set-on) { display: none; }
#settings[data-page] .set-card > h3[data-ic] { display: none; } /* название раздела — в заголовке панели */
#settings[data-page] .set-card { margin-top: 6px; }
.set-menu { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 4px; }
.set-group { background: color-mix(in srgb, var(--text) 3.5%, var(--side)); border-radius: 14px; overflow: hidden; }
.set-nav { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 14px; text-align: left; font-size: 1rem; color: var(--text); position: relative; }
.set-nav + .set-nav::before { content: ""; position: absolute; top: 0; left: 56px; right: 0; border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent); }
.set-nav .sic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; }
.set-nav .sic svg { width: 17px; height: 17px; }
.set-nav .sn-name { flex: 1; min-width: 0; }
.set-nav .sn-chev { color: var(--muted); display: grid; }
.set-nav .sn-chev svg { width: 18px; height: 18px; }
@media (hover: hover) { .set-nav:hover { background: var(--hover); } }
.set-nav:active { background: var(--hover); }

/* Метка «стили загрузились целиком» — последней строкой: её проверяет страница (index.html, «стили не загрузились»). */
:root { --css-ok: 1; }
/* удержание: участник ушёл в другой разговор (телефон, другое приложение) */
.tile.on-hold video, .tile.on-hold .avatar { opacity: .45; filter: grayscale(.6); }
.tile .hold { margin-right: 4px; }
.tile .hold-tag { margin-left: 6px; font-size: .78em; opacity: .85; }

/* ================= задачи в группе (js/12-tasks.js) ================= */
.tchip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.tchip.st-new { background: color-mix(in srgb, var(--accent) 16%, transparent); color: color-mix(in srgb, var(--accent) 70%, var(--text)); }
.tchip.st-work { background: color-mix(in srgb, #f08c00 18%, transparent); color: color-mix(in srgb, #b35c00 75%, var(--text)); }
.tchip.st-done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: color-mix(in srgb, #1d6e37 75%, var(--text)); }
.chat-head .icon-btn.head-tasks { width: auto; min-width: 42px; padding: 0 8px; gap: 3px; display: inline-flex; align-items: center; border-radius: 21px; }
.head-tasks svg { flex: none; }
.head-tasks span:empty { display: none; }
.head-tasks span { font-weight: 700; font-size: .85rem; color: var(--accent); }
.head-tasks span.inq-n, #mnuInqN { color: #e8590c; font-weight: 700; } /* открытые обращения с сайта — цвет пометки обращений в списке чатов */
#chatTasksN:not(:empty) + .inq-n:not(:empty) { margin-left: 3px; }
.head-tasks.alert::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: 2px; }
.msg.task-msg { min-width: min(300px, 78vw); }
.task-card { cursor: pointer; display: flex; flex-direction: column; gap: 4px; padding: 2px 0; }
.task-card .tc-head { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--accent); }
.task-card .tc-head b { flex: 1; }
.tc-ic svg, .tc-mi svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.task-card .tc-title { font-weight: 700; font-size: 1.02rem; line-height: 1.3; overflow-wrap: anywhere; }
.task-card.done .tc-title { color: var(--muted); }
.task-card .tc-text { font-size: .92rem; max-height: 7.5em; overflow: hidden; overflow-wrap: anywhere; }
.tc-photos { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.tc-photo { width: 72px; height: 72px; border-radius: 10px; background: var(--hover) center / cover no-repeat; position: relative; overflow: hidden; }
.tk-card .tc-photo, .tk-cm .tc-photo { width: 96px; height: 96px; }
.tc-photo.broken { background-image: none; }
.tc-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font-weight: 700; }
.tc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .84rem; color: var(--muted); }
.tc-meta > * { display: inline-flex; align-items: center; gap: 4px; }
.tc-due.late, .tk-late { color: var(--danger); font-weight: 600; }
.tc-foot { margin-top: 4px; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--muted) 25%, transparent); font-size: .84rem; color: var(--accent); font-weight: 600; }
.sys.link { cursor: pointer; }
.composer #taskBtn { color: var(--accent); }
.tasks-card { height: 100%; }
.tasks-card .panel-head { gap: 6px; flex-wrap: wrap; }
.tasks-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.tk-tabs { flex: 1; min-width: 0; display: flex; gap: 4px; }
.tk-tabs button { padding: 8px 12px; border-radius: 10px; font-weight: 600; color: var(--muted); font-size: .95rem; }
.tk-tabs button.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tk-head-title { flex: 1; }
.tk-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-flt { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); font-size: .86rem; color: var(--text); background: var(--side); }
.tk-flt.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tk-list { display: flex; flex-direction: column; }
.tk-item { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; border-radius: 8px; color: var(--text); }
.tk-item:hover { background: var(--hover); }
.tk-top { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.tk-no { color: var(--muted); }
.tk-title { font-weight: 600; overflow-wrap: anywhere; }
.tk-meta { font-size: .84rem; color: var(--muted); }
.tk-card { background: var(--hover); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.tk-card h4, .tk-comments h4 { margin: 0; font-size: .95rem; }
.tk-h { margin: 4px 0 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.tk-text { overflow-wrap: anywhere; }
.tk-status button.on.st-new { color: var(--accent); }
.tk-status button.on.st-work { color: #b35c00; }
.tk-status button.on.st-done { color: #1d7a3f; }
.tk-status button:disabled { cursor: default; opacity: .75; }
.tk-hint { font-size: .84rem; color: var(--muted); }
.tk-row { display: flex; align-items: center; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: .92rem; flex-wrap: wrap; }
.tk-row .k { width: 96px; flex: none; color: var(--muted); }
.tk-row .tk-sel { width: auto; flex: 1; min-width: 150px; }
.tk-due-edit { flex: 1; min-width: 0; }
.tk-due-edit .remind-when { margin: 0; flex-wrap: wrap; }
.tk-ev { display: flex; gap: 10px; font-size: .86rem; padding: 3px 0; }
.tk-ev span { flex: 1; overflow-wrap: anywhere; }
.tk-ev time { color: var(--muted); white-space: nowrap; }
.tk-comments { display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.tk-cm { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.tk-cm.mine { align-self: flex-end; }
.tk-cm.pending { opacity: .6; }
.tk-cm-av { flex: none; }
.tk-cm-b { background: var(--theirs); border-radius: 14px 14px 14px 4px; padding: 6px 10px; box-shadow: var(--bubble-shadow, 0 1px 2px rgba(0,0,0,.1)); min-width: 80px; overflow-wrap: anywhere; }
.tk-cm.mine .tk-cm-b { background: var(--mine); color: var(--mine-text); border-radius: 14px 14px 4px 14px; }
.tk-cm-n { font-size: .8rem; font-weight: 700; }
.tk-cm-t { font-size: .72rem; color: var(--muted); text-align: right; margin-top: 2px; }
.tk-cm-act { background: none; border: 0; padding: 0 0 0 8px; font: inherit; color: var(--accent); cursor: pointer; }
.tk-cm-act:hover { text-decoration: underline; }
.tk-edit-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 6px; font-size: .85rem; color: var(--accent); }
.tk-edit-bar .icon-btn { width: 28px; height: 28px; }
.tk-composer { position: sticky; bottom: -12px; margin: 0 -12px -12px; padding: 8px 8px 10px; background: var(--side); border-top: 1px solid var(--line); }
.tk-cm-line { display: flex; align-items: flex-end; gap: 4px; }
.tk-cm-line textarea { flex: 1; min-width: 0; resize: none; min-height: 40px; max-height: 120px; border-radius: 20px; padding: 9px 14px; margin: 0; }
.tk-send { color: var(--accent); }
.tk-tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 8px; }
.tk-tile { width: 56px; height: 56px; border-radius: 10px; background: var(--hover) center / cover no-repeat; position: relative; flex: none; }
.tk-tile.big { width: 80px; height: 80px; }
.tk-tile.busy { opacity: .55; }
.tk-tile button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: rgba(23,33,43,.7); color: #fff; display: grid; place-items: center; }
.tk-tile button svg, .tk-add svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.tk-add { width: 80px; height: 80px; border-radius: 10px; border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: .8rem; cursor: pointer; }
.tk-add svg { width: 20px; height: 20px; }
.task-dialog { width: min(480px, calc(100vw - 24px)); }
.task-dialog .field { margin-bottom: 10px; }
.task-dialog textarea { resize: vertical; }
.task-photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.task-lbl { display: block; font-size: .86rem; color: var(--muted); margin-bottom: 4px; }
.task-lbl .field, .task-lbl .remind-when { margin-top: 4px; color: var(--text); }
.task-lbl .remind-when select:first-child { flex: 1; min-width: 0; }
.task-check { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin: 6px 0 4px; }
.task-check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ================= обращения с сайта и настройки виджета (js/12-tasks.js) ================= */
/* в списке чатов: обращения с сайта ждут ответа — оранжевая точка на аватарке и счётчик */
.badge.inq { background: #e8590c; margin-right: 4px; }
.inq-dot { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; background: #e8590c; border: 2px solid var(--side); }
/* «Обращение с сайта #N» в ленте — карточкой: кто, вопрос, статус; ждёт ответа — оранжевая рамка */
.sys.inq-card { display: flex; flex-direction: column; gap: 5px; width: min(380px, 92%); max-width: 92%; text-align: left; padding: 10px 14px 10px;
                background: var(--side); color: var(--text); font-size: .9rem; border-radius: 14px; margin: 8px 0;
                border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--bubble-shadow, 0 1px 3px rgba(0,0,0,.15)); }
.sys.inq-card.waiting { border-color: #f08c00; }
.sys.inq-card.done { border-color: var(--line); }
.inq-head { display: flex; align-items: center; gap: 7px; color: var(--accent); }
.inq-head b { flex: 1; min-width: 0; font-size: 1rem; color: var(--text); overflow-wrap: anywhere; } /* кто пишет — целиком, длинное переносится */
.inq-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.inq-q { color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.inq-foot { display: flex; align-items: center; gap: 10px; padding-top: 6px; border-top: 1px solid var(--line); font-size: .84rem; }
.inq-state { flex: 1; min-width: 0; color: var(--muted); }
.inq-card.waiting .inq-state { color: color-mix(in srgb, #f08c00 75%, var(--text)); font-weight: 700; }
.inq-go { flex: none; padding: 5px 12px; border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 700; }
.inq-card.done .inq-go { background: var(--hover); color: var(--accent); }
/* посетитель написал снова: новая карточка внизу с меткой, прежняя — одной строкой «продолжение ниже ↓» */
.inq-again { flex: none; padding: 2px 8px; border-radius: 10px; background: #f08c00; color: #fff; font-size: .75rem; font-weight: 700; }
.sys.inq-card.old { width: auto; padding: 6px 12px; border-width: 1px; border-color: var(--line); box-shadow: none; margin: 4px 0; }
.sys.inq-card.old .inq-head { color: var(--muted); }
.sys.inq-card.old .inq-head b { font-size: .85rem; font-weight: 600; color: var(--muted); }
.inq-more { flex: none; font-size: .8rem; color: var(--accent); }
.sys.inq-card.flash { animation: inq-flash 1.5s ease-out; }
@keyframes inq-flash { from { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); } }
@media (prefers-reduced-motion: reduce) { .sys.inq-card.flash { animation: none; } }
.tk-sys { align-self: center; font-size: .8rem; color: var(--text); text-align: center; background: var(--hover); padding: 4px 12px; border-radius: 10px; font-weight: 600; }
.tk-sys.again { color: color-mix(in srgb, #f08c00 75%, var(--text)); }
.tk-link { color: var(--accent); font-weight: 600; text-decoration: underline; }
.tk-val { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tk-plain { white-space: pre-wrap; }
.tk-cm.other .tk-cm-b { background: color-mix(in srgb, var(--accent) 14%, var(--side)); }
.tk-guest-hint { text-align: center; }
.tk-lang-hint { margin: 8px 0 0; padding: 6px 10px; border-radius: 8px; background: rgba(217, 119, 6, .12); color: var(--warn, #d97706); font-size: .85rem; text-align: center; }
.tk-tr-btn.on { color: var(--accent); border-color: var(--accent); }
.inq-lang { font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: rgba(47, 127, 209, .14); color: var(--accent); margin-left: auto; }
.inq-lang + .tchip { margin-left: 6px; }
.inq-q.tr::before { content: "🌐 "; opacity: .6; }
.wg-warn { background: color-mix(in srgb, #f08c00 14%, transparent); border-radius: 10px; padding: 8px 10px; }
.wg-colors { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin: 4px 0 12px; font-size: .86rem; color: var(--muted); }
.wg-pal { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wg-sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--side); box-shadow: 0 0 0 1px var(--line); }
.wg-sw.on { box-shadow: 0 0 0 2px var(--accent); }
.wg-own { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--text); }
.wg-own input { width: 34px; height: 28px; padding: 1px; border: 1px solid var(--line); border-radius: 8px; background: var(--side); }
.wg-ask { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 10px; align-items: center; margin: 6px 0 12px; font-size: .9rem; }
.wg-ask .seg button { font-size: .78rem; padding: 7px 4px; }
.wg-greet { margin: 6px 0 8px; }
.wg-greet button { font-size: .82rem; padding: 7px 4px; }
.wg-greet-std { margin: 0 0 12px; font-style: italic; }
.wg-greet-own { margin: 0 0 12px; }
.wg-sched { margin: 4px 0 12px; }
.wg-days { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px 8px; align-items: center; font-size: .9rem; }
.wg-days label { display: flex; align-items: center; gap: 6px; min-width: 64px; }
.wg-days input[type=time] { width: 100%; padding: 6px 8px; }
.wg-days input[type=time]:disabled { opacity: .45; }
.wg-days span { color: var(--muted); }
.wg-tz-q { margin: 6px 0; }
.tk-off { color: var(--muted); white-space: nowrap; } /* посетитель написал вне графика работы */
.wg-pre { margin: 4px 0 8px; padding: 10px 12px; border-radius: 10px; background: #17212b; color: #e8edf2; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; user-select: all; }
.wg-row { display: flex; gap: 8px; margin-bottom: 10px; }
.wg-params { margin: 4px 0 10px; font-size: .84rem; }
.wg-params dt { font: 600 12px/1.5 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.wg-params dd { margin: 0 0 8px; color: var(--text); }
