/* Линия — экран «Сообщения»: список чатов | переписка | профиль собеседника (DESIGN.md §3, §5.1, §5.4–5.6, §5.8).
   ≥1280 три колонки; ≤1279 профиль выезжает поверх переписки; ≤767 два экрана (список ↔ чат), профиль на весь экран
   над таб-баром. Порог 1280 повторён в syncProfileOverlay и ловушке Tab (app.js). Шапка чата и поле ввода
   подстраиваются под ширину колонки переписки (container queries), а не окна: при открытом профиле она уже.
   Только переменные из tokens.css; компоненты (.btn, .chip, .st, kbd, .notice, .ui-empty, #modal) — из app.css. */

/* ===== Раскладка ===== */
.messages-panel { display: flex; flex: 1 1 0; min-height: 420px; overflow: hidden; }   /* заполняет высоту страницы, списки прокручиваются внутри */
.local-inbox { position: relative; display: grid; flex: 1; grid-template-columns: 352px minmax(0, 1fr); min-width: 0; min-height: 0; }
.local-inbox.profile-open { grid-template-columns: 352px minmax(0, 1fr) 320px; }

/* ===== Список чатов ===== */
.inbox-sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.inbox-sidebar-head { flex: none; padding: 12px 12px 0; }
/* Блок над списком (filters-spec §6): переключатель аккаунта без рамки и заливки, поле поиска — единственная коробка,
   строка фильтров закрывает блок линией на всю ширину колонки. Аватар переключателя — на оси аватаров строк чатов. */
.account-switch { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 12px 8px 8px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--text-3); text-align: left; transition: background-color var(--dur) ease-out; }
.account-switch:is(:hover, [aria-expanded="true"]) { background: var(--hover); }
.account-switch:is(:hover, [aria-expanded="true"]) .all-avatar { background: var(--line-2); }   /* иначе значок «Все аккаунты» сливается с фоном */
.account-switch > .ui-icon { width: 16px; height: 16px; }
.account-switch-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 1.3; }
.account-switch-copy strong { overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.account-switch-copy small { overflow: hidden; color: var(--text-3); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.all-avatar { background: var(--hover); color: var(--text-2); }
.all-avatar .ui-icon { width: 16px; height: 16px; }
.inbox-sidebar-tools { position: relative; z-index: 2; display: flex; flex: none; flex-direction: column; gap: 4px; padding: 8px 12px 0; }   /* z-index: меню «Ещё» поверх списка */
/* Фильтры чатов (docs/design/filters-spec.md): вкладки «Все» / «Непрочитанные» / «Без ответа» + меню «Ещё» — одна строка при
   любой ширине колонки, без переноса и прокрутки. Выбор — цвет --text и полоса --accent 2 px на нижней линии блока; вес не
   меняется, чтобы соседи не сдвигались. Вкладка заходит на линию (+1 px): цель касания — вся высота строки, полоса лежит на линии.
   Места мало (§0) — уступают по очереди: подпись в «Ещё» (название выбранного фильтра или само «Ещё») прячется целиком,
   остаётся шеврон, и только потом подпись «Без ответа» (не её счётчик). Оси: текст «Все» и начало полосы — по левому краю
   поиска (12 px), конец полосы «Ещё» — по правому, глиф шеврона на 11.5 (у lucide своё поле ≈ 3.5). Поля вкладки 4 при любой
   колонке (решение 2026-10-04: в колонке 352 название фильтра из меню видно при обычных счётчиках): между подписями 8,
   кольцо фокуса в 2 px от текста. */
.inbox-tabs { position: relative; display: flex; align-items: stretch; gap: 0; height: 36px; margin: 0 -12px; padding: 0 4px 0 8px; border-bottom: 1px solid var(--line); }
:root[data-density="compact"] .inbox-tabs { height: 32px; }
.inbox-tabs-main { display: flex; flex: 0 1 auto; gap: 0; min-width: 0; }
.inbox-tab[data-id="needs"] { flex: 0 1 auto; min-width: 0; }   /* последняя уступка: подпись с многоточием, счётчик целиком */
.inbox-tab { position: relative; display: inline-flex; flex: none; align-items: center; height: calc(100% + 1px); margin-bottom: -1px; padding: 0 4px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: var(--fs-sm2); font-weight: 500; white-space: nowrap; transition: color var(--dur) ease-out; }
.inbox-tab:hover, .inbox-tab[aria-expanded="true"], .inbox-tab[aria-checked="true"], .inbox-more.is-current { color: var(--text); }
.inbox-tab:focus-visible { outline-offset: -2px; }
.inbox-tab::after { content: ""; position: absolute; right: 4px; bottom: 0; left: 4px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); opacity: 0; transition: opacity var(--dur) ease-out; }
.inbox-tab[aria-checked="true"]::after, .inbox-more.is-current::after { opacity: 1; }
@media (forced-colors: active) { .inbox-tab::after { background: Highlight; } }   /* высокий контраст Windows: полоса выбора не пропадает */
.inbox-tab-l { white-space: nowrap; }   /* подпись и счётчик — одна строка: общая базовая линия */
.inbox-tabs-main .inbox-tab-l { display: inline-flex; align-items: baseline; gap: 3px; min-width: 0; }   /* пробел перед счётчиком — для имени, глазу — gap шириной в пробел */
.inbox-tab-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.inbox-tabs-main .n { flex: none; }
.inbox-tab .n, .inbox-menu-item .n { color: var(--text-3); font-size: var(--fs-sm); }
.inbox-more-slot { display: flex; flex: 1 1 0; justify-content: flex-end; min-width: 22px; container: inbox-more / inline-size; }   /* остаток строки; не уже шеврона */
.inbox-more { flex: 0 1 auto; gap: 0; min-width: 0; padding: 0 4px; }   /* зазор до шеврона — его собственное поле ≈ 3.5 */
.inbox-more::after { right: 8px; }
.inbox-more .inbox-tab-l { position: relative; min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* relative: sr-only внутри обрезки, строка не шире колонки */
.inbox-more .ui-icon { flex: none; width: 14px; height: 14px; color: var(--text-3); }
/* Подпись в «Ещё» — целиком или никак: «Е…» / «Без реак…» не бывает. Не помещается — остаётся шеврон (у выбранного фильтра —
   с полосой), имя — в title и в доступном имени. Порог — ширина кнопки с подписью (Onest 12.5 / 500: поля 4 + подпись +
   шеврон 14) плюс 0.5 px; на телефоне свои пороги (ниже). */
@container inbox-more (max-width: 47.7px) { .inbox-more:not(.is-current) .inbox-tab-l { width: 0; } }
@container inbox-more (max-width: 55px) { .inbox-more[data-filter="leads"] .inbox-tab-l { width: 0; } }
@container inbox-more (max-width: 59.6px) { .inbox-more[data-filter="archive"] .inbox-tab-l { width: 0; } }
@container inbox-more (max-width: 67.4px) { .inbox-more[data-filter="channels"] .inbox-tab-l { width: 0; } }
@container inbox-more (max-width: 98.8px) { .inbox-more[data-filter="no-response"] .inbox-tab-l { width: 0; } }
.inbox-more:is(.is-current, [aria-expanded="true"]) .ui-icon { color: var(--text-2); }
.inbox-menu { position: absolute; top: calc(100% + 4px); right: 8px; z-index: 6; display: flex; flex-direction: column; gap: 2px; width: 224px; max-width: calc(100% - 16px); padding: 4px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--raised); box-shadow: var(--shadow); transition: opacity 150ms ease-out, transform 150ms var(--ease); }
@starting-style { .inbox-menu { opacity: 0; transform: translateY(-4px); } }
.inbox-menu-item { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); font-size: var(--fs-md); text-align: left; }
:root[data-density="compact"] .inbox-menu-item { height: 32px; }
.inbox-menu-item:is(:hover, :focus-visible) { background: var(--hover); }
.inbox-menu-item:focus-visible { outline-offset: -2px; }
.inbox-menu-item .ui-icon { width: 16px; height: 16px; color: var(--accent); visibility: hidden; }
.inbox-menu-item[aria-checked="true"] { font-weight: 500; }
.inbox-menu-item[aria-checked="true"] .ui-icon { visibility: visible; }
.inbox-menu-sep { height: 1px; margin: 2px 4px; background: var(--line); }
.inbox-hint-slot { display: contents; }   /* слот есть всегда: подсказка появляется без пересоздания соседей */
.queue-hint, .inbox-filter-help { display: flex; align-items: center; gap: 8px; padding: 8px 0 4px; color: var(--text-3); font-size: var(--fs-sm); }   /* под линией блока */
.queue-hint .ui-icon { width: 14px; height: 14px; }
.queue-left { margin-left: auto; color: var(--text-2); white-space: nowrap; }

.local-dialogs, .inbox-account-list { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 8px; overscroll-behavior: contain; }
.local-dialogs { padding-top: 4px; }   /* первая строка чата не прилипает к линии блока над списком */
.local-dialog { position: relative; display: block; border-radius: var(--r-md); transition: background-color 150ms ease-out; }
.local-dialog:hover { background: var(--hover); }
.local-dialog.active { background: var(--accent-soft); }
/* Кнопка «открыть чат» — на всё содержимое строки; действия — её соседи (WCAG 4.1.2: без вложенных интерактивных) */
.dialog-main { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px; border: 0; border-radius: inherit; background: transparent; text-align: left; }
.dialog-main:focus-visible { outline-offset: -2px; }
:root[data-density="compact"] .dialog-main { padding: 8px 12px; }
.dialog-avatar { display: grid; place-items: center; flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: 50%; background: var(--av3); color: var(--text); font-size: var(--fs-md); font-weight: 600; }   /* цвет — класс avN по id чата (app.css) */
.dialog-avatar img, .profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* Строка чата: имя · время / превью · счётчик / отправитель · «ждёт N». Обёртки .dialog-top и .dialog-preview-row
   растворяются в сетке, чтобы на сенсорном экране действия встали справа от имени, а время ушло к «ждёт N». */
.dialog-copy { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name time" "prev count" "meta meta"; align-items: center; gap: 2px 8px; min-width: 0; }
.dialog-top, .dialog-preview-row { display: contents; }
.dialog-name { grid-area: name; display: flex; align-items: center; gap: 4px; min-width: 0; }
.local-dialog { --act: 28px; }   /* размер кнопки действия строки: на телефоне 40 */
.dialog-name strong { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.local-dialog.is-unread .dialog-name strong { font-weight: 600; }
.dialog-lead-slot { display: contents; }
.lead-mark { display: inline-flex; flex: none; color: var(--warn); }
.lead-mark .ui-icon { width: 14px; height: 14px; fill: currentColor; }
.dialog-top time { grid-area: time; justify-self: end; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; }
.dialog-preview { grid-area: prev; min-width: 0; overflow: hidden; color: var(--text-2); font-size: var(--fs-md); text-overflow: ellipsis; white-space: nowrap; }
.local-dialog.is-muted .dialog-preview { color: var(--text-3); }
.dialog-preview-row .unread-count { grid-area: count; justify-self: end; }
.dialog-meta { grid-area: meta; display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 2px; color: var(--text-3); font-size: var(--fs-sm); }
.dialog-meta:empty { display: none; }
.dialog-sender { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dialog-sender > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait-chip { flex: none; margin-left: auto; font-size: var(--fs-sm); }
.wait-chip.st-info { color: var(--text-2); }
.dialog-engagement { color: var(--text-3); font-size: var(--fs-sm); }
/* Выбранная строка (--accent-soft): --text-3 там ниже 4.5:1 в тёмной теме — подписи на ступень светлее */
.local-dialog.active .dialog-top time, .local-dialog.active .dialog-meta, .local-dialog.active .dialog-engagement, .local-dialog.active.is-muted .dialog-preview { color: var(--text-2); }
.call-preview.missed { color: var(--bad); }
/* Действия строки: при наведении — плавающая панель поверх времени; скрытые не ловят нажатия */
.dialog-actions { position: absolute; top: 4px; right: 8px; z-index: 1; display: flex; gap: 2px; padding: 1px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--raised); opacity: 0; pointer-events: none; transition: opacity 150ms ease-out; }
.local-dialog:hover .dialog-actions, .local-dialog:focus-within .dialog-actions { opacity: 1; pointer-events: auto; }
.dialog-action { display: inline-grid; place-items: center; width: var(--act, 28px); height: var(--act, 28px); padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); transition: background-color 150ms ease-out, color 150ms ease-out; }
.dialog-action:hover { background: var(--hover); color: var(--text); }
.dialog-action .ui-icon { width: 16px; height: 16px; }
.dialog-action.is-lead { color: var(--warn); }
.dialog-action.is-lead .ui-icon { fill: currentColor; }
.dialog-more { display: none; }
@media (hover: hover) {   /* панель лежит над концом строки: имя уступает ей место и получает многоточие, высота строки та же */
 .local-dialog:is(:hover, :focus-within) .dialog-name { grid-column: 1 / -1; padding-right: calc(4 * var(--act) + 12px); }
}
@media (hover: none) {   /* сенсорный экран: наведения нет — в строке одна «⋯» справа от имени, время — к отправителю */
 .dialog-copy { grid-template-areas: "name name" "prev count" "meta time"; }
 .dialog-name { min-height: var(--act); padding-right: calc(var(--act) + 8px); }   /* строка имени — высотой «⋯», как когда она стояла в сетке */
 .dialog-more { position: absolute; top: 12px; right: 12px; z-index: 1; display: inline-grid; }
 :root[data-density="compact"] .dialog-more { top: 8px; }
 .dialog-more[aria-expanded="true"] { background: var(--hover); color: var(--text); }
 .dialog-actions { display: none; top: calc(12px + var(--act)); z-index: 3; opacity: 1; pointer-events: auto; box-shadow: var(--shadow); }
 .local-dialog.menu-open .dialog-actions { display: flex; }
}
.dialogs-more { display: flex; justify-content: center; padding: 8px 0 4px; }
.queue-empty { padding: 32px 16px; }
.queue-empty .ui-empty-icon { background: var(--ok-soft); color: var(--ok); }

/* Режим выбора аккаунта */
.inbox-account-list { padding-top: 8px; }
.inbox-account-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--text); text-align: left; transition: background-color 150ms ease-out; }
.inbox-account-row:hover { background: var(--hover); }
.inbox-account-row.active { background: var(--accent-soft); }
.inbox-account-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.inbox-account-copy strong { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.inbox-account-copy strong.mono { font-size: var(--fs-md); }   /* аккаунт без имени: номер — заголовок строки */
.inbox-account-copy small { color: var(--text-3); font-size: var(--fs-sm); }
.inbox-account-row .inbox-account-wait { flex: none; font-size: var(--fs-sm); font-weight: 400; }
.account-unread-empty { min-width: 20px; color: var(--text-3); font-size: var(--fs-sm); text-align: center; }

/* ===== Переписка ===== */
.local-chat { container: chat / inline-size; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-empty { justify-content: center; }
.chat-empty .kbd-row { margin-left: 4px; }
.chat-header { display: flex; flex: none; align-items: center; gap: 12px; min-height: 64px; padding: 8px 12px 8px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.mobile-back { display: none; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); }
.mobile-back:hover { background: var(--hover); color: var(--text); }
.chat-title { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.chat-title-row { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.chat-title h2 { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }   /* имя важнее телефона и статуса */
.chat-peer-meta { display: flex; flex: 0 1 auto; align-items: center; gap: 12px; min-width: 0; overflow: hidden; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; }
.chat-peer-meta .mono { color: var(--text-2); }
.chat-peer-meta .presence-state { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-meta .presence-state > i { display: inline-block; margin-right: 8px; vertical-align: 1px; }
.chat-sender { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; color: var(--text-2); font-size: var(--fs-sm2); white-space: nowrap; }
.chat-sender .mono { min-width: 0; overflow: hidden; color: var(--text); font-weight: 500; text-overflow: ellipsis; }   /* сжимается номер, не статус */
.sender-lead { flex: none; color: var(--text-3); }
.sender-label { flex: 0 999 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* не хватает места — сначала сжимается имя, номер последним */
.chat-sender .st { flex: none; font-size: var(--fs-sm); font-weight: 400; }
.chat-sender .st-ok { color: var(--text-2); }
.l-narrow { display: none; }
.chat-header-actions { display: flex; flex: none; align-items: center; gap: 4px; }
.chat-tools { display: flex; gap: 2px; padding-right: 4px; }
.chat-tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.chat-tool.is-lead[aria-pressed="true"] { background: var(--warn-soft); color: var(--warn); }
.chat-tool.is-lead[aria-pressed="true"] .ui-icon { fill: currentColor; }
/* lead-files 4.4 (D-07): статус CSV-лида — родной список слева от звёздочки; вне .chat-tools — остаётся в узкой колонке */
.chat-lead-status { width: auto; max-width: 200px; height: var(--btn-h-sm); padding: 0 8px; font-size: var(--fs-md); text-overflow: ellipsis; }
.chat-empty kbd { min-width: 18px; height: 18px; }

.local-history { display: flex; flex: 1; flex-direction: column; gap: 4px; min-height: 0; overflow: auto; padding: 20px 28px; overscroll-behavior: contain; }
.history-more { display: flex; justify-content: center; margin-bottom: 8px; }
.message-day-separator { display: flex; justify-content: center; margin: 12px 0 8px; }
.message-day-separator span { padding: 2px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }

/* Пузыри: входящие --raised, исходящие --accent-soft; подряд от одного автора — плотнее и с «хвостом» только у крайних */
.local-message { position: relative; display: flex; flex-direction: column; gap: 4px; align-self: flex-start; width: fit-content; max-width: min(560px, calc(100% - 48px)); padding: 8px 12px 4px; border: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px; background: var(--raised); color: var(--text); font-size: var(--fs-msg); line-height: 1.5; overflow-wrap: anywhere; }
.local-message:not(.grouped-previous) { margin-top: 8px; }
.message-day-separator + .local-message, .history-more + .local-message { margin-top: 0; }
.local-message.grouped-previous { border-top-left-radius: 4px; }
.local-message.out { align-self: flex-end; border-color: transparent; border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg); background: var(--accent-soft); }
.local-message.out.grouped-previous { border-top-right-radius: 4px; }
.message-body { white-space: pre-wrap; }
.message-meta { display: inline-flex; align-self: flex-end; align-items: center; gap: 4px; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.2; }
.message-checks { display: inline-flex; color: var(--accent-text); }
.message-checks .ui-icon { width: 14px; height: 14px; }
.message-edited { color: var(--text-3); }
.message-pin { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: var(--fs-xs); font-weight: 500; }
.message-pin .ui-icon { width: 12px; height: 12px; }
/* На --accent-soft --text-3 даёт 4.36–4.39:1 — у исходящих подписи на ступень светлее (AA) */
.local-message.out .message-meta, .local-message.out .message-pin, .local-message.out .message-edited { color: var(--text-2); }
.local-message.is-pinned { border-color: var(--line-2); }
.local-message.is-deleted { border-style: dashed; border-color: var(--line-2); background: transparent; }
.local-message.is-deleted .message-body { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.local-message.is-deleted .message-body .ui-icon { width: 14px; height: 14px; }
/* Ещё не отправлено: пунктир и статус с иконкой, без полупрозрачности (контраст текста сохраняется) */
.local-message.pending-message { border: 1px dashed var(--line-2); background: var(--accent-soft); }
.pending-message > p { white-space: pre-wrap; }
.pending-status { display: inline-flex; align-self: flex-end; align-items: center; gap: 4px; color: var(--text-2); font-size: var(--fs-xs); }
.pending-status .ui-icon { width: 12px; height: 12px; }
.local-message.pending-message.is-failed { border-color: var(--bad); background: var(--bad-soft); }
.pending-message.is-failed .pending-status { color: var(--bad); }
.pending-send-now { align-self: flex-end; margin-bottom: 4px; }
.pending-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Ответ на сообщение (reply-feature Ф3, как Telegram Desktop): цитата цели — тонированный блок над текстом, имя акцентом,
   текст одной строкой; удалённая цель — пунктир, без перехода. Полосы слева нет (DESIGN.md §7: цветная кромка толще 1 px). */
.message-quote { display: flex; flex-direction: column; align-self: stretch; min-width: 0; max-width: 100%; padding: 4px 8px; border: 1px solid transparent; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--text-2); font: inherit; font-size: var(--fs-sm2); line-height: 1.35; text-align: left; cursor: pointer; transition: border-color 150ms ease-out; }
.message-quote:hover { border-color: var(--line-2); }
.message-quote.is-gone { border: 1px dashed var(--line-2); background: transparent; cursor: default; }
.quote-name, .quote-text { max-width: 336px; }   /* пузырь короткого ответа не раздувается длинной цитатой (px — работает и в fit-content) */
.quote-name { overflow: hidden; color: var(--accent-text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.quote-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Переход по цитате: цель обведена акцентом 1,5 с — только она (прозрачная обводка у всех пузырей в forced-colors стала бы
   рамкой каждого); в высоком контрасте — системный Highlight */
.local-message.is-reply-target { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (forced-colors: active) { .local-message.is-reply-target { outline-color: Highlight; } }
@media (prefers-reduced-motion: reduce) { .message-quote { transition: none; } }

/* «⋯» сообщения — сбоку от пузыря (у исходящих слева), меню — под пузырём: текст не перекрывается.
   details растянут по пузырю (внутри рамки, отсюда +1px) и прозрачен для мыши; прозрачная кромка кнопки — мостик для наведения. */
.message-actions { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.message-actions summary { position: absolute; top: 2px; left: calc(100% + 1px); display: grid; place-items: center; width: 32px; height: 28px; border-left: 4px solid transparent; border-radius: var(--r-sm); background-clip: padding-box; color: var(--text-3); list-style: none; cursor: pointer; pointer-events: auto; transition: opacity 150ms ease-out, background-color 150ms ease-out, color 150ms ease-out; }
.local-message.out > .message-actions summary { left: auto; right: calc(100% + 1px); border-left: 0; border-right: 4px solid transparent; }
.message-actions summary::-webkit-details-marker { display: none; }
.message-actions summary:hover, .message-actions[open] summary { background-color: var(--hover); color: var(--text); }
.message-actions summary .ui-icon { width: 16px; height: 16px; }
.message-actions:not([open]) summary { opacity: 0; pointer-events: none; }
.local-message:hover > .message-actions summary, .local-message:focus-within > .message-actions summary { opacity: 1; pointer-events: auto; }
@media (hover: none) { .message-actions:not([open]) summary { opacity: 1; pointer-events: auto; } }
.message-actions-list { position: absolute; top: calc(100% + 4px); left: 0; z-index: 3; display: flex; flex-direction: column; gap: 2px; min-width: 200px; padding: 4px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--raised); box-shadow: var(--shadow); pointer-events: auto; }
.local-message.out .message-actions-list { left: auto; right: 0; }
.message-actions-list .btn { justify-content: flex-start; width: 100%; font-weight: 400; }

/* Вложения и звонки */
.message-file { display: flex; align-items: center; gap: 12px; min-width: min(260px, 100%); padding: 8px; border-radius: var(--r-md); background: var(--panel); color: var(--text); text-decoration: none; }
.local-message.out .message-file { background: var(--panel); }
a.message-file:hover { background: var(--hover); color: var(--text); }
.message-file > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; min-width: 0; font-size: var(--fs-md); }
.message-file strong { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.message-file small { color: var(--text-3); font-size: var(--fs-sm); }
.file-icon, .audio-icon, .call-icon { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--hover); color: var(--text-2); }
.file-icon .ui-icon, .audio-icon .ui-icon, .call-icon .ui-icon { width: 16px; height: 16px; }
.message-photo-trigger { display: block; padding: 0; border: 0; border-radius: var(--r-md); background: none; cursor: zoom-in; }
.message-photo, .message-video { display: block; max-width: min(320px, 100%); border-radius: var(--r-md); }
.message-audio { display: flex; align-items: center; gap: 8px; }
.message-audio audio { max-width: 260px; height: 36px; }
.missed-call, .call-event { display: flex; align-items: center; gap: 12px; }
.missed-call > span:last-child, .call-event > span:last-child { display: flex; flex-direction: column; font-size: var(--fs-md); }
.missed-call small, .call-event small { color: var(--text-3); font-size: var(--fs-sm); }
.missed-call { color: var(--bad); }
.missed-call .call-icon { background: var(--bad-soft); color: var(--bad); }

/* ===== Поле ввода ===== */
.read-only-notice { margin: 12px 16px; }
.local-compose { position: relative; display: flex; flex: none; flex-direction: column; gap: 8px; padding: 12px 24px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.quick-replies { display: flex; align-items: center; gap: 8px; }
/* «Изменить» всегда виден, листаются только ответы; тонкая полоса прокрутки — знак, что их больше. Правый край затухает
   (--qr-fade): обрезанный чип читается как «дальше ещё», а не как оборванное слово; отступ той же ширины в конце —
   докрученный до конца последний чип целиком вне затухания (и фокус клавиатуры туда же: scroll-padding).
   Маска берёт только альфу: цвет в градиенте — любой непрозрачный токен. */
.qr-list { --qr-fade: 32px; display: flex; flex: 1; gap: 8px; min-width: 0; overflow-x: auto; padding: 0 var(--qr-fade) 4px 0; scroll-padding-inline-end: var(--qr-fade); mask-image: linear-gradient(to right, var(--text) calc(100% - var(--qr-fade)), transparent); }
.qr { flex: none; max-width: 280px; height: 30px; padding: 0 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text-2); font-size: var(--fs-md); text-overflow: ellipsis; white-space: nowrap; transition: border-color 150ms ease-out, color 150ms ease-out; }
.qr:hover { border-color: var(--accent); color: var(--text); }
.qr-edit { flex: none; color: var(--text-3); }
.qr-edit .ui-icon { width: 14px; height: 14px; }
/* Список не загрузился: честный статус вместо «Добавить» над сохранённым списком (DESIGN.md §5.8) */
.qr-state { display: inline-flex; flex: 0 1 auto; align-items: center; gap: 8px; min-width: 0; color: var(--text-2); font-size: var(--fs-md); white-space: nowrap; }
.qr-state > span { overflow: hidden; text-overflow: ellipsis; }
.qr-state .ui-icon { flex: none; width: 16px; height: 16px; color: var(--warn); }
.qr-list:empty { display: none; }
.compose-box { display: flex; align-items: flex-end; gap: 4px; padding: 4px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--raised); transition: border-color var(--dur) ease-out; }
.compose-box:focus-within { border-color: var(--accent); }
.compose-tool { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); transition: background-color 150ms ease-out, color 150ms ease-out; }
.compose-tool:hover { background: var(--hover); color: var(--text); }
.compose-tool.recording { background: var(--bad-soft); color: var(--bad); }
.compose-box textarea { flex: 1; min-height: 36px; max-height: 160px; padding: 8px 4px; border: 0 !important; outline: none !important; background: transparent; font-size: var(--fs-msg); resize: none; field-sizing: content; }
.compose-box .send-button { flex: none; width: 36px; height: 36px; padding: 0; }
.outbox-status { color: var(--text-3); font-size: var(--fs-sm); }
.attachment-preview { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-md); background: var(--raised); }
.attachment-preview-media { display: grid; place-items: center; flex: none; width: 48px; height: 48px; overflow: hidden; border-radius: var(--r-sm); background: var(--hover); }
.attachment-preview-media img, .attachment-preview-media video { width: 100%; height: 100%; object-fit: cover; }
.attachment-preview-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.attachment-preview-copy small { color: var(--text-3); font-size: var(--fs-sm); }
/* Плашка ответа над полем ввода — как вложение; над вложением, если оба */
.reply-preview { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 12px; border-radius: var(--r-md); background: var(--raised); }
.reply-preview > .ui-icon { flex: none; width: 20px; height: 20px; color: var(--accent-text); }
.reply-preview + .attachment-preview { margin-top: 8px; }
.reply-preview-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; padding: 4px 0; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.reply-preview-copy strong { overflow: hidden; color: var(--accent-text); font-size: var(--fs-sm2); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.reply-preview-copy small { overflow: hidden; color: var(--text-2); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }

/* «/» — пикер шаблонов над полем ввода */
.template-picker-slot { display: contents; }
.template-picker { position: absolute; right: 24px; bottom: calc(100% + 8px); left: 24px; z-index: 5; display: flex; flex-direction: column; max-height: min(320px, 50vh); padding: 4px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--raised); box-shadow: var(--shadow); transition: opacity 150ms ease-out, transform 150ms var(--ease); }
@starting-style { .template-picker { opacity: 0; transform: translateY(4px); } }
.template-picker-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 4px; color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
.picker-keys { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; white-space: nowrap; }
.picker-keys .kbd-row:not(:first-child) { margin-left: 8px; }
.template-list { min-height: 0; overflow: auto; }
.template-option { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px 12px; border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-md); cursor: pointer; }
.template-option:hover { background: var(--hover); }
.template-option[aria-selected="true"] { background: var(--accent-soft); }
.template-option-title { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
/* Длинный ответ — две строки начала текста: узнаётся, но не раздувает пикер */
.template-option-preview { display: -webkit-box; overflow: hidden; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.4; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }

/* ===== Редактор быстрых ответов (quick-replies.js): «список — ответ» в модалке-форме =====
   Окно постоянной высоты: переключение между короткими и длинными ответами не прыгает. Слева список (подпись + начало
   текста), справа выбранный ответ; прокручиваются список и правая часть по отдельности. ≤ 767 — на весь экран, список —
   строкой чипов над ответом. */
#modal:has(.qr-editor) { width: min(920px, calc(100vw - 32px)); height: min(86dvh, 760px); }
.qr-form .modal-body { display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.qr-form .modal-body > :is(#modal-error, #modal-progress, #qr-conflict) { flex: none; padding: 8px 20px; border-top: 1px solid var(--line); }
/* Конфликт вкладок: что случилось и одно действие, правки окна целы */
.qr-conflict { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; background: var(--warn-soft); font-size: var(--fs-md); }
.qr-conflict > span { display: inline-flex; flex: 1 1 320px; align-items: flex-start; gap: 8px; min-width: 0; color: var(--text); }
.qr-conflict > span .ui-icon { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--warn); }
.qr-editor { display: grid; flex: 1; grid-template-columns: 280px minmax(0, 1fr); min-height: 0; }
.qr-master { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.qr-master-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 8px 16px; }
.qr-count-label { color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
.qr-form .qr-limit { flex: none; padding: 0 16px 8px; color: var(--text-2); font-size: var(--fs-sm); }
.qr-form .qr-limit:empty { display: none; }
.qr-items { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; outline: none; }
.qr-item { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; min-height: 56px; padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; transition: background-color 150ms ease-out; }
.qr-item + .qr-item { margin-top: 2px; }
.qr-item:hover { background: var(--hover); }
.qr-item[aria-selected="true"] { background: var(--accent-soft); }
.qr-items:focus-visible .qr-item[aria-selected="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.qr-item-title { overflow: hidden; color: var(--text); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.qr-item-preview { overflow: hidden; color: var(--text-3); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.qr-undo { display: flex; flex: none; align-items: center; gap: 8px; margin: 0 8px 8px; padding: 4px 4px 4px 12px; border-radius: var(--r-sm); background: var(--raised); color: var(--text-2); font-size: var(--fs-sm); }
.qr-undo:empty { display: none; }
.qr-undo > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-detail { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; overflow-y: auto; padding: 12px 20px 20px; }
.qr-detail-tools { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; }
.qr-position { color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
.qr-tools { display: flex; align-items: center; gap: 4px; }
.qr-detail :is(input, textarea) { font-weight: 400; }   /* label.field даёт 500 — значение читается как текст сообщения */
/* Поле растёт с текстом до свободной высоты, дальше прокручивается само: счётчик под ним всегда на виду */
.qr-text-field { flex: 0 1 auto; min-height: 0; }
.qr-text-field textarea { flex: 0 1 auto; min-height: 220px; font-size: var(--fs-msg); line-height: 1.5; resize: none; field-sizing: content; }
.qr-form .qr-count { flex: none; margin-top: -8px; color: var(--text-3); font-size: var(--fs-sm); text-align: right; }
.qr-form .qr-count.is-warn { color: var(--warn); }
.qr-form .qr-count.is-over { color: var(--bad); }   /* больше предела: сохранить нельзя, превышение названо словами */
.qr-detail .qr-empty { flex: 1; }
/* «Изменения не сохранены»: вопрос встаёт на место кнопок подвала — одна пара действий за раз */
.qr-discard { display: flex; flex: 1; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.qr-discard > span { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; color: var(--warn); font-weight: 500; }
.qr-discard > span .ui-icon { width: 16px; height: 16px; }
.qr-confirming .modal-footer > .btn { display: none; }
@media (max-width: 767px) {
 #modal:has(.qr-editor) { width: 100vw; max-width: none; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
 .qr-editor { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
 .qr-master { border-right: 0; border-bottom: 1px solid var(--line); }
 .qr-master-head { padding: 8px 8px 8px 16px; }
 .qr-items { display: flex; flex: none; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 16px 12px; }
 .qr-item, .qr-item + .qr-item { flex: none; justify-content: center; max-width: 200px; height: 40px; min-height: 0; margin: 0; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; }
 .qr-item[aria-selected="true"] { border-color: var(--accent); }
 .qr-item-preview { display: none; }
 /* Список здесь — строка: «раньше» — влево, «позже» — вправо */
 .qr-tools :is([data-qr=up], [data-qr=down]) .ui-icon { rotate: -90deg; }
 .qr-undo { margin: 0 16px 12px; }
 .qr-detail { padding: 12px 16px 16px; }
 .qr-text-field textarea { min-height: 160px; }
 .qr-form .btn-sm, .qr-form .modal-footer .btn { height: 40px; }
 .qr-form .btn-sm.icon-btn { width: 40px; }
 .qr-form .modal-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
 /* «Изменения не сохранены»: сообщение отдельной строкой, под ним две равные кнопки */
 .qr-discard > span { flex-basis: 100%; margin-right: 0; }
 .qr-discard .btn { flex: 1; }
 .qr-form .modal-body > :is(#modal-error, #modal-progress, #qr-conflict) { padding: 8px 16px; }
}
.template-empty { padding: 4px 8px 8px; color: var(--text-2); font-size: var(--fs-md); }

/* ===== Профиль собеседника ===== */
.profile-drawer-layer { display: contents; }
.profile-drawer-backdrop { display: none; }
.profile-drawer { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: auto; background: var(--panel); border-left: 1px solid var(--line); }
.profile-drawer-head { position: sticky; top: 0; z-index: 1; background: var(--panel); }   /* шапка и кнопка закрытия — общие .sheet-head / .icon-btn (app.css) */
.viewer-close, .viewer-control { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); }
.viewer-close:hover, .viewer-control:hover { background: var(--hover); color: var(--text); }
.viewer-close { padding: 0; }
.profile-status-slot { display: contents; }
.profile-notice { margin: 12px 16px 0; }   /* загрузка и ошибка — общие плашки .notice */
.profile-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 24px 20px 16px; text-align: center; }
.profile-avatar { margin-bottom: 8px; }
.profile-avatar .dialog-avatar { width: 64px; height: 64px; font-size: var(--fs-lg); }
.profile-card h3 { color: var(--text); font-size: var(--fs-msg); }
.profile-username { color: var(--text-2); font-family: var(--font-data); font-size: var(--fs-sm2); }
.profile-phone { color: var(--text-3); font-family: var(--font-data); font-size: var(--fs-sm2); }
.profile-card .presence-state { margin-top: 4px; }
.profile-bio { margin-top: 8px; color: var(--text-2); font-size: var(--fs-md); }
.profile-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 0 12px 16px; border-bottom: 1px solid var(--line); }
.profile-action { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 64px; padding: 12px 4px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; line-height: 1.25; transition: background-color 150ms ease-out, color 150ms ease-out; }
.profile-action:hover { background: var(--hover); color: var(--text); }
.profile-action .ui-icon { width: 16px; height: 16px; }
.profile-action[aria-pressed="true"] { color: var(--text); }
.profile-action.is-lead[aria-pressed="true"] { color: var(--warn); }
.profile-action.is-lead[aria-pressed="true"] .ui-icon { fill: currentColor; }
.profile-queue-slot { display: contents; }
.profile-queue { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.profile-queue .wait-chip { margin-left: 0; }
.profile-body { display: flex; flex-direction: column; gap: 24px; padding: 20px; }
.profile-section { display: flex; flex-direction: column; gap: 12px; }
.profile-note { padding: 12px; border-radius: var(--r-sm); background: var(--raised); font-size: var(--fs-md); white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-details { display: grid; grid-template-columns: minmax(96px, 120px) minmax(0, 1fr); gap: 8px 12px; font-size: var(--fs-md); }
.profile-details > div { display: contents; }
.profile-details dt { color: var(--text-3); }
.profile-details dd { min-width: 0; overflow-wrap: anywhere; }
.profile-details .mono { font-size: var(--fs-sm); }
.profile-danger { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: auto; padding: 12px 16px 16px; border-top: 1px solid var(--line); }

/* ===== Просмотр фото ===== */
dialog.media-viewer { width: min(96vw, 1000px); max-width: none; height: min(92dvh, 820px); max-height: none; padding: 0; overflow: hidden; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog.media-viewer[open] { display: flex; flex-direction: column; }
.media-viewer-head, .media-viewer-controls { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 8px; height: 52px; padding: 0 12px 0 16px; color: var(--text-2); font-size: var(--fs-md); }
.media-viewer-head { border-bottom: 1px solid var(--line); }
.media-viewer-controls { justify-content: center; border-top: 1px solid var(--line); }
.media-viewer-stage { flex: 1; min-height: 0; overflow: auto; background: var(--bg); overscroll-behavior: contain; }
.media-viewer-canvas { display: grid; place-items: center; min-width: 100%; min-height: 100%; }
.media-viewer-canvas img { display: block; max-width: none; }

/* Модалка действия с сообщением */
.message-action-preview { padding: 8px 12px; border-radius: var(--r-sm); background: var(--raised); color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ===== Брейкпоинты (DESIGN.md §3) ===== */
@media (min-width: 1280px) and (max-width: 1439px) {   /* три колонки на ноутбуке: переписке остаётся ≥ 398 px, а не 318 */
 .local-inbox.profile-open { grid-template-columns: 296px minmax(0, 1fr) 296px; }
}
@media (max-width: 1279px) {
 .local-inbox, .local-inbox.profile-open { grid-template-columns: 300px minmax(0, 1fr); }
 .profile-drawer-layer { position: absolute; inset: 0; z-index: 8; display: block; }
 .profile-drawer-backdrop { position: absolute; inset: 0; display: block; width: 100%; padding: 0; border: 0; background: color-mix(in srgb, var(--bg) 55%, transparent); cursor: default; }
 .profile-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, calc(100% - 32px)); box-shadow: var(--shadow); transition: transform 220ms var(--ease), opacity 220ms var(--ease); }
 @starting-style { .profile-drawer { transform: translateX(24px); opacity: 0; } }
 .local-history { padding: 20px 24px; }
}
@media (max-width: 1023px) {
 .local-inbox, .local-inbox.profile-open { grid-template-columns: 280px minmax(0, 1fr); }
 .chat-header { padding-left: 16px; }
 .local-history { padding: 16px; }
 .local-compose { padding: 12px 16px; }
 .template-picker { right: 16px; left: 16px; }
}
@media (max-width: 767px) {
 .page:has(.local-inbox.chat-open) > .page-toolbar { display: none; }   /* открытый чат на телефоне — вся высота под переписку */
 /* Баннер «Обработчик не запущен» (~110 px) здесь повторяет плашку шапки «Обработчик стоит» (запуск — в её поповере) и
    статус отправителя «отправка стоит»; на остальных экранах он остаётся с пояснением и кнопкой. */
 .page:has(.local-inbox.chat-open) > .worker-notice { display: none; }
 .messages-panel { min-height: 360px; margin: 0 -16px -20px; border-width: 1px 0 0; border-radius: 0; }
 .local-inbox, .local-inbox.profile-open { display: block; }
 .inbox-sidebar, .local-chat { height: 100%; border-right: 0; }
 .local-inbox.chat-open .inbox-sidebar, .local-inbox:not(.chat-open) .local-chat { display: none; }
 .mobile-back { display: inline-grid; }
 .chat-header { --sender-indent: 12px; min-height: 56px; gap: 8px; padding: 8px 8px 8px 4px; }   /* строка отправителя — по оси значка «назад», не у края экрана */
 .chat-header .dialog-avatar { width: 32px; height: 32px; }
 .local-history { padding: 16px 12px; }
 .local-message { max-width: calc(100% - 48px); }
 .local-compose { padding: 8px 8px 12px; }
 .qr { height: 40px; }
 .quick-replies:has(.qr-state) { flex-wrap: wrap; }   /* список не обновился: чипы — строкой, статус и «Повторить» — под ними */
 .quick-replies:has(.qr-state) .qr-list { flex-basis: 100%; }
 .compose-tool, .compose-box .send-button { width: 40px; height: 40px; }   /* DESIGN.md §2: цель касания ≥ 40 */
 .template-picker { right: 8px; left: 8px; }
 .dialog-action, .viewer-close, .viewer-control { min-width: 40px; height: 40px; }
 .local-dialog { --act: 40px; }
 .message-actions summary { width: 44px; height: 40px; }
 /* Фильтры чатов: цели касания 44 × 44, и в компактной плотности тоже (filters-spec §5) */
 .inbox-tabs, :root[data-density="compact"] .inbox-tabs { height: 44px; }
 .inbox-tabs { padding: 0; }   /* поля строки — у вкладок: текст «Все» на 12, по краю поиска, как на компьютере */
 .inbox-tabs-main { gap: 0; }
 .inbox-tab { justify-content: center; min-width: 44px; padding: 0 12px; }
 .inbox-tab:focus-visible { outline-offset: -4px; }   /* кольцо не у края экрана, полоса под ним видна */
 .inbox-tab::after { right: 12px; left: 12px; }   /* полоса — по ширине подписи */
 .inbox-more { padding: 0 8px 0 12px; }
 .inbox-more::after { right: 12px; left: 12px; }
 .inbox-more-slot { min-width: 44px; }
 @container inbox-more (max-width: 59.7px) { .inbox-more:not(.is-current) .inbox-tab-l { width: 0; } }   /* поля 12 и 8: порог +12 */
 @container inbox-more (max-width: 67px) { .inbox-more[data-filter="leads"] .inbox-tab-l { width: 0; } }
 @container inbox-more (max-width: 71.6px) { .inbox-more[data-filter="archive"] .inbox-tab-l { width: 0; } }
 @container inbox-more (max-width: 79.4px) { .inbox-more[data-filter="channels"] .inbox-tab-l { width: 0; } }
 @container inbox-more (max-width: 110.8px) { .inbox-more[data-filter="no-response"] .inbox-tab-l { width: 0; } }
 .inbox-menu-item, :root[data-density="compact"] .inbox-menu-item { height: 44px; }
 /* Профиль — на весь экран над таб-баром: таб-бар не закрыт и работает */
 .profile-drawer-layer { position: fixed; inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0; z-index: 35; }
 .profile-drawer-backdrop { display: none; }
 .profile-drawer { position: absolute; inset: 0; width: 100%; border-left: 0; box-shadow: none; }
}

/* Шапка и поле ввода — по ширине колонки переписки (при открытом профиле она уже окна). В конце файла: перекрывают базовые правила. */
@container chat (max-width: 719px) {
 /* §5.6: рядом с действиями чата отправителю оставалось 30–200 px — «От», номер и имя обрезались. Здесь он — второй
    строкой шапки на всю её ширину; .chat-title растворяется, его строки становятся элементами шапки. */
 .chat-header { flex-wrap: wrap; row-gap: 4px; }
 .chat-title { display: contents; }
 .chat-title-row { flex: 1 1 0; }
 .chat-sender { order: 1; flex: 1 0 100%; padding-left: var(--sender-indent, 0); }
}
@container chat (max-width: 599px) { .chat-tools, .chat-peer-meta .mono { display: none; } .chat-lead-status { max-width: 132px; } }
@container chat (max-width: 479px) {
 .l-wide { display: none; }
 .l-narrow { display: inline; }   /* «От +7…»: номер и имя отправителя помещаются целиком */
 .chat-title-row { flex-wrap: wrap; row-gap: 0; }   /* статус собеседника не помещается рядом с именем — второй строкой */
 .local-inbox.profile-open .chat-peer-meta { display: none; }   /* при открытом профиле он и так виден рядом */
}
