/* ═══════════════════════════════════════════════════════════════════════════
   Community v26 — Telegram-style message bubbles, chat header, in-chat search,
   comment threads, hashtags, search page.
   Параметры взяты из исходников Telegram Web K (tweb) и Telegram Web A:
   радиусы 15/5/6px, хвост 9×20, группировка ≤120с, цвета light/dark.
   Файл подключается ПОСЛЕДНИМ — перебивает v21/v22 редизайны.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --tg-in-bg: #ffffff;
  --tg-out-bg: #eeffde;
  --tg-in-text: #000000;
  --tg-out-text: #000000;
  --tg-time-in: #707579;
  --tg-time-out: #4fae4e;
  --tg-bubble-shadow: 0 1px 2px 0 rgba(16, 35, 47, 0.15);
  --tg-author-link: #3d6a9e;
  --tg-radius-big: 15px;
  --tg-radius-small: 5px;
  --tg-service-bg: rgba(74, 142, 58, 0.55);
  --tg-search-hit: rgba(255, 213, 79, 0.45);
  --tg-panel-bg: #ffffff;
  --tg-panel-border: #e4e7eb;
  --tg-panel-text: #1a1d26;
  --tg-panel-muted: #707579;
  --tg-peer-0: #d45246;
  --tg-peer-1: #f68136;
  --tg-peer-2: #6c61df;
  --tg-peer-3: #46ba43;
  --tg-peer-4: #5caffa;
  --tg-peer-5: #408acf;
  --tg-peer-6: #d95574;
}

body[data-theme="dark"],
body[data-theme="midnight"],
body[data-theme="graphite"] {
  --tg-in-bg: #212121;
  --tg-out-bg: #766ac8;
  --tg-in-text: #ffffff;
  --tg-out-text: #ffffff;
  --tg-time-in: #aaaaaa;
  --tg-time-out: rgba(255, 255, 255, 0.65);
  --tg-bubble-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --tg-author-link: #8abcF0;
  --tg-service-bg: rgba(90, 100, 110, 0.5);
  --tg-panel-bg: #212121;
  --tg-panel-border: #303030;
  --tg-panel-text: #ffffff;
  --tg-panel-muted: #aaaaaa;
}

/* ────────────────────────────── 1. БАБЛЫ ────────────────────────────────── */

/* Цвета и фон: Telegram light (входящий белый / исходящий светло-зелёный) */
html body.chats-page #appRoot .message:not(.message-own) .message-bubble,
html body.chats-page #appRoot .message-stack-single:not(.message-own) .message-bubble,
html body.chats-page #appRoot .message-stack-first:not(.message-own) .message-bubble,
html body.chats-page #appRoot .message-stack-middle:not(.message-own) .message-bubble,
html body.chats-page #appRoot .message-stack-last:not(.message-own) .message-bubble,
html body.chats-page > .app > .feed > #appRoot .message:not(.message-own) .message-bubble {
  background: var(--tg-in-bg) !important;
  background-color: var(--tg-in-bg) !important;
  background-image: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  box-shadow: var(--tg-bubble-shadow) !important;
  color: var(--tg-in-text) !important;
  text-shadow: none !important;
}

html body.chats-page #appRoot .message-own .message-bubble,
html body.chats-page #appRoot .message-stack-single.message-own .message-bubble,
html body.chats-page #appRoot .message-stack-first.message-own .message-bubble,
html body.chats-page #appRoot .message-stack-middle.message-own .message-bubble,
html body.chats-page #appRoot .message-stack-last.message-own .message-bubble,
html body.chats-page > .app > .feed > #appRoot .message-own .message-bubble {
  background: var(--tg-out-bg) !important;
  background-color: var(--tg-out-bg) !important;
  background-image: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none !important;
  box-shadow: var(--tg-bubble-shadow) !important;
  color: var(--tg-out-text) !important;
  text-shadow: none !important;
}

/* Позиционирование баблов: свои — вправо */
html body.chats-page #appRoot .message-shell {
  display: flex !important;
  align-items: flex-end;
}
html body.chats-page #appRoot .message-shell--own {
  justify-content: flex-end !important;
}
html body.chats-page #appRoot .message-shell:not(.message-shell--own) {
  justify-content: flex-start !important;
}

/* Скругления по схеме Telegram: 15px внешние, 5px внутренние, 0 у хвоста */
html body.chats-page #appRoot .message-bubble {
  position: relative;
  box-sizing: border-box;
  border-radius: var(--tg-radius-big);
}
html body.chats-page #appRoot .message-stack-single:not(.message-own) .message-bubble {
  border-radius: var(--tg-radius-big) var(--tg-radius-big) var(--tg-radius-big) 0 !important;
}
html body.chats-page #appRoot .message-stack-first:not(.message-own) .message-bubble {
  border-radius: var(--tg-radius-big) var(--tg-radius-big) var(--tg-radius-big) var(--tg-radius-small) !important;
}
html body.chats-page #appRoot .message-stack-middle:not(.message-own) .message-bubble {
  border-radius: var(--tg-radius-small) var(--tg-radius-big) var(--tg-radius-big) var(--tg-radius-small) !important;
}
html body.chats-page #appRoot .message-stack-last:not(.message-own) .message-bubble {
  border-radius: var(--tg-radius-small) var(--tg-radius-big) var(--tg-radius-big) 0 !important;
}
html body.chats-page #appRoot .message-stack-single.message-own .message-bubble {
  border-radius: var(--tg-radius-big) var(--tg-radius-big) 0 var(--tg-radius-big) !important;
}
html body.chats-page #appRoot .message-stack-first.message-own .message-bubble {
  border-radius: var(--tg-radius-big) var(--tg-radius-big) var(--tg-radius-small) var(--tg-radius-big) !important;
}
html body.chats-page #appRoot .message-stack-middle.message-own .message-bubble {
  border-radius: var(--tg-radius-big) var(--tg-radius-small) var(--tg-radius-small) var(--tg-radius-big) !important;
}
html body.chats-page #appRoot .message-stack-last.message-own .message-bubble {
  border-radius: var(--tg-radius-big) 0 var(--tg-radius-small) var(--tg-radius-big) !important;
}

/* Хвостик (SVG-маска, цвет = фон бабла) — только у последнего в группе */
html body.chats-page #appRoot .message-stack-last .message-bubble::after,
html body.chats-page #appRoot .message-stack-single .message-bubble::after {
  content: "" !important;
  position: absolute;
  bottom: 0;
  width: 9px;
  height: 20px;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 20'%3E%3Cpath d='M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z' fill='black'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 20'%3E%3Cpath d='M6 17H0V0c.193 2.84.876 5.767 2.05 8.782.904 2.325 2.446 4.485 4.625 6.48A1 1 0 016 17z' fill='black'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  pointer-events: none;
  z-index: 0;
}
html body.chats-page #appRoot .message-stack-last:not(.message-own) .message-bubble::after,
html body.chats-page #appRoot .message-stack-single:not(.message-own) .message-bubble::after {
  left: -8px;
  transform: scaleX(-1);
  background: var(--tg-in-bg);
}
html body.chats-page #appRoot .message-stack-last.message-own .message-bubble::after,
html body.chats-page #appRoot .message-stack-single.message-own .message-bubble::after {
  right: -8px;
  background: var(--tg-out-bg);
}

/* Текст и внутренние отступы — как в Telegram: ~4-5px/8-9px, 15px/1.3 */
html body.chats-page #appRoot .message-bubble .message-content {
  padding: 4px 9px 6px !important;
  font-size: 15px;
  line-height: 1.3125;
}
html body.chats-page #appRoot .message-bubble .message-content--media {
  padding: 3px !important;
}

/* ОДИН уровень паддинга: сам бабл — 0, воздух даёт .message-content.
   (было 7x12 на бабле + 4x9x6 на контенте = раздутые баблы) */
html body.chats-page #appRoot .message-bubble {
  padding: 0 !important;
}

/* Пустой блок реакций не занимает место */
html body.chats-page #appRoot .message-reactions-wrap:has(.message-reactions:empty),
html body.chats-page #appRoot .message-reactions:empty {
  display: none !important;
}
/* Непустые реакции — вровень с текстом бабла */
html body.chats-page #appRoot .message-reactions-wrap {
  margin-top: 4px !important;
  padding: 0 9px 6px !important;
}
html body.chats-page #appRoot .message-bubble .message-content--gift {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
html body.chats-page #appRoot .message-bubble .message-text {
  overflow-wrap: break-word;
}
html body.chats-page #appRoot .message-bubble .message-text a {
  color: inherit;
  text-decoration: underline;
}

/* Цвет ссылок/упоминаний/хештегов в бабле */
html body.chats-page #appRoot .message-bubble .post-mention,
html body.chats-page #appRoot .message-bubble .post-hashtag {
  color: #3390ec;
  font-weight: 600;
  text-decoration: none;
}
html body.chats-page #appRoot .message-own .message-bubble .post-mention,
html body.chats-page #appRoot .message-own .message-bubble .post-hashtag {
  color: #2a7a3b;
}
body[data-theme="dark"] #appRoot .message-own .message-bubble .post-mention,
body[data-theme="midnight"] #appRoot .message-own .message-bubble .post-mention,
body[data-theme="graphite"] #appRoot .message-own .message-bubble .post-mention {
  color: #ffffff;
}

/* Имя автора в группе — жирное, цвет по палитре peer (класс задаёт JS) */
html body.chats-page #appRoot .message-bubble .message-author {
  margin: 2px 0 1px !important;
  font-weight: 700 !important;
  font-size: 14px;
  line-height: 1.3;
}
html body.chats-page #appRoot .message-bubble .message-author .message-author__label {
  color: var(--tg-author-link);
}
html body.chats-page #appRoot .message-author.peer-color-0 .message-author__label { color: var(--tg-peer-0); }
html body.chats-page #appRoot .message-author.peer-color-1 .message-author__label { color: var(--tg-peer-1); }
html body.chats-page #appRoot .message-author.peer-color-2 .message-author__label { color: var(--tg-peer-2); }
html body.chats-page #appRoot .message-author.peer-color-3 .message-author__label { color: var(--tg-peer-3); }
html body.chats-page #appRoot .message-author.peer-color-4 .message-author__label { color: var(--tg-peer-4); }
html body.chats-page #appRoot .message-author.peer-color-5 .message-author__label { color: var(--tg-peer-5); }
html body.chats-page #appRoot .message-author.peer-color-6 .message-author__label { color: var(--tg-peer-6); }

/* Время внутри бабла */
html body.chats-page #appRoot .message:not(.message-own) .message-time {
  color: var(--tg-time-in) !important;
}

/* Время — В СТРОКУ с текстом, как в Telegram (не второй строкой):
   .message-body-row = flex, текст слева, время прижато к его концу вниз. */
html body.chats-page #appRoot .message-bubble .message-body-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-end !important;
  column-gap: 6px !important;
  width: max-content !important;
  max-width: 100% !important;
  min-width: 0 !important;
}
html body.chats-page #appRoot .message-bubble .message-body-row .message-text {
  flex: 0 1 auto !important;
  min-width: 0 !important;
}
html body.chats-page #appRoot .message-bubble .message-body-row .message-meta,
html body.chats-page #appRoot .message-bubble .message-meta--inside {
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: flex-end !important;
  margin: 0 0 1px !important;
  white-space: nowrap !important;
  align-self: flex-end !important;
  float: none !important;
  clear: none !important;
}
/* Длинный текст: время переносится вниз-вправо, но остаётся мелким и аккуратным */
html body.chats-page #appRoot .message-bubble .message-body-row .message-meta .message-time {
  line-height: 1.1 !important;
}
html body.chats-page #appRoot .message-own .message-time {
  color: var(--tg-time-out) !important;
}

/* Интервалы: внутри группы 2px, между группами 6px (+10px после последней) */
html body.chats-page #appRoot .message-shell {
  margin-bottom: 6px;
}
html body.chats-page #appRoot .message-shell:has(+ .message-shell .message-stack-middle),
html body.chats-page #appRoot .message-shell:has(+ .message-shell .message-stack-last) {
  margin-bottom: 2px;
}
@supports not selector(:has(*)) {
  html body.chats-page #appRoot .message-shell { margin-bottom: 3px; }
}

/* Аватар у входящих с автором */
html body.chats-page #appRoot .msg-avatar-slot {
  flex-shrink: 0;
  width: 34px;
  margin-inline-end: 8px;
  align-self: flex-end;
}
html body.chats-page #appRoot .msg-avatar-slot .avatar,
html body.chats-page #appRoot .msg-avatar-slot img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

/* ── Цитата ответа внутри бабла (как в Telegram: цветная полоса + tint) ── */
html body.chats-page #appRoot .message-reply-quote {
  display: block;
  margin: 3px 4px 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(51, 144, 236, 0.10);
  border-left: 3px solid #3390ec;
  cursor: pointer;
  overflow: hidden;
}
html body.chats-page #appRoot .message-own .message-reply-quote {
  background: rgba(0, 0, 0, 0.07);
  border-left-color: #2a7a3b;
}
body[data-theme="dark"] #appRoot .message-own .message-reply-quote {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: rgba(255, 255, 255, 0.8);
}
html body.chats-page #appRoot .message-reply-quote .message-reply-author {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #3390ec;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html body.chats-page #appRoot .message-own .message-reply-quote .message-reply-author {
  color: #2a7a3b;
}
body[data-theme="dark"] #appRoot .message-own .message-reply-quote .message-reply-author {
  color: #ffffff;
}
html body.chats-page #appRoot .message-reply-quote .message-reply-snippet {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  color: var(--tg-time-in);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Реакции-пилюли на баблах */
html body.chats-page #appRoot .message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 6px 6px;
}
html body.chats-page #appRoot .reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 22px;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--tg-in-text);
  transition: transform 0.12s ease, background 0.12s ease;
}
html body.chats-page #appRoot .message-own .reaction-pill {
  background: rgba(0, 0, 0, 0.10);
  color: var(--tg-out-text);
}
html body.chats-page #appRoot .reaction-pill:hover {
  transform: scale(1.05);
}
html body.chats-page #appRoot .reaction-pill--mine {
  background: #3390ec;
  color: #ffffff;
}
html body.chats-page #appRoot .reaction-pill .reaction-emoji-img {
  width: 15px;
  height: 15px;
}

/* ─────────────── 2. ДАТА-СЕПАРАТОРЫ И СЕРВИСНЫЕ ПЛАШКИ ─────────────────── */
html body.chats-page #appRoot .chat-date-sep {
  display: flex;
  justify-content: center;
  margin: 10px 0 8px;
  pointer-events: none;
}
html body.chats-page #appRoot .chat-date-sep span {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--tg-service-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

/* ───────────────────────── 3. ШАПКА ЧАТА (КАПСУЛА) ─────────────────────────
   Тёмная КАПСУЛА (border-radius 9999px) — как на референсе Telegram,
   в ЛЮБОЙ теме (в light тоже тёмная — «почему шапка белая» → фикс). */
html body.chats-page #appRoot.app--show-chat .chat-header,
html body.chats-page #appRoot.chat-has-conversation .chat-header,
html body.chats-page > .app > .feed > #appRoot.app--show-chat .chat-header {
  height: 54px !important;
  min-height: 54px !important;
  margin: 8px 8px 0 !important;
  border-radius: 9999px !important;
  background: #1c1c1e !important;
  background-color: #1c1c1e !important;
  background-image: none !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.30) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  gap: 10px !important;
  z-index: 20 !important;
  overflow: hidden !important;
}
/* Светлая тема — шапка ВСЁ РАВНО тёмная капсула */
html body.chats-page[data-theme="light"] #appRoot.app--show-chat .chat-header,
html body.chats-page[data-theme="light"] #appRoot.chat-has-conversation .chat-header,
html body.chats-page[data-theme="light"] > .app > .feed > #appRoot.app--show-chat .chat-header {
  background: #1c1c1e !important;
  background-color: #1c1c1e !important;
  border-radius: 9999px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}
html body.chats-page[data-theme="light"] #appRoot .chat-header .chat-name {
  color: #ffffff !important;
}
html body.chats-page[data-theme="light"] #appRoot .chat-header .chat-status {
  color: #aaaaaa !important;
}
html body.chats-page[data-theme="light"] #appRoot .chat-header .chat-status.chat-status--online-line {
  color: #3390ec !important;
}
html body.chats-page[data-theme="light"] #appRoot .chat-header .chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}
html body.chats-page #appRoot .chat-header .chat-avatar,
html body.chats-page > .app > .feed > #appRoot .chat-header .chat-avatar {
  width: 38px !important;
  height: 38px !important;
  border-radius: 50% !important;
  flex-shrink: 0;
}
html body.chats-page #appRoot .chat-header .chat-name {
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
}
html body.chats-page #appRoot .chat-header .chat-status {
  font-size: 12.5px !important;
  color: var(--tg-panel-muted) !important;
  line-height: 1.15 !important;
}
html body.chats-page #appRoot .chat-header .chat-status.chat-status--online-line {
  color: #3390ec !important;
}
html body.chats-page #appRoot .chat-header .chat-header-btn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
}
html body.chats-page #appRoot .chat-header .chat-header-btn:hover {
  background: rgba(0, 0, 0, 0.06) !important;
}
body[data-theme="dark"] #appRoot .chat-header .chat-header-btn:hover,
body[data-theme="midnight"] #appRoot .chat-header .chat-header-btn:hover,
body[data-theme="graphite"] #appRoot .chat-header .chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}
/* Кнопка поиска в шапке — видна и на телефонах (в Telegram она есть всегда) */
html body.chats-page #appRoot .chat-header .chat-header-btn#chatSearchBtn {
  display: inline-flex !important;
}

/* ───────────────────── 4. ПОИСК ПО ЧАТУ (ПАНЕЛЬ) ────────────────────────── */
html body.chats-page #appRoot .chat-search-panel {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 40;
  border-radius: 16px;
  background: var(--tg-panel-bg);
  border: 1px solid var(--tg-panel-border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  color: var(--tg-panel-text);
}
html body.chats-page #appRoot .chat-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}
html body.chats-page #appRoot .chat-search-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: rgba(127, 127, 127, 0.10);
  padding: 0 12px;
  font-size: 14px;
  color: var(--tg-panel-text);
  outline: none;
}
html body.chats-page #appRoot .chat-search-input:focus {
  background: transparent;
  border-color: #3390ec;
}
html body.chats-page #appRoot .chat-search-nav-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(127, 127, 127, 0.10);
  color: var(--tg-panel-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}
html body.chats-page #appRoot .chat-search-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
html body.chats-page #appRoot .chat-search-counter {
  font-size: 12.5px;
  color: var(--tg-panel-muted);
  min-width: 52px;
  text-align: center;
  white-space: nowrap;
}
html body.chats-page #appRoot .chat-search-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--tg-panel-muted);
  font-size: 16px;
  cursor: pointer;
}
html body.chats-page #appRoot .chat-search-results {
  max-height: min(320px, 45vh);
  overflow-y: auto;
  border-top: 1px solid var(--tg-panel-border);
}
html body.chats-page #appRoot .chat-search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--tg-panel-text);
}
html body.chats-page #appRoot .chat-search-result:hover,
html body.chats-page #appRoot .chat-search-result.is-active {
  background: rgba(51, 144, 236, 0.10);
}
html body.chats-page #appRoot .chat-search-result__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}
html body.chats-page #appRoot .chat-search-result__author {
  font-weight: 700;
  font-size: 13.5px;
  color: #3390ec;
}
html body.chats-page #appRoot .chat-search-result__time {
  font-size: 12px;
  color: var(--tg-panel-muted);
  flex-shrink: 0;
}
html body.chats-page #appRoot .chat-search-result__snippet {
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--tg-panel-text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
html body.chats-page #appRoot .chat-search-result__snippet mark {
  background: rgba(255, 213, 79, 0.55);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
html body.chats-page #appRoot .chat-search-empty {
  padding: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--tg-panel-muted);
}

/* Подсветка сообщения, к которому прыгнули */
html body.chats-page #appRoot .message-search-hit .message-bubble {
  outline: 2px solid #3390ec !important;
  outline-offset: 1px;
  transition: outline-color 1.6s ease;
}

/* ───────────── 5. КОММЕНТАРИИ: ВЕТКИ, ОТВЕТЫ, ЛАЙКИ/ДИЗЛАЙКИ ────────────── */
.comment-item {
  padding: 10px 2px 6px;
  border-top: 1px solid rgba(127, 127, 127, 0.14);
}
.comment-item.comment-item--reply {
  margin-left: 34px;
  position: relative;
}
.comment-item.comment-item--reply::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 4px;
  bottom: 14px;
  width: 14px;
  border-left: 2px solid rgba(127, 127, 127, 0.25);
  border-bottom: 2px solid rgba(127, 127, 127, 0.25);
  border-bottom-left-radius: 10px;
}
.comment-reply-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #3390ec;
  margin-bottom: 2px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.comment-reply-tag b {
  font-weight: 700;
}
.comment-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.comment-like-btn,
.comment-dislike-btn,
.comment-reply-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--rd-muted, #6b7280);
  font-size: 12.5px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 8px;
}
.comment-like-btn:hover,
.comment-dislike-btn:hover,
.comment-reply-btn:hover {
  background: rgba(127, 127, 127, 0.10);
}
.comment-like-btn.is-liked {
  color: #ef4444;
}
.comment-dislike-btn.is-disliked {
  color: #3390ec;
}
.comment-replies-note,
.comment-replies-count {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rd-muted, #6b7280);
  padding: 3px 4px;
}
/* Превью ответа над полем ввода */
.comment-reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin: 0 0 8px;
  border-left: 3px solid #3390ec;
  background: rgba(51, 144, 236, 0.08);
  border-radius: 6px;
  font-size: 13px;
}
.comment-reply-preview__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--rd-muted, #6b7280);
}
.comment-reply-preview__text b {
  color: #3390ec;
}
.comment-reply-preview__cancel {
  border: none;
  background: transparent;
  color: var(--rd-muted, #6b7280);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}

/* ─────────────────────────── 6. ХЕШТЕГИ ─────────────────────────────────── */
.post-hashtag {
  color: #3390ec;
  font-weight: 600;
  text-decoration: none;
}
.post-hashtag:hover {
  text-decoration: underline;
}

/* ──────────────── 7. КНОПКИ-ИКОНКИ ПРОФИЛЯ (подарок/бабл) ───────────────── */
/* Причина бага: unified_page_width.css красит ВСЕ /icons/ в белый, а фон
   кнопки не задан → белое на белом. Задаём контрастный фон и тёмные иконки. */
.profile-btn.profile-btn-icon {
  background: #3390ec !important;
  background-color: #3390ec !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25) !important;
}
.profile-btn.profile-btn-icon:hover {
  background: #2a7ecb !important;
  background-color: #2a7ecb !important;
}
.profile-btn.profile-btn-icon img[src^="/icons/"] {
  filter: brightness(0) invert(1) !important;
  opacity: 1 !important;
}

/* ─────────────────────── 8. СТРАНИЦА ПОИСКА ─────────────────────────────── */
.search-page-wrap {
  width: min(640px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 0 90px;
}
.search-page-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  background: var(--rd-page-bg, #eef0f4);
}
.search-page-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 2px solid transparent;
  border-radius: 21px;
  background: rgba(127, 127, 127, 0.10);
  padding: 0 16px;
  font-size: 15px;
  color: var(--rd-text, #1a1d26);
  outline: none;
}
.search-page-input:focus {
  background: var(--rd-card, #ffffff);
  border-color: #3390ec;
}
.search-page-tabs {
  display: flex;
  gap: 6px;
  margin: 4px 0 12px;
}
.search-page-tab {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: 18px;
  background: rgba(127, 127, 127, 0.10);
  color: var(--rd-text, #1a1d26);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.search-page-tab.is-active {
  background: #3390ec;
  color: #ffffff;
}
.hashtag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hashtag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 18px;
  background: var(--rd-card, #ffffff);
  border: 1px solid var(--rd-border, #dfe3eb);
  color: var(--rd-text, #1a1d26);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.hashtag-chip:hover {
  border-color: #3390ec;
  transform: translateY(-1px);
}
.hashtag-chip__icon {
  color: #3390ec;
  font-weight: 700;
}
.hashtag-chip__count {
  font-size: 12px;
  font-weight: 700;
  color: var(--rd-muted, #6b7280);
  background: rgba(127, 127, 127, 0.10);
  border-radius: 10px;
  padding: 1px 7px;
}
.hashtag-chip--lg .hashtag-chip__name {
  font-size: 16px;
  font-weight: 600;
}
.search-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 6px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--rd-text, #1a1d26);
}
.search-user-item:hover {
  background: rgba(127, 127, 127, 0.08);
}
.search-user-item .avatar,
.search-user-item .avatar-wrap .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}
.search-user-item__name {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.search-user-item__username {
  font-size: 13px;
  color: var(--rd-muted, #6b7280);
}
.search-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rd-muted, #6b7280);
  margin: 14px 2px 8px;
}
.tag-feed-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
}
.tag-feed-header__back {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(127, 127, 127, 0.10);
  color: var(--rd-text, #1a1d26);
  font-size: 18px;
  cursor: pointer;
}
.tag-feed-header__title {
  font-size: 20px;
  font-weight: 800;
  color: #3390ec;
}

/* ────────────────────────── 9. МОБИЛЬНАЯ ВЁРСТКА ────────────────────────── */
@media (max-width: 768px) {
  html body.chats-page #appRoot.app--show-chat .chat-header,
  html body.chats-page #appRoot.chat-has-conversation .chat-header {
    height: 50px !important;
    min-height: 50px !important;
    margin: calc(env(safe-area-inset-top, 0px) + 6px) 6px 0 !important;
    border-radius: 9999px !important;
    background: #1c1c1e !important;
    background-color: #1c1c1e !important;
  }
  html body.chats-page #appRoot .chat-search-panel {
    top: calc(env(safe-area-inset-top, 0px) + 6px);
    left: 6px;
    right: 6px;
  }
  html body.chats-page #appRoot .chat-header .chat-avatar {
    width: 34px !important;
    height: 34px !important;
  }
  html body.chats-page #appRoot .chat-header .chat-name {
    font-size: 14.5px !important;
  }
  html body.chats-page #appRoot .message-bubble .message-content {
    font-size: 14.5px;
  }
  html body.chats-page #appRoot .message-shell:not(.message-shell--own) .message-content,
  html body.chats-page #appRoot .message-shell .message-bubble {
    max-width: calc(100vw - 96px) !important;
  }
  .comment-item.comment-item--reply {
    margin-left: 22px;
  }
  .comment-item.comment-item--reply::before {
    left: -16px;
  }
}
