:root {
  --bg: #0e1621;
  --bg-panel: #17212b;
  --bg-hover: #202b36;
  --bg-input: #242f3d;
  --bg-own: #2b5278;
  --text: #f5f5f5;
  --text-dim: #7d8b99;
  --accent: #64b5f6;
  --accent-strong: #2196f3;
  --red: #e53935;
  --green: #4caf50;
  --radius: 14px;
  --radius-sm: 8px;
}

/* ===== ТЕМЫ (ОФОРМЛЕНИЕ) ===== */
body.theme-dark, body.theme-night {
  --bg: #0e1621; --bg-panel: #17212b; --bg-hover: #202b36; --bg-input: #242f3d;
  --bg-own: #2b5278; --text: #f5f5f5; --text-dim: #7d8b99;
  --accent: #64b5f6; --accent-strong: #2196f3;
}
body.theme-light {
  --bg: #f5f5f5; --bg-panel: #ffffff; --bg-hover: #e4e4e5; --bg-input: #ebebed;
  --bg-own: #d3efff; --text: #1c2733; --text-dim: #6b7a88;
  --accent: #168acd; --accent-strong: #0f6fc2;
}
body.theme-blue {
  --bg: #0a2740; --bg-panel: #0f3352; --bg-hover: #174264; --bg-input: #1d4b6f;
  --bg-own: #105a8f; --text: #eaf6ff; --text-dim: #7fb2d6;
  --accent: #4fc3f7; --accent-strong: #0288d1;
}
body.theme-green {
  --bg: #0c2417; --bg-panel: #123620; --bg-hover: #1a4529; --bg-input: #1f5231;
  --bg-own: #1b6b3a; --text: #eafff0; --text-dim: #7fc99a;
  --accent: #81c784; --accent-strong: #43a047;
}
body.theme-purple {
  --bg: #1d132e; --bg-panel: #2a1b40; --bg-hover: #37234f; --bg-input: #3f2a5a;
  --bg-own: #5c3a8f; --text: #f4ecff; --text-dim: #a98ad1;
  --accent: #b388ff; --accent-strong: #7c4dff;
}
body.theme-oled {
  --bg: #000000; --bg-panel: #0b0b0d; --bg-hover: #151519; --bg-input: #1c1c21;
  --bg-own: #1d3d55; --text: #f0f0f0; --text-dim: #6d7a88;
  --accent: #55a7ee; --accent-strong: #1e88e5;
}

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

body {
  transition: background-color .25s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* ===== Auth ===== */
.auth-view {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b3447 0%, var(--bg) 60%);
  padding: 16px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.auth-logo { font-size: 56px; text-align: center; }
.auth-card h1 { text-align: center; font-size: 28px; margin-top: 8px; }
.auth-sub { text-align: center; color: var(--text-dim); margin-bottom: 24px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 10px; border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-dim); font-weight: 600;
}
.tab.active { background: var(--accent-strong); color: #fff; }
.auth-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  background: var(--bg-input); border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px; outline: none;
}
.auth-card input:focus { border-color: var(--accent); }
.btn {
  width: 100%; padding: 12px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700;
}
.btn.primary { background: var(--accent-strong); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.cancel { background: var(--bg-input); color: var(--text-dim); }
.auth-error { margin-top: 12px; padding: 10px; background: rgba(229,57,53,.15); color: #ff8a80; border-radius: var(--radius-sm); font-size: 14px; }

/* ===== Layout ===== */
.app-view { display: flex; height: 100dvh; }
.sidebar {
  width: 320px; min-width: 280px;
  background: var(--bg-panel);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar-header { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
.profile-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff; text-transform: uppercase;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-input); font-size: 18px; color: var(--accent);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--bg-hover); }
.search-wrap { padding: 10px 12px; }
.search-wrap input {
  width: 100%; padding: 10px 14px; background: var(--bg-input);
  border: 1px solid transparent; border-radius: 20px; color: var(--text); outline: none; font-size: 14px;
}
.search-wrap input:focus { border-color: var(--accent); }

.chats-list { flex: 1; overflow-y: auto; }
.chats-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 5px; }
.chats-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }

.chat-item {
  display: flex; gap: 12px; padding: 10px 12px; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.04); cursor: pointer;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-hover); }
.chat-item .avatar { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; position: relative; }
.chat-item .avatar .dot {
  position: absolute; bottom: 1px; right: 1px; width: 12px; height: 12px;
  border-radius: 50%; border: 2px solid var(--bg-panel); background: #666;
}
.chat-item .avatar .dot.online { background: var(--green); }

/* картинки аватаров: круглые, вписанные в контейнер, не вылезают на текст.
   overflow не трогаем: круглая форма у картинки своя (border-radius), а точка
   статуса лежит на границе круга и НЕ должна обрезаться контейнером */
.avatar img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 50%; display: block; flex-shrink: 0;
}
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-item-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.chat-item-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.chat-item-preview { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-preview.draft { color: var(--accent); }
.unread-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent-strong); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-item .tick { color: var(--text-dim); font-size: 11px; }

/* ===== Chat area ===== */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-dim); gap: 8px; }
.chat-empty-icon { font-size: 64px; opacity: .5; }
.chat-empty-title { font-size: 20px; color: var(--text); }
.chat-empty-sub { font-size: 14px; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; height: 100dvh; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; flex-wrap: nowrap;
  border-bottom: 1px solid rgba(255,255,255,.06); background: var(--bg-panel); }
.chat-header-info { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; flex: 1; }
.chat-header .avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink: 0; }
.chat-header-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-status { font-size: 12px; color: var(--text-dim); }
.chat-members-count { margin-left: 0; font-size: 13px; color: var(--text-dim); flex-shrink: 0; }
#call-btn { margin-left: auto; flex-shrink: 0; }

.messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.date-divider {
  align-self: center; text-align: center; background: var(--bg-panel);
  color: var(--text-dim); font-size: 12px; padding: 5px 14px; border-radius: 12px; margin: 10px 0;
}
.msg-system {
  align-self: center; text-align: center; color: var(--text-dim); font-size: 13px;
  padding: 6px 14px; margin: 10px 0; border-radius: 12px;
}
.msg-row { display: flex; }
.msg-row.own { justify-content: flex-end; }
.msg-bubble {
  max-width: 70%; padding: 7px 12px 6px; border-radius: var(--radius);
  background: var(--bg-panel); position: relative; word-wrap: break-word; overflow-wrap: break-word;
  display: flex; flex-direction: column;
}
.msg-row.own .msg-bubble { background: var(--bg-own); border-top-right-radius: 3px; }
.msg-row.peer .msg-bubble { border-top-left-radius: 3px; }
.msg-row.grouped .msg-bubble { border-radius: var(--radius); margin-top: 2px; }
.msg-row.grouped.own .msg-bubble { border-top-right-radius: 3px; }
.msg-row.grouped.peer .msg-bubble { border-top-left-radius: 3px; }
.msg-row.first.own .msg-bubble { margin-top: 8px; }
.msg-row.first.peer .msg-bubble { margin-top: 8px; }
.msg-sender { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 2px; cursor: pointer; }
.msg-text { font-size: 15px; line-height: 1.35; white-space: pre-wrap; }
.msg-meta {
  align-self: flex-end; display: flex; align-items: center; gap: 4px;
  color: var(--text-dim); font-size: 11px; margin-top: 2px; padding-top: 1px;
}
.msg-row.own .msg-meta { color: rgba(255,255,255,.55); }
.msg-meta .tick { font-size: 14px; line-height: 1; }
.msg-meta .tick.read { color: var(--accent); }
.msg-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 4px; background: rgba(255,255,255,.06); border-radius: var(--radius-sm); cursor: pointer; min-width: 210px; }
.msg-file .file-icon { font-size: 26px; }
.msg-file .file-name { font-size: 14px; font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file .file-size { font-size: 12px; color: var(--text-dim); }
.msg-image { max-width: 320px; width: 100%; border-radius: var(--radius-sm); display: block; margin-bottom: 4px; cursor: zoom-in; }
.msg-image-full {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.msg-image-full img { max-width: 95vw; max-height: 95vh; border-radius: 6px; }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-panel); border-top: 1px solid rgba(255,255,255,.06);
}
.composer-input-wrap { flex: 1; background: var(--bg-input); border-radius: 20px; padding: 8px 14px; }
#msg-input { width: 100%; background: none; border: none; outline: none; color: var(--text); font-size: 15px; resize: none; max-height: 120px; line-height: 1.4; }
.send-btn { background: var(--accent-strong); color: #fff; border-radius: 50%; font-size: 16px; }
.send-btn:hover { filter: brightness(1.15); }

.typing-indicator { padding: 4px 20px; font-size: 13px; color: var(--accent); font-style: italic; }

/* ===== Смайлики и стикеры ===== */
.msg-shell { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.emoji-panel {
  background: var(--bg-panel); border-top: 1px solid rgba(255,255,255,.08);
  padding: 8px; max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
}
.emoji-tabs { display: flex; gap: 6px; border-bottom: 1px solid rgba(255,255,255,.08); padding-bottom: 6px; position: sticky; top: 0; background: var(--bg-panel); }
.etab { padding: 6px 14px; border-radius: 12px; font-size: 13px; color: var(--text-dim); background: var(--bg-input); }
.etab.active { background: var(--accent-strong); color: #fff; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 2px; }
.emoji-cell { font-size: 24px; padding: 4px; border-radius: 6px; text-align: center; line-height: 1.2; }
.emoji-cell:hover { background: var(--bg-hover); }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.sticker-cell { font-size: 44px; padding: 8px; border-radius: 10px; background: var(--bg-input); }
.sticker-cell:hover { background: var(--bg-hover); transform: scale(1.08); }
.msg-sticker { font-size: 64px; line-height: 1.1; padding: 2px 6px; user-select: none; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--bg-panel); border-radius: 16px; width: 100%; max-width: 420px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { padding: 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.08); }
.modal-header h3 { font-size: 17px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-body input, .modal-body textarea {
  width: 100%; padding: 10px 12px; margin-bottom: 12px; background: var(--bg-input);
  border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text); outline: none; font-size: 14px; resize: vertical;
}
.modal-body input:focus, .modal-body textarea:focus { border-color: var(--accent); }
.modal-actions { padding: 12px 16px; display: flex; gap: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.modal-actions .btn { width: auto; flex: 1; }
.user-list-item { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.user-list-item:hover { background: var(--bg-hover); }
.user-list-item.sel { background: var(--accent-strong); color: #fff; }
.user-list-item.sel .sub { color: rgba(255,255,255,.75); }
.user-list-item .avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-list-item .name { font-weight: 600; font-size: 15px; }
.user-list-item .sub { font-size: 12px; color: var(--text-dim); }
.grp-actions { text-align: center; margin: 6px 0 12px; }
.grp-tools { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.grp-tools .mini { padding: 5px 9px; }
.checkbox { margin-left: auto; }
.group-badge { width: 46px; height: 46px; border-radius: 50%; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-panel); color: var(--text); padding: 12px 18px; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 300; font-size: 14px;
  border-left: 3px solid var(--accent);
}
.toast.error { border-left-color: var(--red); }

/* ===== Папки чатов ===== */
.folders-bar {
  display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.folders-bar::-webkit-scrollbar { height: 3px; }
.folder-chip {
  flex-shrink: 0; padding: 10px 12px; border-radius: 18px; background: var(--bg-input);
  color: var(--text-dim); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.folder-chip.active { background: var(--accent-strong); color: #fff; }
.folder-chip .fcount { opacity: .75; font-size: 11px; margin-left: 5px; }
.folder-manage {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--bg-input);
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--accent);
}

/* ===== Кнопки чата ===== */
#chat-back { flex-shrink: 0; }
.chat-header { gap: 8px; }
.chat-more-btn { flex-shrink: 0; }

/* темы в модалке */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-card {
  border-radius: 12px; overflow: hidden; cursor: pointer; border: 2px solid transparent;
  background: var(--bg-panel); text-align: center; padding: 0 0 10px;
}
.theme-card.active { border-color: var(--accent-strong); }
.theme-swatches { height: 44px; display: flex; flex-direction: column; }
.theme-card-name { font-size: 12px; color: var(--text-dim); padding-top: 6px; }

/* ===== Тайпинг анимация (как Telegram) ===== */
@keyframes td {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-3px); opacity: 1; }
}
.typing-dots { display: inline-flex; gap: 3px; align-items: flex-end; margin-left: 4px; }
.typing-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block;
  animation: td 1.2s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
.typing-title { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--accent); font-style: normal; }
.typing-inline { text-align: center; padding: 8px 0; color: var(--accent); font-size: 13px; display: flex; justify-content: center; align-items: center; }

/* ===== Аватары в сообщениях ===== */
.msg-avatar { display: block; font-size: 26px; margin-right: 6px; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; align-self: flex-end; position: relative; overflow: visible; padding: 0; }
.msg-avatar .dot { width: 10px; height: 10px; bottom: -1px; right: -1px; border-width: 2px; border-color: var(--bg); }
.msg-row { align-items: flex-end; gap: 0; }
.msg-row.grouped { margin-top: 2px; }
.msg-row.first { margin-top: 8px; }

/* ===== Тумблеры ===== */
.pass-block { margin: 10px 0; padding: 10px 12px; background: var(--bg-input); border-radius: 12px; }
.ci-row {
  padding: 9px 6px; border-top: 1px solid rgba(255,255,255,.06);
  font-size: 14px; color: var(--text-dim);
}
.ci-row b { color: var(--text); font-weight: 600; }
.pass-summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 14px; outline: none; }
.pass-block input { width: 100%; padding: 9px 12px; margin: 8px 0 0; background: var(--bg-panel); border: 1px solid transparent; border-radius: 8px; color: var(--text); font-size: 14px; outline: none; }
.pass-block input:focus { border-color: var(--accent); }
.pass-block .btn { margin-top: 10px; }

.mini {
  padding: 5px 12px; border-radius: 8px; font-size: 12px; background: var(--bg-input);
  color: var(--accent); cursor: pointer; border: none; white-space: nowrap;
}
.mini:hover { background: var(--bg-hover); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.toggle-row:last-child { border-bottom: none; }
.toggle { position: relative; width: 46px; height: 26px; border-radius: 14px; background: var(--bg-input); transition: background .2s; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; }
.toggle.on { background: var(--accent-strong); }
.toggle.on::after { left: 23px; }

/* ===== Responsive ===== */
@media (max-width: 760px) {
  .sidebar { width: 100%; }
  .sidebar.closed { display: none; }
  .chat-view.mobile-open { position: fixed; inset: 0; z-index: 50; width: 100%; height: 100dvh; background: var(--bg); }
  .msg-bubble { max-width: 85%; }
  .msg-image { max-width: 240px; }
  .sidebar-header { padding: 10px 8px; }
  .composer { padding: 6px 8px; }
  .emoji-panel { max-height: 38vh; }
  .msg-avatar { display: none !important; }
  .chat-header-info .avatar { width: 36px !important; height: 36px !important; }
  .sel-bar .sel-actions .mini { padding: 4px 8px; font-size: 11px; }
  .ctx-menu { max-width: 92vw; }
}

/* ============ ОТВЕТ / ВЫБОР / РЕАКЦИИ / ЗАКРЕП / ПЕРЕСЫЛКА ============ */

/* Панель выбора нескольких сообщений */
.sel-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px; background: var(--accent-strong); color: #fff;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.sel-bar .sel-count { white-space: nowrap; }
.sel-bar .sel-actions { display: flex; gap: 6px; }
.sel-bar .mini { background: rgba(255,255,255,.18); color: #fff; }
.sel-bar .mini:hover { background: rgba(255,255,255,.3); }
.sel-bar .mini.danger { background: rgba(229,57,53,.55); }

/* ===== Аудиозвонки ===== */
.call-overlay {
  position: fixed; inset: 0; z-index: 500; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.call-overlay.hidden { display: none; }
.call-card {
  text-align: center; max-width: 320px; width: 100%;
  background: var(--bg-panel); border-radius: 20px; padding: 26px 20px 22px;
  box-shadow: 0 14px 50px rgba(0,0,0,.45);
}
.call-name { font-size: 20px; font-weight: 700; margin-top: 14px; }
.call-status { font-size: 14px; color: var(--text-dim); margin-top: 4px; }
.call-btns { display: flex; justify-content: center; align-items: flex-start; gap: 18px; margin-top: 24px; }
.call-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: none; background: none; color: var(--text); cursor: pointer; font-size: 13px;
  width: 92px;
}
.call-btn span { margin-top: 2px; text-align: center; line-height: 1.25; }
.call-btn::before {
  content: ''; display: block; width: 58px; height: 58px; border-radius: 50%;
  background: var(--bg-input); font-size: 24px; line-height: 1; display: flex;
  align-items: center; justify-content: center;
}
.call-btn { position: relative; }
.call-btn:not(.call-ghost) { font-weight: 600; }
.call-btn.icon-svg svg { display: block; width: 58px; height: 58px; padding: 13px; box-sizing: border-box; border-radius: 50%; background: var(--bg-input); }
.call-btn.icon-svg::before { display: none; }
.call-green svg { background: var(--green); color: #fff; }
.call-red svg { background: #e53935; color: #fff; }
.call-ghost svg { background: var(--bg-input); color: var(--text); }
.call-btn.muted svg { background: #e53935; color: #fff; }
.call-btn:hover { filter: brightness(1.15); }

/* Шапка действий чата (как в Telegram) */
.cta-header:hover { background: var(--bg-input); border-radius: 10px; }

/* Сообщение о звонке в чате (как в Telegram) */
.msg-call { text-align: center; }
.call-ic { font-size: 22px; }
.call-lbl { font-size: 14px; font-weight: 600; color: var(--text); }
.call-details { margin-top: 8px; border-top: 1px solid var(--border, rgba(128,128,128,.25)); padding-top: 6px; }
.call-det-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 2px 0; }
.call-det-row span:first-child { color: var(--text-dim); }
.call-det-row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }

/* Индикатор выбора сообщения (чекбокс-круг) */
.msg-row { align-items: center; gap: 6px; }.msg-row .sel-circle {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--text-dim); color: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; transition: all .15s;
}
.msg-row .sel-circle.on { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.msg-row.selected .msg-bubble { box-shadow: 0 0 0 2px var(--accent-strong); }

/* Баббл, выбранный для ответа (сдвиг влево + подсветка как в Telegram) */
.msg-row.replying .msg-bubble {
  transform: translateX(-8px);
  box-shadow: 0 0 0 2px var(--accent);
  transition: transform .2s ease, box-shadow .2s ease;
}

/* Прыжок к найденному сообщению */
.msg-row.jump-highlight .msg-bubble {
  box-shadow: 0 0 0 2px var(--accent-strong), 0 0 18px var(--accent-strong);
  transition: box-shadow .3s ease;
}

/* ===== Поиск по чату ===== */
.chat-search-bar {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg-panel);
  border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
}
.chat-search-bar input {
  flex: 1; min-width: 0; background: var(--bg-input); border: none; outline: none;
  border-radius: 10px; color: var(--text); font-size: 14px; padding: 8px 12px;
}
.chat-search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
  max-height: 45vh; overflow-y: auto; background: var(--bg-panel);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
.cs-item { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.05); }
.cs-item:hover { background: var(--bg-hover); }
.cs-name { font-size: 12px; font-weight: 700; color: var(--accent); }
.cs-text { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-empty { padding: 14px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* Бар ответа над композером */
.reply-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; background: var(--bg-panel);
  border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0;
}
.reply-bar .reply-info { min-width: 0; flex: 1; }
.reply-name { font-size: 13px; font-weight: 700; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-text { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Превью ответа внутри бабла */
.msg-reply {
  border-left: 3px solid var(--accent); padding: 4px 8px; margin-bottom: 5px;
  background: rgba(255,255,255,.05); border-radius: 6px; cursor: pointer; min-width: 0; max-width: 100%;
}
.msg-reply-name { font-size: 12px; font-weight: 700; color: var(--accent); }
.msg-reply-text { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Метки пересылки и закрепа */
.msg-forwarded, .msg-pinned {
  font-size: 11px; color: var(--text-dim); font-weight: 600; margin-bottom: 2px;
}
/* Удалённое сообщение */
.msg-deleted {
  font-size: 14px; font-style: italic; color: var(--text-dim); padding: 4px 2px;
}

/* Реакции под баблом */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react-pill {
  border: none; cursor: pointer; background: var(--bg-input);
  color: var(--text); border-radius: 14px; padding: 2px 9px; font-size: 13px;
  display: inline-flex; align-items: center; gap: 4px;
}
.react-pill.mine { background: var(--accent); color: #fff; }
.react-pill:hover { filter: brightness(1.15); }

/* Контекстное меню (долгое нажатие) */
.ctx-backdrop { position: fixed; inset: 0; z-index: 400; background: transparent; }
.ctx-menu {
  position: fixed; z-index: 401; background: var(--bg-panel);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.55);
  padding: 8px; width: 230px; overflow: hidden;
}
.ctx-reactions {
  display: flex; gap: 2px; padding: 4px 2px 8px;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 6px;
}
.ctx-reaction {
  flex: 1; border: none; background: none; cursor: pointer;
  font-size: 21px; border-radius: 8px; padding: 3px 0;
}
.ctx-reaction:hover { background: var(--bg-hover); }
.ctx-item {
  padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
  color: var(--text); white-space: nowrap;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: #ff5252; }
