/* Мессенджер — оформление в стиле Telegram Web.
   Палитра Telegram Web A: синий #3390ec, свои сообщения #eeffde с зелёными галочками #4fae4e,
   вторичный текст #707579, фон чата — фирменный зелёный градиент с узором.
   Ночной режим: акцент #8774e1, свои сообщения #766ac8. Аватарки — 7 градиентов Telegram.
   Тема: по системе или вручную (data-theme="light|dark" на <html>). */

/* Roboto — свой файл: на Windows его нет, и без него текст уходил в Segoe UI */
@font-face { font-family: Roboto; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/roboto-cyrillic-400.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Roboto; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/roboto-latin-400.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Roboto; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/roboto-cyrillic-500.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Roboto; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/roboto-latin-500.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* полужирный 600/700 — синтетический из 500: на нём держатся только заголовки */

:root {
  --primary: #3390ec;
  --primary-hover: #2a7ed6;
  --primary-soft: rgba(51, 144, 236, .1);
  --bg: #ffffff;
  --bg-2: #f4f4f5;
  --hover: #f4f4f5;
  --active: #3390ec;
  --active-text: #ffffff;
  --text: #000000;
  --text-2: #707579;
  --text-3: #a2acb4;
  --border: #dadce0;
  --divider: #efefef;
  --bubble-in: #ffffff;
  --bubble-out: #eeffde;
  --bubble-out-text: #000000;
  --meta-out: #4fae4e;
  --meta-in: #686c72;
  --link: #3390ec;
  --danger: #e53935;
  --ok: #4fae4e;
  --warn: #e6a23c;
  --note: #fff6d6;
  --note-border: #f2d77a;
  --note-head: #9a7b0a;
  --failed-bg: #ffe9e7;
  --warn-bg: rgba(255, 246, 214, .96);
  --warn-text: #6b5300;
  --unread: #3390ec;
  --muted-badge: #c4c9cc;
  --service-bg: rgba(0, 0, 0, .22);
  --chat-bg: #b8d39a;
  --chat-grad: radial-gradient(circle at 12% 12%, #dbddbb 0, transparent 55%),
               radial-gradient(circle at 88% 18%, #6ba587 0, transparent 50%),
               radial-gradient(circle at 22% 88%, #d5d88d 0, transparent 55%),
               radial-gradient(circle at 82% 82%, #88b884 0, transparent 55%);
  --pattern-opacity: .17;
  --shadow: 0 4px 16px rgba(0, 0, 0, .12);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .18);
  --bubble-shadow: 0 1px 2px rgba(16, 35, 47, .15);
  --r: 12px;
  color-scheme: light;
}

/* ночной режим: по системе (если не выбран светлый) или вручную */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #8774e1; --primary-hover: #7a66d6; --primary-soft: rgba(135, 116, 225, .16);
    --bg: #212121; --bg-2: #181818; --hover: #2c2c2c; --active: #8774e1;
    --text: #ffffff; --text-2: #aaaaaa; --text-3: #707579; --border: #3a3a3a; --divider: #2c2c2c;
    --bubble-in: #212121; --bubble-out: #766ac8; --bubble-out-text: #ffffff;
    --meta-out: rgba(255, 255, 255, .62); --meta-in: #8f8f8f; --link: #8ab4f8;
    --note: #3a3320; --note-border: #6b5b2b; --note-head: #e4c46a; --failed-bg: #4a2323;
    --warn-bg: rgba(58, 51, 32, .96); --warn-text: #f0cf8a; --unread: #8774e1; --muted-badge: #4c4c4c;
    --service-bg: rgba(0, 0, 0, .45); --chat-bg: #0f0f0f;
    --chat-grad: radial-gradient(circle at 20% 20%, #1c2a24 0, transparent 55%), radial-gradient(circle at 80% 75%, #222031 0, transparent 55%);
    --pattern-opacity: .05;
    --shadow: 0 4px 16px rgba(0, 0, 0, .45); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6); --bubble-shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #8774e1; --primary-hover: #7a66d6; --primary-soft: rgba(135, 116, 225, .16);
  --bg: #212121; --bg-2: #181818; --hover: #2c2c2c; --active: #8774e1;
  --text: #ffffff; --text-2: #aaaaaa; --text-3: #707579; --border: #3a3a3a; --divider: #2c2c2c;
  --bubble-in: #212121; --bubble-out: #766ac8; --bubble-out-text: #ffffff;
  --meta-out: rgba(255, 255, 255, .62); --meta-in: #8f8f8f; --link: #8ab4f8;
  --note: #3a3320; --note-border: #6b5b2b; --note-head: #e4c46a; --failed-bg: #4a2323;
  --warn-bg: rgba(58, 51, 32, .96); --warn-text: #f0cf8a; --unread: #8774e1; --muted-badge: #4c4c4c;
  --service-bg: rgba(0, 0, 0, .45); --chat-bg: #0f0f0f;
  --chat-grad: radial-gradient(circle at 20% 20%, #1c2a24 0, transparent 55%), radial-gradient(circle at 80% 75%, #222031 0, transparent 55%);
  --pattern-opacity: .05;
  --shadow: 0 4px 16px rgba(0, 0, 0, .45); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6); --bubble-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: Roboto, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.35;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; color: inherit; font-size: inherit; }
svg { width: 24px; height: 24px; flex-shrink: 0; }
a { color: var(--link); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .2); border-radius: 3px; }

.msng { display: flex; height: 100vh; height: 100dvh; }

/* ─── Кнопки-иконки ─────────────────────────────────────────────────────── */
.icon-btn { width: 40px; height: 40px; border: none; background: none; border-radius: 50%; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on, .icon-btn.active { color: var(--primary); }
.link-btn { color: var(--primary); background: none; border: none; cursor: pointer; padding: 0; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

/* ─── Левая колонка ─────────────────────────────────────────────────────── */
.sidebar { width: 380px; min-width: 300px; display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--divider); position: relative; overflow: hidden; }
.sb-top { display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px 8px; }
.search-wrap { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 2px solid transparent; border-radius: 22px; height: 42px; padding: 0 12px; color: var(--text-3); transition: border-color .15s, background .15s; cursor: text; }
.search-wrap:focus-within { border-color: var(--primary); background: var(--bg); color: var(--primary); }
.search-ico { width: 20px; height: 20px; }
.search-inp { flex: 1; min-width: 0; border: none; background: none; outline: none; color: var(--text); font-size: 15px; }

/* Меню «☰» */
.menu { position: absolute; top: 52px; left: 8px; z-index: 60; min-width: 270px; max-height: calc(100% - 64px); overflow-y: auto; background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px 0; animation: pop .14s ease-out; transform-origin: top left; }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.menu-me { display: flex; align-items: center; gap: 12px; padding: 8px 16px 12px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.menu-me .av { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 500; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.menu-me b { color: var(--text); font-weight: 500; font-size: 15px; display: block; }
.menu-me span { font-size: 13px; color: var(--text-2); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 16px; border: none; background: none; cursor: pointer; font-size: 14px; text-align: left; color: var(--text); }
.menu-item:hover { background: var(--hover); }
a.menu-item { text-decoration: none; }
.mi-ico { width: 22px; text-align: center; font-size: 16px; opacity: .85; }
.menu-sep { height: 1px; background: var(--divider); margin: 4px 0; }
.menu-foot { padding: 8px 16px 4px; font-size: 12px; color: var(--text-3); }

/* Папки (вкладки) */
.folders-wrap { position: relative; flex-shrink: 0; border-bottom: 1px solid var(--divider); }
.folders { display: flex; gap: 2px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; }
/* стрелки по краям, когда вкладки не помещаются (как в Telegram Desktop) */
.fold-arrow { position: absolute; top: 0; bottom: 1px; width: 40px; border: none; cursor: pointer; z-index: 2; color: var(--text-2);
  display: flex; align-items: center; padding: 0 6px; }
.fold-arrow svg { width: 20px; height: 20px; }
.fold-arrow:hover { color: var(--primary); }
.fold-arrow.left { left: 0; justify-content: flex-start; background: linear-gradient(to right, var(--bg) 55%, transparent); }
.fold-arrow.right { right: 0; justify-content: flex-end; background: linear-gradient(to left, var(--bg) 55%, transparent); }
.fold-arrow.right svg { transform: rotate(180deg); }
.folders::-webkit-scrollbar { display: none; }
.ch-tab { position: relative; border: none; background: none; padding: 10px 10px 11px; font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap; border-radius: 10px 10px 0 0; display: inline-flex; align-items: center; gap: 6px; }
.ch-tab:hover { background: var(--hover); }
.ch-tab.on { color: var(--primary); }
.ch-tab.on::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.ch-tab.off { opacity: .55; }
.ch-tab .dot { width: 8px; height: 8px; border-radius: 50%; }
.cnt { display: inline-block; background: var(--muted-badge); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 500; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; }
.ch-tab.on .cnt { background: var(--primary); }
.cnt.red { background: var(--danger) !important; }
.tag-filter { display: flex; gap: 6px; padding: 8px 12px 2px; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.tag-filter::-webkit-scrollbar { display: none; }

/* Список чатов */
.conv-list { flex: 1; overflow-y: auto; padding: 6px 8px 84px; }
.conv-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r); cursor: pointer; user-select: none; }
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--active); color: var(--active-text); }
.av { border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 500; flex-shrink: 0; }
.conv-av { position: relative; width: 54px; height: 54px; font-size: 20px; }
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.head-av { position: relative; overflow: hidden; }
.ch-mini { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--bg); display: flex; align-items: center; justify-content: center; color: #fff; }
.ch-mini svg { width: 15px; height: 15px; }
/* логотип канала в кружке: вкладки, шапка чата, окно «Каналы» */
.k-logo { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.k-logo svg { width: 13px; height: 13px; }
.k-logo.big { width: 26px; height: 26px; }
.k-logo.big svg { width: 18px; height: 18px; }
/* закреплённые (требуют действия) — сверху, с булавкой */
.conv-item.pinned { background: rgba(229, 57, 53, .045); }
.conv-item.pinned:hover { background: rgba(229, 57, 53, .09); }
.conv-item.pinned.active { background: var(--active); }
.conv-time .pin { width: 14px; height: 14px; color: var(--text-3); transform: rotate(45deg); }
.conv-item.active .conv-time .pin { color: rgba(255,255,255,.85); }
.pin-sep { height: 1px; background: var(--divider); margin: 6px 10px; }
.head-badge { display: inline-flex; align-items: center; gap: 6px; }
.conv-item:hover .av-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.head-av { position: relative; overflow: hidden; }
.ch-mini { border-color: var(--hover); }
.conv-item.active .av-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.head-av { position: relative; overflow: hidden; }
.ch-mini { border-color: var(--active); }
.conv-body { flex: 1; min-width: 0; }
.conv-r1 { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.conv-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-time { font-size: 12px; color: var(--text-2); flex-shrink: 0; display: inline-flex; align-items: center; gap: 3px; }
.conv-time svg { width: 16px; height: 11px; color: var(--meta-out); }
.conv-item.active .conv-time, .conv-item.active .conv-prev, .conv-item.active .conv-prev .you, .conv-item.active .conv-time svg { color: rgba(255,255,255,.85); }
.conv-r2 { display: flex; align-items: center; gap: 6px; }
.conv-prev { font-size: 15px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-prev .you { color: var(--text); }
.conv-tags { display: inline-flex; gap: 3px; margin-right: 5px; vertical-align: 1px; }
.conv-tags i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.unread-cnt { font-size: 12px; font-weight: 500; background: var(--unread); color: #fff; border-radius: 12px; padding: 0 7px; min-width: 22px; text-align: center; line-height: 22px; flex-shrink: 0; }
.conv-item.active .unread-cnt { background: #fff; color: var(--active); }
.wait-pill { font-size: 11px; font-weight: 500; color: var(--danger); background: rgba(229, 57, 53, .1); border-radius: 10px; padding: 1px 7px; flex-shrink: 0; white-space: nowrap; }
.wait-pill.mild { color: #c27c0e; background: rgba(230, 162, 60, .14); }
.conv-item.active .wait-pill { color: #fff; background: rgba(255,255,255,.22); }
.assignee-dot { width: 20px; height: 20px; font-size: 9px; }
.empty-list, .loading-convs { padding: 32px 16px; text-align: center; font-size: 14px; color: var(--text-2); line-height: 1.6; }

.sb-footer { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px 10px; background: linear-gradient(transparent, var(--bg) 40%); display: flex; pointer-events: none; }
.ch-status { display: flex; gap: 4px; flex-wrap: wrap; pointer-events: auto; max-width: calc(100% - 72px); }
.ch-st { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; cursor: pointer; border: none; }
.ch-st-on { background: rgba(79, 174, 78, .15); color: var(--ok); }
.ch-st-wait { background: rgba(230, 162, 60, .16); color: #c27c0e; }
.ch-st-err { background: rgba(229, 57, 53, .12); color: var(--danger); }
.ch-st-off { background: var(--bg-2); color: var(--text-3); }

.fab { position: absolute; right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--primary); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform .15s, background .15s; z-index: 5; }
.fab:hover { background: var(--primary-hover); transform: scale(1.05); }

/* ─── Переписка ─────────────────────────────────────────────────────────── */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background-color: var(--chat-bg); background-image: var(--chat-grad); }
.chat::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: var(--pattern-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23284a2a' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 28l18-8-5 18-5-5z'/%3E%3Ccircle cx='112' cy='26' r='9'/%3E%3Cpath d='M92 92c5-7 15-7 20 0M97 85h.01M107 85h.01'/%3E%3Cpath d='M24 110h22v16H24zM24 110l11 9 11-9'/%3E%3Cpath d='M130 120l8 8m0-8l-8 8'/%3E%3Cpath d='M62 52c0-8 13-8 13 0 0 6-6 7-6 13M69 70h.01'/%3E%3Cpath d='M124 60l-5 13h10l-5 13'/%3E%3Cpath d='M58 138c4-5 12-5 16 0'/%3E%3Cpath d='M150 12l4 4-4 4-4-4z'/%3E%3Cpath d='M8 70c3 0 3 6 6 6s3-6 6-6 3 6 6 6'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 280px; }
.chat > * { position: relative; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.service-pill { background: var(--service-bg); color: #fff; padding: 4px 12px; border-radius: 14px; font-size: 14px; font-weight: 500; }

.chat-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { height: 56px; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 0 8px 0 16px; flex-shrink: 0; box-shadow: 0 1px 0 var(--divider); z-index: 3; }
.back-btn { display: none; margin-left: -8px; }
.head-av { width: 42px; height: 42px; font-size: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 500; flex-shrink: 0; }
.head-info { flex: 1; min-width: 0; cursor: default; }
.head-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub a { color: var(--text-2); }
.head-actions { display: flex; align-items: center; gap: 2px; }
.head-badge { font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 10px; flex-shrink: 0; margin-left: 4px; }
.assignee-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 4px; border-radius: 16px; border: none; background: var(--bg-2); color: var(--text); cursor: pointer; font-size: 13px; max-width: 190px; }
.assignee-chip .av { width: 24px; height: 24px; font-size: 10px; }
.assignee-chip svg { width: 18px; height: 18px; color: var(--text-2); margin-left: 4px; }
.assignee-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignee-chip:hover { background: var(--hover); box-shadow: inset 0 0 0 1px var(--divider); }
.assignee-chip.empty { color: var(--primary); }
.head-tags { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 16px; background: var(--bg); box-shadow: 0 1px 0 var(--divider); z-index: 2; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 12px; color: #fff; border: none; white-space: nowrap; cursor: pointer; }
.tag-chip.ghost { background: var(--bg-2); color: var(--text-2); }
.tag-chip.ghost i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tag-chip.ghost.on { color: #fff; }
/* Кнопки контроля диалога над перепиской (как в CRM-мессенджерах): прочитано, отложить, звонок, ответ */
.chat-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 12px; background: var(--bg); box-shadow: 0 1px 0 var(--divider); z-index: 2; }
.ca-btn { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ca-btn:hover { border-color: var(--primary); color: var(--primary); }
.ca-btn.call { border-color: #f0a35c; color: #c26a0e; background: rgba(240, 163, 92, .1); }
.ca-btn.wait { border-color: rgba(229, 57, 53, .45); color: var(--danger); background: rgba(229, 57, 53, .06); }
.ca-btn.snoozed { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.alert-line { color: var(--danger); }
.alert-line.call { color: #c26a0e; }
.alert-line.snooze { color: var(--primary); }
.conv-item.active .alert-line { color: #fff; font-weight: 500; }
.flag { font-size: 13px; flex-shrink: 0; }
.head-sub a { color: inherit; text-decoration: none; }
.head-sub a:hover { text-decoration: underline; }
.chan-warn { background: var(--warn-bg); color: var(--warn-text); font-size: 13px; padding: 7px 16px; flex-shrink: 0; z-index: 2; }

/* Лента */
.msgs-area { flex: 1; overflow-y: auto; padding: 12px 16px 8px; display: flex; flex-direction: column; }
.msgs-area > * { width: 100%; max-width: 728px; margin-left: auto; margin-right: auto; flex-shrink: 0; }
.date-sep { display: flex; justify-content: center; margin: 8px auto; position: sticky; top: 4px; z-index: 1; pointer-events: none; }
.date-sep span { background: var(--service-bg); color: #fff; padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 500; }
.sys-line { display: flex; justify-content: center; margin: 6px auto; }
.sys-line span { background: var(--service-bg); color: #fff; padding: 3px 12px; border-radius: 12px; font-size: 13px; max-width: 90%; text-align: center; }
.msg { display: flex; flex-direction: column; margin-top: 2px; }
.msg-in { align-items: flex-start; }
.msg-out { align-items: flex-end; }
.msg.tail { margin-bottom: 6px; }
.msg-bubble { position: relative; max-width: min(480px, 82%); min-width: 64px; padding: 6px 10px 7px; border-radius: 15px; font-size: 16px; line-height: 1.3125; word-break: break-word; box-shadow: var(--bubble-shadow); }
.msg-in .msg-bubble { background: var(--bubble-in); }
.msg-out .msg-bubble { background: var(--bubble-out); color: var(--bubble-out-text); }
.msg-in.tail .msg-bubble { border-bottom-left-radius: 0; }
.msg-out.tail .msg-bubble { border-bottom-right-radius: 0; }
/* хвостики как в Telegram — у последнего сообщения группы */
.msg.tail .msg-bubble::after { content: ''; position: absolute; bottom: 0; width: 9px; height: 17px; background: inherit; }
.msg-in.tail .msg-bubble::after { left: -8px; clip-path: path('M9 0v17H1c-1 0-1.3-.6-.6-1.2C3 13.5 9 9 9 0z'); }
.msg-out.tail .msg-bubble::after { right: -8px; clip-path: path('M0 0v17h8c1 0 1.3-.6.6-1.2C6 13.5 0 9 0 0z'); }
.msg-bubble.sticker { background: none !important; box-shadow: none; padding: 0; }
.msg-bubble.sticker::after { display: none; }
.msg-author { font-size: 13px; font-weight: 500; color: var(--primary); margin-bottom: 2px; }
.msg-out .msg-author { color: var(--meta-out); }
.msg-text { white-space: pre-wrap; }
.msg-text a { color: var(--link); }
.msg-out .msg-text a { color: inherit; text-decoration: underline; }
.msg-meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -5px 10px; font-size: 12px; color: var(--meta-in); white-space: nowrap; user-select: none; position: relative; top: 3px; }
.msg-out .msg-meta { color: var(--meta-out); }
.msg-meta svg { width: 16px; height: 11px; }
.msg-meta .clock { width: 13px; height: 13px; }
.msg-meta .dev { font-size: 11px; }
.msg-meta.over { position: absolute; right: 8px; bottom: 8px; top: auto; margin: 0; background: rgba(0,0,0,.4); color: #fff; padding: 1px 6px; border-radius: 10px; float: none; }
.msg-failed .msg-bubble { background: var(--failed-bg); }
.msg-fail { font-size: 12px; color: var(--danger); margin-top: 3px; display: flex; gap: 8px; align-items: center; max-width: min(480px, 82%); }
.retry { color: var(--primary); background: none; border: none; cursor: pointer; font-size: 12px; text-decoration: underline; padding: 0; }
.media-lbl { color: var(--text-2); font-style: italic; display: block; }
.msg-out .media-lbl { color: var(--meta-out); }
.msg-img-wrap { margin: -2px -6px 4px; border-radius: 12px; overflow: hidden; line-height: 0; position: relative; }
.msg-img-wrap.solo { margin: -4px -8px -5px; }
.msg-img { max-width: 100%; max-height: 380px; min-width: 140px; min-height: 80px; display: block; cursor: zoom-in; object-fit: cover; background: rgba(0,0,0,.05); }
.msg-sticker { width: 160px; height: 160px; object-fit: contain; display: block; }
.msg-video { max-width: 100%; max-height: 380px; display: block; border-radius: 10px; background: #000; }
.msg-file { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 2px 0 4px; min-width: 200px; }
.msg-file .fi { width: 46px; height: 46px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg-out .msg-file .fi { background: var(--meta-out); }
.msg-file .fi svg { width: 22px; height: 22px; }
.msg-file .fn { font-weight: 500; font-size: 14px; word-break: break-all; }
.msg-file .fs { font-size: 13px; color: var(--meta-in); }
.msg-out .msg-file .fs { color: var(--meta-out); }
/* Файл в канале, не в базе (убран по сроку хранения): размытое превью и «⬇ Загрузить» */
.media-remote { position: relative; display: flex; align-items: center; justify-content: center; min-width: 220px; min-height: 150px; margin: -2px -6px 4px; border-radius: 12px; overflow: hidden; background: #6f8496; cursor: pointer; }
.media-remote img { position: absolute; inset: -14px; width: calc(100% + 28px); height: calc(100% + 28px); object-fit: cover; filter: blur(12px); }
.media-remote.solo { margin: -4px -8px -5px; }
.media-remote.round { width: 200px; height: 200px; min-width: 0; border-radius: 50%; margin: 0; }
.media-remote .mr-btn { position: relative; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 16px; white-space: nowrap; }
.media-remote.loading { cursor: progress; }
.media-remote.loading .mr-btn { animation: mr-pulse 1.2s ease-in-out infinite; }
@keyframes mr-pulse { 50% { opacity: .55; } }
.alb-t .media-remote { margin: 0; border-radius: 0; min-width: 0; min-height: 0; width: 100%; height: 100%; }
.alb-t .media-remote img { width: calc(100% + 28px); height: calc(100% + 28px); }
.alb-t .media-remote .mr-btn { font-size: 12px; padding: 4px 9px; }
button.msg-file { border: none; background: none; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.mr-file .fi { font-size: 20px; }
.mr-file.loading { cursor: progress; }
.mr-file.loading .mr-btn { animation: mr-pulse 1.2s ease-in-out infinite; }
/* голосовое: кнопка, волна, время */
.voice { display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 2px 0 4px; }
.voice-btn { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--primary); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg-out .voice-btn { background: var(--meta-out); }
:root[data-theme="dark"] .msg-out .voice-btn { background: #fff; color: var(--bubble-out); }
.voice-btn svg { width: 22px; height: 22px; }
.voice-body { flex: 1; min-width: 0; }
.wave { display: flex; align-items: flex-end; gap: 2px; height: 24px; cursor: pointer; }
.wave i { flex: 1; min-width: 2px; max-width: 3px; border-radius: 2px; background: currentColor; opacity: .35; }
.wave i.on { opacity: 1; }
.msg-in .wave { color: var(--primary); }
.msg-out .wave { color: var(--meta-out); }
.voice-time { font-size: 12px; color: var(--meta-in); margin-top: 2px; }
.msg-out .voice-time { color: var(--meta-out); }
.msg-note { align-self: center; max-width: min(560px, 92%); background: var(--note); border: 1px solid var(--note-border); border-radius: 12px; padding: 7px 12px 8px; font-size: 14px; margin: 6px auto; box-shadow: var(--bubble-shadow); }
.msg-note .nh { font-size: 12px; color: var(--note-head); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; font-weight: 500; }
.msg-note .nh svg { width: 15px; height: 15px; }
.msg-note .nt { white-space: pre-wrap; word-break: break-word; }
.no-msgs { margin: auto !important; text-align: center; }
.no-msgs span { background: var(--service-bg); color: #fff; padding: 4px 12px; border-radius: 14px; font-size: 14px; }
.to-bottom { position: absolute; right: 20px; bottom: 84px; width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--bg); color: var(--text-2); box-shadow: var(--shadow); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 4; }
.to-bottom svg { transform: rotate(-90deg); }
.drop-zone { position: absolute; inset: 64px 16px 16px; border: 2px dashed var(--primary); border-radius: 16px; background: rgba(255,255,255,.85); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 500; z-index: 20; pointer-events: none; }
:root[data-theme="dark"] .drop-zone { background: rgba(33,33,33,.9); }

#img-lightbox { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0, 0, 0, .9); align-items: center; justify-content: center; cursor: zoom-out; }
#img-lightbox.open { display: flex; }
#img-lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 6px; object-fit: contain; cursor: default; }
.lb-top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: linear-gradient(rgba(0,0,0,.6), transparent); color: #fff; cursor: default; }
.lb-info { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-info b { font-weight: 500; margin-right: 6px; }
.lb-count { font-size: 13px; opacity: .8; margin-right: 6px; }
.lb-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 19px; border: none; background: rgba(255,255,255,.12);
  color: #fff; font-size: 14px; cursor: pointer; text-decoration: none; }
.lb-btn:hover { background: rgba(255,255,255,.24); }
.lb-btn svg { width: 20px; height: 20px; }
#img-lightbox-close { font-size: 18px; width: 38px; padding: 0; justify-content: center; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.12); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 16px; }
.media-dl { display: inline-block; font-size: 12px; margin-top: 4px; color: var(--link); }
@media (max-width: 760px) { .lb-nav { width: 40px; height: 40px; font-size: 26px; } .lb-btn span { display: none; } }

/* Поле ввода */
.compose-wrap { display: flex; align-items: flex-end; gap: 8px; padding: 6px 16px 14px; width: 100%; max-width: 760px; margin: 0 auto; flex-shrink: 0; }
.compose { flex: 1; min-width: 0; background: var(--bg); border-radius: 18px 18px 0 18px; box-shadow: var(--bubble-shadow); position: relative; }
.compose::after { content: ''; position: absolute; right: -8px; bottom: 0; width: 9px; height: 17px; background: inherit; clip-path: path('M0 0v17h8c1 0 1.3-.6.6-1.2C6 13.5 0 9 0 0z'); }
.compose-row { display: flex; align-items: flex-end; gap: 0; padding: 3px 4px; }
.compose-inp { flex: 1; min-width: 0; border: none; outline: none; background: none; resize: none; padding: 11px 6px; min-height: 46px; max-height: 180px; line-height: 1.35; font-size: 16px; }
.compose.note-mode { background: var(--note); }
.note-banner { display: flex; align-items: center; gap: 8px; padding: 8px 14px 0; font-size: 13px; color: var(--note-head); font-weight: 500; }
.note-banner svg { width: 18px; height: 18px; }
.note-banner .link-btn { margin-left: auto; font-size: 13px; }
.rec-row { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 52px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 500; }
.rec-hint { color: var(--text-2); flex: 1; font-size: 14px; }
.send-btn { width: 54px; height: 54px; border-radius: 50%; border: none; background: var(--bg); color: var(--primary); box-shadow: var(--bubble-shadow); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .15s, color .15s, transform .1s; }
.send-btn:hover { background: var(--primary); color: #fff; }
.send-btn:active { transform: scale(.94); }
.send-btn .ico-send { display: none; }
.send-btn.sending .ico-send, .send-btn.recording .ico-send { display: block; }
.send-btn.sending .ico-mic, .send-btn.recording .ico-mic { display: none; }
.send-btn.recording { background: var(--primary); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(51, 144, 236, .45); } 70% { box-shadow: 0 0 0 14px rgba(51, 144, 236, 0); } 100% { box-shadow: 0 0 0 0 rgba(51, 144, 236, 0); } }
.send-btn:disabled { opacity: .6; cursor: default; }
.compose-disabled { text-align: center; font-size: 14px; color: #fff; padding: 12px; }
.compose-disabled span { background: var(--service-bg); padding: 4px 12px; border-radius: 14px; }

/* Шаблоны */
.tmpl-popup { position: absolute; bottom: calc(100% + 8px); left: 0; right: 0; background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow-lg); z-index: 50; max-height: 340px; display: flex; flex-direction: column; overflow: hidden; animation: pop .14s ease-out; transform-origin: bottom center; }
.tmpl-popup-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; border-bottom: 1px solid var(--divider); flex-shrink: 0; }
.tmpl-popup-title { font-size: 13px; font-weight: 500; color: var(--text-2); }
.tmpl-popup-mgr { font-size: 13px; color: var(--primary); background: none; border: none; cursor: pointer; }
.tmpl-list, .slash-list { overflow-y: auto; padding: 4px 0; }
.tmpl-item { padding: 8px 14px; cursor: pointer; }
.tmpl-item:hover, .tmpl-item.sel { background: var(--hover); }
.tmpl-item-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; display: flex; gap: 6px; align-items: center; }
.tmpl-item-name .mine { font-size: 11px; color: var(--primary); font-weight: 400; background: var(--primary-soft); border-radius: 8px; padding: 0 6px; }
.tmpl-item-prev { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmpl-empty { padding: 20px; text-align: center; color: var(--text-2); font-size: 13px; }
#slash-popup { position: fixed; z-index: 500; background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 300px; display: flex; flex-direction: column; overflow: hidden; min-width: 280px; }

/* Всплывающие выборы */
.popover { position: fixed; z-index: 300; background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow-lg); min-width: 240px; max-width: calc(100vw - 16px); max-height: 380px; overflow-y: auto; padding: 6px 0; animation: pop .14s ease-out; }
.pop-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border: none; background: none; cursor: pointer; font-size: 14px; text-align: left; color: var(--text); }
.pop-item:hover { background: var(--hover); }
.pop-item .av { width: 30px; height: 30px; font-size: 12px; }
.pop-item .sw { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.pop-item .ck { margin-left: auto; color: var(--primary); font-weight: 700; }
.pop-item .sub { font-size: 12px; color: var(--text-2); margin-left: auto; }
.pop-head { font-size: 12px; color: var(--text-2); padding: 6px 14px 4px; }
.snooze-own { padding: 6px 14px 8px; }
.snooze-row { display: flex; gap: 6px; margin-bottom: 8px; }
.snooze-row .modal-inp, .snooze-row .modal-sel { padding: 8px 10px; font-size: 14px; }
.snooze-row .modal-sel { width: 96px; flex-shrink: 0; }
.pop-sep { height: 1px; background: var(--divider); margin: 4px 0; }

/* ─── Окна ──────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal-box { background: var(--bg); border-radius: var(--r); padding: 20px 22px 18px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); max-height: calc(100dvh - 32px); overflow-y: auto; animation: pop .16s ease-out; }
.modal-box h3, .modal-title { font-size: 20px; font-weight: 500; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.x-btn { background: none; border: none; cursor: pointer; font-size: 18px; width: 36px; height: 36px; border-radius: 50%; color: var(--text-2); flex-shrink: 0; }
.x-btn:hover { background: var(--hover); }
.modal-field { margin-bottom: 14px; }
.modal-label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; display: block; }
.modal-inp, .modal-sel, .modal-ta { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; background: var(--bg); outline: none; transition: border-color .15s, box-shadow .15s; }
.modal-inp:focus, .modal-sel:focus, .modal-ta:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.modal-ta { resize: vertical; min-height: 90px; line-height: 1.45; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.modal-actions.left { justify-content: flex-start; }
.modal-btn { padding: 10px 18px; border-radius: 10px; font-size: 14px; cursor: pointer; font-weight: 500; border: none; text-transform: uppercase; letter-spacing: .02em; }
.modal-btn.wide { width: 100%; }
.modal-btn-cancel { background: none; color: var(--primary); }
.modal-btn-cancel:hover { background: var(--primary-soft); }
.modal-btn-submit { background: var(--primary); color: #fff; }
.modal-btn-submit:hover { background: var(--primary-hover); }
.modal-btn-submit:disabled { opacity: .55; cursor: default; }
.form-error { color: var(--danger); font-size: 13px; min-height: 16px; margin-bottom: 4px; }
.field-hint { font-size: 12px; color: var(--text-2); line-height: 1.5; margin: -8px 0 12px; word-break: break-word; }
.muted { color: var(--text-3); font-weight: 400; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 4px 0 10px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.login-box { max-width: 360px; text-align: center; padding-top: 28px; }
.login-logo img { width: 104px; height: 104px; }
.login-title { justify-content: center !important; font-size: 24px !important; margin: 12px 0 4px !important; }
.login-sub { color: var(--text-2); font-size: 14px; margin-bottom: 20px; }
.login-box .modal-field { text-align: left; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, .82); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 1000; max-width: calc(100vw - 32px); }

/* Каналы */
.acc-box { max-width: 580px; }
.worker-warn { background: rgba(229, 57, 53, .1); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.acc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.acc-row { border-radius: var(--r); padding: 12px 14px; background: var(--bg-2); }
.acc-r1 { display: flex; align-items: center; gap: 8px; }
.acc-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.acc-name { font-weight: 500; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-kind { font-size: 12px; color: var(--text-2); }
.acc-state { font-size: 13px; margin-top: 6px; line-height: 1.5; }
.acc-state.ok { color: var(--ok); }
.acc-state.err { color: var(--danger); }
.acc-state.wait { color: #c27c0e; }
.acc-state.off { color: var(--text-3); }
.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tool-btn { padding: 5px 12px; border-radius: 16px; font-size: 13px; border: none; background: var(--bg); color: var(--primary); cursor: pointer; font-weight: 500; }
.tool-btn:hover { background: var(--primary-soft); }
.tool-btn.primary { background: var(--primary); color: #fff; }
.tool-btn.primary:hover { background: var(--primary-hover); }
.tool-btn.danger { color: var(--danger); }
.acc-form { border-top: 1px solid var(--divider); padding-top: 14px; margin-bottom: 8px; }
.empty-acc { font-size: 14px; color: var(--text-2); padding: 12px 0; line-height: 1.6; }
.acc-chooser { border-top: 1px solid var(--divider); padding-top: 14px; margin-bottom: 8px; }
.acc-chooser-title { font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.acc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.acc-tile { text-align: left; border: none; border-radius: var(--r); padding: 12px; background: var(--bg-2); cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: box-shadow .15s; }
.acc-tile:hover { box-shadow: 0 0 0 2px var(--primary) inset; }
.acc-tile-name { font-weight: 500; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.acc-tile-sub { font-size: 12px; color: var(--text-2); line-height: 1.4; }
.acc-tile-fast { font-size: 11px; font-weight: 500; color: var(--ok); }
details.adv { margin: 4px 0 10px; }
details.adv summary { font-size: 13px; color: var(--primary); cursor: pointer; margin-bottom: 10px; }

/* Нейроменеджер */
.ai-box { max-width: 640px; }
.ai-chip { border: none; border-radius: 16px; padding: 5px 11px; font-size: 13px; cursor: pointer; white-space: nowrap; background: var(--bg-2); color: var(--text-2); }
.ai-chip.on { background: rgba(135, 116, 225, .14); color: #6c5bd0; font-weight: 500; }
.ai-chip.handed { background: rgba(230, 162, 60, .16); color: #b06a00; }
.ai-chip:hover { box-shadow: inset 0 0 0 1px currentColor; }
.ai-draft { font-size: 19px; }
.ai-draft.busy { animation: blink 1s infinite; }
.time-row { display: flex; gap: 6px; align-items: center; }
.ai-test { background: var(--bg-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; white-space: pre-wrap; }
.msg-meta .ai { font-size: 12px; }

/* Журнал канала */
.log-box { max-width: 780px; }
.log-lines { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; background: var(--bg-2);
  border-radius: 10px; padding: 8px 10px; max-height: 62vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.log-lines .t { color: var(--text-3); margin-right: 6px; }
.log-lines .trace { color: var(--text-2); }
.log-lines .warn { color: #c27c0e; }
.log-lines .error { color: var(--danger); }

/* Сеть */
.net-summary { width: 100%; text-align: left; border: none; border-radius: var(--r); padding: 12px 14px; background: var(--bg-2); cursor: pointer; margin-bottom: 12px; font-size: 14px; line-height: 1.5; }
.net-summary:hover { box-shadow: 0 0 0 2px var(--primary) inset; }
.net-summary b { font-weight: 500; }
.net-summary .ok, .net-state .ok { color: var(--ok); }
.net-summary .err, .net-state .err { color: var(--danger); }
.net-summary .wait { color: #c27c0e; }
.net-box { max-width: 580px; }
.net-state { font-size: 14px; margin: 12px 0; line-height: 1.5; }
.net-exits { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 40vh; overflow-y: auto; }
.net-exit { border-radius: var(--r); padding: 10px 12px; background: var(--bg-2); }
.net-exit.off { opacity: .55; }
.net-exit-r1 { display: flex; align-items: center; gap: 8px; }
.net-exit-name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-exit-meta { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.net-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.net-badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg); color: var(--text-2); }
.net-badge.ok { background: rgba(79, 174, 78, .15); color: var(--ok); }
.net-badge.err { background: rgba(229, 57, 53, .12); color: var(--danger); }
.net-badge.auto { background: var(--primary-soft); color: var(--primary); }

/* Подключение */
.connect-box { max-width: 440px; }
.cn-qr { width: 264px; height: 264px; border-radius: 12px; background: #fff; padding: 8px; display: block; margin: 0 auto 16px; box-shadow: 0 0 0 1px var(--divider); }
.cn-steps { font-size: 14px; line-height: 1.6; padding-left: 22px; margin: 0 0 12px; }
.cn-steps li { margin-bottom: 4px; }
.cn-steps b { font-weight: 500; }
.cn-code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 34px; font-weight: 600; letter-spacing: .12em; text-align: center; padding: 14px 0; margin: 4px 0 14px; background: var(--bg-2); border-radius: 12px; user-select: all; }
.cn-note { font-size: 13px; color: var(--text-2); line-height: 1.55; margin-bottom: 12px; }
.cn-note.small { font-size: 12px; margin-top: 10px; margin-bottom: 0; }
.cn-hint { font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.cn-err { color: var(--danger); font-size: 13px; margin: -4px 0 10px; }
.cn-err:empty { display: none; }
.cn-alt { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.cn-form .code-inp { font-size: 22px; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }
.cn-wait { padding: 34px 0 26px; text-align: center; color: var(--text-2); font-size: 14px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--divider); border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 14px; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cn-done { text-align: center; padding: 18px 0 8px; }
.cn-done-ico { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 34px; line-height: 64px; margin: 0 auto 14px; }
.cn-done-title { font-size: 18px; font-weight: 500; margin-bottom: 4px; }
.cn-done-sub { font-size: 14px; color: var(--text-2); margin-bottom: 16px; }

/* Шаблоны — управление */
.tmpl-box { max-width: 540px; }
.tmpl-mgr-form { background: var(--bg-2); border-radius: var(--r); padding: 14px; margin-bottom: 14px; }
.tmpl-mgr-inp, .tmpl-mgr-ta { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; background: var(--bg); outline: none; }
.tmpl-mgr-inp:focus, .tmpl-mgr-ta:focus { border-color: var(--primary); }
.tmpl-mgr-inp { margin-bottom: 8px; }
.tmpl-mgr-ta { min-height: 100px; resize: vertical; line-height: 1.45; }
.tmpl-vars { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; align-items: center; }
.tmpl-vars span { font-size: 12px; color: var(--text-2); margin-right: 2px; }
.tmpl-vars button { font-size: 12px; padding: 3px 9px; border-radius: 12px; border: none; background: var(--primary-soft); color: var(--primary); cursor: pointer; }
.tmpl-vars button:hover { background: var(--primary); color: #fff; }
.tmpl-mgr-list { max-height: 320px; overflow-y: auto; }
.tmpl-mgr-item { display: flex; align-items: flex-start; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--divider); }
.tmpl-mgr-item:last-child { border-bottom: none; }
.tmpl-mgr-body { flex: 1; min-width: 0; }
.tmpl-mgr-iname { font-size: 14px; font-weight: 500; margin-bottom: 2px; display: flex; gap: 6px; align-items: center; }
.tmpl-mgr-itext { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmpl-mgr-edit { flex-shrink: 0; background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 3px 6px; }
.tmpl-mgr-del { flex-shrink: 0; background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 17px; padding: 2px 4px; line-height: 1; }
.tmpl-mgr-del:hover { color: var(--danger); }

/* Файл перед отправкой */
.file-box { max-width: 440px; }
.file-preview { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.file-preview img { max-width: 100%; max-height: 300px; border-radius: 10px; object-fit: contain; align-self: center; background: var(--bg-2); }
.file-preview .msg-file { background: var(--bg-2); border-radius: 10px; padding: 8px 10px; }
.file-preview .fs.err { color: var(--danger); }

/* Сотрудники, теги */
.users-box { max-width: 620px; }
.users-settings { background: var(--bg-2); border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; font-size: 14px; display: grid; gap: 10px; }
.users-settings label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.users-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r); background: var(--bg-2); }
.user-row .av { width: 40px; height: 40px; font-size: 15px; }
.user-row .ui { flex: 1; min-width: 0; }
.user-row .un { font-weight: 500; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.user-row .us { font-size: 13px; color: var(--text-2); }
.user-row.off { opacity: .5; }
.role-badge { font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.user-form { border-top: 1px solid var(--divider); padding-top: 14px; }
.tags-box { max-width: 460px; }
.tag-form { display: flex; flex-direction: column; gap: 10px; background: var(--bg-2); padding: 12px; border-radius: var(--r); margin-bottom: 14px; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-row button.on { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--bg); }
.tags-list { display: flex; flex-direction: column; }
.tag-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--divider); }
.tag-row:last-child { border-bottom: none; }
.tag-row .tag-chip { margin-right: auto; cursor: default; }
.tag-row .cnt-l { font-size: 13px; color: var(--text-2); }

/* Аналитика */
.analytics-box { max-width: 800px; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; margin-bottom: 16px; flex-wrap: wrap; }
.seg button { border: none; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.kpi { background: var(--bg-2); border-radius: var(--r); padding: 12px 14px; }
.kpi .kv { font-size: 24px; font-weight: 500; }
.kpi .kl { font-size: 13px; color: var(--text-2); margin-top: 2px; line-height: 1.35; }
.kpi .kv.bad { color: var(--danger); }
.kpi .kv.good { color: var(--ok); }
.an-h { font-size: 15px; font-weight: 500; margin: 18px 0 8px; }
.an-note { font-size: 12px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }
.an-wrap { overflow-x: auto; }
.an-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
.an-table th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--divider); }
.an-table th.num, .an-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.an-table td { padding: 8px; border-bottom: 1px solid var(--divider); }
.bars { display: flex; justify-content: center; align-items: flex-end; gap: 3px; height: 130px; padding-top: 8px; border-bottom: 1px solid var(--divider); }
.bars .b { flex: 1; max-width: 56px; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 4px; height: 100%; }
.bars .b i { display: block; border-radius: 3px 3px 0 0; min-height: 0; }
.bars .b i.in { background: var(--primary); }
.bars .b i.out { background: var(--ok); }
.bars .b i.h { background: var(--warn); }
.bars-x { display: flex; justify-content: center; gap: 3px; font-size: 10px; color: var(--text-2); margin-top: 4px; }
.bars-x span { flex: 1; max-width: 56px; text-align: center; min-width: 4px; overflow: hidden; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ─── Телефон: список и переписка по очереди ─────────────────────────────── */
@media (max-width: 760px) {
  .sidebar { width: 100%; min-width: 0; border-right: none; }
  .chat { display: none; }
  body.chat-open .sidebar { display: none; }
  body.chat-open .chat { display: flex; }
  .back-btn { display: inline-flex; }
  .chat-head { padding: 0 4px 0 8px; gap: 8px; }
  .msgs-area { padding: 8px 8px 6px; }
  .msg-bubble { max-width: 86%; }
  .compose-wrap { padding: 4px 8px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
  .send-btn { width: 48px; height: 48px; }
  .head-badge { display: none; }
  .assignee-chip { max-width: 44px; padding: 0 4px; }
  .assignee-chip span:not(.av), .assignee-chip svg { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal-box { max-height: calc(100dvh - 16px); }
  .to-bottom { right: 12px; bottom: 76px; }
}

/* ─── Действия с сообщениями ─────────────────────────────────────────────── */
.pop-item .pi-ico { width: 22px; display: inline-flex; justify-content: center; font-size: 16px; color: var(--text-2); }
.pop-item .pi-ico svg { width: 20px; height: 20px; }
.pop-item.danger { color: var(--danger); }
.pop-item.danger .pi-ico { color: var(--danger); }
.pop-head.small { font-size: 11.5px; line-height: 1.35; padding-bottom: 6px; }

/* кнопка «⋯» у пузыря — при наведении */
.msg-more { position: absolute; top: 2px; width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--bg); color: var(--text-2);
  box-shadow: var(--bubble-shadow); cursor: pointer; display: none; align-items: center; justify-content: center; padding: 0; z-index: 1; }
.msg-more svg { width: 16px; height: 16px; }
.msg-in .msg-more { right: -32px; }
.msg-out .msg-more { left: -32px; }
@media (hover: hover) { .msg:hover .msg-more { display: inline-flex; } }
.msg-more:hover { color: var(--primary); }

/* цитата и «переслано» */
.msg-quote { display: flex; flex-direction: column; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 4px 6px 6px 4px;
  padding: 3px 8px 4px; margin: 1px 0 5px; font-size: 13.5px; line-height: 1.3; cursor: pointer; max-width: 100%; overflow: hidden; }
.msg-quote b { color: var(--primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); opacity: .85; }
.msg-out .msg-quote { border-left-color: var(--meta-out); background: rgba(79, 174, 78, .12); }
.msg-out .msg-quote b { color: var(--meta-out); }
.msg-quote:hover { filter: brightness(.97); }
.msg-fwd { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--primary); margin-bottom: 2px; font-weight: 500; }
.msg-out .msg-fwd { color: var(--meta-out); }
.msg-fwd svg { width: 15px; height: 15px; }
.msg-meta .ed { margin-right: 2px; font-style: italic; }
.msg-meta svg.read { color: var(--meta-out); }
.msg.deleted .msg-bubble { opacity: .75; }
.msg-deleted { font-style: italic; color: var(--text-2); font-size: 14px; }
.msg.scheduled .msg-bubble { background: var(--bg); border: 1.5px dashed var(--primary); }
.msg.scheduled .msg-bubble::after { display: none; }
.msg.scheduled .msg-meta { color: var(--primary); }
.msg-meta .sched::before { content: '⏰ '; }
@keyframes flash { 0%, 60% { background: var(--primary-soft); } 100% { background: transparent; } }
.msg.flash, .msg-note.flash { animation: flash 2.2s ease-out; border-radius: 10px; }
.msgs-area.loading-older::before { content: 'Загрузка…'; display: block; text-align: center; color: #fff; font-size: 13px; margin: 0 auto 6px;
  background: var(--service-bg); border-radius: 12px; padding: 2px 12px; width: auto; max-width: none; align-self: center; }
@media (pointer: coarse) { .msg-bubble { -webkit-touch-callout: none; } }

/* кружок */
.msg-round { position: relative; width: 240px; height: 240px; border-radius: 50%; overflow: hidden; cursor: pointer; background: #000; box-shadow: var(--bubble-shadow); }
.msg-round video { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg-round .round-ico { position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff;
  display: flex; align-items: center; justify-content: center; pointer-events: none; }
.msg-round.playing .round-ico { opacity: 0; }
.msg-round .round-dur { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 12px; color: #fff; background: rgba(0,0,0,.45); padding: 1px 7px; border-radius: 10px; pointer-events: none; }
@media (max-width: 760px) { .msg-round { width: 200px; height: 200px; } }

/* PDF */
.pdf-open { margin: 2px 0 6px 56px; border: 1px solid var(--primary); color: var(--primary); background: none; border-radius: 14px; padding: 2px 12px; font-size: 13px; cursor: pointer; }
.msg-out .pdf-open { border-color: var(--meta-out); color: var(--meta-out); }
.pdf-box { max-width: min(980px, 96vw); height: 92dvh; display: flex; flex-direction: column; padding: 12px 14px 14px; }
.pdf-box .modal-title { gap: 10px; }
.pdf-box .modal-title span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-dl { font-size: 14px; white-space: nowrap; text-decoration: none; }
#pdf-frame { flex: 1; width: 100%; border: 1px solid var(--divider); border-radius: 8px; background: #fff; }

/* превью ссылки */
.lp { display: flex; gap: 8px; margin: 6px 0 2px; border-left: 3px solid var(--primary); padding: 2px 0 2px 8px; text-decoration: none; color: inherit; max-width: 100%; }
.msg-out .lp { border-left-color: var(--meta-out); }
.lp img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: rgba(0,0,0,.05); }
.lp-b { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; line-height: 1.3; }
.lp-b b { color: var(--primary); font-weight: 500; }
.msg-out .lp-b b { color: var(--meta-out); }
.lp-t { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-d { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msg-out .lp-d { color: inherit; opacity: .75; }

/* ответ / правка / вложение быстрого ответа над полем ввода */
.reply-bar, .pending-file { display: flex; align-items: center; gap: 10px; padding: 7px 6px 2px 12px; }
.reply-bar > svg { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }
.rb-body, .pf-body { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 2px solid var(--primary); padding-left: 8px; font-size: 13.5px; line-height: 1.3; cursor: pointer; }
.rb-body b, .pf-body b { color: var(--primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-body span, .pf-body span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.pending-file img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.pending-file .fi { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pending-file .fi svg { width: 20px; height: 20px; }
.send-btn.editing .ico-send, .send-btn.editing .ico-mic { display: none !important; }
.send-btn.editing::after { content: '✓'; font-size: 24px; font-weight: 700; color: inherit; }

/* поиск в чате */
.chat-search { display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 14px; background: var(--bg); box-shadow: 0 1px 0 var(--divider); z-index: 3; }
.chat-search > svg { width: 18px; height: 18px; color: var(--text-2); }
.chat-search input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-size: 15px; padding: 6px 0; }
.cs-count { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.icon-btn.small { width: 32px; height: 32px; font-size: 15px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.chat-search { position: relative; }
.chat-search-res { position: absolute; top: 100%; left: 0; right: 0; z-index: 6; background: var(--bg); box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.csr { display: flex; flex-direction: column; width: 100%; text-align: left; border: none; background: none; padding: 7px 16px; cursor: pointer; gap: 1px; }
.csr:hover, .csr.on { background: var(--hover); }
.csr-t { font-size: 12px; color: var(--text-2); }
.csr-b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
mark { background: rgba(255, 200, 0, .45); color: inherit; border-radius: 2px; }

/* тот же клиент в других каналах */
.head-others { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 5px 16px; font-size: 12.5px; color: var(--text-2); background: var(--bg); box-shadow: 0 1px 0 var(--divider); z-index: 2; }
.head-others .oc { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--bg); border-radius: 14px; padding: 2px 10px 2px 3px; font-size: 13px; cursor: pointer; color: var(--text); }
.head-others .oc:hover { border-color: var(--primary); color: var(--primary); }
.head-others .k-logo { width: 20px; height: 20px; }

/* список: черновик, без звука, «непрочитанный», найденные сообщения */
.conv-prev .draft { color: var(--danger); }
.conv-time svg.mute { width: 15px; height: 15px; color: var(--text-3); }
.unread-cnt.muted { background: var(--muted-badge); }
.unread-cnt.mark { min-width: 20px; height: 20px; padding: 0; }
.list-sep { font-size: 13px; color: var(--text-2); padding: 10px 16px 6px; background: var(--bg-2); font-weight: 500; }
.conv-item.hit .conv-prev { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#chat-more-btn.on { color: var(--primary); }

/* эмодзи */
.emoji-pop { width: 320px; padding: 0; max-height: 340px; display: flex; flex-direction: column; overflow: hidden; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 6px 4px; border-bottom: 1px solid var(--divider); flex-shrink: 0; }
.emoji-tabs button { flex: 1; border: none; background: none; font-size: 18px; padding: 4px 0; border-radius: 8px; cursor: pointer; opacity: .55; }
.emoji-tabs button.on { opacity: 1; background: var(--hover); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); padding: 6px; overflow-y: auto; }
.emoji-grid button { border: none; background: none; font-size: 24px; line-height: 1; padding: 5px 0; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--hover); }
@media (pointer: coarse) { #emoji-btn { display: none; } } /* на телефоне — эмодзи с клавиатуры */

/* переслать */
.fwd-box { max-width: 460px; display: flex; flex-direction: column; gap: 10px; }
.fwd-what { display: flex; gap: 10px; align-items: center; background: var(--bg-2); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; }
.fwd-what svg { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; }
.fwd-what div { display: flex; flex-direction: column; min-width: 0; }
.fwd-what b { font-weight: 500; color: var(--primary); }
.fwd-what span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.fwd-list { max-height: 46dvh; overflow-y: auto; border: 1px solid var(--divider); border-radius: 10px; }
.fwd-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; padding: 7px 12px; cursor: pointer; text-align: left; }
.fwd-item:hover { background: var(--hover); }
.fwd-item.on { background: var(--primary-soft); }
.fwd-item:disabled { opacity: .5; cursor: default; }
.fwd-item .av { width: 38px; height: 38px; font-size: 14px; position: relative; overflow: hidden; flex-shrink: 0; }
.fwd-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fwd-name small { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.fwd-name .k-logo { width: 16px; height: 16px; }
.fwd-ck { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.fwd-item.on .fwd-ck { background: var(--primary); border-color: var(--primary); }

/* быстрые ответы: вложение */
.tmpl-file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.tmpl-file-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; background: var(--bg-2); border-radius: 14px; padding: 0 2px 0 10px; }
.tmpl-file-chip .x-btn { width: 26px; height: 26px; font-size: 13px; }

/* горячие клавиши */
.keys-box { max-width: 480px; }
.keys-list { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.keys-list div { display: flex; align-items: center; gap: 4px; }
.keys-list span { margin-left: auto; color: var(--text-2); text-align: right; padding-left: 12px; }
kbd { font-family: inherit; font-size: 12px; background: var(--bg-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
.keys-hint { margin-top: 14px; font-size: 13px; color: var(--text-2); line-height: 1.45; }

#chat-pop, #msg-pop { max-width: min(320px, calc(100vw - 16px)); }

/* ─── Время в строке текста, дни, «Новые сообщения» ───────────────────────── */
/* время прижато к концу последней строки; не помещается — уходит на следующую */
.msg-text .msg-meta { float: right; position: relative; top: 6px; margin: 0 -4px 0 14px; line-height: 16px; height: 16px; }
.msg-text::after { content: ''; display: table; clear: both; }
/* день — своим блоком: его дата «прилипает» только пока виден этот день */
.day { display: flex; flex-direction: column; }
.unread-sep { display: flex; justify-content: center; margin: 8px -16px; padding: 4px 0; background: var(--service-bg); }
.unread-sep span { color: #fff; font-size: 13px; font-weight: 500; }
.to-bottom .tb-cnt { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--primary); color: #fff;
  font-size: 12px; font-weight: 500; display: flex; align-items: center; justify-content: center; padding: 0 6px; }

/* ─── Альбом ───────────────────────────────────────────────────────────── */
.msg-bubble.has-album { width: min(420px, 82%); }
.album { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; margin: -2px -6px 4px; border-radius: 12px; overflow: hidden; }
.album.solo { margin: -4px -8px -5px; }
.alb-t { position: relative; height: 150px; background: rgba(0, 0, 0, .08); overflow: hidden; }
.alb-t img, .alb-t video { width: 100%; height: 100%; object-fit: cover; display: block; }
.album .msg-img { max-height: none; min-width: 0; min-height: 0; cursor: zoom-in; }
.album.n3 .alb-t:first-child { grid-column: span 2; height: 210px; }
.album.n5, .album.n6 { grid-template-columns: repeat(6, 1fr); }
.album.n5 .alb-t:nth-child(-n+2) { grid-column: span 3; height: 160px; }
.album.n5 .alb-t:nth-child(n+3), .album.n6 .alb-t { grid-column: span 2; height: 115px; }
.alb-play { position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; }
.alb-play svg { width: 22px; height: 22px; }
@media (max-width: 760px) { .alb-t { height: 120px; } .album.n3 .alb-t:first-child { height: 170px; } }

/* ─── «Печатает…» и «Олеся отвечает…» ──────────────────────────────────── */
.head-sub .typing, .typing-prev { color: var(--primary); }
.conv-item.active .typing-prev { color: #fff; }
.staff-typing { align-self: center; margin: 0 auto 4px; background: var(--warn-bg); color: var(--warn-text); font-size: 13px; padding: 4px 12px; border-radius: 12px;
  box-shadow: var(--bubble-shadow); max-width: calc(100% - 32px); z-index: 2; }

/* ─── Клиент: статус и метки в строке, каналы, ★ ───────────────────────── */
.conv-chips { display: flex; gap: 4px; margin-top: 4px; overflow: hidden; }
.cchip { font-size: 11px; font-weight: 500; line-height: 18px; padding: 0 7px; border-radius: 9px; color: #fff; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.cchip.more { background: var(--bg-2); color: var(--text-2); }
.conv-item.active .cchip { box-shadow: 0 0 0 1px rgba(255, 255, 255, .55); }
.cfav { color: #f5b301; font-size: 14px; flex-shrink: 0; }
.cchan { width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.cchan svg { width: 11px; height: 11px; }
.conv-name { flex: 0 1 auto; }
.conv-r1 .conv-time { margin-left: auto; }
.search-new { display: block; width: calc(100% - 16px); margin: 6px 8px; padding: 10px 14px; border: 1px dashed var(--primary); border-radius: var(--r); background: var(--primary-soft); color: var(--primary); text-align: left; font-size: 14px; cursor: pointer; }
.tf-sep { width: 1px; background: var(--divider); flex-shrink: 0; margin: 2px 2px; }
.tf-clear { padding: 3px 8px; }

/* вкладки каналов клиента в чате */
.head-others { gap: 4px; padding: 4px 12px 0; box-shadow: 0 1px 0 var(--divider); }
.cht { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; padding: 6px 10px 8px; font-size: 13.5px; font-weight: 500; color: var(--text-2); cursor: pointer; border-radius: 8px 8px 0 0; position: relative; }
.cht:hover { background: var(--hover); color: var(--text); }
.cht.on { color: var(--primary); cursor: default; }
.cht.on::after { content: ''; position: absolute; left: 6px; right: 6px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.cht .k-logo { width: 18px; height: 18px; }
.cht i { font-style: normal; font-size: 11px; background: var(--unread); color: #fff; border-radius: 9px; padding: 0 6px; line-height: 18px; }

/* ─── Карточка клиента ─────────────────────────────────────────────────── */
.client-card { width: 340px; flex-shrink: 0; background: var(--bg); border-left: 1px solid var(--divider); overflow-y: auto; padding: 0 0 20px; }
.cc-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 10px 16px; background: var(--bg); border-bottom: 1px solid var(--divider); font-size: 16px; }
.cc-empty { padding: 24px 16px; color: var(--text-2); font-size: 14px; }
.cc-top { display: flex; align-items: center; gap: 12px; padding: 14px 16px 6px; }
.cc-av { width: 56px; height: 56px; font-size: 20px; position: relative; overflow: hidden; flex-shrink: 0; }
.cc-name { flex: 1; min-width: 0; }
.cc-fav { border: none; background: none; font-size: 24px; color: var(--text-3); cursor: pointer; line-height: 1; padding: 4px; }
.cc-fav.on { color: #f5b301; }
.cc-row { display: flex; align-items: center; gap: 8px; padding: 6px 16px; flex-wrap: wrap; }
.cc-status { border: 1px solid var(--border); background: var(--bg-2); color: var(--text); border-radius: 14px; padding: 5px 10px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.cc-call { margin-left: auto; text-decoration: none; font-size: 13.5px; color: var(--ok); border: 1px solid var(--ok); border-radius: 14px; padding: 4px 12px; }
.cc-sec { font-size: 12.5px; font-weight: 500; color: var(--primary); padding: 14px 16px 6px; text-transform: uppercase; letter-spacing: .3px; }
.cc-chans { padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }
.cc-chan { display: flex; align-items: center; border-radius: 10px; }
.cc-chan.on { background: var(--primary-soft); }
.cc-chan-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: none; background: none; padding: 7px 8px; text-align: left; cursor: pointer; border-radius: 10px; }
.cc-chan-open:hover { background: var(--hover); }
.cc-chan-open .k-logo { width: 28px; height: 28px; }
.cc-chan-open .k-logo svg { width: 17px; height: 17px; }
.cc-chan-open span { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.cc-chan-open small { color: var(--text-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-unread { margin-left: auto; font-style: normal; font-size: 12px; background: var(--unread); color: #fff; border-radius: 10px; padding: 0 7px; line-height: 20px; }
.cc-unlink { border: none; background: none; color: var(--text-3); cursor: pointer; width: 30px; height: 30px; border-radius: 50%; }
.cc-unlink:hover { color: var(--danger); background: var(--hover); }
.cc-link { margin: 6px 8px 0; font-size: 13.5px; text-align: left; }
.cc-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.cc-f { display: flex; flex-direction: column; gap: 3px; padding: 5px 16px; font-size: 12.5px; color: var(--text-2); }
.cc-inp { border: none; border-bottom: 1px solid var(--border); background: none; color: var(--text); font-size: 15px; padding: 4px 0 5px; outline: none; width: 100%; }
.cc-inp:focus { border-bottom-color: var(--primary); }
.cc-inp.big { font-size: 18px; font-weight: 500; }
.cc-note { display: block; width: calc(100% - 32px); margin: 0 16px; min-height: 90px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 14px; background: var(--bg); color: var(--text); resize: vertical; outline: none; }
.cc-note:focus { border-color: var(--primary); }
.cc-hint { padding: 8px 16px 0; font-size: 12px; color: var(--text-3); }
#card-btn.on, body.card-open #card-btn { color: var(--primary); }
.statuses-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.st-row { display: flex; align-items: center; gap: 8px; }
.st-row input[type=color] { width: 36px; height: 36px; border: none; background: none; padding: 0; cursor: pointer; flex-shrink: 0; }
@media (max-width: 1099px) {
  /* узкий экран — карточка поверх чата */
  .client-card { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 60; box-shadow: var(--shadow-lg); }
}

/* ─── Бэкап — строкой в меню ───────────────────────────────────────────── */
.menu-info { font-size: 12.5px; color: var(--text-2); padding: 8px 16px; line-height: 1.4; }
.menu-info.warn { color: var(--danger); }

/* ─── Закреплённое сообщение ───────────────────────────────────────────── */
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 14px; background: var(--bg); box-shadow: 0 1px 0 var(--divider); z-index: 2; }
.pb-ico { font-size: 16px; }
.pb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 2px solid var(--primary); padding-left: 8px; cursor: pointer; font-size: 13.5px; line-height: 1.3; }
.pb-body b { color: var(--primary); font-weight: 500; }
.pb-body span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Выбор сообщений ──────────────────────────────────────────────────── */
.select-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin: 0 auto 12px; width: calc(100% - 32px); max-width: 728px; background: var(--bg); border-radius: 16px; box-shadow: var(--bubble-shadow); }
.select-bar b { font-weight: 500; margin-right: auto; }
.sb-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 16px; padding: 5px 12px; font-size: 13.5px; cursor: pointer; }
.sb-btn svg { width: 16px; height: 16px; }
.sb-btn.danger { color: var(--danger); }
.sb-btn:disabled { opacity: .5; cursor: default; }
.compose-wrap.hidden-by-select { display: none !important; }
.msg.selecting { position: relative; cursor: pointer; padding-left: 34px; }
.msg-check { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .9);
  background: rgba(0, 0, 0, .15); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.msg.picked .msg-check { background: var(--primary); border-color: var(--primary); }
.msg.picked .msg-bubble { filter: brightness(.94); }

/* ─── Реакции ──────────────────────────────────────────────────────────── */
.msg-reacts { display: flex; gap: 4px; margin-top: 3px; }
.msg-in .msg-reacts { padding-left: 4px; }
.msg-out .msg-reacts { padding-right: 4px; }
.rc { font-size: 15px; line-height: 24px; padding: 0 8px; border-radius: 12px; background: var(--bg); box-shadow: var(--bubble-shadow); border: none; }
.rc.mine { background: var(--primary); cursor: pointer; }
.react-row { display: flex; gap: 2px; padding: 4px 8px 6px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.react-row button { border: none; background: none; font-size: 22px; line-height: 1; padding: 5px; border-radius: 10px; cursor: pointer; }
.react-row button:hover { background: var(--hover); transform: scale(1.12); }
.react-row button.on { background: var(--primary-soft); }

/* ─── Общая лента клиента ──────────────────────────────────────────────── */
.cht.all { font-weight: 500; }
.mchan { width: 14px; height: 14px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; margin-right: 3px; flex-shrink: 0; }
.mchan svg { width: 10px !important; height: 10px !important; }
.msg-meta .auto { font-style: italic; }
.target-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 7px 10px 2px 14px; font-size: 13px; color: var(--text-2); }
.tg-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 14px; padding: 2px 10px 2px 3px; font-size: 13px; cursor: pointer; }
.tg-chip .k-logo { width: 18px; height: 18px; }
.tg-chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 500; }

/* ─── Голосовые: скорость и расшифровка ────────────────────────────────── */
.voice-speed { border: none; background: var(--primary-soft); color: var(--primary); border-radius: 10px; font-size: 12px; font-weight: 500; padding: 2px 7px; cursor: pointer; align-self: center; margin-left: 4px; flex-shrink: 0; }
.msg-out .voice-speed { background: rgba(79, 174, 78, .15); color: var(--meta-out); }
.vtext { font-size: 14px; line-height: 1.35; margin: 6px 0 2px; padding: 6px 9px; border-radius: 10px; background: var(--primary-soft); white-space: pre-wrap; max-width: 340px; }
.msg-out .vtext { background: rgba(79, 174, 78, .12); }
.vtext.wait { color: var(--text-2); font-style: italic; }
.vtext.err { color: var(--danger); font-size: 12.5px; }
.vt-btn { display: inline-block; margin-top: 4px; border: none; background: var(--primary-soft); color: var(--primary); border-radius: 12px; font-size: 12.5px; padding: 3px 10px; cursor: pointer; }
.msg-out .vt-btn { background: rgba(79, 174, 78, .15); color: var(--meta-out); }
.msg-round + .vtext, .msg-round ~ .vt-btn { max-width: 240px; }

/* ─── Окна: автоответ, расшифровка ─────────────────────────────────────── */
.ar-hours { display: flex; align-items: center; gap: 8px; }
.ar-hours .modal-inp { width: auto; }
.ar-days { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chip input { display: none; }
.day-chip span { display: inline-block; padding: 5px 11px; border-radius: 14px; border: 1px solid var(--border); font-size: 13.5px; cursor: pointer; }
.day-chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.stt-eng { display: flex; flex-direction: column; align-items: stretch; gap: 2px; width: 100%; }
.stt-eng label { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.stt-eng label:has(input:checked) { background: var(--bg); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 500; }
.stt-help { font-size: 12.5px; color: var(--text-2); line-height: 1.45; margin: 0 0 10px; }

/* ─── Карточка: медиа, файлы, ссылки ───────────────────────────────────── */
.cc-mtabs { display: flex; gap: 4px; padding: 0 12px 8px; }
.cc-mtabs button { flex: 1; border: none; background: var(--bg-2); color: var(--text-2); border-radius: 10px; padding: 6px 0; font-size: 13px; cursor: pointer; }
.cc-mtabs button.on { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.cc-media { padding: 0 12px; }
.cc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.cc-tile { position: relative; aspect-ratio: 1; border: none; padding: 0; overflow: hidden; border-radius: 6px; background: var(--bg-2); cursor: pointer; }
.cc-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-tile i { position: absolute; right: 4px; bottom: 4px; font-style: normal; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .5); border-radius: 8px; padding: 0 6px; }
.cc-vid { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 22px; color: var(--text-2); }
.cc-tile .cc-blur { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); filter: blur(6px); }
.cc-tile .cc-blur + .cc-vid { position: relative; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.cc-file { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.cc-file .fi { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cc-file .fi svg { width: 18px; height: 18px; }
.cc-file-b { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; border: none; background: none; cursor: pointer; padding: 0; color: var(--text); }
.cc-file-b b { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-file-b small { font-size: 12px; color: var(--text-2); }
.cc-dl { text-decoration: none; font-size: 16px; padding: 4px 6px; }
.cc-link-row { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; font-size: 13.5px; border-bottom: 1px solid var(--divider); }
.cc-link-row a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-link-row .link-btn { font-size: 12px; white-space: nowrap; }

/* ─── Свайпы ───────────────────────────────────────────────────────────── */
.msg.swipe-ready .msg-bubble { box-shadow: 0 0 0 2px var(--primary); }
.conv-item.swipe-ready { background: var(--primary-soft); }

/* Витрина (демо для заведений): окно «Это демо-версия» */
.showcase-box p { font-size: 15px; line-height: 1.45; margin-bottom: 12px; }
.showcase-box ul { margin: 0 0 12px 18px; font-size: 14px; line-height: 1.45; }
.showcase-box li { margin-bottom: 6px; }
.showcase-note { color: var(--text-2); font-size: 13px !important; }
.showcase-box a.modal-btn { text-decoration: none; display: inline-flex; align-items: center; }
