:root {
  /* Локальные — светлые панели чата на тёмном фоне */
  --bg: #0f1117;
  --bg-mid: #1a1d27;
  --panel: #ffffff;
  --panel-header: #f7f8fc;
  --panel-border: #e8eaf0;
  --text: #1a1d27;
  --text-2: #5a5f72;
  --text-3: #9499a8;
  --text-on-dark: #f5f6fa;
  --text-on-dark-2: #767c8c;
  /* Плашка удаления с провалами (warn): оранжевый акцент */
  --del-warn-fg: #b45309;
  --del-warn-bg: rgba(245, 158, 11, 0.12);
  --del-warn-mark: #d97706;
  --nav-w: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
}

.lk {
  display: flex;
  flex-direction: row;
  height: 100vh;
}

.lk-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.lk-nav {
  width: var(--nav-w);
  background: var(--bg-mid);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
  border-right: 1px solid #2e3342;
  flex-shrink: 0;
  z-index: 10;
}

.lk-nav__logo {
  font-size: 18px;
  margin-bottom: 12px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.lk-nav__btn {
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-on-dark-2);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.lk-nav__btn:hover {
  background: #2e3342;
  color: var(--text-on-dark);
}

.lk-nav__btn.active {
  background: #2e3342;
  color: var(--accent);
}

.lk-nav__btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--gradient-brand);
  border-radius: 0 3px 3px 0;
}

.lk-nav__spacer { flex: 1; }

.bridges-bar {
  background: var(--bg-mid);
  border-bottom: 1px solid #2e3342;
  flex-shrink: 0;
  z-index: 20;
}

.bridges-bar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 44px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.bridges-bar__head:hover { background: #20243a; }

.bridges-bar__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-on-dark);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bridges-bar__label.--hint {
  color: #6c6fff;
  font-weight: 700;
  font-size: 15px;
}

.bridges-bar__arrow-OLD {
  font-size: 14px;
  color: var(--text-on-dark-2);
  margin-left: 12px;
  display: inline-block;
  flex-shrink: 0;
}

.bridges-bar.open .bridges-bar__arrow-OLD {

}

.bridges-bar__body {
  display: none;
  border-top: 1px solid #2e3342;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 8px;
}

.bridges-bar.open .bridges-bar__body { display: block; }

.bridge-item {
  border: 1px solid #2e3342;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
}

.bridge-item:hover { background: #2e3342; border-color: #454d63; }
.bridge-item.active { background: #1e2235; border-color: #6c8cff; }

.bridge-item__info {
  flex: 1;
  min-width: 0;
}

.bridge-item__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-on-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bridge-item__sig {
  font-size: 11px;
  color: var(--text-on-dark-2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bridge-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  opacity: 0.3;
  transition: opacity var(--transition), background var(--transition);
}

.lk-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  transition: flex var(--transition);
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel-header);
  border-bottom: 1px solid var(--panel-border);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0;
}

.panel__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.1px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel__foot {
  padding: 12px 16px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  background: var(--panel-header);
  flex-shrink: 0;
}

.panel__textarea-row {
  padding: 8px 0px 0;
}
.panel__input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  outline: none;
  resize: none;
  min-height: 38px;
  line-height: 1.45;
  transition: border-color var(--transition);
  border-radius: var(--radius-sm);
}

.panel__input::placeholder { color: var(--text-3); }
.panel__input:focus { border-color: var(--accent); }

.panel__send {
  height: 36px;
  padding: 0 16px;
  border: none;
  background: var(--gradient-brand);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  transition: opacity var(--transition);
  white-space: nowrap;
  border-radius: var(--radius-sm);
}

.panel__send:hover { opacity: .88; }
.panel__send:disabled { opacity: .45; cursor: default; }

.msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  transition: background var(--transition);
}

/* Заливку при наведении убрали: строка не подсвечивается, кнопки действий остаются */

.msg__meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.msg__author {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.msg__author.service { color: var(--accent-2); }

.msg__time {
  font-size: 11px;
  color: var(--text-3);
}

.msg__type-badge {
  font-size: 11px;
  color: var(--text-3);
  background: #f0f1f7;
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}

.msg__text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.msg__reply {
  font-size: 12px;
  color: var(--text-2);
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
}

.empty-state__icon { font-size: 32px; }

.empty-state__text {
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 4px;
}

.lk-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1d27;
  color: #f5f6fa;
  font-size: 13px;
  padding: 10px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.lk-toast.show { opacity: 1; pointer-events: auto; }
.lk-toast.toast-error { background: #3d1a1a; color: #ff9494; }

.bridges-bar__arrow {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #6c6fff 0%, #9d6cff 100%);
  margin-left: 0;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bridges-bar__arrow::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid #fff;
  margin-left: 1px;
  transition: transform var(--transition);
  transform: rotate(0deg);
}

.bridges-bar.open .bridges-bar__arrow::after {
  transform: rotate(90deg);
}

/* Строка ввода с кнопками */
.panel__input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Подпись «Макс. 50 МБ» — отдельной строкой под иконками, прижата влево */
.panel__max-size {
  margin-top: 4px;
  margin-left: 4px;
  font-size: 11px;
  color: var(--text-3, #aaa);
  font-weight: 500;
}

/* Обёртка кнопки микрофона — для выпадающего списка поверх */
.panel__mic-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Список доступных микрофонов — всплывает над кнопкой */
.panel__mic-list {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 300001;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
  max-width: 280px;
}
.panel__mic-list[style*="display: flex"],
.panel__mic-list[style*="display:flex"] { display: flex; }

.panel__mic-item {
  background: var(--panel-header);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), border-color var(--transition);
}
.panel__mic-item:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.panel__mic-item--current {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--panel-header);
}

/* Кнопка-иконка (скрепка, эмодзи) */
.panel__btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--panel-border);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
  line-height: 1;
  border-radius: var(--radius-sm);
}

.panel__btn-icon:hover { background: #e0e2ea; }

/* Превью прикреплённого файла */
.panel__attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #eef0ff;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
}

.panel__attach-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel__attach-remove {
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color var(--transition);
}

.panel__attach-remove:hover { color: var(--red); }

/* Пикер эмодзи — заменён на Emoji Mart */
.panel__emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  margin-top: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.panel__emoji-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  line-height: 1;
}

.panel__emoji-btn:hover { background: #f0f1f7; }

/* Обёртка Emoji Mart. Fixed + координаты от кнопки (как в «Контенте»):
   раньше absolute внутри панели — пикер уезжал за края поля редактора. */
/* Панель смайлов всплывает НАД полем ввода (как в Максе): прижата к правому
   краю композера, накрывает ленту, но не поле ввода и не растит пустоту.
   Посадку держит css; координаты JS не считает — у #emojiWrap в chat.html
   стоит data-no-coords, chat-editor.js их пропускает. */
.panel__emoji-wrap {
  position: absolute;
  bottom: calc(100% + 4px);
  right: 10px;
  width: auto;
}

.panel__emoji-wrap em-emoji-picker {
  position: static;
  width: 352px;
  max-height: min(560px, calc(100vh - 240px));
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Мобильный/узкий экран: пикер над полем ввода, но пониже */
@media (max-width: 760px) {
  .panel__emoji-wrap { right: 6px; bottom: calc(100% + 2px); }
  .panel__emoji-wrap em-emoji-picker { max-height: min(420px, calc(100vh - 200px)); }
}

/* Статусы доставки */
.msg__delivery { font-size: 10px; font-weight: 600; margin-left: 6px; vertical-align: middle; letter-spacing: 0.02em; }
.msg__delivery--ok   { color: #34a853; }
.msg__delivery--fail { color: #ea4335; }
.msg__delivery--pending { color: #9aa0a6; font-size: 12px; }
.msg__author.cabinet { color: #1a73e8; font-weight: 600; }
.panel__record-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel-header); border-top: 1px solid rgba(255,255,255,.07); }
.panel__record-wave { flex: 1; height: 36px; border-radius: var(--radius-sm); background: rgba(255,255,255,.04); }
.panel__record-timer { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-muted, #8888aa); min-width: 32px; text-align: right; }
.panel__record-dot { width: 8px; height: 8px; border-radius: 50%; background: #e05555; flex-shrink: 0; animation: recDotBlink 1s ease-in-out infinite; }
@keyframes recDotBlink { 0%,100%{ opacity:1; } 50%{ opacity:0; } }
.panel__btn-icon--confirm { color: #63b3ed; font-size: 18px; font-weight: 700; }

.bridge-item.active .bridge-item__dot { background: var(--green); opacity: 1; }
.panel__record-bar { overflow: hidden; }
.panel__record-wave { min-width: 0; }
#voicePreviewPlayer { width: 300px; height: 36px; }
@media (max-width: 600px) { #voicePreviewPlayer { width: 100%; } }

.panel__textarea-row { position: relative; }

.panel__resize-corner {
  position: absolute;
  top: 11px;
  right: 0px;
  width: 16px;
  height: 16px;
  cursor: n-resize;
  user-select: none;
  z-index: 2;
  background: url('https://fs.getcourse.ru/fileservice/file/download/a/644347/sc/110/h/1fe4700aa23d05a1b93a42b21c0f1098.svg') center / contain no-repeat;
  opacity: 0.4;
  transition: opacity var(--transition);
}

.panel__resize-corner:hover { opacity: 0.8; }

/* Раскладка сторон */
.msg--in  { align-items: flex-start; }
.msg--out { align-items: flex-end; }
.msg--service { align-items: center; }
.msg--out .msg__meta { flex-direction: row-reverse; }
.msg--out .msg__text, .msg--in .msg__text { max-width: 78%; }
/* Пузырь исходящего */
.msg--out .msg__text { background: #e7f0ff; border-radius: 12px 12px 4px 12px; padding: 7px 11px; }
/* Пузырь входящего */
.msg--in .msg__text { background: #f0f1f7; border-radius: 12px 12px 12px 4px; padding: 7px 11px; }
/* Цитата над сообщением */
.msg__quote { font-size: 12px; color: var(--text-2); border-left: 3px solid var(--accent); padding: 3px 8px; margin-bottom: 3px; max-width: 78%; cursor: pointer; border-radius: 4px; background: rgba(0,0,0,0.03); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg__quote:hover { background: rgba(0,0,0,0.06); }
/* Кнопка ответа */
.msg--highlight { background: #9d6cff2e !important; border-radius: 10px; transition: background 0.4s; } /* Podsvetka pri perehode k citate */

/* Удалённое сообщение */
.msg--deleted .msg__text { text-decoration: line-through; color: var(--text-3); opacity: 0.65; }

/* Бейдж статуса удаления */
.msg__del-badge { font-size: 11px; font-style: italic; margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.msg__del-badge--ok { color: var(--text-3); }
.msg__del-badge--fail { color: #c0392b; font-style: normal; }
.msg--out .msg__del-badge { justify-content: flex-end; }
/* Подпись неудачи */
.msg__del-failnote { font-size: 11px; color: #c0392b; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.msg--out .msg__del-failnote { justify-content: flex-end; }
.msg__del-info { cursor: help; opacity: 0.7; }
/* Кнопка повтора удаления */
.msg__del-retry { margin-top: 4px; padding: 3px 10px; font-size: 11px; border: 1px solid #c0392b; color: #c0392b; background: transparent; border-radius: 6px; cursor: pointer; }
.msg__del-retry:hover:not(:disabled) { background: #c0392b; color: #fff; }
.msg__del-retry:disabled { opacity: 0.5; cursor: default; }
.msg--out .msg__del-retry { margin-left: auto; }
/* Состояние «удаляется» */
.msg--deleting { opacity: 0.55; }
.msg__deleting-mark { font-size: 11px; font-style: italic; color: var(--text-3); margin-top: 3px; }
.msg--out .msg__deleting-mark { text-align: right; }

/* Удалённое сообщение — скрываем медиа, доставку, цитату и панель действий */
.msg--deleted .msg__media, .msg--deleted .msg__delivery-wrap, .msg--deleted .msg__quote, .msg--deleted .msg__actions { display: none; }

/* Панель действий над сообщением */
.msg__actions { display: flex; flex-direction: row; gap: 2px; align-items: center; opacity: 0; transition: opacity var(--transition); }
.msg:hover .msg__actions { opacity: 1; }
.msg--out .msg__actions { justify-content: flex-end; }

/* Сброс старой анимации появления у одиночных кнопок — теперь её несёт контейнер */
.msg__reply-btn, 
/* Кнопки в панели действий — одинаковый размер и стиль */
.msg__reply-btn, .msg__del-btn { width: 26px; height: 26px; padding: 0; border: none; background: #eef0f6; color: var(--text-3); border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: background var(--transition), color var(--transition); }
.msg__reply-btn:hover, .msg__del-btn:hover { background: #d8dbe6; color: var(--text); }
.msg__del-btn--confirm { width: auto !important; padding: 10px 10px !important; background: #c0392b !important; color: #fff !important; font-size: 11px !important; }
.msg__actions { gap: 6px; }
.msg__actions { margin-top: 8px; }

/* Контейнер бейджей реакций под сообщением */
.msg__reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* Бейдж одной реакции */
.msg__reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: rgba(0, 120, 215, 0.12);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  user-select: none;
  transition: background 0.15s;
}

.msg__reaction:hover {
  background: rgba(0, 120, 215, 0.22);
}

/* Своя реакция — выделена */
.msg__reaction--mine {
  background: rgba(0, 120, 215, 0.28);
}

.msg__reaction--mine:hover {
  background: rgba(0, 120, 215, 0.38);
}

/* Эмодзи в бейдже */
.msg__reaction-emo {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", "EmojiOne Color", sans-serif;
  font-size: 14px;
}

/* Счётчик */
.msg__reaction-cnt {
  font-weight: 600;
  color: #0078d7;
  font-size: 12px;
}

/* Кнопка вызова picker (☺ над сообщением) */
.msg__react-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 5px;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.msg__react-btn:hover {
  opacity: 1;
}

/* Плавающая панель выбора эмодзи */
.reaction-picker {
  position: fixed;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  z-index: 10000;
  width: 380px;
  max-height: 280px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

/* Кнопка одного эмодзи в picker */
.reaction-picker__btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", "EmojiOne Color", sans-serif;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.1s;
  line-height: 1;
}

.reaction-picker__btn:hover {
  background: rgba(0, 120, 215, 0.15);
}

/* ===== Панели чата и тикетов: layout и сворачивание ===== */

/* Базовая шапка панели */
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}

.panel__title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* Кнопка-стрелка */
.panel__arrow {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s;
}

.panel__arrow:hover {
  background: rgba(108, 140, 255, 0.15);
}

/* Треугольники через ::before */
.panel__arrow::before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
}

/* Десктоп: ◀ */
.panel__arrow--left::before {
  border-width: 5px 7px 5px 0;
  border-color: transparent var(--text-2) transparent transparent;
}

/* Десктоп: ▶ */
.panel__arrow--right::before {
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent var(--text-2);
}

.panel__arrow:hover::before {
  border-right-color: #6c8cff;
  border-left-color: #6c8cff;
}

/* ===== Десктоп: горизонтальная раскладка ===== */
@media (min-width: 800px) {
  .lk-workspace {
    flex-direction: row;
    gap: 12px;
    position: relative;
  }

  #panelChat    { order: 1; }
  .panel-splitter { order: 2; }
  #panelTickets { order: 3; }

  .panel--tickets,
  .panel--chat {
    flex: 1 1 50%;
    min-width: 56px;
    transition: flex-basis 0.25s ease;
  }

  .panel.is-full {
    flex: 1 1 auto !important;
  }

  .panel.is-collapsed {
    flex: 0 0 90px !important;
    min-width: 90px;
    max-width: 90px;
  }

  /* Шапка свёрнутой панели: одна строка — стрелка и заголовок на одном уровне */
  .panel.is-collapsed .panel__head {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 10px !important;
    gap: 6px !important;
  }

  .panel.is-collapsed .panel__title {
    font-size: 12px !important;
    writing-mode: horizontal-tb !important;
    transform: none !important;
    white-space: nowrap !important;
  }

  /* У свёрнутой панели прячем кнопку close (некуда дальше закрывать) */
  .panel.is-collapsed .panel__arrow[data-action="close"] { display: none !important; }

  .panel.is-collapsed .panel__body,
  .panel.is-collapsed .panel__foot,
  .panel.is-collapsed .ticket-list,
  .panel.is-collapsed .message-list {
    display: none !important;
  }

  .panel-splitter {
    flex: 0 0 6px;
    background: var(--border);
    cursor: col-resize;
    transition: background 0.15s;
    align-self: stretch;
    border-radius: 3px;
  }

  .panel-splitter:hover,
  .panel-splitter.is-dragging {
    background: #6c8cff;
  }

  .lk-workspace.has-collapsed .panel-splitter {
    display: none;
  }


}

/* ===== Мобила: вертикальная раскладка ===== */
@media (max-width: 799px) {
  .lk-workspace {
    flex-direction: column;
    gap: 12px;
  }

  /* Тикеты сверху, чат снизу */
  #panelTickets { order: 1; }
  .panel-splitter { display: none; }
  #panelChat    { order: 2; }

  .panel--tickets,
  .panel--chat {
    flex: 1 1 50%;
    min-height: 44px;
    transition: flex-basis 0.25s ease;
  }

  /* Если один свёрнут — второй забирает оставшееся */
  .lk-workspace.has-collapsed .panel:not(.is-collapsed) {
    flex: 1 1 auto;
  }

  /* Свёрнутое состояние на мобиле */
  .panel.is-full {
    flex: 1 1 auto !important;
  }

  .panel.is-collapsed {
    flex: 0 0 44px !important;
    min-height: 44px;
    max-height: 44px;
  }

  .panel.is-collapsed .panel__body,
  .panel.is-collapsed .panel__foot,
  .panel.is-collapsed .ticket-list,
  .panel.is-collapsed .message-list {
    display: none !important;
  }

  /* На мобиле стрелки превращаем в ▼ / ▲ */
  .panel__arrow--left::before {
    border-width: 7px 5px 0 5px !important;
    border-color: var(--text-2) transparent transparent transparent !important;
  }
  .panel__arrow--right::before {
    border-width: 0 5px 7px 5px !important;
    border-color: transparent transparent var(--text-2) transparent !important;
  }
  .panel__arrow--left:hover::before {
    border-top-color: #6c8cff !important;
  }
  .panel__arrow--right:hover::before {
    border-bottom-color: #6c8cff !important;
  }

  /* На мобиле: свёрнутая прячет close, раскрытая на 100% прячет open */
  .panel.is-collapsed .panel__arrow[data-action="close"] { display: none !important; }
}
.panel__arrow.is-hidden { display: none !important; }

/* ========== Статус доставки: жёлтая ошибка ========== */

/* Обёртка кликабельной иконки провала */
.msg__delivery--warn {
  color: #f59e0b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px;
  border-radius: 3px;
  transition: background var(--transition);
}
.msg__delivery--warn:hover {
  background: rgba(245, 158, 11, 0.12);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

/* Кружок ⓘ — рисуется CSS: жёлтый круг с белым восклицательным */
.msg__delivery-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  font-family: Arial, sans-serif;
  line-height: 1;
  flex-shrink: 0;
}

/* ========== Попап ошибки доставки ========== */

/* Затемнение фона + перехват кликов вне попапа */
.delivery-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: transparent;
}

/* Попап — привязан к иконке через inline top/left */
.delivery-popup {
  position: absolute;
  z-index: 9999;
  min-width: 280px;
  max-width: 360px;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  overflow: hidden;
  animation: deliveryPopupIn 0.15s ease-out;
}
@keyframes deliveryPopupIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Шапка */
.delivery-popup__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(245, 158, 11, 0.08);
}
.delivery-popup__title {
  font-size: 13px;
  font-weight: 600;
  color: #f59e0b;
}
.delivery-popup__close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color var(--transition);
}
.delivery-popup__close:hover { color: var(--text); }

/* Тело */
.delivery-popup__body {
  padding: 10px 12px;
  max-height: 320px;
  overflow-y: auto;
}
.delivery-popup__group + .delivery-popup__group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}
.delivery-popup__chats {
  list-style: none;
  margin: 0 0 6px 0;
  padding: 0;
}
.delivery-popup__chats li {
  padding: 2px 0;
  font-size: 13px;
  color: var(--text);
}
.delivery-popup__chats li::before {
  content: "• ";
  color: #f59e0b;
  margin-right: 2px;
}
.delivery-popup__chat-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.delivery-popup__chat-link:hover { text-decoration: underline; }

.delivery-popup__err-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin: 4px 0 2px 0;
}
.delivery-popup__err-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Футер */
.delivery-popup__foot {
  padding: 10px 12px;
  border-top: 1px solid var(--panel-border);
}
.delivery-popup__retry {
  width: 100%;
  padding: 9px 14px;
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}
.delivery-popup__retry:hover:not(:disabled) { opacity: 0.9; }
.delivery-popup__retry:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Иконка доставки при активном ретрае */
.msg__delivery--retrying {
  color: var(--text-muted);
  cursor: wait;
  opacity: 0.7;
}

/* Кликабельный ник бота в подсказке */
.delivery-popup__bot-copy { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-style: dotted; }
.delivery-popup__bot-copy:hover { opacity: 0.8; }

/* Плашка даты в ленте */
.feed-day { display: flex; align-items: center; justify-content: center; margin: 18px 0 10px; }
.feed-day span { padding: 3px 12px; border-radius: 12px; background: rgba(0,0,0,0.06); color: #6b7280; font-size: 12px; font-weight: 500; }

/* === TD-34d: пометка «изменено» + история версий === */
.msg__edited-mark { display: inline-block; margin-top: 4px; font-size: 11px; color: #8a94a6; cursor: pointer; user-select: none; border-bottom: 1px dashed #b7bfcc; line-height: 1.3; }
.msg__edited-mark:hover { color: #5a6472; border-bottom-color: #8a94a6; }
.msg__edited-mark--open { color: #5a6472; border-bottom-style: solid; }
.msg__history { margin-top: 6px; padding: 8px 10px; background: rgba(0, 0, 0, 0.04); border-radius: 8px; border-left: 2px solid #c3cad6; }
.msg__history-item { padding: 4px 0; }
.msg__history-item + .msg__history-item { border-top: 1px solid rgba(0, 0, 0, 0.06); }
.msg__history-time { display: block; font-size: 10px; color: #9aa3b2; margin-bottom: 2px; }
.msg__history-text { font-size: 13px; color: #3a4250; white-space: pre-wrap; word-break: break-word; line-height: 1.35; }

/* Кнопка правки в ряду действий */
.msg__edit-btn { background: none; border: none; cursor: pointer; font-size: 15px; padding: 2px 4px; color: #8a8f98; opacity: .7; transition: opacity .15s, color .15s; }
.msg__edit-btn:hover { opacity: 1; }
/* Подложка модалки правки */
.edit-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 9999; }
/* Окно модалки правки */
.edit-modal { background: #fff; border-radius: 12px; padding: 20px; width: 90%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
/* Заголовок модалки правки */
.edit-modal__title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
/* Поле ввода текста правки */
.edit-modal__textarea { width: 100%; min-height: 100px; box-sizing: border-box; padding: 10px; border: 1px solid #d0d0d0; border-radius: 8px; font-size: 14px; font-family: inherit; resize: vertical; }
/* Ряд кнопок модалки правки */
.edit-modal__row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
/* Общий вид кнопок модалки правки */
.edit-modal__btn { padding: 8px 18px; border-radius: 8px; border: none; cursor: pointer; font-size: 14px; }
/* Кнопка отмены модалки правки */
.edit-modal__btn--cancel { background: #ececec; color: #333; }
/* Кнопка сохранения модалки правки */
.edit-modal__btn--save { background: #2c6bed; color: #fff; }
/* Кнопка сохранения в процессе */
.edit-modal__btn--save:disabled { opacity: .6; cursor: default; }

/* Карандаш ✎: плашка как у соседних кнопок */
.msg__edit-btn { width: 26px; height: 26px; padding: 0; border: none; background: #eef0f6; color: var(--text-3); border-radius: 6px; font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; opacity: 1; transition: background var(--transition), color var(--transition); }
.msg__edit-btn:hover { background: #d8dbe6; color: var(--text); opacity: 1; }

/* Реакция ☺: плашка как у соседних кнопок */
.msg__react-btn { width: 26px; height: 26px; padding: 0; border: none; background: #eef0f6; color: var(--text-3); border-radius: 6px; font-size: 16px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; opacity: 1; transition: background var(--transition), color var(--transition); }
.msg__react-btn:hover { background: #d8dbe6; color: var(--text); opacity: 1; }
.panel__reply-bar { display: flex; align-items: center; gap: 8px; }
.panel__reply-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.panel__edit-bar { padding: 7px 10px; border: 1px solid #e8dcc4; border-radius: var(--radius-sm); background: #fbf5ea; }
.panel__edit-bar .panel__reply-author { color: #a06a1f; font-weight: 600; }
.panel__edit-bar .panel__reply-text { font-size: 12px; opacity: .8; max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel__reply-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.msg__quote { display: flex; gap: 8px; align-items: flex-start; }
.msg__quote-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.msg__quote-thumb.is-deleted { opacity: 0.45; filter: grayscale(1); }
.msg__quote-body { display: flex; flex-direction: column; min-width: 0; }
.msg__quote-author { font-weight: 600; font-size: 12px; opacity: 0.85; }
.msg__quote-text.is-deleted { text-decoration: line-through; opacity: 0.6; }
.msg__quote-deleted { font-size: 11px; opacity: 0.6; font-style: italic; }

/* Спиннер над лентой при догрузке старых сообщений */
/* Опорная точка ленты — спиннер догрузки позиционируется от неё */
#chatFeed { position: relative; }
/* Подстройку прокрутки при догрузке делает наш код — встроенная дала двойной сдвиг, ленту дёргало */
#chatFeed { overflow-anchor: none; }

/* Спиннер догрузки — поверх ленты, чтобы лента не прыгала на его высоту */
.feed-top-spinner { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; padding: 0; z-index: 6; pointer-events: none; }
.feed-top-spinner__dot { width: 20px; height: 20px; border: 2px solid rgba(0,0,0,0.15); border-top-color: rgba(0,0,0,0.55); border-radius: 50%; animation: feed-spin 0.7s linear infinite; }
@keyframes feed-spin { to { transform: rotate(360deg); } }

/* Маркер начала переписки */
.feed-start-marker { text-align: center; padding: 10px 0; font-size: 12px; color: rgba(0,0,0,0.45); }

/* Круглая кнопка прыжка вниз — висит внутри ленты снизу по центру */
.feed-jump-down {
  position: sticky;
  bottom: 8px;
  align-self: center;
  margin-top: -50px;
  margin-bottom: 0;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  max-width: 42px;
  max-height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #333;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 20;
}
.feed-jump-down:hover { background: #f5f5f5; }
.feed-jump-down.feed-jump-down--show { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* Мобильная — меньше */
@media (max-width: 768px) {
  .feed-jump-down {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    max-width: 34px;
    max-height: 34px;
    flex: 0 0 34px;
    bottom: 4px;
    margin-top: -42px;
  }
  .feed-jump-down svg { width: 18px; height: 18px; }
}

/* Плавающая дата сверху ленты */
.feed-day-float { position: absolute; z-index: 20; display: flex; justify-content: center; pointer-events: none; opacity: 0; transition: opacity 0.35s ease; }
.feed-day-float.is-visible { opacity: 1; }
.feed-day-float span { padding: 3px 12px; border-radius: 12px; background: rgba(0,0,0,0.06); color: #6b7280; font-size: 12px; font-weight: 500; backdrop-filter: blur(4px); }

/* ========== Провал удаления: жёлтый значок ========== */

/* Модификатор корзинки внутри msg__delivery-mark */
.msg__delivery-mark--del {
  font-size: 8px;
  line-height: 1;
}

/* Тусклое сообщение пока идут автопопытки */
.msg--deleting {
  opacity: 0.5;
  transition: opacity var(--transition);
}
/* Панель действий в процессе удаления скрыта — бейдж встаёт на её место, без пустоты */
.msg--deleting .msg__actions { display: none; }

/* Подпись "Удаляется…" рядом с тусклым сообщением */
.msg__deleting-note {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 6px;
}

/* ========== Расширение попапа доставки для удаления ========== */

/* Строка чата с чекбоксом «удалил вручную» */
.delivery-popup__manual-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 12.5px;
  cursor: pointer;
}
.delivery-popup__manual-row:hover { color: var(--text); }

/* Сам чекбокс */
.delivery-popup__manual-check {
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Кнопка «ОК» — вторичный стиль */
.delivery-popup__ok {
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: background var(--transition);
}
.delivery-popup__ok:hover { background: var(--panel-hover); }

/* ========== Плашка удаления сообщения (Г13, единообразие с доставкой) ========== */

/* Общая плашка под удалённым сообщением — серый тон */
.msg__del-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(107, 114, 128, 0.08);
  border-radius: 8px;
  width: fit-content;
}

/* Плашка "Удаляем…" — тот же серый, но с индикацией процесса */
.msg__del-badge--progress {
  color: #6b7280;
  font-style: italic;
}

/* Плашка "Удалено" — состояние (б) */
.msg__del-badge--ok {
  color: #6b7280;
}

/* Плашка с провалами — состояние (в), оранжевый акцент */
.msg__del-badge--warn {
  color: inherit;
  background: none;
  padding: 0;
  gap: 4px;
  font-style: normal;
  font-weight: 600;
  font-size: 10px;
}

/* Серая галочка успеха внутри плашки */
.msg__del-check {
  color: #9ca3af;
  margin-left: 3px;
  font-weight: 700;
}

/* Кликабельный канал с провалом — обёртка над "Телеграм !" */
.msg__del-chan {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.msg__del-chan--warn {
  color: #f59e0b;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
  transition: background var(--transition);
}
.msg__del-chan--warn:hover {
  background: rgba(245, 158, 11, 0.12);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

/* ===== Попап "не удалено" (del-fail) ===== */
.del-fail-overlay { position: fixed; inset: 0; z-index: 9998; background: transparent; }
.del-fail-popup { position: absolute; z-index: 9999; min-width: 300px; max-width: 380px; background: #ffffff; color: var(--text); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.15); font-size: 13px; overflow: hidden; animation: deliveryPopupIn 0.15s ease-out; }
.del-fail-popup__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--panel-border); background: rgba(239,68,68,0.08); }
.del-fail-popup__title { font-size: 13px; font-weight: 600; color: #ef4444; }
.del-fail-popup__close { background: none; border: none; color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; transition: color var(--transition); }
.del-fail-popup__close:hover { color: var(--text); }
.del-fail-popup__sub { padding: 8px 12px; font-size: 12px; color: var(--text-muted); line-height: 1.4; border-bottom: 1px solid var(--panel-border); }
.del-fail-popup__body { padding: 10px 12px; max-height: 320px; overflow-y: auto; }
.del-fail-group + .del-fail-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--panel-border); }
.del-fail-group__head { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.del-fail-chat { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.del-fail-chat + .del-fail-chat { border-top: 1px dashed var(--panel-border); }
.del-fail-chat__top { display: flex; align-items: center; gap: 6px; }
.del-fail-chat__link { color: var(--accent); text-decoration: none; font-weight: 500; }
.del-fail-chat__link:hover { text-decoration: underline; }
.del-fail-chat__reason { font-size: 12px; color: var(--text); }
.del-fail-chat__rec { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.del-fail-chk { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }
.del-fail-popup__foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--panel-border); }
.del-fail-popup__manual { flex: 1; padding: 9px 14px; background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity var(--transition); }
.del-fail-popup__manual:hover { background: rgba(108,140,255,0.08); }
.del-fail-popup__retry, .del-fail-popup__save { flex: 1; padding: 9px 14px; background: var(--gradient-brand); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity var(--transition); }
.del-fail-popup__retry:hover:not(:disabled), .del-fail-popup__save:hover:not(:disabled) { opacity: 0.9; }
.del-fail-popup__retry:disabled, .del-fail-popup__save:disabled { opacity: 0.5; cursor: wait; }
.del-fail-chat--manual { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.del-fail-chat--manual .del-fail-chk { flex: none; margin: 0; }
.del-fail-chat__line { font-size: 13px; color: var(--text); }

/* === Заглушка: лимит связок превышен === */
.chat-lock { position: fixed; inset: 0; z-index: 999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 40px 24px; text-align: center; background: var(--bg-dark, #0f1117); }
.chat-lock__icon { font-size: 44px; }
.chat-lock__title { font-size: 17px; font-weight: 700; color: var(--text-on-dark); max-width: 460px; line-height: 1.5; }
.chat-lock__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.chat-lock__btn { height: 42px; padding: 0 24px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; transition: opacity var(--transition), border-color var(--transition), color var(--transition); }
.chat-lock__btn--primary { background: var(--gradient-brand); color: #fff; border: none; }
.chat-lock__btn--primary:hover { opacity: .88; }
.chat-lock__btn--ghost { background: transparent; border: 1px solid #2e3342; color: var(--text-on-dark-2); }
.chat-lock__btn--ghost:hover { border-color: #3e4558; color: var(--text-on-dark); }
@media (max-width: 600px) { .chat-lock__actions { flex-direction: column; width: 100%; max-width: 380px; } .chat-lock__btn { width: 100%; } }

/* --- Стили для панели видеозаписи --- */
.panel__video-record {
  position: absolute;
  bottom: 60px; /* Поднимаем над строкой ввода */
  right: 10px;
  width: 380px;
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 9999; /* Выводим поверх всего */
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel__video-tabs { display: flex; gap: 4px; }
.panel__video-tabs button { flex: 1; padding: 6px; border: 1px solid #ccc; background: #f8f9fa; border-radius: 4px; cursor: pointer; font-size: 13px; }
.panel__video-tabs button.active { background: #6c8cff; color: #fff; border-color: #6c8cff; }
.panel__video-record video { width: 100%; height: 180px; background: #000; border-radius: 4px; object-fit: cover; }
.panel__video-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel__btn-icon--rec { color: red; font-size: 16px; }
.panel__btn-icon--stop { color: #333; font-size: 16px; }

#videoPreview { width: 100%; max-height: 450px; background: #000; border-radius: 8px; }

/* force-audio */
.msg__media audio { display: block !important; width: 100% !important; min-width: 280px !important; max-width: 320px !important; height: 54px !important; min-height: 54px !important; background: #f8f9fa !important; border-radius: 8px; outline: none; }


/* ===== Поиск по чату ===== */
.chat-search-toggle { background: none; border: none; cursor: pointer; color: var(--text-secondary, #888); padding: 4px; margin-left: auto; margin-right: 4px; display: flex; align-items: center; transition: color .2s; }
.chat-search-toggle:hover { color: var(--accent, #7c5ce0); }
.chat-search { background: var(--bg-panel, #fff); border-bottom: 1px solid var(--border, #e5e5e5); padding: 10px 12px 8px; }
.chat-search__main { display: flex; gap: 8px; align-items: center; }
.chat-search__input { flex: 1; padding: 7px 10px; border: 1px solid var(--border, #ddd); border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; background: var(--bg-input, #fafafa); }
.chat-search__input:focus { border-color: var(--accent, #7c5ce0); }
.chat-search__close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-secondary, #888); padding: 2px 4px; }
.chat-search__close:hover { color: var(--text-primary, #333); }
.chat-search__filter-toggle { background: none; border: none; cursor: pointer; font-size: 12px; color: var(--accent, #7c5ce0); padding: 4px 0; margin-top: 2px; font-family: inherit; }
.chat-search__filters { display: none; flex-direction: column; gap: 6px; margin-top: 6px; }
.chat-search__author { padding: 6px 10px; border: 1px solid var(--border, #ddd); border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; background: var(--bg-input, #fafafa); }
.chat-search__author:focus { border-color: var(--accent, #7c5ce0); }
.chat-search__dates { display: flex; gap: 6px; align-items: center; }
.chat-search__date { padding: 5px 8px; border: 1px solid var(--border, #ddd); border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; background: var(--bg-input, #fafafa); flex: 1; }
.chat-search__date:focus { border-color: var(--accent, #7c5ce0); }
.chat-search__date-sep { color: var(--text-secondary, #aaa); font-size: 13px; }
.chat-search__results { max-height: 320px; overflow-y: auto; margin-top: 8px; }
.chat-search__item { padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.chat-search__item:hover { background: var(--bg-hover, #f5f0ff); }
.chat-search__item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.chat-search__item-author { font-size: 12px; font-weight: 600; color: var(--accent, #7c5ce0); }
.chat-search__item-time { font-size: 11px; color: var(--text-secondary, #aaa); }
.chat-search__item-text { font-size: 13px; color: var(--text-primary, #333); line-height: 1.4; word-break: break-word; }
.chat-search__item-text mark { background: #e8dbff; border-radius: 2px; padding: 0 1px; }
.chat-search__empty { padding: 16px; text-align: center; color: var(--text-secondary, #aaa); font-size: 13px; }

/* Форматирование из мессенджеров внутри пузыря */
.msg__text a { color: var(--accent); text-decoration: underline; word-break: break-word; }
.msg__text blockquote { border-left: 3px solid var(--accent); margin: 4px 0; padding: 2px 10px; opacity: 0.85; }
.msg__text code { background: rgba(0, 0, 0, 0.06); padding: 1px 4px; border-radius: 4px; font-family: monospace; font-size: 0.95em; }
.msg__text pre { background: rgba(0, 0, 0, 0.06); padding: 8px 10px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; }

/* Панель форматирования над полем ввода */
.panel__input-row { position: relative; }

/* Меню форматирования (волшебная палочка): полоска ПОВЕРХ футера,
   открытие не сдвигает поле ввода и плашки */
.panel__foot { position: relative; }
.panel__fmt-menu {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 8px 12px;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 12px;
  right: 12px;
  z-index: 30;
  background: var(--panel-header);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.panel__fmt-menu[hidden] { display: none; }
.panel__fmt-btn--active { border-color: var(--accent); color: var(--accent); }

/* Поле ввода как визуальный редактор */
.panel__input--rich { overflow-y: auto; min-height: 38px; line-height: 1.45; }
.panel__input--rich:empty:before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.panel__input--rich blockquote { border-left: 3px solid var(--accent); margin: 4px 0; padding: 2px 10px; }
.panel__input--rich code { font-family: monospace; background: rgba(0, 0, 0, 0.06); padding: 1px 4px; border-radius: 4px; }
.panel__input--rich pre { font-family: monospace; background: rgba(0, 0, 0, 0.06); padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; }
.panel__input--rich a { color: var(--accent); text-decoration: underline; word-break: break-word; }
.panel__input[hidden] { display: none; }

/* Код-режим (теги): «чёрное окно с белым текстом» — переключение видно сразу,
   моноширинный шрифт, чтобы теги читались */
#chatCode {
  background: #101319;
  color: #f2f4fa;
  border-color: #2c3140;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 13px;
  caret-color: #f2f4fa;
}
#chatCode::placeholder { color: #6b7080; }
.panel__fmt-btn { border: 1px solid var(--panel-border, #e8eaf0); background: transparent; border-radius: 6px; min-width: 30px; height: 28px; padding: 0 8px; cursor: pointer; font-size: 13px; color: var(--text, #1a1d27); font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.panel__fmt-btn:hover { border-color: var(--accent); color: var(--accent); }
.panel__btn-icon--active { background: #e0e2ea; }
.panel__btn-icon svg { display: block; }
.panel__btn-chip-ico { display: inline-flex; align-items: center; }

/* Чипы выбранных кнопок поста */
.panel__buttons-row { display: flex; gap: 6px; padding: 6px 8px 0; flex-wrap: wrap; }
.panel__btn-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border-radius: 14px; padding: 3px 10px; font-size: 12px; }
.panel__btn-chip-x { cursor: pointer; opacity: 0.8; }

/* Кнопки поста в ленте */
.msg__buttons { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.msg__btn { display: inline-block; border: 1px solid var(--accent); color: var(--accent); border-radius: 10px; padding: 4px 12px; font-size: 13px; text-decoration: none; }
.msg__btn:hover { background: var(--accent); color: #fff; }

/* Канальная связка: без тикетов, чат на всю ширину, посты в ширину телефона */
.lk-workspace--channel #panelSplitter,
.lk-workspace--channel #panelTickets { display: none !important; }
/* Чат в канальной связке: по умолчанию 50%, стрелкой разворачивается на 100% */
@media (min-width: 800px) {
  .lk-workspace--channel .panel--chat { flex: 0 0 50% !important; }
  .lk-workspace--channel .panel--chat.is-expanded { flex: 0 0 100% !important; }
  /* Контент следует за шириной чата: входящие слева, исходящие справа */
}
/* Посты канала — колонка ширины телефона у левого края */
.lk-workspace--channel .msg {
  width: 100%;
  margin-left: 0;
  margin-right: auto;
  box-sizing: border-box;
}
/* Пузырь контента: при чате 50% — 78% ширины строки;
   при развороте на 100% — 78% от своей половины поля (39% от строки) */
.lk-workspace--channel .msg__text { max-width: 78%; }
.lk-workspace--channel .msg__quote { max-width: 78%; }
.lk-workspace--channel .panel--chat.is-expanded .msg__text { max-width: 39%; }
.lk-workspace--channel .panel--chat.is-expanded .msg__quote { max-width: 39%; }

/* Панель правки ссылки в редакторе: широкое поле, значки с подсказками */
.lnk-pop { position: absolute; z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(560px, calc(100vw - 16px)); background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.lnk-pop__input { width: 100%; padding: 8px 10px; border: 1px solid var(--panel-border); border-radius: 8px; font: inherit; font-size: 13px; color: var(--text); }
.lnk-pop__row { display: flex; align-items: center; gap: 8px; }
.lnk-pop__btn { width: 34px; height: 32px; padding: 0; border: none; border-radius: 8px; background: #eef0f6; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background var(--transition), color var(--transition); }
.lnk-pop__ok { background: #2b4acb; color: #fff; }
.lnk-pop__ok:hover { background: #2340b8; }
.lnk-pop__rm { position: relative; }
/* Красный крестик на цепочке: убрать ссылку (в отличие от ✕, который закрывает панель) */
.lnk-pop__rm::after { content: '×'; position: absolute; top: -3px; right: -3px; width: 13px; height: 13px; border-radius: 50%; background: #c0392b; color: #fff; font-size: 10px; font-weight: 700; line-height: 13px; text-align: center; }
.lnk-pop__rm:hover, .lnk-pop__x:hover { background: #d8dbe6; color: var(--text); }

/* ── Галерея: несколько снимков одним пузырём ── */
.msg__gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  max-width: 320px;
  margin-bottom: 8px;
  align-items: start;
}
/* Раскладки галереи по пропорциям вложений (выбирает JS после загрузки медиа) */
.msg__gallery--tall-left {
  grid-template-rows: repeat(2, minmax(0, 1fr));
  height: 300px;
  align-items: stretch;
}
.msg__gallery--wide-top {
  grid-template-rows: minmax(0, 1.35fr) minmax(0, 1fr);
  height: 300px;
  align-items: stretch;
}
.msg__gallery--tall-left .msg__gallery-item,
.msg__gallery--wide-top .msg__gallery-item {
  aspect-ratio: auto;
  min-height: 0;
}
.msg__gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel-header);
  aspect-ratio: 1 / 1;
}
.msg__gallery-item img,
.msg__gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}
.msg__gallery-item span.msg__gallery-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg__gallery-item span.msg__gallery-play::before {
  content: "\25B6";
  font-size: 22px;
  color: var(--text);
  opacity: 0.85;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}
/* Просмотр на весь экран */
.gal-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 23, 0.92);
  padding: 40px;
}
.gal-viewer img,
.gal-viewer video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}
.gal-viewer button {
  background: none;
  border: none;
  cursor: pointer;
}
.gal-viewer__close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 32px;
  color: #ffffff;
}
.gal-viewer__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 40px;
  color: #ffffff;
  padding: 20px;
}
.gal-viewer__nav--prev { left: 8px; }
.gal-viewer__nav--next { right: 8px; }
/* Панельный режим: просмотрщик живёт в границах чата */
.gal-viewer--pane {
  padding: 16px;
  border-radius: 10px;
}
/* Принудительный полноэкранный режим -- перекос inline-размеров */
.gal-viewer--full {
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
}
/* Кнопка на весь экран -- внизу справа */
.gal-viewer__full {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 20px;
  color: var(--accent, #7a86ff);
  padding: 8px;
}

/* ── Превьюшки нескольких файлов галереи ── */
.panel__attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.panel__attach-chip {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-panel);
}
.panel__attach-chip-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}
.panel__attach-chip-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  background: rgba(15, 17, 23, 0.55);
  color: #ffffff;
}

/* Слоты видео-превьюшки и документов */
.panel__attach-chip-media--wait {
  background: var(--bg-input);
}
.panel__attach-chip-media--dark {
  background: var(--bg-mid);
}
.panel__attach-chip .panel__attach-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.panel__attach-chip .panel__attach-play::before {
  content: "▶";
  font-size: 18px;
  color: var(--bg);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}
.panel__attach-chip-name {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 4px;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  word-break: break-all;
  color: inherit;
}

/* Одиночное фото в пузыре открывается на весь экран */
.msg__media > img {
  cursor: zoom-in;
}

/* Файл внутри галереи: плитка-контейнер на всю ширину сетки */
.msg__gallery-doc {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-input);
  color: inherit;
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
