/* =============================================================================
 *  chat/chat.css — «Караван · Чат». Надстройка над tokens.css / tl.css.
 *  ЛЕГО: один самодостаточный кубик. Удалить файл — стили чата исчезнут,
 *  дашборд не тронут. Префикс .tlm- (trade-lens messenger), без коллизий со
 *  старым FAB-виджетом (.chat-*).
 * ============================================================================= */

/* ── корень: две панели ─────────────────────────────────────────────────── */
.tlm {
  display: grid;
  grid-template-columns: 312px 1fr;
  height: 100%;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  color: var(--ink-1);
}
.tlm * { box-sizing: border-box; }

/* ================================================================ SIDEBAR == */
.tlm-side {
  display: flex; flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
}
.tlm-side-head { padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.tlm-side-title { display: flex; align-items: center; gap: 10px; }
.tlm-side-title .t { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
.tlm-side-title .spacer { flex: 1; }

/* демо-переключатель «кто я» (RBAC) — в проде роль из JWT */
.tlm-whoami { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.tlm-whoami .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.tlm-whoami select { font: inherit; font-size: 12px; font-weight: 600; border: 0; background: transparent; color: var(--ink-1); cursor: pointer; outline: 0; flex: 1; }
.tlm-whoami .owner-dot { font-size: 10px; color: var(--accent); font-weight: 600; }

/* поиск */
.tlm-search { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-3); }
.tlm-search:focus-within { border-color: var(--accent); color: var(--accent); }
.tlm-search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 13px; color: var(--ink-1); outline: 0; }
.tlm-search .clr { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; padding: 0; }

/* список */
.tlm-list { flex: 1 1 auto; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.tlm-sec-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; padding: 12px 8px 5px; }

.tlm-conv { display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; align-items: center; padding: 9px 10px; border: 0; background: transparent; border-radius: var(--r-md); cursor: pointer; text-align: left; width: 100%; transition: background .12s; }
.tlm-conv:hover { background: var(--surface); }
.tlm-conv.active { background: var(--surface); box-shadow: var(--shadow-sm); }
.tlm-conv .mid { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tlm-conv .top { display: flex; align-items: baseline; gap: 8px; }
.tlm-conv .nm { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tlm-conv .tm { font-size: 10.5px; color: var(--ink-3); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.tlm-conv .last { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.tlm-conv .last .who { color: var(--ink-2); font-weight: 500; }
.tlm-conv .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tlm-badge { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 10.5px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.tlm-eye { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; color: var(--c-violet); background: var(--c-violet-soft); padding: 2px 6px; border-radius: 99px; font-weight: 600; }

.tlm-new { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 6px 4px 2px; padding: 10px; border: 1px dashed var(--line-2); border-radius: var(--r-md); background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.tlm-new:hover { border-color: var(--accent); color: var(--accent); }

.tlm-support-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; align-items: center; padding: 9px 10px; border: 0; background: transparent; border-radius: var(--r-md); text-align: left; width: 100%; cursor: pointer; opacity: .85; }
.tlm-support-row:hover { background: var(--surface); }
.tlm-soon { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); background: var(--surface-3); padding: 2px 7px; border-radius: 99px; font-weight: 600; }

/* ── аватары: инициалы на детерминированном цвете ─────────────────────────── */
.tlm-av { width: 42px; height: 42px; border-radius: 99px; flex: 0 0 auto; display: grid; place-items: center; font-size: 14px; font-weight: 650; color: #fff; position: relative; letter-spacing: -0.01em; }
.tlm-av.sm { width: 32px; height: 32px; font-size: 12px; }
.tlm-av.lg { width: 40px; height: 40px; font-size: 14px; }
.tlm-av.team { background: linear-gradient(135deg, var(--accent), var(--c-violet)); }
.tlm-av.bot  { background: var(--c-violet-soft); color: var(--c-violet); }
.tlm-av-c0 { background: #6CA2C8; } .tlm-av-c1 { background: #62B09C; } .tlm-av-c2 { background: #D88676; }
.tlm-av-c3 { background: #CE9E62; } .tlm-av-c4 { background: #9680C4; } .tlm-av-c5 { background: #CE8AA4; }
.tlm-av-c6 { background: #7AB2CE; } .tlm-av-c7 { background: #94B68C; } .tlm-av-c8 { background: #C8927A; } .tlm-av-c9 { background: #8C9BC6; }
.tlm-av .pres { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 99px; background: var(--ink-4); border: 2px solid var(--bg-elev); }
.tlm-av .pres.on { background: var(--pos); }

/* ================================================================== MAIN === */
.tlm-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.tlm-main-head { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; background: var(--surface); }
.tlm-main-head .mid { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.tlm-main-head .nm { font-size: 15px; font-weight: 650; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlm-main-head .st { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.tlm-main-head .st .on { color: var(--pos); font-weight: 500; }
.tlm-back { display: none; }

.tlm-icon-btn { width: 34px; height: 34px; border-radius: 99px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; transition: background .12s; }
.tlm-icon-btn:hover { background: var(--surface-2); color: var(--ink-1); }

/* наблюдение owner-ом */
.tlm-monitor { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--c-violet-soft); color: var(--c-violet); font-size: 12px; font-weight: 500; border-bottom: 1px solid var(--line); flex: 0 0 auto; }

/* ── лента ────────────────────────────────────────────────────────────────── */
.tlm-feed { flex: 1 1 auto; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 2px; }
.tlm-feed-inner { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }

.tlm-day { align-self: center; margin: 12px 0; font-size: 11px; font-weight: 600; color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); padding: 4px 13px; border-radius: 99px; box-shadow: var(--shadow-sm); }

.tlm-msg { display: flex; gap: 9px; align-items: flex-end; max-width: 76%; margin-top: 9px; }
.tlm-msg.tight { margin-top: 2px; }
.tlm-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.tlm-msg .av-slot { width: 30px; flex: 0 0 auto; }
.tlm-bub-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tlm-msg.mine .tlm-bub-wrap { align-items: flex-end; }

.tlm-bubble { padding: 8px 12px 7px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.45; box-shadow: var(--shadow-sm); position: relative; max-width: 100%; }
.tlm-msg:not(.mine) .tlm-bubble { border-bottom-left-radius: 5px; }
.tlm-msg.mine .tlm-bubble { background: var(--accent); border-color: transparent; color: var(--accent-ink); border-bottom-right-radius: 5px; }
.tlm-msg.tight:not(.mine) .tlm-bubble { border-bottom-left-radius: 16px; border-top-left-radius: 5px; }
.tlm-msg.tight.mine .tlm-bubble { border-bottom-right-radius: 16px; border-top-right-radius: 5px; }
.tlm-bubble.bot { background: var(--c-violet-soft); border-color: transparent; }

.tlm-sender { font-size: 11.5px; font-weight: 650; margin-bottom: 2px; letter-spacing: -0.01em; }
.tlm-text { white-space: pre-wrap; word-break: break-word; }
.tlm-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.tlm-msg.mine .tlm-text a { color: #fff; }
.tlm-text mark { background: var(--warn-bg); color: var(--warn); border-radius: 3px; padding: 0 2px; }

.tlm-meta { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--ink-4); padding: 0 4px; }
.tlm-msg.mine .tlm-meta { color: var(--ink-4); }
.tlm-ticks { display: inline-flex; color: var(--ink-4); }
.tlm-ticks.read { color: var(--info); }

.tlm-sys { align-self: center; font-size: 11.5px; color: var(--ink-3); background: var(--surface-2); padding: 5px 13px; border-radius: 99px; margin: 8px 0; text-align: center; }

/* подсветка сообщения при переходе из поиска */
.tlm-flash .tlm-bubble { animation: tlm-flash 1.4s ease; }
@keyframes tlm-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent-soft); } 100% { box-shadow: var(--shadow-sm); } }

/* ── вложения ─────────────────────────────────────────────────────────────── */
.tlm-atts { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.tlm-bubble.media-only { padding: 4px; }
.tlm-bubble.media-only .tlm-atts { margin-top: 0; }

.tlm-att-img { display: block; border-radius: 12px; overflow: hidden; max-width: 248px; cursor: pointer; border: 0; padding: 0; background: var(--surface-3); line-height: 0; }
.tlm-att-img img { display: block; width: 100%; height: auto; max-height: 320px; object-fit: cover; }
.tlm-att-imgph { width: 248px; max-width: 100%; aspect-ratio: 3 / 2; display: grid; place-items: center; background-image: repeating-linear-gradient(45deg, var(--surface-3) 0 10px, var(--surface-2) 10px 20px); color: var(--ink-3); }
.tlm-att-imgph .nm { font-family: 'Geist Mono', monospace; font-size: 10px; }

.tlm-att-doc { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-1); text-decoration: none; min-width: 210px; max-width: 280px; }
.tlm-msg.mine .tlm-att-doc { background: rgba(255,255,255,.16); border-color: transparent; color: #fff; }
.tlm-att-doc .ic { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: 0 0 auto; }
.tlm-msg.mine .tlm-att-doc .ic { background: rgba(255,255,255,.22); color: #fff; }
.tlm-att-doc .col { min-width: 0; line-height: 1.3; }
.tlm-att-doc .fn { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlm-att-doc .fs { font-size: 10.5px; opacity: .7; }
.tlm-att-doc .dl { flex: 0 0 auto; opacity: .65; }

/* видео */
.tlm-att-vid { position: relative; border-radius: 12px; overflow: hidden; max-width: 260px; background: #000; line-height: 0; }
.tlm-att-vid video { display: block; width: 100%; height: auto; max-height: 320px; }
.tlm-att-vidph { width: 260px; max-width: 100%; aspect-ratio: 16 / 9; background: repeating-linear-gradient(45deg, #2a2a2e 0 10px, #232327 10px 20px); display: grid; place-items: center; }
.tlm-vid-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.tlm-vid-play span { width: 52px; height: 52px; border-radius: 99px; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px); }

/* аудио / голосовое — плеер с волной */
.tlm-voice { display: flex; align-items: center; gap: 11px; padding: 6px 6px 6px 4px; min-width: 200px; max-width: 280px; }
.tlm-voice .play { width: 38px; height: 38px; border-radius: 99px; border: 0; cursor: pointer; flex: 0 0 auto; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.tlm-msg.mine .tlm-voice .play { background: rgba(255,255,255,.22); color: #fff; }
.tlm-bubble.bot .tlm-voice .play { background: var(--c-violet); color: #fff; }
.tlm-voice .wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px; }
.tlm-voice .wave i { flex: 1; min-width: 2px; border-radius: 99px; background: var(--ink-4); opacity: .45; transition: opacity .1s, background .1s; }
.tlm-msg.mine .tlm-voice .wave i { background: rgba(255,255,255,.55); }
.tlm-voice .wave i.on { opacity: 1; background: var(--accent); }
.tlm-msg.mine .tlm-voice .wave i.on { background: #fff; }
.tlm-voice .dur { font-size: 11px; font-variant-numeric: tabular-nums; opacity: .75; flex: 0 0 auto; min-width: 30px; }

/* ── поле ввода ──────────────────────────────────────────────────────────── */
.tlm-composer { border-top: 1px solid var(--line); padding: 10px 12px; background: var(--surface); position: relative; flex: 0 0 auto; }
.tlm-composer.drag { outline: 2px dashed var(--accent); outline-offset: -7px; }
.tlm-drop { position: absolute; inset: 6px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; font-weight: 600; pointer-events: none; z-index: 3; }

.tlm-pending { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.tlm-pend { position: relative; display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; color: var(--ink-2); max-width: 220px; }
.tlm-pend .thumb { width: 38px; height: 38px; border-radius: 7px; object-fit: cover; background: var(--surface-3); flex: 0 0 auto; }
.tlm-pend .thumb-ic { width: 38px; height: 38px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: 0 0 auto; }
.tlm-pend .col { min-width: 0; line-height: 1.3; }
.tlm-pend .fn { font-weight: 600; color: var(--ink-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.tlm-pend .x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 99px; border: 0; background: var(--ink-1); color: var(--bg); cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow-sm); }

.tlm-input-row { display: flex; align-items: flex-end; gap: 7px; }
.tlm-ta { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 18px; padding: 9px 14px; font: inherit; font-size: 13.5px; background: var(--surface-2); color: var(--ink-1); outline: 0; max-height: 108px; line-height: 1.45; }
.tlm-ta:focus { border-color: var(--accent); background: var(--surface); }
.tlm-send, .tlm-mic { width: 40px; height: 40px; border-radius: 99px; border: 0; cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; }
.tlm-send { background: var(--accent); color: var(--accent-ink); }
.tlm-send:disabled { opacity: .4; cursor: default; }
.tlm-mic { background: var(--surface-2); color: var(--ink-2); }
.tlm-mic:hover { background: var(--surface-3); color: var(--ink-1); }
.tlm-mic.recording { background: var(--neg); color: #fff; }

/* запись голосового */
.tlm-rec { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 8px; }
.tlm-rec .dot { width: 11px; height: 11px; border-radius: 99px; background: var(--neg); animation: tlm-pulse 1s ease-in-out infinite; flex: 0 0 auto; }
.tlm-rec .timer { font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; color: var(--ink-1); min-width: 46px; }
.tlm-rec .hint { flex: 1; font-size: 12px; color: var(--ink-3); }
.tlm-rec .cancel { border: 0; background: transparent; color: var(--neg); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
@keyframes tlm-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ── пустое состояние ────────────────────────────────────────────────────── */
.tlm-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 40px; color: var(--ink-3); }
.tlm-empty .ic { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2); color: var(--ink-3); display: grid; place-items: center; }
.tlm-empty .t { font-size: 16px; font-weight: 600; color: var(--ink-1); }
.tlm-empty .s { font-size: 13px; max-width: 320px; line-height: 1.5; }

/* ── поиск: результаты ───────────────────────────────────────────────────── */
.tlm-results { flex: 1; overflow-y: auto; padding: 6px; }
.tlm-result { display: grid; grid-template-columns: 38px 1fr; gap: 10px; padding: 9px 10px; border: 0; background: transparent; border-radius: var(--r-md); text-align: left; width: 100%; cursor: pointer; }
.tlm-result:hover { background: var(--surface); }
.tlm-result .top { display: flex; justify-content: space-between; gap: 8px; }
.tlm-result .nm { font-size: 12.5px; font-weight: 600; }
.tlm-result .tm { font-size: 10px; color: var(--ink-3); }
.tlm-result .snip { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.tlm-result .snip mark { background: var(--warn-bg); color: var(--warn); border-radius: 3px; padding: 0 2px; }

/* ── просмотрщик изображений ─────────────────────────────────────────────── */
.tlm-viewer { position: fixed; inset: 0; z-index: 200; background: rgba(15,14,12,.78); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 40px; animation: fadeIn .18s ease; }
.tlm-viewer img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); box-shadow: var(--shadow-xl); }
.tlm-viewer .vbar { position: absolute; top: 18px; right: 18px; display: flex; gap: 8px; }
.tlm-viewer .vbar a, .tlm-viewer .vbar button { width: 40px; height: 40px; border-radius: 99px; border: 0; background: rgba(255,255,255,.14); color: #fff; cursor: pointer; display: grid; place-items: center; text-decoration: none; }
.tlm-viewer .vbar a:hover, .tlm-viewer .vbar button:hover { background: rgba(255,255,255,.26); }

/* ── модалка нового чата ─────────────────────────────────────────────────── */
.tlm-userpick { display: flex; flex-direction: column; gap: 4px; }
.tlm-userpick .u { display: grid; grid-template-columns: 40px 1fr auto; gap: 11px; align-items: center; padding: 9px 10px; border: 0; background: transparent; border-radius: var(--r-md); cursor: pointer; text-align: left; width: 100%; }
.tlm-userpick .u:hover { background: var(--surface-2); }
.tlm-userpick .u .nm { font-size: 13.5px; font-weight: 600; }
.tlm-userpick .u .role { font-size: 11.5px; color: var(--ink-3); }
.tlm-userpick .u .go { color: var(--ink-3); }

/* ── адаптив: на узком экране sidebar → отдельный «экран» ─────────────────── */
@media (max-width: 720px) {
  .tlm { grid-template-columns: 1fr; }
  .tlm-side { border-right: 0; }
  .tlm[data-view="thread"] .tlm-side { display: none; }
  .tlm[data-view="list"] .tlm-main { display: none; }
  .tlm-back { display: grid; }
  .tlm-msg { max-width: 86%; }
}

/* ── встраивание блока в дашборд /v2/ (раздел «Чат») ──────────────────────── */
/* Чат — фиксированной высоты двухпанельный кубик внутри непрерывного скролла:
   рамка задаёт высоту, .tlm (height:100%) её заполняет и сам скроллит ленту. */
.tl-chat-frame { height: clamp(520px, calc(100vh - 208px), 880px); }
.tl-chat-frame .tlm { height: 100%; }
@media (max-width: 920px) { .tl-chat-frame { height: clamp(480px, calc(100vh - 180px), 760px); } }

/* ── мобильный экран чата (PWA «Караван · Склад») ─────────────────────────── */
.m-chat-row { min-height: 56px; padding: 8px 6px; border-radius: var(--r-md); }
.m-chat-row:active { background: var(--surface-2); }
.m-chat-row .nm { font-size: 15px; }
.m-chat-row .last { font-size: 13px; }
.m-chat-result { grid-template-columns: 40px 1fr; padding: 10px 6px; min-height: 56px; }
.m-newchat { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; text-transform: none; letter-spacing: 0; }

/* лента/композер в мобильном стеке (m-grp = display:contents) */
.m-app .tlm-feed { background: var(--bg); padding: 14px 12px 6px; }
.m-app .tlm-composer { padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); }
.m-app .tlm-send, .m-app .tlm-mic { width: 44px; height: 44px; }
.m-app .tlm-icon-btn { width: 44px; height: 44px; }
.m-app .tlm-ta { min-height: 44px; font-size: 16px; }
.m-app .tlm-msg { max-width: 84%; }

/* ===========================================================================
 *  FAB-виджет: плавающая кнопка чата + мини-окно поверх дашборда.
 *  Префикс .tlm-fab-* . Переиспользует .tlm (<ChatBlock/>) в одно-панельном
 *  режиме (медиа-запрос .tlm@720px не сработает в узкой панели — форсим тут).
 * =========================================================================== */
.tlm-fab {
  position: fixed; z-index: 1200;
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  border: 0; cursor: pointer; touch-action: none;
  box-shadow: var(--shadow-lg);
  transition: transform .14s ease, filter .14s ease, box-shadow .14s ease;
}
.tlm-fab:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: var(--shadow-xl); }
.tlm-fab:active { transform: scale(.96); }
.tlm-fab.is-open { filter: brightness(.98); }
.tlm-fab-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 19px; height: 19px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--neg, #D6604A); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 1;
  border-radius: 99px; border: 2px solid var(--bg);
}

.tlm-fab-panel {
  position: fixed; z-index: 1199;
  width: 380px; height: 600px;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: tlm-fab-in .18s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes tlm-fab-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.tlm-fab-panel-header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 9px;
  padding: 11px 12px 11px 15px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-1);
}
.tlm-fab-panel-header .ttl { font-size: 14px; font-weight: 600; }
.tlm-fab-panel-header .sp { flex: 1; }
.tlm-fab-hbtn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ink-2);
  cursor: pointer; transition: background .12s, color .12s;
}
.tlm-fab-hbtn:hover { background: var(--surface-3); color: var(--ink); }

.tlm-fab-panel-body { flex: 1; min-height: 0; display: flex; }

/* форсим одно-панельный режим внутри узкой панели (вне зависимости от ширины окна) */
.tlm-fab-panel-body .tlm { grid-template-columns: 1fr; height: 100%; width: 100%; border-radius: 0; }
.tlm-fab-panel-body .tlm[data-view="thread"] .tlm-side { display: none; }
.tlm-fab-panel-body .tlm[data-view="list"]   .tlm-main { display: none; }
.tlm-fab-panel-body .tlm-back { display: grid; }
.tlm-fab-panel-body .tlm-msg { max-width: 88%; }

/* узкие экраны: мини-окно на весь экран */
@media (max-width: 480px) {
  .tlm-fab-panel { left: 0 !important; top: 0 !important; width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
}
