/* Мессенджер БАНЬЯН. Вид в духе Telegram (решение 29.10): раскладка, пузыри с хвостиками, плавающие даты,
   поле ввода «островом» на фоне; значки, узор фона и цвета — свои. Тёмная тема — html[data-theme="dark"]
   (ставит js/theme.js: «авто» по системе или выбор в меню). Админ-панель и помощь тоже берут этот файл,
   тёмную тему им не включаем. */
:root {
  --accent: #3390ec; --accent-ink: #2a7ac9; --accent-soft: rgba(51, 144, 236, .12); --on-accent: #fff;
  --bg: #f4f4f5; --panel: #fff; --text: #111417; --muted: #707579; --line: #e4e6ea;
  --err: #e53935; --err-soft: #fdecec; --ok: #4fae4e;
  --hover: #f4f4f5; --active: var(--accent); --active-ink: #fff;
  --wall: linear-gradient(160deg, #d4e5cc 0%, #e4e3bf 38%, #c6ddd5 72%, #bcd4df 100%);
  --pattern: #31533a; --pattern-op: .11;
  --theirs: #fff; --mine: #e2f8d1; --meta: #8d969c; --mine-meta: #4fa24d; --read: #3390ec;
  --mine-soft: rgba(79, 162, 77, .14); --mine-strong: #4fa24d;
  --sys-bg: rgba(46, 70, 52, .42); --sys-ink: #fff;
  --shadow: 0 1px 2px rgba(16, 35, 47, .15);
  --pop-bg: rgba(255, 255, 255, .94); --pop-shadow: 0 6px 28px rgba(16, 35, 47, .2);
  --field: #fff; --field-line: #d5d9de;
  --scroll: rgba(0, 0, 0, .18);
  /* цвета людей: фон аватара и имя в пузыре */
  --av0: #e3666f; --av1: #ef9550; --av2: #9a84df; --av3: #5fb35a; --av4: #47b3bb; --av5: #4b9ad8; --av6: #df6c9d; --av7: #c49c33;
  --pc0: #c8434d; --pc1: #c7671e; --pc2: #7258c4; --pc3: #3a9334; --pc4: #24939b; --pc5: #2d7bbf; --pc6: #c04a7d; --pc7: #9e7b17;
  color-scheme: light;
}
html[data-theme="dark"] {
  --accent: #5ea9ee; --accent-ink: #6eb4f2; --accent-soft: rgba(94, 169, 238, .16); --on-accent: #fff;
  --bg: #242f3d; --panel: #17212b; --text: #f2f5f8; --muted: #7d8e9e; --line: #0e1621;
  --err: #ef5350; --err-soft: rgba(239, 83, 80, .14); --ok: #5fc15c;
  --hover: #202b36; --active: #2b5278; --active-ink: #fff;
  --wall: #0e1621; --pattern: #8fb3d0; --pattern-op: .045;
  --theirs: #182533; --mine: #2b5278; --meta: #6d8193; --mine-meta: #7fb2e0; --read: #8fd0ff;
  --mine-soft: rgba(255, 255, 255, .1); --mine-strong: #5ea9ee;
  --sys-bg: rgba(36, 52, 68, .78); --sys-ink: #e8eef3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --pop-bg: rgba(30, 41, 53, .96); --pop-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --field: #242f3d; --field-line: #2f3b4a;
  --scroll: rgba(255, 255, 255, .16);
  --pc0: #f07f86; --pc1: #f5a86b; --pc2: #b4a3f0; --pc3: #7fcf79; --pc4: #6fd0d6; --pc5: #6db6ef; --pc6: #f08fb8; --pc7: #e0bd5a;
  color-scheme: dark;
}
* { box-sizing: border-box; }

/* ───── Смайлики: шрифт Noto Color Emoji (Google, SIL OFL 1.1 — vendor/noto-emoji-47/OFL.txt; куски из fontsource v47, оставлены цветные контуры COLRv1 без таблицы SVG) с нашего сервера:
   браузер качает только те, где есть показанные смайлики. На айфонах и маках раньше него — родной Apple Color Emoji. */
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-0.woff2) format('woff2'); unicode-range: U+1f1e6-1f1ff; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-1.woff2) format('woff2'); unicode-range: U+200d,U+2620,U+26a7,U+fe0f,U+1f308,U+1f38c,U+1f3c1,U+1f3f3-1f3f4,U+1f6a9,U+e0062-e0063,U+e0065,U+e0067,U+e006c,U+e006e,U+e0073-e0074,U+e0077,U+e007f; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-2.woff2) format('woff2'); unicode-range: U+23,U+2a,U+30-39,U+a9,U+ae,U+200d,U+203c,U+2049,U+20e3,U+2122,U+2139,U+2194-2199,U+21a9-21aa,U+23cf,U+23e9-23ef,U+23f8-23fa,U+24c2,U+25aa-25ab,U+25b6,U+25c0,U+25fb-25fe,U+2611,U+2622-2623,U+2626,U+262a,U+262e-262f,U+2638,U+2640,U+2642,U+2648-2653,U+2660,U+2663,U+2665-2666,U+2668,U+267b,U+267e-267f,U+2695,U+269b-269c,U+26a0,U+26a7,U+26aa-26ab,U+26ce,U+26d4,U+2705,U+2714,U+2716,U+271d,U+2721,U+2733-2734,U+2747,U+274c,U+274e,U+2753-2755,U+2757,U+2764,U+2795-2797,U+27a1,U+27b0,U+27bf,U+2934-2935,U+2b05-2b07,U+2b1b-2b1c,U+2b55,U+3030,U+303d,U+3297,U+3299,U+fe0f,U+1f170-1f171,U+1f17e-1f17f,U+1f18e,U+1f191-1f19a,U+1f201-1f202,U+1f21a,U+1f22f,U+1f232-1f23a,U+1f250-1f251,U+1f310,U+1f3a6,U+1f3b5-1f3b6,U+1f3bc,U+1f3e7,U+1f441,U+1f499-1f49c,U+1f49f-1f4a0,U+1f4ac-1f4ad,U+1f4b1-1f4b2,U+1f4b9,U+1f4db,U+1f4f2-1f4f6,U+1f500-1f507,U+1f515,U+1f518-1f524,U+1f52f-1f53d,U+1f549,U+1f54e,U+1f5a4,U+1f5e8,U+1f5ef,U+1f6ab,U+1f6ad-1f6b1,U+1f6b3,U+1f6b7-1f6bc,U+1f6be,U+1f6c2-1f6c5,U+1f6d0-1f6d1,U+1f6d7,U+1f6dc,U+1f7e0-1f7eb,U+1f7f0,U+1f90d-1f90e,U+1f9d1-1f9d2,U+1f9e1,U+1fa75-1fa77,U+1faaf; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-3.woff2) format('woff2'); unicode-range: U+200d,U+231a-231b,U+2328,U+23f0-23f3,U+2602,U+260e,U+2692,U+2694,U+2696-2697,U+2699,U+26b0-26b1,U+26cf,U+26d1,U+26d3,U+2702,U+2709,U+270f,U+2712,U+fe0f,U+1f302,U+1f321,U+1f392-1f393,U+1f3a9,U+1f3bd,U+1f3ee,U+1f3f7,U+1f3fa,U+1f451-1f462,U+1f484,U+1f489-1f48a,U+1f48c-1f48e,U+1f4a1,U+1f4a3,U+1f4a5,U+1f4b0,U+1f4b3-1f4b8,U+1f4bb-1f4da,U+1f4dc-1f4f1,U+1f4ff,U+1f508-1f514,U+1f516-1f517,U+1f526-1f529,U+1f52c-1f52e,U+1f550-1f567,U+1f56f-1f570,U+1f576,U+1f587,U+1f58a-1f58d,U+1f5a5,U+1f5a8,U+1f5b1-1f5b2,U+1f5c2-1f5c4,U+1f5d1-1f5d3,U+1f5dc-1f5de,U+1f5e1,U+1f5f3,U+1f6aa,U+1f6ac,U+1f6bd,U+1f6bf,U+1f6c1,U+1f6cb,U+1f6cd-1f6cf,U+1f6d2,U+1f6e0-1f6e1,U+1f6f0,U+1f97b-1f97f,U+1f9af,U+1f9ba,U+1f9e2-1f9e6,U+1f9ea-1f9ec,U+1f9ee-1f9f4,U+1f9f7-1f9ff,U+1fa71-1fa74,U+1fa79-1fa7b,U+1fa86,U+1fa8e-1fa8f,U+1fa91-1fa93,U+1fa96,U+1fa99-1faa0,U+1faa2-1faa7,U+1faaa-1faae; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-4.woff2) format('woff2'); unicode-range: U+265f,U+26bd-26be,U+26f3,U+26f8,U+fe0f,U+1f004,U+1f0cf,U+1f380-1f384,U+1f386-1f38b,U+1f38d-1f391,U+1f396-1f397,U+1f399-1f39b,U+1f39e-1f39f,U+1f3a3-1f3a5,U+1f3a7-1f3a9,U+1f3ab-1f3b4,U+1f3b7-1f3bb,U+1f3bd-1f3c0,U+1f3c5-1f3c6,U+1f3c8-1f3c9,U+1f3cf-1f3d3,U+1f3f8-1f3f9,U+1f47e,U+1f4e2,U+1f4f7-1f4fd,U+1f52b,U+1f579,U+1f58c-1f58d,U+1f5bc,U+1f6f7,U+1f6f9,U+1f6fc,U+1f93f,U+1f941,U+1f945,U+1f947-1f94f,U+1f9e7-1f9e9,U+1f9f5-1f9f6,U+1fa70-1fa71,U+1fa80-1fa81,U+1fa83-1fa85,U+1fa87-1fa8a,U+1fa94-1fa95,U+1fa97-1fa98,U+1faa1,U+1faa9,U+1fadf; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-5.woff2) format('woff2'); unicode-range: U+2693,U+26e9-26ea,U+26f1-26f2,U+26f4-26f5,U+26fa,U+26fd,U+2708,U+fe0f,U+1f301,U+1f303,U+1f306-1f307,U+1f309,U+1f310,U+1f3a0-1f3a2,U+1f3aa,U+1f3cd-1f3ce,U+1f3d5,U+1f3d7-1f3db,U+1f3df-1f3e6,U+1f3e8-1f3ed,U+1f3ef-1f3f0,U+1f488,U+1f492,U+1f4ba,U+1f54b-1f54d,U+1f5fa-1f5ff,U+1f680-1f6a2,U+1f6a4-1f6a8,U+1f6b2,U+1f6d1,U+1f6d5-1f6d6,U+1f6dd-1f6df,U+1f6e2-1f6e5,U+1f6e9,U+1f6eb-1f6ec,U+1f6f3-1f6f6,U+1f6f8,U+1f6fa-1f6fb,U+1f9bc-1f9bd,U+1f9ed,U+1f9f3,U+1fa7c; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-6.woff2) format('woff2'); unicode-range: U+200d,U+2615,U+fe0f,U+1f32d-1f330,U+1f336,U+1f33d,U+1f344-1f37f,U+1f382,U+1f52a,U+1f7e9,U+1f7eb,U+1f942-1f944,U+1f950-1f96f,U+1f99e,U+1f9aa,U+1f9c0-1f9cb,U+1fad0-1fadc; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-7.woff2) format('woff2'); unicode-range: U+200d,U+2600-2601,U+2603-2604,U+2614,U+2618,U+26a1,U+26c4-26c5,U+26c8,U+26f0,U+2728,U+2744,U+2b1b,U+2b50,U+fe0f,U+1f300,U+1f304-1f305,U+1f308,U+1f30a-1f30f,U+1f311-1f321,U+1f324-1f32c,U+1f331-1f335,U+1f337-1f33c,U+1f33e-1f344,U+1f3d4,U+1f3d6,U+1f3dc-1f3de,U+1f3f5,U+1f400-1f43f,U+1f490,U+1f4a7,U+1f4ae,U+1f525,U+1f54a,U+1f573,U+1f577-1f578,U+1f648-1f64a,U+1f6d8,U+1f940,U+1f980-1f9ae,U+1f9ba,U+1fa90,U+1faa8,U+1fab0-1fabf,U+1facd-1facf,U+1fae7; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-8.woff2) format('woff2'); unicode-range: U+200d,U+2640,U+2642,U+2695-2696,U+26f7,U+26f9,U+2708,U+2764,U+27a1,U+fe0f,U+1f33e,U+1f373,U+1f37c,U+1f384-1f385,U+1f393,U+1f3a4,U+1f3a8,U+1f3c2-1f3c4,U+1f3c7,U+1f3ca-1f3cc,U+1f3eb,U+1f3ed,U+1f3fb-1f3ff,U+1f430,U+1f466-1f469,U+1f46b-1f478,U+1f47c,U+1f481-1f483,U+1f486-1f487,U+1f48b,U+1f48f,U+1f491,U+1f4bb-1f4bc,U+1f527,U+1f52c,U+1f574-1f575,U+1f57a,U+1f645-1f647,U+1f64b,U+1f64d-1f64e,U+1f680,U+1f692,U+1f6a3,U+1f6b4-1f6b6,U+1f6c0,U+1f6cc,U+1f91d,U+1f926,U+1f930-1f931,U+1f934-1f93a,U+1f93c-1f93e,U+1f977,U+1f9af-1f9b3,U+1f9b8-1f9b9,U+1f9bc-1f9bd,U+1f9cc-1f9cf,U+1f9d1-1f9df,U+1fa70,U+1fa82,U+1fac3-1fac5,U+1fac8,U+1faef; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-9.woff2) format('woff2'); unicode-range: U+200d,U+2194-2195,U+2603,U+261d,U+2620,U+2639-263a,U+2665,U+26a1,U+26c4,U+270a-270d,U+2728,U+2763-2764,U+2b50,U+fe0f,U+1f31a-1f31f,U+1f32b,U+1f389-1f38a,U+1f3fb-1f3ff,U+1f440-1f450,U+1f463-1f465,U+1f479-1f47b,U+1f47d-1f480,U+1f485,U+1f48b-1f48c,U+1f493-1f49f,U+1f4a2,U+1f4a4-1f4a6,U+1f4a8-1f4ab,U+1f4af,U+1f525,U+1f573,U+1f590,U+1f595-1f596,U+1f5a4,U+1f5e3,U+1f600-1f644,U+1f648-1f64a,U+1f64c,U+1f64f,U+1f90c-1f925,U+1f927-1f92f,U+1f932-1f933,U+1f970-1f976,U+1f978-1f97a,U+1f9a0,U+1f9b4-1f9b7,U+1f9bb,U+1f9be-1f9bf,U+1f9d0,U+1f9e0-1f9e1,U+1fa75-1fa79,U+1fac0-1fac2,U+1fac6,U+1fae0-1fae6,U+1fae8-1faea,U+1faef-1fafa; }
@font-face { font-family: 'M15 Emoji'; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/vendor/noto-emoji-47/noto-color-emoji-10.woff2) format('woff2'); unicode-range: U+1f6d9,U+1fa8b-1fa8d,U+1facc,U+1fadd,U+1faeb; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Apple Color Emoji", "M15 Emoji", sans-serif; color: var(--text); background: var(--bg);
       -webkit-font-smoothing: antialiased; }
html[data-theme="dark"] body { background: var(--panel); }
button { font: inherit; color: inherit; }
input, textarea, select { color: inherit; }
.hidden { display: none !important; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ───── Экран входа / сообщений */
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 28px 24px; text-align: center;
        box-shadow: 0 1px 3px rgba(16,24,40,.08), 0 8px 24px rgba(16,24,40,.06); }
.card h1 { font-size: 21px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.err { color: var(--err); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; padding: 10px 20px;
       font-weight: 600; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 10px; cursor: pointer; transition: filter .15s, background .15s; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.ghost { color: var(--accent); background: transparent; }
.btn.danger { background: var(--err); }
.btn.light { color: var(--accent); background: var(--accent-soft); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--accent-soft); border-top-color: var(--accent);
           border-radius: 50%; animation: spin .8s linear infinite; margin: 8px auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───── Каркас: список чатов + лента (на телефоне — по очереди) */
.app { height: 100%; height: 100dvh; display: grid; grid-template-columns: clamp(300px, 30%, 420px) 1fr; overflow: hidden; position: relative; }
.icon-btn { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%;
            background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.ava { flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background-color: var(--av5);
       background-image: linear-gradient(rgba(255,255,255,.24), rgba(255,255,255,0) 70%);
       color: #fff; font-weight: 600; font-size: 17px; letter-spacing: .01em; user-select: none; }
.ava.sm { width: 36px; height: 36px; font-size: 14px; }
.ava.xs { width: 26px; height: 26px; font-size: 11px; }
.ava.lg { width: 112px; height: 112px; font-size: 40px; }
.ava.xl { width: 120px; height: 120px; font-size: 44px; }
.ava { position: relative; overflow: hidden; }
.ava .ava-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.ava.has-photo { background-image: none; }
.ava.zoom { cursor: zoom-in; }
.ava.fired { background: #98a2b3 !important; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px; vertical-align: 1px; }
.chip.fired { background: var(--err-soft); color: var(--err); }
.chip.owner { background: var(--accent-soft); color: var(--accent-ink); }
.title-btn span.chip, .row-p .mid span.chip { display: inline-block; }

/* ───── Слева: шапка с меню и поиском, папки, список, кнопка «новый чат» */
.side { position: relative; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px 8px 8px; min-height: 56px; }
.side-head .search { flex: 1; margin: 0; }
.search { display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; padding: 0 14px; height: 42px; border-radius: 21px; background: var(--bg);
          color: var(--muted); border: 2px solid transparent; transition: border-color .15s, background .15s; }
.search:focus-within { border-color: var(--accent); background: var(--panel); color: var(--accent); }
.search svg.i { width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; padding: 0; height: 100%; font: inherit; font-size: 15px; border: 0; background: transparent; color: var(--text); outline: none; }
.search input::placeholder { color: var(--muted); }
.list { flex: 1; overflow-y: auto; min-height: 0; padding: 6px 8px 84px; }
.item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 9px; border: 0; border-radius: 12px;
        background: transparent; text-align: left; cursor: pointer; transition: background .12s; -webkit-tap-highlight-color: transparent; }
.item > .ava, .item > .ava-wrap .ava { width: 54px; height: 54px; font-size: 19px; }
.item.nested > .ava, .item.nested > .ava-wrap .ava { width: 40px; height: 40px; font-size: 15px; }
.item:hover { background: var(--hover); }
.item.on { background: var(--active); color: var(--active-ink); }
.item .mid { flex: 1; min-width: 0; }
.item .row { display: flex; align-items: center; gap: 5px; min-height: 22px; }
.item .t { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { flex: none; font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 2px; }
.item .time svg.i { width: 17px; height: 17px; color: var(--accent); }
.item .pv { flex: 1; min-width: 0; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .pv .me { color: var(--text); }
.item .pv svg.i { width: 14px; height: 14px; vertical-align: -2px; }
.item.on .time, .item.on .pv, .item.on .pv .me, .item.on .pv .fk, .item.on .parent, .item.on .kind-ico, .item.on .muted-ico, .item.on .time svg.i { color: rgba(255,255,255,.88); }
.item.on .badge { background: #fff; color: var(--accent); }
.item.on .badge.grey { background: rgba(255,255,255,.75); color: var(--active); }
.badge { flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #fff;
         font-size: 12.5px; font-weight: 600; display: inline-grid; place-items: center; }
.badge.grey { background: #a8b0b8; }
html[data-theme="dark"] .badge.grey { background: #3e4c5a; }
.pin-ico { flex: none; color: var(--muted); display: inline-flex; transform: rotate(40deg); }
.item.on .pin-ico { color: rgba(255,255,255,.85); }
.ava.archive-ava { background: #8f9ba7 !important; background-image: none !important; }
html[data-theme="dark"] .ava.archive-ava { background: #3e4c5a !important; }
.item > .ava.archive-ava svg.i { width: 26px; height: 26px; }
.archive-row .t { font-weight: 600; }
.archive-head { display: flex; align-items: center; gap: 8px; padding: 2px 6px 6px 0; font-size: 17px; }
.archive-head b { font-weight: 600; }
.archive-head .muted { font-size: 14px; }
.pin-ico svg.i { width: 16px; height: 16px; }
.empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); }
.fab { position: absolute; right: 20px; bottom: 20px; z-index: 5; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
       display: grid; place-items: center; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.25); transition: transform .15s, filter .15s; }
.fab:hover { filter: brightness(1.07); transform: scale(1.04); }
.fab svg.i { width: 24px; height: 24px; }

/* ───── Справа: фон-обои, шапка чата */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--wall); isolation: isolate; }
.main::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: var(--pattern); opacity: var(--pattern-op);
                -webkit-mask: url(/wall.svg) 0 0 / 320px 320px repeat; mask: url(/wall.svg) 0 0 / 320px 320px repeat; }
.placeholder { flex: 1; display: grid; place-items: center; color: var(--sys-ink); padding: 24px; text-align: center; }
.placeholder span { display: inline-block; padding: 4px 14px; border-radius: 14px; background: var(--sys-bg); font-weight: 500;
                    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 8px 6px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 3; }
.chat-head .ava { width: 42px; height: 42px; font-size: 16px; cursor: pointer; }
.chat-head .back { display: none; }
.title-btn { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; padding: 2px 0; cursor: pointer; }
.title-btn b { display: block; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-btn span { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───── Лента */
.feed { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; padding: 8px max(14px, calc((100% - 760px) / 2)) 10px; overscroll-behavior: contain; }
.feed-note { text-align: center; color: var(--sys-ink); font-size: 13px; margin: 8px auto 12px; width: fit-content; max-width: 90%; padding: 3px 12px; border-radius: 12px; background: var(--sys-bg); }
.list .feed-note, .dialog .feed-note { color: var(--muted); background: none; }
.day-sec { display: flow-root; }
.day, .sys, .unread-line { display: flex; justify-content: center; margin: 10px 0; }
.day { z-index: 2; pointer-events: none; }
.feed.scrolling .day { position: sticky; top: 6px; }
.day span, .sys span { padding: 3px 10px; border-radius: 13px; background: var(--sys-bg); color: var(--sys-ink); font-size: 14px; font-weight: 500; text-align: center; max-width: 90%;
                       -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); overflow-wrap: anywhere; }
.sys span { font-size: 13.5px; }
.unread-line { margin: 12px calc(-1 * max(14px, calc((100% - 760px) / 2))); }
.unread-line span { flex: 1; text-align: center; font-size: 14px; font-weight: 500; color: var(--muted); background: var(--panel); opacity: .92; padding: 3px 0; }

.msg { display: flex; align-items: flex-end; margin-top: 8px; position: relative; }
.msg.cont { margin-top: 3px; }
.msg.mine { justify-content: flex-end; }
.msg .slot { flex: none; width: 42px; align-self: flex-end; display: flex; }
.msg .slot .ava { width: 34px; height: 34px; font-size: 13px; cursor: pointer; }
.bubble { position: relative; max-width: min(80%, 500px); padding: 6px 9px 7px 10px; border-radius: 15px; background: var(--theirs);
          box-shadow: var(--shadow); overflow-wrap: anywhere; transition: transform .1s; }
.msg .slot + .bubble { max-width: min(calc(80% - 42px), 500px); }
.msg.mine .bubble { background: var(--mine); }
/* углы как в группе сообщений: у отправителя — меньше, у последнего — хвостик */
.msg.theirs.cont .bubble { border-top-left-radius: 6px; }
.msg.theirs:not(.end) .bubble { border-bottom-left-radius: 6px; }
.msg.mine.cont .bubble { border-top-right-radius: 6px; }
.msg.mine:not(.end) .bubble { border-bottom-right-radius: 6px; }
.msg.end .bubble::before { content: ''; position: absolute; bottom: 0; width: 9px; height: 17px; background: inherit; }
.msg.end.theirs .bubble { border-bottom-left-radius: 0; }
.msg.end.theirs .bubble::before { left: -8.6px; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M9 0c0 8-3.2 13.8-9 17h9z'/%3E%3C/svg%3E") no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M9 0c0 8-3.2 13.8-9 17h9z'/%3E%3C/svg%3E") no-repeat; }
.msg.end.mine .bubble { border-bottom-right-radius: 0; }
.msg.end.mine .bubble::before { right: -8.6px; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M0 0c0 8 3.2 13.8 9 17H0z'/%3E%3C/svg%3E") no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M0 0c0 8 3.2 13.8 9 17H0z'/%3E%3C/svg%3E") no-repeat; }
.bubble.media-only::before { display: none; }
.bubble .name { font-size: 14px; font-weight: 600; margin-bottom: 1px; line-height: 1.3; }
.bubble .text { white-space: pre-wrap; font-size: 15.5px; line-height: 1.38; }
.bubble .text.gone { color: var(--muted); font-style: italic; }
.bubble .text a { color: var(--accent-ink); }
.msg.mine .bubble .text a { color: var(--mine-strong); }
/* Время — в правом нижнем углу; под него в конце текста оставлено место */
.bubble .text::after { content: ''; display: inline-block; width: 44px; }
.msg.mine .bubble .text::after { width: 66px; }
.bubble.has-reacts .text::after { display: none; }
.bubble .meta { position: absolute; right: 9px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--meta); line-height: 1; user-select: none; }
.bubble .meta svg.i { width: 17px; height: 17px; stroke-width: 2.1; }
.msg.mine .meta { color: var(--mine-meta); }
.bubble .meta svg.i.read { color: var(--read); }
.msg.failed { flex-direction: column; align-items: flex-end; }
.msg.failed .bubble { background: var(--err-soft); }
.msg.failed .bubble::before { display: none; }
.msg.failed .meta { color: var(--err); }
.fail { margin-top: 4px; font-size: 13px; color: var(--err); text-align: right; background: var(--panel); padding: 3px 8px; border-radius: 10px; }
.fail button { border: 0; background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; padding: 2px 4px; }

.down { position: absolute; right: max(14px, calc((100% - 860px) / 2)); bottom: 84px; z-index: 4; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--panel);
        color: var(--muted); box-shadow: 0 1px 6px rgba(0,0,0,.18); display: grid; place-items: center; cursor: pointer; animation: pop .15s ease-out; }
.down .badge { position: absolute; top: -6px; right: -2px; }

/* ───── Поле ввода: «остров» на фоне + круглая кнопка */
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 6px max(12px, calc((100% - 776px) / 2)); padding-bottom: max(12px, env(safe-area-inset-bottom)); background: transparent; position: relative; }
.input-box { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel); border-radius: 16px 16px 0 16px; box-shadow: var(--shadow); position: relative; }
.input-box::after { content: ''; position: absolute; right: -8.6px; bottom: 0; width: 9px; height: 17px; background: var(--panel);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M0 0c0 8 3.2 13.8 9 17H0z'/%3E%3C/svg%3E") no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='17'%3E%3Cpath d='M0 0c0 8 3.2 13.8 9 17H0z'/%3E%3C/svg%3E") no-repeat; }
.input-row { display: flex; align-items: flex-end; min-height: 54px; padding: 0 4px; }
.composer textarea { flex: 1; min-width: 0; max-height: 200px; resize: none; padding: 15px 6px 14px; font: inherit; font-size: 16px; line-height: 1.35;
                     border: 0; background: transparent; outline: none; color: var(--text); }
.composer textarea::placeholder { color: var(--muted); }
.composer .icon-btn { width: 46px; height: 46px; margin-bottom: 4px; }
.composer .icon-btn svg.i { width: 24px; height: 24px; }
.send { flex: none; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--panel); color: var(--accent); display: grid; place-items: center; cursor: pointer;
        box-shadow: var(--shadow); transition: background .15s, color .15s, transform .12s; }
.send svg.i { width: 26px; height: 26px; }
.send:not(:disabled):hover { background: var(--accent); color: #fff; }
.send:active:not(:disabled) { transform: scale(.94); }
.send:disabled { color: var(--muted); cursor: default; }
.send.mic { color: var(--muted); }
.send.mic:hover { background: var(--accent); color: #fff; }
.blocked { align-self: center; width: min(calc(100% - 24px), 760px); margin: 6px 12px max(12px, env(safe-area-inset-bottom)); padding: 15px 16px; text-align: center; color: var(--err);
           background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); font-weight: 600; }
.blocked.chan { color: var(--muted); font-weight: 500; }

/* Нет связи — полоса вверху над списком и чатом (04.11) */
.app.offline { grid-template-rows: auto minmax(0, 1fr); }
.net { grid-column: 1 / -1; z-index: 30; padding: 7px 14px calc(7px); padding-top: max(7px, env(safe-area-inset-top)); background: #f2a33a; color: #3a2400;
       font-size: 14px; font-weight: 600; text-align: center; line-height: 1.3; animation: fade .15s ease-out; }
.net.ok { background: var(--ok, #2e9d5b); color: #fff; }
html[data-theme="dark"] .net:not(.ok) { background: #b9741c; color: #fff; }

/* ───── О чате (профиль) */
.info { position: absolute; top: 0; right: 0; bottom: 0; width: min(400px, 100%); z-index: 20; background: var(--panel);
        border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(16,24,40,.08); animation: slide-l .2s ease-out; }
.info-head { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 8px 6px 20px; border-bottom: 1px solid var(--line); }
.info-head b { flex: 1; font-size: 17px; font-weight: 600; }
.info-body { flex: 1; overflow-y: auto; padding-bottom: 24px; }
.info-top { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px 16px; text-align: center; }
.info-top b { font-size: 20px; font-weight: 600; margin-top: 8px; }
.info-sec { padding: 10px 20px 6px; color: var(--accent-ink); font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; border-top: 10px solid var(--bg); }
html[data-theme="dark"] .info-sec { border-top-color: #0e1621; }
.info-sec button { border: 0; background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.info-sec button:hover { background: var(--accent-soft); }
.row-p { display: flex; align-items: center; gap: 12px; padding: 7px 20px; }
.row-p .ava { width: 42px; height: 42px; font-size: 16px; }
.row-p .mid { flex: 1; min-width: 0; }
.row-p .mid b { font-weight: 600; }
.row-p .mid span { display: block; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-p .act { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.row-p .act:hover { background: var(--hover); color: var(--err); }
.row-p .act.sure { color: #fff; background: var(--err); }
.kv { padding: 7px 20px; }
.kv span { display: block; font-size: 13.5px; color: var(--muted); }
.rename { display: flex; gap: 8px; padding: 0 20px 12px; }
.rename input, .field { flex: 1; min-width: 0; padding: 10px 12px; font: inherit; border: 1px solid var(--field-line); border-radius: 10px; outline: none; background: var(--field); color: var(--text); }
.rename input:focus, .field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.leave { display: block; width: calc(100% - 40px); margin: 16px 20px; padding: 11px; border: 0; border-radius: 10px; background: var(--err-soft); color: var(--err); font-weight: 600; cursor: pointer; }
.leave.sure { background: var(--err); color: #fff; }

/* ───── Окна: выбор сотрудников, файлы, уведомления */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.dialog { width: 100%; max-width: 440px; max-height: min(660px, calc(100dvh - 32px)); background: var(--panel); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden;
          box-shadow: 0 20px 48px rgba(0,0,0,.28); animation: pop .18s ease-out; }
.dialog-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 20px; min-height: 56px; }
.dialog-head b { flex: 1; font-size: 18px; font-weight: 600; }
.tabs { display: flex; gap: 6px; padding: 4px 16px 10px; }
.tabs button { flex: 1; padding: 8px; border: 0; border-radius: 10px; background: var(--bg); cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--accent-soft); color: var(--accent-ink); }
.dialog .field { margin: 0 16px 10px; flex: none; }
.people { flex: 1; overflow-y: auto; min-height: 120px; border-top: 1px solid var(--line); }
.person { width: 100%; display: flex; align-items: center; gap: 12px; padding: 7px 16px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.person .ava { width: 44px; height: 44px; font-size: 16px; }
.person:hover { background: var(--hover); }
.person .mid { flex: 1; min-width: 0; }
.person .mid span { display: block; font-size: 13.5px; color: var(--muted); }
.tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--field-line); display: grid; place-items: center; color: transparent; }
.person.sel .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.tick svg.i { width: 14px; height: 14px; stroke-width: 3; }
.dialog-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.dialog-foot span { flex: 1; color: var(--muted); font-size: 14px; }
.dialog-foot .btn { margin: 0; }
.dialog .note { padding: 18px 16px; color: var(--muted); text-align: center; }
.dialog .err-line { margin: -4px 16px 8px; color: var(--err); font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; max-width: calc(100% - 32px);
         padding: 10px 18px; border-radius: 12px; background: rgba(20, 26, 32, .86); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.3);
         -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: toast-in .2s ease-out; }

/* меню ☰ */
.menu { position: absolute; top: 52px; left: 8px; z-index: 40; min-width: 270px; background: var(--pop-bg); border-radius: 12px; padding: 6px 0;
        box-shadow: var(--pop-shadow); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); transform-origin: top left; animation: pop .15s ease-out; }
.menu button, .menu a { display: flex; color: inherit; font: inherit; font-size: 14.5px; font-weight: 500; width: 100%; gap: 18px; align-items: center; padding: 9px 18px; border: 0; background: transparent; cursor: pointer; text-align: left; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--hover); }
.menu button svg.i, .menu a svg.i { color: var(--muted); }
.menu .me-card { display: flex; align-items: center; gap: 12px; padding: 8px 18px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; border-radius: 0; }
.menu .me-card .who span { color: var(--accent-ink); }
.who { min-width: 0; flex: 1; }
.who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { display: block; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu .me-card .who b { font-size: 15px; }
.menu .theme-row .switch { margin-left: auto; pointer-events: none; }
.menu .menu-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* ───── Телефон: список и лента по очереди */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .main { display: none; }
  .app.chat-open .side { display: none; }
  .app.chat-open .main { display: flex; animation: slide-l .22s ease-out; }
  .chat-head .back { display: grid; }
  .chat-head { padding-left: 4px; gap: 8px; }
  .feed { padding-left: 8px; padding-right: 8px; }
  .unread-line { margin-left: -8px; margin-right: -8px; }
  .bubble { max-width: 86%; }
  .msg .slot + .bubble { max-width: calc(86% - 42px); }
  .composer { padding-left: 8px; padding-right: 8px; gap: 6px; }
  .send { width: 50px; height: 50px; }
  .input-row { min-height: 50px; }
  .composer textarea { padding: 13px 4px 12px; }
  .info { width: 100%; border-left: 0; }
  .modal { padding: 0; place-items: stretch; }
  .dialog { max-width: none; max-height: none; height: 100dvh; border-radius: 0; }
  .down { right: 10px; bottom: 76px; }
}

/* ═════════════ шаг 3: вложения, ответы, реакции, меню, закреплённое, просмотр */
.pin-bar { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 14px; background: var(--panel); border-bottom: 1px solid var(--line); color: var(--accent); position: relative; z-index: 3; }
.pin-bar svg.i { width: 18px; height: 18px; }
.pin-text { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; padding: 3px 0 3px 9px; cursor: pointer; border-left: 2px solid var(--accent); }
.pin-text b { display: block; font-size: 13.5px; color: var(--accent-ink); font-weight: 600; }
.pin-text span { display: block; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fwd { display: flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--accent-ink); margin-bottom: 2px; font-weight: 500; }
.msg.mine .fwd { color: var(--mine-strong); }
.fwd svg.i { width: 15px; height: 15px; }
.quote { display: block; width: 100%; text-align: left; margin: 2px 0 4px; padding: 3px 8px 4px 9px; border: 0; border-left: 3px solid var(--accent);
         border-radius: 5px; background: var(--accent-soft); cursor: pointer; color: inherit; }
.quote b { display: block; font-size: 13.5px; font-weight: 600; }
.quote span { display: block; font-size: 14px; color: var(--text); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.msg.mine .quote { background: var(--mine-soft); }

/* Фото и видео как в Telegram (04.11): пузырь шириной с фото (--mw из ленты), подпись переносится по этой ширине */
.media { margin: 0 0 4px; border-radius: 12px; overflow: hidden; }
.bubble.has-media { width: calc(var(--mw, 440px) + 6px); padding: 3px 3px 7px; }
.bubble.has-media > :not(.media):not(.meta) { margin-left: 7px; margin-right: 6px; }
.bubble.has-media > .quote { width: auto; }
.bubble.has-media > .name { margin-top: 3px; }
.bubble.has-media > .text { display: block; padding-top: 2px; }
.bubble.has-media.no-text { padding-bottom: 24px; }
.bubble.media-only { width: var(--mw, 440px); padding: 0; background: transparent; box-shadow: none; }
.bubble.media-only > .name { margin-left: 0; }
.bubble.media-only .media { margin: 0; border-radius: 15px; }
.media.one .cell { width: 100%; aspect-ratio: 4 / 3; background: rgba(0,0,0,.08); }
.media.one img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.media.video .cell { background: #000; }
.media.video video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.media.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
.media.grid .cell { aspect-ratio: 1; background: rgba(0,0,0,.08); min-width: 0; }
.media.grid img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.doc-note { display: block; width: 100%; font-size: 12.5px; color: var(--muted); }
.msg.pending .media img { opacity: .75; cursor: default; }
.bubble.media-only .meta { right: 8px; bottom: 8px; padding: 3px 7px; border-radius: 10px; background: rgba(0,0,0,.45); color: #fff !important; }
.bubble.media-only .meta svg.i.read { color: #fff; }
.bubble.media-only .reacts { position: absolute; left: 6px; bottom: 6px; margin: 0; }
.bubble.media-only .name { display: inline-block; padding: 2px 9px; border-radius: 11px; background: var(--theirs); margin-bottom: 4px; box-shadow: var(--shadow); }
.bubble.no-text { padding-bottom: 22px; }

.doc { display: flex; align-items: center; gap: 12px; padding: 4px 0; min-width: 220px; }
.doc-ico { flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; }
.msg.mine .doc-ico { background: var(--mine-strong); }
.doc-ico svg.i { width: 22px; height: 22px; }
.doc-mid { min-width: 0; display: flex; flex-direction: column; }
.doc-name { font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
a.doc { color: inherit; text-decoration: none; cursor: pointer; border-radius: 10px; margin: -2px -6px; padding: 6px; -webkit-tap-highlight-color: transparent; }
a.doc:hover .doc-name { color: var(--accent-ink); }
a.doc:hover .doc-ico { filter: brightness(1.1); }
a.doc:active { background: var(--accent-soft); }
a.doc:focus-visible, .doc-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.doc-open { cursor: pointer; border-radius: 10px; margin: -2px -6px; padding: 6px; -webkit-tap-highlight-color: transparent; }
.doc-open:hover .doc-name { color: var(--accent-ink); }
.doc-open:hover .doc-ico { filter: brightness(1.1); }
.doc-open:active { background: var(--accent-soft); }
.doc-ico.pdf, .msg.mine .doc-ico.pdf { background: #e0463c; }
.doc-ico.pdf b { font-size: 12px; letter-spacing: .3px; }
.doc-dl { flex: none; margin-left: auto; color: var(--muted); }
.doc-dl:hover { color: var(--accent); }
/* просмотр PDF */
.viewer.pdf .viewer-body { display: block; overflow: auto; padding: 8px 0 32px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: min-content; padding: 0 12px; }
.pdf-page { flex: none; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35); display: grid; place-items: center; }
.pdf-canvas { width: 100%; height: 100%; display: block; }
.pdf-page-err { color: #667085; font-size: 13px; }
.pdf-msg { color: #e4e7ec; text-align: center; margin: 20vh 16px 0; font-size: 15px; }
.pdf-msg.err { color: #fecdca; }
.viewer-top .pdf-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-tools { flex: none; display: inline-flex; align-items: center; gap: 2px; }
.pdf-zoom { font-size: 22px; line-height: 1; width: 36px; height: 36px; }
.pdf-no { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .viewer.pdf .viewer-top { flex-wrap: wrap; padding: 6px 4px 6px 12px; }
  .viewer.pdf #viewerInfo { flex-wrap: wrap; gap: 6px 10px; }
  .viewer.pdf .viewer-top .pdf-title { flex-basis: 100%; }
}
.doc-size { font-size: 13px; color: var(--muted); }
.msg.mine .doc-size { color: var(--mine-meta); }
.voice { display: flex; align-items: center; gap: 10px; padding: 4px 0 2px; width: 270px; max-width: 100%; }
.voice audio { display: none; }
.vplay { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.msg.mine .vplay { background: var(--mine-strong); }
.vplay svg.i { width: 22px; height: 22px; }
.vmid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.vbar { height: 6px; border-radius: 3px; background: var(--accent-soft); cursor: pointer; position: relative; overflow: hidden; }
.vbar::before { content: ''; position: absolute; inset: -8px 0; }
.vfill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.msg.mine .vbar { background: var(--mine-soft); }
.msg.mine .vfill { background: var(--mine-strong); }
.vtime { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg.mine .vtime { color: var(--mine-meta); }
.vspeed { flex: none; border: 0; background: var(--accent-soft); color: var(--accent-ink); border-radius: 8px; padding: 3px 6px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; min-width: 36px; }
.msg.mine .vspeed { background: var(--mine-soft); color: var(--mine-strong); }

.progress { position: relative; margin-top: 6px; height: 18px; font-size: 12px; color: var(--muted); }
.progress .bar { position: absolute; left: 0; top: 0; height: 3px; border-radius: 2px; background: var(--accent); transition: width .2s; }
.progress span { position: absolute; left: 0; top: 4px; }

.mention { color: var(--accent-ink); font-weight: 500; }
.msg.mine .mention { color: var(--mine-strong); }
.mention.me { background: var(--accent-soft); border-radius: 4px; padding: 0 2px; }
.hashtag { color: var(--accent-ink); font-weight: 500; text-decoration: none; }
a.hashtag:hover { text-decoration: underline; }
.msg.mine .hashtag { color: var(--mine-strong); }
.msg.tagged .bubble { box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.edited { font-style: normal; }

/* реакции — внутри пузыря, перед временем */
.reacts { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0 1px; }
.reacts::after { content: ''; flex: 0 0 auto; width: 40px; }
.msg.mine .reacts::after { width: 62px; }
.react { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 9px 0 7px; border-radius: 14px; border: 0;
         background: var(--accent-soft); color: var(--accent-ink); font-size: 15px; cursor: pointer; transition: transform .1s, background .15s; }
.react:active { transform: scale(.92); }
.react span { font-size: 13px; font-weight: 600; color: inherit; }
.react.mine { background: var(--accent); color: #fff; }
.msg.mine .react { background: var(--mine-soft); color: var(--mine-strong); }
.msg.mine .react.mine { background: var(--mine-strong); color: #fff; }
.bubble.media-only .react { background: rgba(0,0,0,.4); color: #fff; }
.bubble.media-only .react.mine { background: var(--accent); }

.msg .more { flex: none; align-self: center; margin: 0 6px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--sys-bg);
             color: var(--sys-ink); display: none; place-items: center; cursor: pointer; visibility: hidden; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.msg .more svg.i { width: 18px; height: 18px; }
.msg.mine .more { order: -1; }
@media (hover: hover) { .msg .more { display: grid; } .msg:hover .more { visibility: visible; } }
.msg.flash .bubble { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(51, 144, 236, .5); } 100% { box-shadow: var(--shadow); } }

.msg-menu { position: fixed; z-index: 45; min-width: 220px; background: var(--pop-bg); border-radius: 12px; padding: 6px 0;
            box-shadow: var(--pop-shadow); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); animation: pop .14s ease-out; }
.msg-menu > button { display: flex; width: 100%; gap: 16px; align-items: center; padding: 8px 18px; border: 0; background: transparent; cursor: pointer; text-align: left; font-size: 14.5px; font-weight: 500; }
.msg-menu > button:hover { background: var(--hover); }
.msg-menu > button svg.i { width: 20px; height: 20px; color: var(--muted); }
.msg-menu > button.danger { color: var(--err); }
.msg-menu > button.danger svg.i { color: var(--err); }
.msg-menu > button.sure { background: var(--err); color: #fff; }
.msg-menu > button.sure svg.i { color: #fff; }
.menu-reacts { display: flex; justify-content: space-between; gap: 2px; padding: 0 8px 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-reacts button { border: 0; background: transparent; font-size: 24px; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; transition: transform .12s, background .12s; display: grid; place-items: center; }
.menu-reacts button:hover { background: var(--hover); transform: scale(1.18); }

.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 6px 0 14px; color: var(--accent); background: transparent; }
.reply-bar svg.i { width: 22px; height: 22px; }
.rb-mid { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding: 1px 0 1px 9px; border-radius: 2px; background: var(--accent-soft); }
.rb-mid b { display: block; font-size: 13.5px; font-weight: 600; }
.rb-mid span { display: block; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-box { position: absolute; left: max(12px, calc((100% - 776px) / 2)); bottom: calc(100% + 2px); z-index: 25; width: min(340px, calc(100% - 24px));
               max-height: 280px; overflow-y: auto; background: var(--pop-bg); border-radius: 12px; padding: 6px 0; box-shadow: var(--pop-shadow);
               -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); animation: pop .12s ease-out; }
.mention-opt { display: flex; width: 100%; align-items: baseline; gap: 8px; padding: 9px 16px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.mention-opt span { color: var(--muted); font-size: 13px; }
.mention-opt.on, .mention-opt:hover { background: var(--hover); }
.chat.drop::after { content: 'Отпустите, чтобы отправить файлы'; position: absolute; inset: 8px; z-index: 30; display: grid; place-items: center;
                    border: 2px dashed var(--accent); border-radius: 16px; background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--accent); font-weight: 600; }

.att-list { overflow-y: auto; max-height: 300px; padding: 0 8px; }
.att { display: flex; align-items: center; gap: 12px; padding: 6px 8px; }
.att-prev { flex: none; width: 52px; height: 52px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.att-prev img { width: 100%; height: 100%; object-fit: cover; }
.att-mid { flex: 1; min-width: 0; }
.att-mid b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.att-mid span { font-size: 13px; color: var(--muted); }
.att-opts { display: flex; align-items: center; gap: 8px; padding: 8px 18px; color: var(--muted); font-size: 14px; }
.att-opts input { width: 18px; height: 18px; accent-color: var(--accent); }

.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .9); display: flex; flex-direction: column; animation: fade .15s ease-out; }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; color: #e4e7ec; font-size: 14px; }
.viewer-top #viewerInfo { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; }
.viewer-top #viewerInfo > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer .icon-btn { color: #e4e7ec; }
.viewer .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.viewer-dl { display: inline-flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.12); }
.viewer-dl svg.i { width: 18px; height: 18px; }
/* Ячейка — ровно размер окна: иначе высокое (вертикальное) фото на ПК вылезало вниз и обрезалось (04.11) */
.viewer-body { flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 8px; position: relative; overflow: hidden; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; animation: pop .18s ease-out; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0;
              background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 2; }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }

.pin-row { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 20px; cursor: pointer; }
.pin-row:hover { background: var(--hover); }
.pin-row b { display: block; font-size: 13.5px; font-weight: 600; }
.pin-row span { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-p .acts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row-p .act.danger:hover { color: var(--err); }
.item .pv .fk { color: var(--accent-ink); }

@media (max-width: 720px) {
  .msg .more { display: none !important; }
  .quote span { max-width: 60vw; }
}

/* ═════════════ шаг 4: галочки, «в сети», «печатает» */
.title-btn span.online { color: var(--accent-ink); }
.title-btn span.typing, .pv .typing { color: var(--accent-ink); }
.item.on .pv .typing { color: #fff; }
.ava-wrap { position: relative; flex: none; display: inline-block; line-height: 0; }
.ava-wrap .dot { position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px; border-radius: 50%; background: #0ac630; border: 2.5px solid var(--panel); }
.item.on .ava-wrap .dot { border-color: var(--active); }
.readers-head { padding: 6px 16px 6px; font-weight: 600; font-size: 14px; }
.reader { display: flex; align-items: center; gap: 10px; padding: 5px 16px; font-size: 14px; }
.readers-foot { padding: 6px 16px 4px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); margin-top: 4px; }

/* ═════════════ шаг 5: уведомления */
.muted-ico { flex: none; color: var(--muted); display: inline-flex; }
.muted-ico svg.i { width: 15px; height: 15px; }
.settings-body { overflow-y: auto; padding: 0 20px 18px; }
.set-sec { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-sec:last-child { border-bottom: 0; }
.set-sec p { margin: 4px 0 8px; font-size: 14px; }
.set-sec .btn { margin-top: 4px; }
.set-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.set-check input { flex: none; width: 18px; height: 18px; accent-color: var(--accent); }
.set-sec > b + .set-check { margin-top: 8px; }
.set-sec .set-check + .set-check { margin-top: 8px; }
.set-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-row .btn { margin: 0; }
.field.wide { width: 100%; margin: 0; }
.set-row .field { margin: 0; flex: none; width: auto; }
.notify-sec .kv select { width: 100%; margin: 0; }
.notify-sec > select.field { display: block; width: calc(100% - 40px); margin: 4px 20px 6px; }
.mute-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 2px 16px 8px 20px; font-size: 14px; }
.mute-row .act { border: 0; background: var(--bg); border-radius: 8px; padding: 5px 10px; cursor: pointer; color: var(--accent-ink); font-weight: 600; font-size: 13px; }

/* ═════════════ шаг 6: папки (вкладки), проекты и изделия, отделы */
.tabs-bar { display: flex; gap: 2px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); flex: none; }
.tabs-bar::-webkit-scrollbar { display: none; }
.tab { flex: none; position: relative; padding: 11px 10px 10px; border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 14.5px;
       cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: color .15s, background .15s; }
.tab:hover { background: var(--hover); }
.tab.on { color: var(--accent-ink); }
.tab.on::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.tab-n { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #a8b0b8; color: #fff; font-size: 12px; display: inline-grid; place-items: center; }
html[data-theme="dark"] .tab-n { background: #3e4c5a; }
.tab.on .tab-n { background: var(--accent); }
.proj { position: relative; }
.proj .item { padding-right: 54px; }
.chev { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); height: 28px; padding: 0 6px; border: 0; border-radius: 8px; background: var(--bg);
        color: var(--muted); display: inline-flex; align-items: center; gap: 2px; cursor: pointer; font-size: 12px; font-weight: 700; }
.proj .item.on + .chev { background: rgba(255,255,255,.22); color: #fff; }
.chev svg.i { width: 16px; height: 16px; transition: transform .15s; transform: rotate(-90deg); }
.chev.open svg.i { transform: rotate(0); }
.item.nested { padding-left: 30px; }
.item .parent { font-size: 12.5px; color: var(--accent-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kind-ico { flex: none; color: var(--muted); display: inline-flex; }
.kind-ico svg.i { width: 16px; height: 16px; }
.ava.k-project { border-radius: 14px; }
.ava.k-item { border-radius: 12px; }
.ava.long { font-size: 14px; letter-spacing: 0; }
.ava.sm.long { font-size: 11px; }
.item > .ava.long, .item > .ava-wrap .ava.long { font-size: 15px; }
.ava.emoji { background: var(--accent-soft) !important; background-image: none !important; font-size: 24px; }
.ava.sm.emoji { font-size: 18px; }
.item > .ava.emoji { font-size: 28px; }
.proj-fields { padding: 0 16px 4px; }
.proj-fields .set-row { margin-bottom: 8px; }
.proj-fields .field { margin: 0; }
.roles-hint { font-size: 13px; margin: 0 0 6px; }
.person .tick.r-observer, .person.sel .tick.r-observer { background: #98a2b3; border-color: #98a2b3; color: #fff; font-size: 11px; font-weight: 700; }
.person .tick.r-responsible, .person.sel .tick.r-responsible { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.person .role-l.obs { color: var(--muted); }
.person .role-l { font-size: 12px; font-weight: 600; color: var(--accent-ink); margin-right: 4px; }
.links-list { padding: 0 20px 8px; }
.link-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.link-row span { flex: 1; min-width: 0; }
.link-add { display: flex; gap: 6px; padding: 0 20px 10px; flex-wrap: wrap; }
.link-add .field { margin: 0; flex: 1; min-width: 120px; }
.item-row { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; padding: 7px 20px; cursor: pointer; text-align: left; }
.item-row:hover { background: var(--hover); }
.item-row .mid { flex: 1; min-width: 0; }
.item-row .mid span { display: block; font-size: 13px; color: var(--muted); }
.parent-link { display: block; width: calc(100% - 40px); margin: 0 20px 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-align: left; cursor: pointer; }
.parent-link span { display: block; font-size: 12px; color: var(--muted); }

/* ═════════════ шаг 7: сообщения модулей */
.msg.bot .bubble { background: var(--theirs); }
.msg.important .bubble { box-shadow: inset 4px 0 0 var(--err), var(--shadow); padding-left: 14px; }
.card-box { margin: 4px 0 6px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 14px; }
.card-box b { display: block; margin-bottom: 2px; }
.card-f { display: flex; gap: 8px; justify-content: space-between; }
.card-f span:first-child { color: var(--muted); }
.card-f span:last-child { text-align: right; font-weight: 600; }
.bot-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.bot-btn { flex: 1 1 auto; text-align: center; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 14px; text-decoration: none; }
.bot-btn:hover { filter: brightness(.96); }

/* ─── поиск (шаг 8) */
.find-bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 3; animation: fade .15s; }
.find-bar > svg.i { width: 18px; height: 18px; color: var(--muted); flex: none; }
.find-bar input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; padding: 8px 4px; }
.find-count { flex: none; font-size: 13px; color: var(--muted); min-width: 2ch; white-space: nowrap; }
.find-bar .icon-btn:disabled { opacity: .35; cursor: default; }
svg.i.up { transform: rotate(180deg); }
.list-sec { padding: 14px 10px 4px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.item.hit { align-items: flex-start; }
.item .pv2 { color: var(--muted); font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.item .pv2 .me { color: var(--text); }
.item.on .pv2, .item.on .pv2 .me { color: rgba(255,255,255,.9); }
mark { background: #ffe58a; color: #111; border-radius: 3px; padding: 0 1px; }
::highlight(m15-find) { background-color: #ffe58a; color: #101828; }
.more-hits { display: block; margin: 6px auto 0; padding: 8px 16px; border: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.more-hits:disabled { opacity: .6; cursor: default; }
.ctx-dlg { max-width: 760px; height: min(720px, calc(100dvh - 32px)); }
.ctx-body { flex: 1; background: var(--wall); padding: 8px 12px; }

/* ─── голосовые (шаг 9) */
.rec-bar { align-items: center; }
.rec-bar .input-row { align-items: center; gap: 8px; padding-right: 12px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--err); flex: none; animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4ch; }
.rec-hint { flex: 1; color: var(--muted); font-size: 14px; min-width: 0; }
.rec-hint.warn { color: var(--err); }
/* Уровень звука при записи: полоски бегут справа налево */
.rec-level { display: flex; align-items: center; gap: 2px; height: 24px; flex: 0 1 auto; overflow: hidden; }
.rec-level i { display: block; width: 3px; height: 3px; border-radius: 2px; background: var(--accent); opacity: .85; transition: height .07s linear; flex: none; }
@media (max-width: 720px) { .rec-level i:nth-child(-n+12) { display: none; } .rec-hint:not(.warn) { display: none; } .rec-hint.warn { font-size: 12.5px; } }
.rec-bar #recSend { background: var(--accent); color: #fff; }
.help-link { color: var(--accent-ink); font-weight: 600; text-decoration: none; font-size: 14px; }

/* ── настройки группы, описание, смайлики (28.10, вечер) */
.info-desc { margin: 8px 16px 0; color: var(--text); font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; text-align: center; }
.desc-edit { padding: 0 20px 12px; }
.desc-edit textarea { width: 100%; resize: vertical; min-height: 64px; }
.settings-sec .set-h { padding: 8px 20px 2px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.gs-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 20px; font-size: 15px; cursor: pointer; }
.gs-row:hover { background: var(--hover); }
.gs-row > span:first-child { flex: 1; min-width: 0; }
.gs-row select.field { flex: 0 1 190px; margin: 0; padding: 7px 8px; font-size: 14px; }
.switch { position: relative; flex: none; width: 36px; height: 20px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 3px 0; border-radius: 7px; background: #c5cad0; transition: background .15s; pointer-events: none; }
html[data-theme="dark"] .switch i { background: #3d4b59; }
.switch i::after { content: ''; position: absolute; top: -3px; left: 0; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid #c5cad0; transition: transform .15s, border-color .15s; box-sizing: border-box; }
html[data-theme="dark"] .switch i::after { background: var(--panel); border-color: #3d4b59; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); border-color: var(--accent); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch.on i { background: var(--accent); }
.switch.on i::after { transform: translateX(16px); border-color: var(--accent); }
.emoji-btn { color: var(--muted); }
.emoji-btn.on { color: var(--accent); background: var(--accent-soft); }
.react-more { font-size: 20px !important; color: var(--muted); font-weight: 600; }
.emoji-panel { position: fixed; z-index: 80; width: 372px; max-width: calc(100vw - 16px); height: 400px; background: var(--pop-bg); border: 0;
  border-radius: 14px; box-shadow: var(--pop-shadow); display: flex; flex-direction: column; overflow: hidden;
  -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); animation: pop .15s ease-out; transform-origin: bottom left; }
/* телефон: панель — под полем ввода, вместо клавиатуры (поле остаётся видно) */
.emoji-panel.sheet { position: relative; flex: none; width: auto; max-width: none; height: 44vh; max-height: 360px; border-radius: 0; background: var(--panel);
  box-shadow: none; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); animation: rise .18s ease-out; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 6px 4px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: none; }
.emoji-tab { border: 0; background: transparent; font-size: 20px; width: 38px; height: 34px; border-radius: 10px; cursor: pointer; flex: none; filter: grayscale(.6); opacity: .8; transition: filter .15s, background .15s; }
.emoji-tab:hover { filter: none; opacity: 1; }
.emoji-tab.on { background: var(--accent-soft); filter: none; opacity: 1; }
.emoji-grid { flex: 1; overflow-y: auto; padding: 0 6px 8px; position: relative; overscroll-behavior: contain; }
.emoji-cells { display: grid; grid-template-columns: repeat(var(--cols, 8), minmax(0, 1fr)); content-visibility: auto; contain-intrinsic-size: auto 264px; }
.emoji-title { position: sticky; top: 0; z-index: 1; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 4px 4px; height: 28px;
  background: linear-gradient(var(--pop-bg) 70%, transparent); }
.emoji-panel.sheet .emoji-title { background: linear-gradient(var(--panel) 70%, transparent); }
.emoji-empty { color: var(--muted); font-size: 13px; padding: 16px 6px; text-align: center; }
.emoji-grid .emoji, .emoji-skins .emoji { position: relative; min-width: 0; padding: 0; border: 0; background: transparent; font-size: 28px; line-height: 1; height: 44px; border-radius: 10px; cursor: pointer; transition: transform .1s, background .1s; }
.emoji-grid .emoji:hover, .emoji-grid .emoji:focus-visible, .emoji-skins .emoji:hover { background: var(--hover); transform: scale(1.12); }
.emoji.has-skins::after { content: ''; position: absolute; right: 3px; bottom: 3px; border: 3px solid transparent; border-right-color: var(--muted); border-bottom-color: var(--muted); opacity: .45; }
.emoji-search-row { padding: 8px 8px 2px; flex: none; }
.emoji-search { width: 100%; height: 34px; padding: 0 12px; border: 0; border-radius: 17px; background: var(--hover); color: var(--text); font: inherit; font-size: 14.5px; outline: none; }
.emoji-search:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.emoji-skins { position: absolute; z-index: 3; display: flex; gap: 2px; padding: 4px; border-radius: 14px; background: var(--pop-bg); box-shadow: var(--pop-shadow); animation: pop .12s ease-out; }
.emoji-skins .emoji { width: 44px; }

/* Сообщение из 1–3 смайликов — крупно, без пузыря (как в Telegram) */
.bubble.jumbo { background: transparent !important; box-shadow: none; padding: 0 2px 24px; }
.bubble.jumbo::before { display: none; }
.bubble.jumbo .text { font-size: 44px; line-height: 1.12; }
.bubble.jumbo.j1 .text { font-size: 64px; }
.bubble.jumbo .text::after { display: none; }
.bubble.jumbo .meta { right: 2px; bottom: 2px; padding: 3px 7px; border-radius: 10px; background: var(--sys-bg); color: var(--sys-ink) !important; }
.bubble.jumbo .meta svg.i.read { color: var(--sys-ink); }
.bubble.jumbo .name { display: block; width: fit-content; padding: 2px 9px; border-radius: 11px; background: var(--theirs); box-shadow: var(--shadow); margin-bottom: 2px; }
.bubble.jumbo.has-reacts { padding-bottom: 4px; }
.bubble.jumbo .reacts::after { width: 70px; }

/* ═════════════ движение */
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .4; } }
@keyframes slide-l { from { transform: translateX(40px); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.msg.appear { animation: msg-in .22s cubic-bezier(.2, .9, .3, 1.1); }
.msg.mine.appear { transform-origin: bottom right; }
.msg.theirs.appear { transform-origin: bottom left; }
.msg-menu, .menu { transform-origin: top left; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ═════════════ профиль чата как в Telegram (29.10, часть 4) */
.info-head .icon-btn { flex: none; }
.info-top .online { color: var(--accent-ink); }
.info-top .ava + b { margin-top: 10px; }
.info-rows { padding: 4px 0 6px; }
.info-row { display: flex; align-items: flex-start; gap: 20px; width: 100%; padding: 9px 20px; border: 0; background: transparent; text-align: left; font: inherit; color: inherit; }
button.info-row { cursor: pointer; }
button.info-row:hover { background: var(--hover); }
.ir-ico { flex: none; width: 24px; display: grid; place-items: center; color: var(--muted); padding-top: 1px; }
.ir-ico b { font-size: 19px; font-weight: 500; line-height: 22px; }
.ir-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ir-text { font-size: 15.5px; overflow-wrap: anywhere; }
.info-row.desc .ir-text { white-space: pre-wrap; }
.ir-label { font-size: 13.5px; color: var(--muted); }
.prof-tabs { display: flex; gap: 2px; padding: 0 8px; border-top: 10px solid var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; position: sticky; top: 0; z-index: 2; background: var(--panel); }
html[data-theme="dark"] .prof-tabs { border-top-color: #0e1621; }
.prof-tabs::-webkit-scrollbar { display: none; }
.prof-tab { flex: 1 0 auto; position: relative; padding: 12px 10px 11px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border-radius: 8px 8px 0 0; }
.prof-tab:hover { background: var(--hover); }
.prof-tab.on { color: var(--accent-ink); }
.prof-tab.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.prof-n { font-size: 12px; color: var(--muted); font-weight: 600; }
.prof-body { min-height: 180px; padding: 4px 0 8px; }
.prof-empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.prof-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; }
.pg-cell { aspect-ratio: 1; border: 0; padding: 0; background: rgba(0,0,0,.08); cursor: zoom-in; overflow: hidden; }
.pg-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.pg-cell:hover img { transform: scale(1.04); }
.prof-item { display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.prof-item:hover { background: var(--hover); }
.prof-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 8px 4px 8px 20px; border: 0; background: transparent; text-align: left; color: inherit; text-decoration: none; cursor: pointer; font: inherit; }
.prof-row .doc-ico { width: 46px; height: 46px; border-radius: 10px; }
.pm-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pm-mid b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-mid span { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-mid span.url { color: var(--accent-ink); }
.link-ico { flex: none; width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 20px; font-weight: 700; }
.to-msg { width: 34px; height: 34px; }
.to-msg svg.i { width: 18px; height: 18px; }
.voice-row { padding: 6px 12px 6px 20px; gap: 12px; }
.voice-row .voice { flex: 1; width: auto; }
.pm-who { flex: none; display: flex; flex-direction: column; align-items: flex-end; border: 0; background: transparent; cursor: pointer; font: inherit; color: inherit; max-width: 40%; }
.pm-who b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pm-who span { font-size: 12.5px; color: var(--muted); }
.add-row { display: flex; align-items: center; gap: 20px; width: 100%; padding: 10px 20px; border: 0; background: transparent; color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.add-row:hover { background: var(--hover); }
.add-row .ir-ico { color: var(--accent); }
.edit-label { padding: 12px 20px 6px; font-size: 13.5px; font-weight: 600; color: var(--accent-ink); }
.info-top.edit { padding-bottom: 8px; }
.photo-edit { position: relative; }
.photo-cam { position: absolute; inset: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: .85; transition: opacity .15s, background .15s; }
.photo-cam:hover { opacity: 1; background: rgba(0,0,0,.5); }
.photo-cam svg.i { width: 36px; height: 36px; }
.act.link { border: 0; background: transparent; color: var(--err); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.act.link:hover { background: var(--err-soft); }
.muted.small { font-size: 13px; }
.profile-dlg { max-width: 400px; }
.profile-body { overflow-y: auto; padding-bottom: 12px; }
.profile-body .info-top b { font-size: 20px; }
/* профиль сотрудника (29.10): «Написать», переходы по аватарам и именам */
.person-acts { display: flex; justify-content: center; padding: 0 20px 14px; }
.person-write { margin: 0; gap: 10px; padding: 10px 22px; border-radius: 12px; }
.person-write svg.i { width: 20px; height: 20px; }
.person-link { cursor: pointer; }
.row-p.person-link:hover { background: var(--hover); }
.bubble .name.person-link:hover { text-decoration: underline; }
.msg .slot .ava { transition: transform .12s; }
.msg .slot .ava:hover { transform: scale(1.06); }
.mention[data-login] { cursor: pointer; }
.mention[data-login]:hover { text-decoration: underline; }

/* оформление текста (29.10, часть 5) */
.bubble .text b { font-weight: 650; }
.fmt-code { font: 13.5px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, "Apple Color Emoji", "M15 Emoji", monospace; background: var(--accent-soft); color: var(--accent-ink); padding: 1px 4px; border-radius: 5px; }
.msg.mine .fmt-code { background: var(--mine-soft); color: var(--text); }
.fmt-pre { margin: 4px 0 2px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); border-left: 3px solid var(--accent); overflow-x: auto; white-space: pre; }
.msg.mine .fmt-pre { background: var(--mine-soft); border-left-color: var(--mine-strong); }
.fmt-pre code { font: 13.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Apple Color Emoji", "M15 Emoji", monospace; }
.spoiler { background: color-mix(in srgb, var(--text) 38%, transparent); color: transparent; border-radius: 4px; cursor: pointer; user-select: none; transition: background .2s, color .2s; filter: blur(.4px); }
.spoiler * { color: transparent !important; }
.spoiler.shown { background: transparent; color: inherit; cursor: text; user-select: text; filter: none; }
.spoiler.shown * { color: inherit !important; }
.fmt-bar { display: flex; gap: 2px; padding: 6px 8px 0; animation: fade .12s; }
.fmt-bar button { min-width: 34px; height: 30px; border: 0; border-radius: 8px; background: var(--bg); color: var(--text); cursor: pointer; font-size: 15px; }
.fmt-bar button:hover { background: var(--accent-soft); color: var(--accent-ink); }
.fmt-bar code { font-size: 12.5px; }
.fmt-spoiler-ico { letter-spacing: -2px; color: var(--muted); }
/* «Избранное» */
.ava.saved { background: var(--accent) !important; background-image: none !important; }
.ava.saved svg.i { width: 55%; height: 55%; stroke-width: 1.9; }

/* превью ссылок (29.10, часть 6) */
.lp { display: flex; flex-direction: column; gap: 1px; margin: 5px 0 3px; padding: 4px 8px 6px 10px; border-left: 3px solid var(--accent); border-radius: 5px;
      background: var(--accent-soft); color: inherit; text-decoration: none; max-width: 420px; overflow: hidden; }
.msg.mine .lp { border-left-color: var(--mine-strong); background: var(--mine-soft); }
.lp:hover .lp-title { text-decoration: underline; }
.lp-site { font-size: 13.5px; font-weight: 600; color: var(--accent-ink); }
.msg.mine .lp-site { color: var(--mine-strong); }
.lp-title { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.lp-desc { font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lp-img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 8px; margin-top: 6px; background: rgba(0,0,0,.06); }
.bubble.has-lp { min-width: min(320px, 100%); }
.lp-bar svg.i { color: var(--accent); }

/* опросы (29.10, часть 7) */
.poll { display: flex; flex-direction: column; gap: 6px; min-width: min(300px, 62vw); padding: 2px 0 4px; }
.poll-q { font-size: 15.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.poll-kind { font-size: 13px; color: var(--meta); margin-top: -4px; margin-bottom: 4px; }
.msg.mine .poll-kind { color: var(--mine-meta); }
.poll-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 4px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.poll-opt:hover { background: var(--accent-soft); }
.msg.mine .poll-opt:hover { background: var(--mine-soft); }
.po-mark { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--accent); display: grid; place-items: center; }
.msg.mine .po-mark { border-color: var(--mine-strong); }
.poll-opt.multi .po-mark { border-radius: 6px; }
.poll-opt.on .po-mark { background: var(--accent); box-shadow: inset 0 0 0 3px var(--theirs); }
.msg.mine .poll-opt.on .po-mark { background: var(--mine-strong); box-shadow: inset 0 0 0 3px var(--mine); }
.po-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-vote { align-self: stretch; margin: 4px 0 0; }
.poll-res { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto 6px; column-gap: 8px; row-gap: 3px; padding: 3px 0; align-items: center; }
.pr-pct { grid-row: 1 / span 2; font-weight: 700; font-size: 14.5px; text-align: right; }
.pr-text { display: flex; align-items: center; gap: 4px; overflow-wrap: anywhere; }
.pr-text svg.i { width: 16px; height: 16px; color: var(--accent); stroke-width: 2.6; }
.msg.mine .pr-text svg.i { color: var(--mine-strong); }
.pr-bar { height: 6px; border-radius: 3px; background: var(--accent-soft); overflow: hidden; }
.msg.mine .pr-bar { background: var(--mine-soft); }
.pr-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .35s ease-out; }
.msg.mine .pr-bar i { background: var(--mine-strong); }
.poll-res.mine .pr-pct { color: var(--accent-ink); }
.poll-foot { font-size: 13px; color: var(--meta); padding-right: 50px; }
.msg.mine .poll-foot { color: var(--mine-meta); padding-right: 70px; }
.poll-foot.link { border: 0; background: transparent; padding: 0 70px 0 0; text-align: left; cursor: pointer; font: inherit; font-size: 13px; color: var(--accent-ink); }
.msg.mine .poll-foot.link { color: var(--mine-strong); }
.msg-menu.voters { max-height: 60vh; overflow-y: auto; min-width: 240px; }
.poll-dlg { max-width: 460px; }
.poll-form { overflow-y: auto; padding: 0 4px 6px; }
.poll-form > .field { margin: 0 16px 6px; width: calc(100% - 32px); }
.poll-opts { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; }
.poll-row { display: flex; gap: 4px; align-items: center; }
.poll-row .field { margin: 0; }
.poll-count { padding: 4px 16px 8px; }

/* ───── Обсуждения под сообщением (как комментарии в Telegram) */
.bubble.has-thread { padding-bottom: 0; min-width: min(250px, 100%); }
.bubble.has-thread .meta { bottom: 45px; }
.thread-bar { display: flex; align-items: center; gap: 8px; width: calc(100% + 19px); height: 40px; margin: 7px -9px 0 -10px; padding: 0 8px 0 12px;
              border: 0; border-top: 1px solid color-mix(in srgb, var(--muted) 22%, transparent); border-radius: 0 0 15px 15px; background: transparent;
              color: var(--accent-ink); font: inherit; font-size: 14.5px; font-weight: 500; cursor: pointer; text-align: left; }
.bubble.has-thread.no-text .thread-bar { margin-top: 22px; }
.msg.end.theirs .thread-bar { border-bottom-left-radius: 0; }
.msg.end.mine .thread-bar { border-bottom-right-radius: 0; }
.msg.theirs:not(.end) .thread-bar { border-bottom-left-radius: 6px; }
.msg.mine:not(.end) .thread-bar { border-bottom-right-radius: 6px; }
.msg.mine .thread-bar { color: var(--mine-strong); border-top-color: color-mix(in srgb, var(--mine-strong) 22%, transparent); }
.thread-bar:hover { background: color-mix(in srgb, currentColor 7%, transparent); }
.thread-bar .tb-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-bar > svg.i { flex: none; width: 20px; height: 20px; }
.thread-bar > svg.i:last-child { width: 16px; height: 16px; opacity: .7; }
.tb-avas { display: flex; flex: none; }
.tb-avas .ava { width: 24px; height: 24px; font-size: 10px; box-shadow: 0 0 0 2px var(--theirs); margin-left: -7px; }
.tb-avas .ava:first-child { margin-left: 0; }
.msg.mine .tb-avas .ava { box-shadow: 0 0 0 2px var(--mine); }

/* панель обсуждения: справа поверх чата, на телефоне — во весь экран */
.thread-pane { width: min(460px, 100%); background: var(--wall); isolation: isolate; }
.thread-pane::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: var(--pattern); opacity: var(--pattern-op);
                       -webkit-mask: url(/wall.svg) 0 0 / 320px 320px repeat; mask: url(/wall.svg) 0 0 / 320px 320px repeat; }
.thread-pane .info-head { background: var(--panel); padding-left: 16px; }
.th-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.th-title b { font-size: 17px; font-weight: 600; }
.th-title span { font-size: 13.5px; color: var(--muted); }
.th-feed { padding: 8px 10px 10px; }
.th-divider { display: flex; justify-content: center; margin: 14px 0 4px; }
.th-divider span { padding: 3px 12px; border-radius: 12px; background: var(--sys-bg); color: var(--sys-ink); font-size: 13px; font-weight: 500;
                   -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.th-older { display: block; border: 0; cursor: pointer; font: inherit; font-size: 13px; }
.th-composer { padding: 6px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.th-composer .input-row { min-height: 48px; }
.th-composer textarea { padding: 13px 10px 12px; }
.th-composer .send { width: 48px; height: 48px; }
.thread-pane .blocked { width: calc(100% - 20px); margin: 6px 10px max(10px, env(safe-area-inset-bottom)); color: var(--muted); }
@media (max-width: 720px) { .thread-pane { width: 100%; border-left: 0; } }
/* широкий экран: обсуждение — колонкой рядом с чатом (как в Telegram), лента и поле ввода не закрыты */
@media (min-width: 1100px) {
  .main.thread-on .chat { margin-right: 460px; }
  .main.thread-on .thread-pane { box-shadow: none; animation: none; }
}
.tb-avas .ava { position: relative; }
.tb-avas .ava:nth-child(1) { z-index: 3; } .tb-avas .ava:nth-child(2) { z-index: 2; } .tb-avas .ava:nth-child(3) { z-index: 1; }

/* ───── Отложенная отправка и напоминания */
.sched-btn { position: relative; color: var(--accent) !important; }
.sched-count { position: absolute; right: 5px; top: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff;
               font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center; }
.sched-count:empty { display: none; }
.when-dlg, .later-dlg { max-width: 420px; }
.when-presets { display: flex; flex-direction: column; padding: 4px 8px; }
.when-opt { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px;
            background: transparent; font: inherit; font-size: 15px; color: var(--text); cursor: pointer; text-align: left; }
.when-opt:hover { background: var(--hover); }
.when-opt small { font-size: 13px; }
.when-custom { padding: 6px 20px 4px; }
.when-custom .field { width: 100%; margin: 0; }
.when-dlg .err-line { margin: 4px 20px 0; }
.later-body { padding: 4px 0 12px; overflow-y: auto; max-height: min(70vh, 560px); }
.later-item { padding: 10px 20px; border-bottom: 1px solid var(--line); }
.later-item:last-child { border-bottom: 0; }
.li-when { display: flex; align-items: center; gap: 6px; color: var(--accent-ink); font-size: 13.5px; font-weight: 600; }
.li-when svg.i { width: 16px; height: 16px; }
.li-when .muted { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-text { margin-top: 3px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.li-err { margin-top: 4px; color: var(--err); font-size: 13.5px; }
.later-item.failed .li-when { color: var(--err); }
.li-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.li-acts .btn { padding: 6px 12px; font-size: 13.5px; }
.li-acts .btn.danger { color: var(--err); }
.later-empty { padding: 24px 20px; text-align: center; color: var(--muted); }

/* Объяснение «почему нельзя» (микрофон и т. п.) */
.note-dlg { max-width: 420px; height: auto !important; }
.note-text { margin: 4px 20px 8px; font-size: 15px; line-height: 1.45; color: var(--text); }
.note-dlg .dialog-foot { justify-content: flex-end; gap: 8px; }

/* ───── Заставка чата (03.11): готовые фоны — цвет и наш узор, своя картинка — вместо узора (можно размыть) */
[data-wall="sky"]      { --wall: linear-gradient(160deg, #cfe2f6 0%, #dbe8fb 40%, #c3d8f1 75%, #b4cbec 100%); --pattern: #2e5c8a; --pattern-op: .1; }
[data-wall="mint"]     { --wall: linear-gradient(160deg, #cfeedd 0%, #e2f5e4 45%, #bde5d1 100%); --pattern: #2f6b4e; --pattern-op: .1; }
[data-wall="lavender"] { --wall: linear-gradient(160deg, #e2d8f5 0%, #efe2f5 45%, #d6cbef 100%); --pattern: #5b3f8a; --pattern-op: .1; }
[data-wall="peach"]    { --wall: linear-gradient(160deg, #fbdfcd 0%, #fdeadb 45%, #f5cdc4 100%); --pattern: #8a4a2e; --pattern-op: .1; }
[data-wall="sea"]      { --wall: linear-gradient(160deg, #bde2e2 0%, #ceebe6 45%, #b0d4dc 100%); --pattern: #1f5f66; --pattern-op: .1; }
[data-wall="sand"]     { --wall: linear-gradient(160deg, #eee4cc 0%, #f5edda 45%, #e4d8bb 100%); --pattern: #6b5a2f; --pattern-op: .1; }
[data-wall="graphite"] { --wall: linear-gradient(160deg, #d6dade 0%, #e4e7eb 45%, #c7ccd3 100%); --pattern: #39424d; --pattern-op: .1; }
[data-wall="night"]    { --wall: linear-gradient(160deg, #22324b 0%, #2b3d59 45%, #1b283d 100%); --pattern: #9fc3ea; --pattern-op: .08; }
html[data-theme="dark"] [data-wall="sky"]      { --wall: linear-gradient(160deg, #0f2033, #14283f 50%, #0c1a2b); --pattern: #8fb8e6; --pattern-op: .06; }
html[data-theme="dark"] [data-wall="mint"]     { --wall: linear-gradient(160deg, #0f2a22, #133227 50%, #0c211b); --pattern: #8fd6b4; --pattern-op: .06; }
html[data-theme="dark"] [data-wall="lavender"] { --wall: linear-gradient(160deg, #221a35, #2a2040 50%, #1a142b); --pattern: #c2a8f0; --pattern-op: .06; }
html[data-theme="dark"] [data-wall="peach"]    { --wall: linear-gradient(160deg, #33201a, #3b261e 50%, #2a1915); --pattern: #f0b79c; --pattern-op: .06; }
html[data-theme="dark"] [data-wall="sea"]      { --wall: linear-gradient(160deg, #0d2a2c, #113335 50%, #0a2123); --pattern: #86d0d4; --pattern-op: .06; }
html[data-theme="dark"] [data-wall="sand"]     { --wall: linear-gradient(160deg, #2b2517, #332c1c 50%, #221d12); --pattern: #dccb94; --pattern-op: .06; }
html[data-theme="dark"] [data-wall="graphite"] { --wall: linear-gradient(160deg, #1b1f24, #22272d 50%, #15181c); --pattern: #aab4bf; --pattern-op: .06; }
html[data-theme="dark"] [data-wall="night"]    { --wall: linear-gradient(160deg, #0b111c, #0f1726 50%, #080d16); --pattern: #7ea6d6; --pattern-op: .06; }
/* своя картинка: слой узора становится картинкой; в тёмной теме — чуть темнее, чтобы пузыри читались */
.main.has-wall-img { overflow: hidden; }
.main.has-wall-img::before, .main.has-wall-img .thread-pane::before { inset: 0; opacity: 1; -webkit-mask: none; mask: none;
  background: var(--wall-img) center / cover no-repeat; }
.main.has-wall-img.wall-blur::before, .main.has-wall-img.wall-blur .thread-pane::before { inset: -40px; filter: blur(18px); }
.main.has-wall-img .thread-pane { overflow: hidden; }
html[data-theme="dark"] .main.has-wall-img::after, html[data-theme="dark"] .main.has-wall-img .thread-pane::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: rgba(0, 0, 0, .32); }

.wall-dlg { max-width: 460px; height: auto !important; }
.wall-scope { display: flex; gap: 4px; margin: 4px 16px 10px; padding: 3px; border-radius: 12px; background: var(--hover); }
.wall-seg { flex: 1; border: 0; border-radius: 9px; padding: 7px 10px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.wall-seg.on { background: var(--panel); color: var(--accent-ink); box-shadow: var(--shadow); }
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; padding: 0 16px 12px; max-height: min(56vh, 460px); overflow-y: auto; }
.wall-tile { position: relative; height: 128px; border: 0; border-radius: 12px; background: var(--wall) center / cover no-repeat; cursor: pointer; overflow: hidden;
  isolation: isolate; box-shadow: inset 0 0 0 1px var(--line); padding: 0; }
.wall-tile::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--pattern); opacity: var(--pattern-op);
  -webkit-mask: url(/wall.svg) 0 0 / 160px 160px repeat; mask: url(/wall.svg) 0 0 / 160px 160px repeat; }
.wall-tile.img::before { display: none; }
.wall-tile.img { background-color: var(--hover); }
.wall-tile.on { box-shadow: 0 0 0 3px var(--accent); }
.wt-b1, .wt-b2 { position: absolute; height: 14px; border-radius: 7px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.wt-b1 { left: 8px; top: 14px; width: 54%; background: var(--theirs); }
.wt-b2 { right: 8px; top: 36px; width: 46%; background: var(--mine); }
.wt-name { position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 8px; background: var(--sys-bg); color: var(--sys-ink);
  font-size: 12px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wt-plus { position: absolute; inset: 0 0 26px; display: grid; place-items: center; color: var(--accent); }
.wt-plus svg.i { width: 30px; height: 30px; }
.wall-tile.busy { opacity: .6; pointer-events: none; }
.wall-dlg .gs-row { margin: 0 16px 8px; }
.wall-dlg .err-line { margin: 0 16px 8px; }

/* Фото группы — камера прямо у большого кружка в «О группе» (03.11) */
.ava-wrap { position: relative; display: inline-block; }
.ava-cam { position: absolute; right: 0; bottom: 0; width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--panel); background: var(--accent); color: #fff;
  display: grid; place-items: center; cursor: pointer; padding: 0; box-shadow: var(--shadow); transition: transform .12s; }
.ava-cam:hover { transform: scale(1.08); }
.ava-cam svg.i { width: 18px; height: 18px; }

/* ───── Всплывающие уведомления о новых сообщениях (03.11): справа под шапкой чата (кнопки шапки не закрывает), на телефоне — сверху */
.popups { position: fixed; top: 68px; right: 14px; z-index: 95; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 24px)); pointer-events: none; }
.pop { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 12px; border-radius: 14px; background: var(--pop-bg); box-shadow: var(--pop-shadow);
  -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5); cursor: pointer; animation: pop-in .22s ease-out; transition: opacity .18s, transform .18s; }
.pop.out { opacity: 0; transform: translateX(16px); }
.pop:hover { box-shadow: var(--pop-shadow), 0 0 0 2px var(--accent-soft); }
.pop .ava { flex: none; }
.pop-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pop-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-text { font-size: 14px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pop-x { flex: none; width: 32px; height: 32px; color: var(--muted); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@media (max-width: 600px) {
  .popups { left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top)); width: auto; }
  .pop.out { transform: translateY(-16px); }
}

/* ═════════════ 04.11: «@», выбор сообщений, ответ свайпом */
.mention-jump { bottom: 140px; color: var(--accent); }
.mention-jump b { font-size: 21px; font-weight: 700; line-height: 1; }
.down.hidden + .mention-jump { bottom: 84px; }
@media (max-width: 720px) { .mention-jump { bottom: 132px; } .down.hidden + .mention-jump { bottom: 76px; } }
.badge.at { min-width: 22px; padding: 0; margin-right: 4px; font-weight: 700; }
.badge.at + .badge { margin-left: 0; }

.swipe-reply { position: absolute; right: 6px; top: 50%; transform: translateY(-50%) scale(.6); width: 32px; height: 32px; border-radius: 50%;
               display: grid; place-items: center; background: rgba(0,0,0,.18); color: #fff; opacity: 0; pointer-events: none; transition: background .12s; }
.swipe-reply.ready { background: var(--accent); }
.swipe-reply svg.i { width: 18px; height: 18px; }

.feed.selecting .msg[data-id] { cursor: pointer; padding-left: 34px; }
.feed.selecting .msg[data-id]::after { content: ''; position: absolute; left: 4px; bottom: 6px; width: 20px; height: 20px; border-radius: 50%;
               border: 2px solid var(--muted); background: var(--panel); box-sizing: border-box; }
.feed.selecting .msg.sel::after { border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / 14px no-repeat; }
.feed.selecting .msg.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 10px; }
.feed.selecting .msg .more { display: none; }
.sel-bar .input-row { align-items: center; gap: 6px; padding-right: 8px; }
.sel-count { flex: 1; font-weight: 600; font-size: 15px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-act { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 15px; font-weight: 600;
           padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.sel-act:hover:not(:disabled) { background: var(--hover); }
.sel-act:disabled { color: var(--muted); opacity: .6; cursor: default; }
.sel-act.danger { color: var(--err); }
.sel-act.danger.sure { background: var(--err); color: #fff; }
.sel-act svg.i { width: 20px; height: 20px; }
@media (max-width: 720px) { .sel-act span { display: none; } .sel-act.danger.sure span { display: inline; } .sel-act { padding: 8px; } }

/* ═════════════ Размер текста (04.11): ☰ → «Размер текста» — на этом устройстве */
:root { --fz: 1; }
html[data-fs="l"] { --fz: 1.15; }
html[data-fs="xl"] { --fz: 1.32; }
.bubble .text { font-size: calc(15.5px * var(--fz)); }
.bubble .name { font-size: calc(14px * var(--fz)); }
.quote b { font-size: calc(13.5px * var(--fz)); }
.quote span { font-size: calc(14px * var(--fz)); }
.bubble .meta { font-size: calc(12px * var(--fz)); }
.item .t { font-size: calc(16px * var(--fz)); }
.item .pv { font-size: calc(15px * var(--fz)); }
.item .pv2 { font-size: calc(14px * var(--fz)); }
.composer textarea { font-size: calc(16px * var(--fz)); }
.doc-name { font-size: calc(15px * var(--fz)); }
.doc-size { font-size: calc(13px * var(--fz)); }
.day span, .sys span { font-size: calc(14px * var(--fz)); }
.ir-text { font-size: calc(15.5px * var(--fz)); }
html[data-fs="l"] .bubble .text::after { width: 52px; }
html[data-fs="xl"] .bubble .text::after { width: 60px; }
html[data-fs="l"] .msg.mine .bubble .text::after { width: 76px; }
html[data-fs="xl"] .msg.mine .bubble .text::after { width: 86px; }
.fs-row { display: flex; align-items: center; gap: 18px; padding: 7px 12px 7px 18px; font-size: 14.5px; font-weight: 500; }
.fs-row > svg.i { color: var(--muted); }
.fs-row > span:first-of-type { flex: 1; }
.fs-opts { display: inline-flex; gap: 2px; background: var(--hover); border-radius: 10px; padding: 2px; }
.menu .fs-opts button { width: auto; padding: 4px 9px; border-radius: 8px; gap: 0; font-weight: 600; color: var(--muted); line-height: 1; }
.menu .fs-opts button[data-fs="m"] { font-size: 13px; }
.menu .fs-opts button[data-fs="l"] { font-size: 16px; }
.menu .fs-opts button[data-fs="xl"] { font-size: 19px; }
.menu .fs-opts button.on { background: var(--panel); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
/* Переход к дате в поиске по чату (04.11) */
.find-date { position: relative; display: inline-flex; }
.find-date input[type=date] { position: absolute; right: 0; top: 100%; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }
.find-date input[type=date].show { width: auto; height: auto; opacity: 1; pointer-events: auto; z-index: 5; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }

/* ═════════════ Подсказки при первом входе (04.11) */
.tips-dlg { max-width: 420px; padding: 0; }
.tips-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 20px; font-size: 13px; }
.tips-body { padding: 6px 28px 4px; text-align: center; }
.tip-ico { width: 72px; height: 72px; margin: 6px auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tip-ico svg.i { width: 34px; height: 34px; }
.tip-ico b { font-size: 34px; line-height: 1; }
.tip-t { margin: 0 0 8px; font-size: calc(19px * var(--fz)); }
.tip-x { margin: 0 0 14px; font-size: calc(15.5px * var(--fz)); line-height: 1.45; color: var(--text); min-height: 4.4em; }
.tip-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.tip-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tip-dots i.on { background: var(--accent); width: 18px; border-radius: 4px; }
.tips-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px 16px; }
.tips-nav { display: inline-flex; gap: 8px; }
.tips-foot .btn { margin: 0; width: auto; }
.invisible { visibility: hidden; }
@media (max-width: 720px) {
  .tips-modal { padding: 16px; place-items: center; }
  .tips-modal .tips-dlg { height: auto; max-height: calc(100dvh - 32px); border-radius: 16px; }
}
/* Отменить загрузку (05.11) */
.progress { min-width: 230px; height: auto; display: flex; align-items: center; gap: 10px; padding: 7px 62px 0 0; }
.progress span { position: static; }
.up-cancel { position: static; display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--accent);
             font: inherit; font-size: 13px; font-weight: 600; padding: 2px 4px; border-radius: 6px; cursor: pointer; }
.up-cancel:hover { background: var(--hover); }
.up-cancel svg.i { width: 15px; height: 15px; }
.msg.mine .up-cancel { color: var(--mine-strong); }
.bubble.has-media > .progress { margin-bottom: 2px; }

/* Просмотр фото: масштаб и листание (05.11) */
.viewer:not(.pdf) .viewer-body { touch-action: none; }
.viewer-body img { transform-origin: center; will-change: transform; user-select: none; -webkit-user-drag: none; }
.viewer-body.zoomed img { cursor: grab; }
.viewer-body.zoomed img:active { cursor: grabbing; }
.viewer-body.zoomed .viewer-nav { opacity: .35; }

/* Подсказка команд над полем ввода: «/» → /заявка (06.11, модуль 11 «Снабжение») */
#composer { position: relative; }
.slash-hint { position: absolute; left: max(12px, calc((100% - 776px) / 2)); right: max(12px, calc((100% - 776px) / 2)); bottom: calc(100% + 6px); background: var(--pop-bg); box-shadow: var(--pop-shadow); border-radius: 12px; padding: 4px; z-index: 30; backdrop-filter: blur(8px); }
.slash-hint.hidden { display: none; }
.slash-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--text); font: inherit; padding: 9px 10px; border-radius: 9px; cursor: pointer; text-align: left; }
.slash-item:hover { background: var(--hover); }
.slash-item .i { width: 20px; height: 20px; color: var(--accent); flex: none; }
.slash-item span { color: var(--muted); font-size: 13px; }
/* окно заявки поверх мессенджера — шрифт и цвета мессенджера */
.sp-modal { z-index: 1200; }
.sp-toast { z-index: 1300; }

/* Карточка базы знаний в сообщении (1.24.0) */
.kbc { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0; padding: 8px 10px; max-width: 360px; border-radius: 10px; border-left: 3px solid #e8590c; background: rgba(232, 89, 12, .08); color: inherit; text-decoration: none; }
a.kbc:hover .kbc-title { text-decoration: underline; }
.kbc-pic { flex: none; width: 48px; height: 48px; border-radius: 8px; display: grid; place-items: center; font-size: 24px; background: rgba(0, 0, 0, .06); overflow: hidden; }
.kbc-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kbc-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.kbc-title { font-weight: 600; overflow-wrap: anywhere; }
.kbc-path { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.kbc-snip { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kbc-snip:empty { display: none; }
.kbc.off { border-left-color: var(--muted); background: rgba(0, 0, 0, .05); }
.kb-pick { overflow: auto; min-height: 120px; padding: 0 8px 8px; }
.kb-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; cursor: pointer; }
.kb-item:hover, .kb-item:focus-visible { background: var(--hover, rgba(0, 0, 0, .05)); }
.kb-item span { font-size: 13px; color: var(--muted); }
.kbc.off .kbc-title { color: var(--muted); }

/* «← В базу знаний» — пришли из базы знаний в этой же вкладке (1.24.1) */
.backbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 40; display: flex; align-items: center; gap: 2px; background: #24231f; color: #fff; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: 14px; }
.backbar a { color: #fff; text-decoration: none; padding: 8px 6px 8px 14px; font-weight: 600; }
.backbar button { background: none; border: 0; color: #cfccc4; font-size: 18px; padding: 4px 12px 4px 6px; cursor: pointer; }
