:root {
  --blue: #3390ec; --blue-d: #2b7fd6; --danger: #e5484d; --check: #4fa64f;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
  /* Тематизируемые поверхности (светлая тема) */
  --bg: #ffffff; --card: #ffffff; --ink: #0f0f0f; --muted: #93999f; --line: #e9edf0;
  --hover: #f4f7fa; --top-bg: #3390ec; --top-fg: #ffffff; --input-bg: #eef1f4;
  --rail-bg: #f2f5f8; --seg-bg: #eef1f4; --seg-on-bg: #ffffff; --chip-bg: #eef1f4;
  --menu-bg: #ffffff; --myid-bg: #f3f6f9; --preview-fg: #70767d;
  --chat-bg: #b8c6d3; --bubble-in: #ffffff; --bubble-in-fg: #0f0f0f;
  --bubble-out: #eeffde; --bubble-out-fg: #0f0f0f; --meta-out: #6aa84f; --meta-in: #9aa0a8; --v-mine: #4fa64f; --v-mine-fg: #ffffff;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Ccircle cx='20' cy='20' r='9'/%3E%3Ccircle cx='80' cy='45' r='6'/%3E%3Ccircle cx='45' cy='80' r='11'/%3E%3Ccircle cx='100' cy='100' r='7'/%3E%3Ccircle cx='10' cy='95' r='5'/%3E%3C/g%3E%3C/svg%3E");
}
/* ===== Тёмная тема ===== */
body[data-theme="dark"] {
  --bg: #0e1621; --card: #17212b; --ink: #e9edf1; --muted: #7d8b99; --line: #232e3c;
  --hover: #202b36; --top-bg: #17212b; --top-fg: #e9edf1; --input-bg: #242f3d;
  --rail-bg: #131c26; --seg-bg: #232e3c; --seg-on-bg: #3d4655; --chip-bg: #242f3d;
  --menu-bg: #1c2733; --myid-bg: #17212b; --preview-fg: #8a96a3;
  --chat-bg: #0e1621; --bubble-in: #182533; --bubble-in-fg: #e9edf1;
  --bubble-out: #2b5278; --bubble-out-fg: #ffffff; --meta-out: rgba(255,255,255,.55); --meta-in: #6b7885; --v-mine: #ffffff; --v-mine-fg: #2b5278;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
  body[data-theme="system"] {
    --bg: #0e1621; --card: #17212b; --ink: #e9edf1; --muted: #7d8b99; --line: #232e3c;
    --hover: #202b36; --top-bg: #17212b; --top-fg: #e9edf1; --input-bg: #242f3d;
    --rail-bg: #131c26; --seg-bg: #232e3c; --seg-on-bg: #3d4655; --chip-bg: #242f3d;
    --menu-bg: #1c2733; --myid-bg: #17212b; --preview-fg: #8a96a3;
    --chat-bg: #0e1621; --bubble-in: #182533; --bubble-in-fg: #e9edf1;
    --bubble-out: #2b5278; --bubble-out-fg: #ffffff; --meta-out: rgba(255,255,255,.55); --meta-in: #6b7885; --v-mine: #ffffff; --v-mine-fg: #2b5278;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
/* Пользовательские настройки: шрифт и размер */
body[data-font="serif"] { --sans: "Georgia", "Cambria", "Charter", "Times New Roman", serif; }
body[data-font="rounded"] { --sans: "SF Pro Rounded", "Varela Round", "Nunito", "Comfortaa", -apple-system, "Segoe UI", Roboto, sans-serif; }
body[data-size="large"] .bubble { font-size: 16.5px; }
body[data-size="large"] .composer textarea { font-size: 17px; }
body[data-size="large"] .row .name { font-size: 17px; }
body[data-size="large"] .preview { font-size: 15px; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body, #app { height: 100%; }
html, body { overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font: inherit; color: var(--ink); }
.hidden { display: none !important; }

.svg { width: 22px; height: 22px; display: block; flex: none; }
.svg.dots { fill: currentColor; stroke: none; width: 18px; height: 18px; }

/* Вход */
.auth { max-width: 430px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 28px 24px; }
.auth h1 { text-align: center; font-size: 27px; font-weight: 600; margin-bottom: 6px; }
.auth .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.auth label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.auth input { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px; font-size: 16px; background: var(--input-bg); transition: border-color .15s, box-shadow .15s; }
.auth input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(51,144,236,.14); }
.handle-box { border: 1px solid rgba(51,144,236,.3); border-radius: 11px; padding: 13px; background: rgba(51,144,236,.07); }
.handle-box .h { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--blue); text-align: center; font-size: 15px; word-break: break-all; }
.handle-box .regen { display: inline-flex; align-items: center; gap: 6px; justify-content: center; width: 100%; color: var(--blue); font-size: 13px; margin-top: 10px; }
.handle-box .regen .svg { width: 15px; height: 15px; }
.btn { width: 100%; background: var(--blue); color: #fff; border-radius: 11px; padding: 14px; font-size: 16px; font-weight: 600; margin-top: 22px; box-shadow: 0 2px 10px rgba(51,144,236,.28); transition: background .15s; }
.btn:hover { background: var(--blue-d); } .btn:disabled { opacity: .6; }
.link { display: block; text-align: center; color: var(--blue); font-size: 14px; margin-top: 16px; }
.note { background: rgba(51,144,236,.07); border-radius: 11px; padding: 13px; margin-top: 24px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.note.sec { background: #fff7ed; color: #7c2d12; margin-top: 12px; }
.secbar { background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #7c2d12; font-size: 12px; line-height: 1.45; padding: 9px 12px; display: flex; gap: 9px; align-items: flex-start; }
.secbar .svg { width: 17px; height: 17px; color: #ea770c; margin-top: 1px; }
.secbar .x { margin-left: auto; color: #c2410c; padding: 2px; border-radius: 6px; flex: none; display: flex; }
.secbar .x .svg { width: 16px; height: 16px; color: #c2410c; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

/* Каркас */
/* Порядок важен: dvh должен идти ПОСЛЕ vh, иначе он никогда не применится
   (2026-09-05). На телефоне 100vh выше видимой области при открытой
   клавиатуре: браузер прокручивал страницу к полю ввода, и шапка с именем
   собеседника уезжала за верхний край. Экран фиксируем, документ не скроллим. */
.screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; position: fixed; inset: 0; overflow: hidden; }
.top { display: flex; align-items: center; gap: 4px; padding: 8px 10px; background: var(--top-bg); color: var(--top-fg); flex: none; z-index: 10; box-shadow: 0 1px 5px rgba(0,0,0,.12); min-height: 56px; }
.top .title { font-weight: 600; font-size: 19px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 6px; }
.top .back, .top .act, .top .logout { color: var(--top-fg); display: flex; align-items: center; justify-content: center; border-radius: 50%; width: 40px; height: 40px; transition: background .15s; }
.top .back:hover, .top .act:hover, .top .logout:hover { background: rgba(255,255,255,.16); }
.top .back .svg { width: 26px; height: 26px; } .top .act .svg, .top .logout .svg { width: 22px; height: 22px; }
.myid { background: var(--myid-bg); margin: 8px 10px 0; border-radius: 12px; padding: 11px 14px; display: flex; align-items: center; gap: 12px; }
.myid .myid-l { flex: 1; min-width: 0; }
.myid .l { font-size: 11px; color: var(--muted); }
.myid .v { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--blue); font-size: 13px; margin-top: 3px; word-break: break-all; }
.addbtn-top { display: inline-flex; align-items: center; gap: 6px; background: var(--blue); color: #fff; font-weight: 600; font-size: 13.5px; padding: 9px 15px; border-radius: 20px; white-space: nowrap; flex: none; box-shadow: 0 2px 8px rgba(51,144,236,.25); transition: background .15s; }
.addbtn-top:hover { background: var(--blue-d); }
.addbtn-top .svg { width: 17px; height: 17px; }
.offline { background: #fef3c7; color: #92400e; text-align: center; padding: 7px; font-size: 13px; }

.segment { display: flex; margin: 9px 10px; background: var(--seg-bg); border-radius: 11px; padding: 3px; flex: none; }
.segment button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 500; color: var(--muted); font-size: 14px; transition: all .15s; }
.segment button.on { background: var(--seg-on-bg); color: var(--blue); box-shadow: 0 1px 3px rgba(0,0,0,.1); font-weight: 600; }

/* Дом */
.home-body { flex: 1 1 auto; display: flex; min-height: 0; }

.list-col { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.searchbar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--card); border-bottom: 1px solid var(--line); flex: none; }
.searchbar .svg { width: 18px; height: 18px; color: var(--muted); flex: none; margin-left: 4px; }
.searchbar input { flex: 1; border: none; background: var(--input-bg); border-radius: 18px; padding: 9px 14px; font-size: 14.5px; color: var(--ink); }
.searchbar input:focus { outline: none; filter: brightness(.97); }
.list { flex: 1 1 auto; overflow-y: auto; padding-bottom: 90px; background: var(--card); }
.row { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px 8px 11px; background: var(--card); cursor: pointer; transition: background .12s; }
.row:hover { background: var(--hover); }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 20px; position: relative; flex-shrink: 0; }
.avatar .svg { width: 24px; height: 24px; }
.avatar.g { background: #a695e7; } .avatar.c { background: #6ec9cb; }
.dot { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: #31c451; border: 2.5px solid var(--card); }
.row .body { flex: 1; min-width: 0; }
.line1 { display: flex; align-items: baseline; gap: 8px; }
.line1 .name { flex: 1; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.rtime { font-size: 12px; color: var(--muted); flex: none; }
.line2 { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.preview { flex: 1; font-size: 14px; color: var(--preview-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview.muted { color: var(--muted); }
.preview.status { color: var(--muted); }
.preview.status.online { color: var(--blue); }
/* Непрочитанное: синий бейдж со счётчиком + жирное имя */
.unread-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; box-shadow: 0 1px 3px rgba(51,144,236,.4); margin-left: 6px; }
.unread-badge.hidden { display: none; }
.row.unread .name { font-weight: 800; }
.row.unread .preview.status { color: var(--ink); }
.row:hover .unread-badge { margin-right: 30px; }
.row .name, .row .body { min-width: 0; }
.row-more { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--card); opacity: 0; transition: opacity .12s, background .12s; }
.row:hover .row-more { opacity: 1; }
.row-more:hover { background: var(--hover); color: var(--blue); }
.row-menu { top: 44px; right: 10px; }
.ic { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted); flex: none; transition: background .12s, color .12s; }
.ic:hover { background: var(--hover); color: var(--blue); }
.ic .svg { width: 21px; height: 21px; }
.empty { text-align: center; color: var(--muted); padding: 46px 28px; line-height: 1.6; }
.fab { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--blue); color: #fff; border-radius: 26px; padding: 13px 22px; font-size: 15px; font-weight: 600; box-shadow: 0 6px 18px rgba(51,144,236,.4); z-index: 20; display: inline-flex; align-items: center; gap: 7px; transition: background .15s; }
.fab:hover { background: var(--blue-d); }
.fab .svg { width: 19px; height: 19px; }
.fab.fab-round { position: absolute; left: auto; right: 16px; bottom: 16px; transform: none; width: 56px; height: 56px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center; }
.fab.fab-round .svg { width: 24px; height: 24px; }

/* Чат */
.chat-wrap { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; position: relative; }
.msgs { flex: 1 1 auto; overflow-y: auto; padding: 16px 6% 14px; display: flex; flex-direction: column; gap: 2px; background-color: var(--chat-bg); background-image: var(--pattern); }
.bubble { position: relative; max-width: 74%; border-radius: 12px; padding: 6px 10px 6px; font-size: 15px; line-height: 1.35; word-wrap: break-word; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.12); margin-bottom: 2px; }
.bubble.mine { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-fg); border-bottom-right-radius: 4px; }
.bubble.their { align-self: flex-start; background: var(--bubble-in); color: var(--bubble-in-fg); border-bottom-left-radius: 4px; }
.bubble.mine::after { content: ''; position: absolute; bottom: 0; right: -6px; width: 0; height: 0; border: 7px solid transparent; border-bottom-color: var(--bubble-out); border-right: 0; }
.bubble.their::before { content: ''; position: absolute; bottom: 0; left: -6px; width: 0; height: 0; border: 7px solid transparent; border-bottom-color: var(--bubble-in); border-left: 0; }
.bubble .msgtext { white-space: pre-wrap; }
.bubble .msgtext a.msg-link, .post .pb a.msg-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.bubble.their .msgtext a.msg-link, .post .pb a.msg-link { color: var(--blue); }
/* Цитата «в ответ на…» внутри пузыря */
.bubble .quote { border-left: 3px solid var(--blue); padding: 3px 8px; margin: 1px 0 5px; border-radius: 4px; background: rgba(51,144,236,.08); cursor: default; }
.bubble .quote .q-who { font-size: 12px; font-weight: 700; color: var(--blue); }
.bubble .quote .q-text { font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
/* Плашка закреплённого сообщения */
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: var(--card); border-bottom: 1px solid var(--line); flex: none; }
.pin-bar > .svg { width: 17px; height: 17px; color: var(--blue); flex: none; }
.pin-bar .pin-text { flex: 1; min-width: 0; cursor: pointer; }
.pin-bar .pin-t { font-size: 12px; font-weight: 700; color: var(--blue); }
.pin-bar .pin-s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-bar .pin-x { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; color: var(--muted); flex: none; }
.pin-bar .pin-x:hover { background: var(--hover); }
.pin-bar .pin-x .svg { width: 16px; height: 16px; }
/* Подсветка сообщения после перехода */
.bubble.flash { box-shadow: 0 0 0 3px rgba(51,144,236,.55); transition: box-shadow .3s; }
/* Поиск по сообщениям */
.search-msgs { display: flex; align-items: center; gap: 9px; padding: 7px 12px; background: var(--card); border-bottom: 1px solid var(--line); flex: none; }
.search-msgs > .svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search-msgs input { flex: 1; border: none; background: var(--input-bg); border-radius: 16px; padding: 8px 13px; font-size: 14px; color: var(--ink); }
.search-msgs input:focus { outline: none; }
.search-msgs .search-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
/* «печатает…» */
.chat-status.typing { color: var(--blue); font-style: italic; }
.preview.typing { color: var(--blue); font-style: italic; }
/* Карточка контакта (сбоку): медиа диалога */
.side-card { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw; background: var(--bg); border-left: 1px solid var(--line); z-index: 60; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.18); }
.sc-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-bottom: 1px solid var(--line); flex: none; }
.sc-head .avatar { width: 46px; height: 46px; font-size: 18px; }
.sc-titles { flex: 1; min-width: 0; }
.sc-name { font-weight: 700; font-size: 16px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-close { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; color: var(--muted); flex: none; }
.sc-close:hover { background: var(--hover); }
.sc-tabs { margin: 10px 12px; }
.sc-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 24px; }   /* min-height: 0 — иначе flex-ребёнок не сжимается и прокрутки нет */
.sc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 0 12px; }
.sc-cell { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--input-bg); }
.sc-cell img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.sc-jump { position: absolute; right: 4px; bottom: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 2; opacity: 0; transition: opacity .12s; }
.sc-cell:hover .sc-jump, .sc-row:hover .sc-jump { opacity: 1; }
.sc-jump .svg { width: 14px; height: 14px; }
.sc-row { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.sc-row:hover { background: var(--hover); }
.sc-row > .svg { width: 22px; height: 22px; color: var(--blue); flex: none; }
.sc-row .sc-jump { position: static; opacity: 1; background: var(--input-bg); color: var(--muted); }
.sc-row .sc-jump:hover { background: var(--hover); color: var(--blue); }
.sc-rt { flex: 1; min-width: 0; }
.sc-rn { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-rs { font-size: 12px; color: var(--muted); margin-top: 1px; }
.sc-link { font-size: 13.5px; color: var(--blue); text-decoration: none; word-break: break-all; display: block; }
.sc-link:hover { text-decoration: underline; }
/* Кликабельная зона имени в шапке диалога */
.pane-info { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; cursor: pointer; border-radius: 10px; padding: 2px 6px 2px 2px; }
.pane-info:hover { background: var(--hover); }
/* Панель «В ответ на…» над композером */
.reply-bar { display: flex; align-items: center; gap: 9px; padding: 7px 12px; background: var(--card); border-top: 1px solid var(--line); }
.reply-bar .svg { width: 18px; height: 18px; color: var(--blue); flex: none; }
.reply-bar .reply-text { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar .reply-x { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; color: var(--muted); flex: none; }
.reply-bar .reply-x:hover { background: var(--hover); }
.reply-bar .reply-x .svg { width: 16px; height: 16px; color: var(--muted); }
.bubble .snd { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.bubble .locked { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-style: italic; font-size: 13.5px; }
.bubble .locked .svg { width: 15px; height: 15px; }
.bubble .t { font-size: 11px; color: var(--meta-in); margin-top: 1px; text-align: right; user-select: none; display: flex; align-items: center; justify-content: flex-end; gap: 3px; float: right; margin-left: 10px; position: relative; top: 4px; }
.bubble.mine .t { color: var(--meta-out); }
.bubble .t .edited { font-style: italic; opacity: .9; }
.bubble .t .tick { width: 15px; height: 15px; color: var(--meta-out); stroke-width: 2.6; }
.bubble a.file { color: inherit; text-decoration: none; display: flex; gap: 8px; align-items: center; }
.bubble a.file .svg { width: 20px; height: 20px; flex: none; }
.bubble img.prev { max-width: 260px; max-height: 300px; border-radius: 11px; display: block; cursor: zoom-in; }
.bubble .imgwrap { min-width: 120px; min-height: 40px; position: relative; }
.bubble .imgwrap .mh-load { font-size: 13px; color: var(--muted); padding: 8px 4px; }
/* Место под фото до загрузки превью (размер из меты или запомненный) — лента не прыгает, docs/web-media.md */
.bubble .imgwrap.ph { max-width: 100%; min-height: 0; border-radius: 11px; background: rgba(0,0,0,.06); overflow: hidden; }
body[data-theme="dark"] .bubble .imgwrap.ph { background: rgba(255,255,255,.07); }
/* Кнопка «скрыть» поверх картинки */
.media-hide { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .12s; }
.imgwrap:hover .media-hide { opacity: 1; }
.media-hide .svg { width: 16px; height: 16px; }
/* Плашка «изображение скрыто» */
.media-hidden { width: 220px; padding: 18px 12px; border-radius: 10px; background: rgba(0,0,0,.06); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: inherit; }
body[data-theme="dark"] .media-hidden { background: rgba(255,255,255,.07); }
.media-hidden .svg { width: 22px; height: 22px; opacity: .55; }
.media-hidden .mh-t { font-size: 13px; opacity: .75; margin-top: 7px; }
.media-hidden .mh-s { font-size: 11.5px; opacity: .5; margin-top: 2px; }
/* Видео в чате: плитка «нажми ▶» и сам плеер */
.bubble video.prev-vid { max-width: 300px; max-height: 340px; border-radius: 11px; display: block; background: #000; }
.vid-tile { position: relative; width: 260px; max-width: 100%; padding: 22px 12px; border-radius: 11px; background: rgba(0,0,0,.06); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; text-align: center; }
body[data-theme="dark"] .vid-tile { background: rgba(255,255,255,.07); }
.vid-tile .vt-play { width: 52px; height: 52px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(51,144,236,.4); }
.vid-tile .vt-play .svg { width: 24px; height: 24px; margin-left: 3px; fill: #fff; stroke: #fff; }
.vid-tile .vt-name { font-size: 13.5px; font-weight: 600; margin-top: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vid-tile .vt-size { font-size: 11.5px; opacity: .65; margin-top: 2px; }
/* Кнопка «в самый низ» */
.to-bottom { position: absolute; right: 18px; bottom: 84px; width: 44px; height: 44px; border-radius: 50%; background: var(--card); color: var(--muted); box-shadow: 0 2px 12px rgba(0,0,0,.28); display: flex; align-items: center; justify-content: center; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .15s, transform .15s; z-index: 6; }
.to-bottom.visible { opacity: .92; transform: translateY(0); pointer-events: auto; }
.to-bottom:hover { color: var(--blue); opacity: 1; }
.to-bottom .svg { width: 22px; height: 22px; }
/* Счётчик новых сообщений, пришедших, пока читают историю выше */
.tb-count { position: absolute; top: -7px; left: 50%; transform: translateX(-50%); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; box-shadow: 0 1px 3px rgba(51,144,236,.4); box-sizing: border-box; }
.tb-count.hidden { display: none; }
/* Просмотр изображения по центру экрана */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 300; display: flex; align-items: center; justify-content: center; }
.lightbox .lb-img { max-width: 92vw; max-height: 88vh; border-radius: 6px; box-shadow: 0 10px 60px rgba(0,0,0,.6); }
/* Пока качается оригинал, превью (640 px) занимает всё поле просмотра — картинка не прыгает в размере */
.lightbox img.lb-img.lb-thumb { width: 92vw; height: 88vh; object-fit: contain; box-shadow: none; border-radius: 0; }
.lightbox .lb-load { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); background: rgba(0,0,0,.55); color: #fff; font-size: 13px; padding: 5px 12px; border-radius: 14px; pointer-events: none; }
.lightbox .lb-close { position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(255,255,255,.12); }
.lightbox .lb-close:hover { background: rgba(255,255,255,.22); }
.lightbox .lb-close .svg { width: 22px; height: 22px; }
.lightbox .lb-dl { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 7px; color: #fff; background: rgba(255,255,255,.14); padding: 10px 18px; border-radius: 22px; text-decoration: none; font-size: 14px; }
.lightbox .lb-dl:hover { background: rgba(255,255,255,.24); }
.lightbox .lb-dl .svg { width: 17px; height: 17px; }
/* Кнопка «⋮» — СНАРУЖИ пузыря (сбоку), а не внутри */
.msg-act { position: absolute; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0,0,0,.22); opacity: 0; transition: opacity .12s, background .12s; }
.bubble.mine .msg-act { left: -34px; right: auto; }
.bubble.their .msg-act { right: -34px; left: auto; }
.bubble:hover .msg-act { opacity: .85; }
.msg-act:hover { opacity: 1; background: rgba(0,0,0,.38); }
/* Меню открывается сбоку от пузыря */
.msg-menu { position: absolute; top: 0; background: var(--menu-bg); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.28); padding: 5px; z-index: 30; min-width: 190px; }
.bubble.mine .msg-menu { right: calc(100% + 8px); left: auto; }
.bubble.their .msg-menu { left: calc(100% + 8px); right: auto; }
.msg-menu button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border-radius: 8px; font-size: 14.5px; color: var(--ink); text-align: left; }
.msg-menu button:hover { background: var(--hover); }
.msg-menu button .svg { width: 18px; height: 18px; color: var(--muted); }
.msg-menu button.danger { color: var(--danger); }
.msg-menu button.danger .svg { color: var(--danger); }
.bubble.editing { min-width: 250px; max-width: 92%; }
.edit-ta { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 15px; background: var(--card); color: var(--ink); resize: none; max-height: 160px; font-family: var(--sans); }
.edit-ta:focus { outline: none; border-color: var(--blue); }
.edit-row { display: flex; justify-content: flex-end; gap: 4px; margin-top: 6px; }
.edit-row .lnk { padding: 5px 10px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.edit-row .lnk.pri { color: var(--blue); font-weight: 700; }
.edit-row .lnk:hover { background: var(--hover); }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; background: var(--card); border-top: 1px solid var(--line); flex: none; }
.composer textarea { flex: 1; resize: none; max-height: 120px; min-height: 44px; border: 1px solid var(--line); border-radius: 22px; padding: 11px 16px; font-size: 16px; background: var(--input-bg); color: var(--ink); line-height: 1.3; font-family: var(--sans); transition: border-color .15s; }
.composer textarea:focus { outline: none; border-color: var(--blue); }
.composer .send, .composer .clip { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .15s, color .15s; }
.composer .clip { color: var(--muted); } .composer .clip:hover { background: var(--hover); color: var(--blue); }
.composer .send { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(51,144,236,.35); }
.composer .send:hover { background: var(--blue-d); }
.composer .send .svg { width: 20px; height: 20px; margin-left: 1px; } .composer .clip .svg { width: 21px; height: 21px; }
/* Голосовые: микрофон вместо «отправить», пока поле пустое; панель записи */
.composer .mic { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--muted); transition: background .15s, color .15s; }
.composer .mic:hover { background: var(--hover); color: var(--blue); } .composer .mic .svg { width: 22px; height: 22px; }
.composer.has-text .mic { display: none; } .composer:not(.has-text) .send { display: none; }
.composer .rec-bar, .composer .rec-send { display: none; }
.composer.recording > * { display: none; }
.composer.recording .rec-bar { display: flex; flex: 1; min-width: 0; align-items: center; gap: 6px; min-height: 44px; }
.composer.recording .rec-send { display: flex; box-shadow: 0 0 0 calc(var(--lvl, 0) * 12px) rgba(51,144,236,.28), 0 2px 8px rgba(51,144,236,.35); transition: box-shadow .1s; }
.rec-btn { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; color: var(--muted); transition: background .15s, color .15s; }
.rec-btn:hover { background: var(--hover); color: var(--blue); } .rec-btn .svg { width: 21px; height: 21px; }
.rec-trash:hover { color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex: none; animation: recblink 1s infinite; }
@keyframes recblink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 40px; flex: none; }
.rec-wave { flex: 1; min-width: 0; height: 28px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; overflow: hidden; }
.rec-wave i { flex: none; width: 3px; min-height: 3px; border-radius: 2px; background: var(--blue); }
/* Пауза: точка гаснет, вместо неё ▶ «прослушать», волна — вся запись слева направо */
.rec-play { display: none; }
.composer.rec-paused .rec-dot { display: none; }
.composer.rec-paused .rec-play { display: flex; background: var(--blue); color: #fff; width: 34px; height: 34px; }
.composer.rec-paused .rec-play:hover { background: var(--blue-d); color: #fff; }
.composer.rec-paused .rec-play .svg { width: 16px; height: 16px; margin-left: 1px; }
.composer.rec-paused .rec-wave { justify-content: flex-start; }
.composer.rec-paused .rec-wave i { opacity: .4; } .composer.rec-paused .rec-wave i.on { opacity: 1; }
.composer.rec-paused .rec-pause { color: var(--danger); }
/* Пузырь голосового */
.voice { display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 340px; padding: 2px 0; }
.v-play { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; transition: opacity .15s; }
.v-play .svg { width: 20px; height: 20px; margin-left: 1px; } .v-play.busy { opacity: .5; animation: recblink 1s infinite; }
.bubble.their .v-play { background: var(--blue); color: #fff; } .bubble.mine .v-play { background: var(--v-mine); color: var(--v-mine-fg); }
.v-body { flex: 1; min-width: 0; }
.v-wave { display: flex; align-items: center; gap: 2px; height: 26px; cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.v-wave.drag .v-bar { transition: none; }
.v-bar { flex: 1; min-width: 2px; border-radius: 2px; opacity: .35; transition: opacity .1s; } .v-bar.on { opacity: 1; }
.bubble.their .v-bar { background: var(--blue); } .bubble.mine .v-bar { background: var(--v-mine); }
.v-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: .8; margin-top: 3px; }
.v-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.v-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.v-rate { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: rgba(127,127,127,.2); }
.v-subs { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: rgba(127,127,127,.2); opacity: .6; }
.v-subs.on { opacity: 1; background: var(--blue); color: #fff; } .bubble.mine .v-subs.on { background: var(--v-mine); color: var(--v-mine-fg); }
.v-subs[hidden] { display: none; }
/* Расшифровка под плеером */
.tr { margin-top: 4px; font-size: 13.5px; line-height: 1.35; max-width: 340px; }
.tr:empty { display: none; }
.tr-status { opacity: .65; font-style: italic; font-size: 12.5px; }
.tr-text { white-space: pre-wrap; margin: 2px 0 3px; }
.tr-acts { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 12.5px; }
.tr-act { opacity: .75; text-decoration: underline; text-underline-offset: 2px; padding: 0; } .tr-act:hover { opacity: 1; }
.tr-act.tr-toggle { opacity: .8; font-weight: 600; text-decoration: none; }
.tr-act.danger { color: var(--danger); } .tr-act.primary { font-weight: 700; text-decoration: none; opacity: 1; }
.tr-seg { cursor: pointer; border-radius: 3px; padding: 0 1px; transition: background .15s; }
.tr-seg:hover { background: rgba(51,144,236,.12); }
.tr-seg.on { background: rgba(51,144,236,.28); }
.tr-live { width: min(300px, 100%); margin: 2px 0 3px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tr-live:empty { display: none; }
.tr-live span { cursor: pointer; }
.tr-live-prev, .tr-live-next { opacity: .55; } .tr-live-prev:hover, .tr-live-next:hover { opacity: .85; }
.tr-live-cur { font-weight: 600; }
.tr-edit { width: 100%; min-width: 240px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13.5px; background: var(--input-bg); color: var(--ink); resize: vertical; margin: 3px 0; }

/* Предпросмотр вложений (Ctrl+V / drag&drop) над композером */
.attach-preview { background: var(--card); border-top: 1px solid var(--line); padding: 8px 12px 10px; flex: none; }
.attach-preview .ap-head { display: flex; align-items: center; gap: 9px; }
.attach-preview .ap-head > .svg { width: 18px; height: 18px; color: var(--blue); flex: none; }
.attach-preview .ap-title { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-preview .ap-cancel, .attach-preview .ap-ok { padding: 6px 13px; border-radius: 16px; font-size: 13.5px; font-weight: 600; flex: none; transition: background .15s, color .15s; }
.attach-preview .ap-cancel { color: var(--muted); }
.attach-preview .ap-cancel:hover { background: var(--hover); }
.attach-preview .ap-ok { background: var(--blue); color: #fff; }
.attach-preview .ap-ok:hover { background: var(--blue-d); }
.attach-preview .ap-list { display: flex; gap: 8px; overflow-x: auto; padding-top: 8px; }
.attach-preview .ap-item { position: relative; width: 92px; flex: none; }
.attach-preview .ap-item img { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; display: block; background: var(--hover); }
.attach-preview .ap-doc { width: 92px; height: 92px; border-radius: 10px; background: var(--hover); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.attach-preview .ap-doc .svg { width: 30px; height: 30px; }
.attach-preview .ap-name { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-preview .ap-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center; }
.attach-preview .ap-x:hover { background: rgba(0,0,0,.75); }
.attach-preview .ap-x .svg { width: 13px; height: 13px; stroke-width: 3; }

/* Админка: список файлов на диске */
.admin-file { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.admin-file .af-size { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; min-width: 82px; flex: none; }
.admin-file .af-body { flex: 1; min-width: 0; }
.admin-file .af-owner { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-file .af-date { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Прогресс отправки файлов (плашки внизу, поверх композера) */
.uploads { position: fixed; left: 50%; transform: translateX(-50%); bottom: 88px; z-index: 210; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.uploads:empty { display: none; }
.up-card { pointer-events: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.up-top { display: flex; align-items: center; gap: 8px; }
.up-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-phase { font-size: 12.5px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.up-x { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.up-x:hover { background: var(--hover); }
.up-x .svg { width: 14px; height: 14px; }
.up-track { height: 4px; border-radius: 3px; background: var(--hover); margin-top: 8px; overflow: hidden; }
.up-fill { height: 100%; width: 0; background: var(--blue); border-radius: 3px; transition: width .2s linear; }

/* Оверлей при перетаскивании файла в окно */
.drop-ov { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-ov .drop-box { background: var(--card); color: var(--ink); border: 2px dashed var(--blue); border-radius: 16px; padding: 26px 34px; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; box-shadow: var(--shadow); }
.drop-ov .drop-box .svg { width: 34px; height: 34px; color: var(--blue); }

/* Каналы */
.channel-head { background: var(--card); padding: 14px 16px; border-bottom: 1px solid var(--line); }
.public-note { background: #fff7ed; color: #9a3412; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-top: 8px; }
.sub-btn { margin-top: 10px; width: 100%; border: 1px solid var(--blue); color: var(--blue); border-radius: 20px; padding: 10px; font-weight: 600; transition: background .15s; }
.sub-btn:hover { background: rgba(51,144,236,.08); }
.sub-btn.on { background: rgba(51,144,236,.12); border-color: rgba(51,144,236,.4); }
.post { background: var(--card); border-radius: 14px; padding: 15px; margin: 10px 12px; box-shadow: var(--shadow); }
.post .pt { font-weight: 700; font-size: 16px; margin-bottom: 6px; color: var(--ink); }
.post .pb { font-size: 14.5px; color: var(--ink); line-height: 1.55; white-space: pre-wrap; }
.post .pf { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.post .pf .tm { font-size: 11.5px; color: var(--muted); } .post .pf a { color: var(--blue); font-size: 13px; }

/* Формы / модалки */
.form { padding: 16px; }
.form label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.form input, .form textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; font-size: 16px; background: var(--input-bg); color: var(--ink); }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--blue); }
.form textarea { min-height: 90px; resize: vertical; }
.picker-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--muted); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex: none; }
.check.on { background: var(--blue); border-color: var(--blue); }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.preset { background: rgba(51,144,236,.12); color: var(--blue); border-radius: 16px; padding: 7px 12px; font-size: 13px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; backdrop-filter: blur(2px); }
.modal { background: var(--menu-bg); border-radius: 16px; padding: 20px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.4); color: var(--ink); }
.modal h3 { font-size: 17px; margin-bottom: 4px; }
.modal .confirm-text { font-size: 15.5px; line-height: 1.5; color: var(--ink); }
.modal .idline { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.modal input, .modal textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 16px; margin-top: 12px; background: var(--input-bg); color: var(--ink); }
.modal input:focus, .modal textarea:focus { outline: none; border-color: var(--blue); }
.modal .mbtns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 16px; }
.modal .mbtns button { padding: 9px 16px; font-size: 15px; border-radius: 9px; color: var(--ink); }
.modal .mbtns button:hover { background: var(--hover); }
.modal .mbtns .save { color: var(--blue); font-weight: 700; }
.modal .mbtns .save.danger { color: #fff; background: var(--danger); }
.modal .mbtns .save.danger:hover { background: #cf3438; }

/* Звонок */
.call { position: fixed; inset: 0; background: #0b1220; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.call video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0b1220; }
.call video.local { position: absolute; top: 20px; right: 16px; width: 110px; height: 150px; object-fit: cover; border-radius: 12px; background: #000; z-index: 2; }
.call .who { color: #fff; font-size: 24px; font-weight: 700; z-index: 2; }
.call .st { color: #9fb0d0; margin-top: 8px; z-index: 2; }
.call .ctrls { position: absolute; bottom: 40px; display: flex; gap: 16px; z-index: 3; }
.call .ctrl { width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.15); color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; }
.call .ctrl.hang { background: #dc2626; }
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: #14181f; color: #fff; padding: 11px 18px; border-radius: 22px; font-size: 14px; z-index: 200; opacity: .96; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.incoming { position: fixed; top: 20px; left: 12px; right: 12px; background: var(--menu-bg); color: var(--ink); border-radius: 16px; padding: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3); z-index: 150; max-width: 420px; margin: 0 auto; }
.incoming .txt { font-weight: 600; margin-bottom: 12px; }
.incoming .ib { display: flex; gap: 10px; }
.incoming button { flex: 1; padding: 12px; border-radius: 11px; font-weight: 600; font-size: 15px; }
.incoming .acc { background: #22c55e; color: #fff; } .incoming .rej { background: #dc2626; color: #fff; }

/* Запросы */
.addbtn { display: block; width: calc(100% - 24px); margin: 8px 12px; padding: 11px; border-radius: 10px; background: rgba(51,144,236,.12); color: var(--blue); font-weight: 600; font-size: 14px; }
.reqhead { padding: 12px 16px 4px; font-size: 12px; font-weight: 700; color: #d08700; text-transform: uppercase; letter-spacing: .04em; }
.row.req { background: rgba(212,135,0,.08); }
.ic.ok { color: #16a34a; } .ic.ok:hover { background: rgba(22,163,74,.12); }
.ic.no { color: var(--danger); } .ic.no:hover { background: rgba(229,72,77,.12); }

/* Трёхпанельный вид */
.home-body.wide .list-col { flex: none; width: 360px; border-right: 1px solid var(--line); }
.home-body.wide .chat-pane { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.chat-pane .chat-wrap { flex: 1 1 auto; min-height: 0; }
.pane-head { display: flex; align-items: center; gap: 11px; padding: 8px 14px; background: var(--card); border-bottom: 1px solid var(--line); flex: none; min-height: 56px; }
.pane-head .pane-avatar { width: 42px; height: 42px; font-size: 16px; }
.pane-head .pane-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.pane-head .pane-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.chat-status { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.chat-status.online { color: var(--blue); }
.top .title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding-left: 6px; }
.top .title-wrap .title { padding-left: 0; font-size: 17px; line-height: 1.2; flex: none; }
.top .top-status { font-size: 12.5px; color: rgba(255,255,255,.78); }
.top .top-status.online { color: #e6f3ff; }
.pane-head .act { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted); transition: background .12s, color .12s; }
.pane-head .act:hover { background: var(--hover); color: var(--blue); }
.pane-head .act .svg { width: 21px; height: 21px; }
.pane-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: rgba(255,255,255,.85); background-color: var(--chat-bg); background-image: var(--pattern); }
.pane-empty .svg { width: 56px; height: 56px; opacity: .9; stroke-width: 1.5; color: #fff; }
.pane-empty div { background: rgba(0,0,0,.18); padding: 6px 16px; border-radius: 16px; font-size: 14px; }
.row.active { background: rgba(51,144,236,.14); }
.row.active:hover { background: rgba(51,144,236,.18); }

/* Админка */
.admin-group { margin: 8px 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.admin-group-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--hover); border-bottom: 1px solid var(--line); }
.admin-group-head .name { flex: 1; font-weight: 600; font-size: 15px; }
.admin-member { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.admin-member:last-child { border-bottom: none; }
.admin-member .nm { flex: 1; min-width: 0; font-size: 14.5px; word-break: break-all; }
.admin-pick { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: 9px; font-size: 14px; background: var(--chip-bg); color: var(--ink); margin: 5px 0; word-break: break-all; }
.admin-pick:hover { filter: brightness(.97); }
.creds { margin-top: 12px; padding: 12px; background: var(--input-bg); border-radius: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.7; word-break: break-all; color: var(--ink); }

/* Настройки */
.settings { flex: 1 1 auto; overflow-y: auto; padding: 6px 0 40px; background: var(--bg); }
.set-group { padding: 14px 16px 6px; }
.set-title { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 11px; }
.set-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.set-chip { padding: 9px 16px; border-radius: 20px; background: var(--chip-bg); color: var(--ink); font-size: 14px; font-weight: 500; transition: all .12s; }
.set-chip:hover { filter: brightness(.97); }
.set-chip.on { background: var(--blue); color: #fff; }
.set-opts.swatches { gap: 12px; }
.swatch { width: 54px; height: 54px; border-radius: 13px; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch.on { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(51,144,236,.3); }
.swatch.pattern { background-color: #b8c6d3; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg fill='%23ffffff' fill-opacity='0.14'%3E%3Ccircle cx='10' cy='10' r='4'/%3E%3Ccircle cx='30' cy='26' r='5'/%3E%3C/g%3E%3C/svg%3E"); }
.swatch.light { background: #e9eef3; }
.swatch.dark { background: #17212b; }
.swatch.mint { background: #cfe9db; }
.swatch.peach { background: #f4ddcb; }
.set-preview { margin: 8px 16px 6px; padding: 16px; border-radius: 14px; display: flex; flex-direction: column; gap: 4px; background-color: var(--chat-bg); background-image: var(--pattern); }
.set-preview .bubble { max-width: 82%; }

/* Фон чата — действует ТОЛЬКО в светлой теме (переопределяет область сообщений) */
body[data-bg="light"] .msgs, body[data-bg="light"] .pane-empty, body[data-bg="light"] .set-preview { background-color: #e9eef3; background-image: none; }
body[data-bg="dark"] .msgs, body[data-bg="dark"] .pane-empty, body[data-bg="dark"] .set-preview { background-color: #17212b; background-image: var(--pattern); }
body[data-bg="mint"] .msgs, body[data-bg="mint"] .pane-empty, body[data-bg="mint"] .set-preview { background-color: #cfe9db; background-image: none; }
body[data-bg="peach"] .msgs, body[data-bg="peach"] .pane-empty, body[data-bg="peach"] .set-preview { background-color: #f4ddcb; background-image: none; }
/* В тёмной теме всё тёмное: выбор фона игнорируется (выше специфичность — два атрибута) */
body[data-theme="dark"][data-bg] .msgs, body[data-theme="dark"][data-bg] .pane-empty, body[data-theme="dark"][data-bg] .set-preview { background-color: var(--chat-bg); background-image: var(--pattern); }
@media (prefers-color-scheme: dark) {
  body[data-theme="system"][data-bg] .msgs, body[data-theme="system"][data-bg] .pane-empty, body[data-theme="system"][data-bg] .set-preview { background-color: var(--chat-bg); background-image: var(--pattern); }
}

/* Активные сеансы (настройки) */
.sess-list { display: flex; flex-direction: column; gap: 6px; }
.sess-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.sess-row.cur { border-color: var(--blue); }
.sess-body { flex: 1; min-width: 0; }
.sess-dev { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.set-chip.danger { color: #d33; }

/* ===== Стопка фото (2026-09-25): фото подряд от одного отправителя — один пузырь-сетка ===== */
.bubble.stack { padding: 4px 4px 3px; }
.stack-grid { display: grid; gap: 3px; width: 300px; max-width: 100%; }
.stack-grid.n2, .stack-grid.n3, .stack-grid.n4 { grid-template-columns: 1fr 1fr; }
.stack-grid.n3 .stack-tile:first-child { grid-column: 1 / -1; }
.stack-grid.n3 .stack-tile:first-child .stack-pic { aspect-ratio: 2 / 1; }
.stack-tile { position: relative; cursor: zoom-in; }
.stack-pic { aspect-ratio: 1; overflow: hidden; border-radius: 9px; background: rgba(0,0,0,.06); display: flex; align-items: center; justify-content: center; }
body[data-theme="dark"] .stack-pic { background: rgba(255,255,255,.07); }
.stack-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stack-pic .mh-load { font-size: 12px; color: var(--muted); padding: 4px; text-align: center; }
.stack-tile.hid .stack-pic .svg { width: 24px; height: 24px; opacity: .5; }
.stack-more { position: absolute; inset: 0; border-radius: 9px; background: rgba(0,0,0,.45); color: #fff; font-size: 28px; font-weight: 600; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.bubble.stack .stack-tile .msg-act { left: 6px; right: auto; top: 6px; transform: none; background: rgba(0,0,0,.4); }
.bubble.stack .stack-tile:hover .msg-act { opacity: .9; }
.bubble.stack .msg-menu { z-index: 5; }
.bubble.stack .t { margin-top: 2px; padding-right: 3px; }
.lightbox .lb-prev, .lightbox .lb-next { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(255,255,255,.14); left: 18px; }
.lightbox .lb-next { left: auto; right: 18px; }
.lightbox .lb-prev:hover, .lightbox .lb-next:hover { background: rgba(255,255,255,.24); }
.lightbox .lb-prev .svg, .lightbox .lb-next .svg { width: 24px; height: 24px; }
.lightbox .lb-next .svg { transform: scaleX(-1); }
.lightbox .lb-count { position: absolute; top: 26px; left: 50%; transform: translateX(-50%); color: #fff; opacity: .8; font-size: 14px; user-select: none; }
.lightbox .lb-img.lb-nav { cursor: pointer; }

/* Реакции на сообщения (из «Семьи», 2026-09-25): чипы под текстом пузыря и ряд выбора в меню сообщения */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 1px; }
.react { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; background: rgba(0,0,0,.08); color: inherit; font-size: calc(13px * var(--k, 1)); line-height: 1.5; }
.bubble.mine .react { background: rgba(255,255,255,.2); }
.react.on { box-shadow: inset 0 0 0 1.5px var(--blue); }
.bubble.mine .react.on { box-shadow: inset 0 0 0 1.5px currentColor; }
.react-e { font-size: calc(15px * var(--k, 1)); }
.react-n { font-weight: 600; }
.msg-react { display: flex; justify-content: space-between; gap: 2px; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.msg-menu .msg-react button.react-pick { width: auto; flex: 1; justify-content: center; padding: 6px 0; font-size: calc(21px * var(--k, 1)); border-radius: 10px; }
.msg-menu .msg-react button.react-pick.on { background: var(--hover); box-shadow: inset 0 0 0 1.5px var(--blue); }
.msg-menu.over { top: calc(100% + 4px); }
.msg-menu.over.up { top: auto; bottom: calc(100% + 4px); }
.bubble.mine .msg-menu.over { right: 0; left: auto; }
.bubble.their .msg-menu.over { left: 0; right: auto; }

/* Панель смайликов у поля ввода (2026-09-25): между лентой и композером, вкладки по категориям */
.composer .emoji-btn.on { color: var(--blue); background: var(--hover); }
.emoji-panel { flex: none; display: flex; flex-direction: column; height: 280px; max-height: 45vh; background: var(--card); border-top: 1px solid var(--line); }
.emoji-tabs { display: flex; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.emoji-tabs .emoji-tab { width: 36px; height: 32px; flex: none; border-radius: 8px; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.emoji-tabs .emoji-tab:hover { background: var(--hover); }
.emoji-tabs .emoji-tab.on { background: var(--hover); box-shadow: inset 0 0 0 1.5px var(--blue); }
.emoji-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); align-content: start; gap: 2px; padding: 6px; }
.emoji-grid .emoji { height: 40px; border-radius: 8px; font-size: 24px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.emoji-grid .emoji:hover { background: var(--hover); }
