/* Список чатов, лента сообщений и поле ввода. */

/* ==================================================================
   Строка списка чатов
   ================================================================== */
.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  margin: 0 6px;
  width: calc(100% - 12px);
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--fast) var(--ease);
}

.chat-item:hover {
  background: var(--surface-2);
}

.chat-item[aria-selected="true"] {
  background: var(--accent-tint);
}

.chat-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-item__top,
.chat-item__bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-item__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
  flex: 1;
  min-width: 0;
}

.chat-item__time {
  font-size: 11.5px;
  color: var(--text-faint);
  flex: none;
}

.chat-item__preview {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-item__preview .icon {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--text-faint);
}

/* «Печатает…» подсвечивается акцентом — это живое событие, а не текст. */
.chat-item__activity {
  color: var(--accent-soft);
  font-weight: 500;
}

.chat-item__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.chat-item__status {
  color: var(--text-faint);
  display: inline-flex;
}

.chat-item__status--read {
  color: var(--accent-soft);
}

/* ==================================================================
   Шапка диалога
   ================================================================== */
.conv-header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 10px 0 8px;
  flex: none;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 3;
}

/* Нажатие на имя и аватар открывает профиль — как в концепте. */
.conv-header__peer {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--fast) var(--ease);
}

.conv-header__peer:hover {
  background: var(--surface-2);
}

.conv-header__name {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.1px;
}

.conv-header__status {
  font-size: 12.5px;
  color: var(--text-dim);
}

.conv-header__status--online {
  color: var(--online);
}

.conv-header__status--activity {
  color: var(--accent-soft);
}

.conv-header__back {
  display: none;
}

@media (max-width: 900px) {
  .conv-header__back {
    display: inline-flex;
  }

  .conv-header__close {
    display: none;
  }
}

/* ==================================================================
   Лента сообщений
   ================================================================== */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 16px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* scroll-behavior здесь намеренно не задан.
     Глобальное smooth анимирует ЛЮБУЮ установку scrollTop, включая
     техническую — при перерисовке по галочке прочтения или готовности
     вложения. Лента уезжала с анимацией даже когда пользователь уже внизу и
     содержимое не менялось. Анимация включается точечно из кода: при новом
     сообщении и при переходе к цитате. */
}

.messages__inner {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.messages__loader {
  display: grid;
  place-items: center;
  padding: 14px;
}

/* Разделитель дат — липкий, чтобы при прокрутке было видно, какой сейчас день. */
.day-sep {
  position: sticky;
  top: 6px;
  z-index: 2;
  align-self: center;
  margin: 14px 0 10px;
  padding: 5px 13px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--surface-3) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 2px;
}

/* Отступ между блоками разных отправителей больше, чем внутри блока:
   так переписка визуально разбивается на реплики. */
.msg-row--first {
  margin-top: 12px;
}

.msg-row--own {
  flex-direction: row-reverse;
}

.msg-row__avatar {
  width: 30px;
  flex: none;
}

.bubble {
  position: relative;
  max-width: min(560px, 78%);
  padding: 8px 12px 7px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  font-size: 14.7px;
  line-height: 1.42;
  word-break: break-word;
  overflow-wrap: anywhere;
  animation: pop-in var(--fast) var(--ease);
}

.msg-row--own .bubble {
  background: var(--gradient-bubble);
  color: #fff;
}

/* Хвостик у последнего сообщения в блоке — как в концепте. */
.msg-row--last .bubble {
  border-bottom-left-radius: var(--r-xs);
}

.msg-row--own.msg-row--last .bubble {
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-xs);
}

.bubble--media {
  padding: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.msg-row--own .bubble--media {
  background: var(--gradient-bubble);
}

.bubble--bare {
  padding: 0;
  background: none !important;
}

.bubble__author {
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 2px;
  color: var(--accent-soft);
}

.bubble__text {
  white-space: pre-wrap;
}

/* Время «влетает» в конец последней строки: так пузырь не растёт впустую. */
.bubble__meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 6px -3px -2px 10px;
  font-size: 11px;
  line-height: 1;
  color: var(--text-faint);
  user-select: none;
}

.msg-row--own .bubble__meta {
  color: rgba(255, 255, 255, 0.78);
}

.bubble__meta .icon {
  width: 15px;
  height: 15px;
}

.bubble__edited {
  font-style: italic;
  opacity: 0.75;
}

.bubble--media .bubble__meta {
  position: absolute;
  right: 10px;
  bottom: 9px;
  float: none;
  margin: 0;
  padding: 3px 7px;
  border-radius: var(--r-full);
  background: rgba(6, 6, 12, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.92);
}

/* Цитата */
.reply-quote {
  display: flex;
  gap: 8px;
  padding: 5px 9px;
  margin-bottom: 5px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.09);
  font-size: 13px;
  border-left: 3px solid var(--accent-soft);
  cursor: pointer;
}

.msg-row--own .reply-quote {
  border-left-color: rgba(255, 255, 255, 0.75);
}

.reply-quote__body {
  min-width: 0;
}

.reply-quote__author {
  font-weight: 600;
  font-size: 12.5px;
}

.reply-quote__text {
  color: var(--text-dim);
  font-size: 12.5px;
}

.msg-row--own .reply-quote__text {
  color: rgba(255, 255, 255, 0.8);
}

/* Системное сообщение и отметка о звонке */
.msg-system {
  align-self: center;
  margin: 10px 0;
  padding: 6px 14px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: center;
}

.msg-call {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  min-width: 210px;
}

.msg-call__icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-dim);
  flex: none;
}

.msg-call__icon--missed {
  background: var(--danger-soft);
  color: var(--danger);
}

.msg-call__title {
  font-size: 14px;
  font-weight: 550;
}

.msg-call__sub {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* Действия над сообщением */
.msg-row__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
  flex: none;
}

.msg-row:hover .msg-row__actions,
.msg-row:focus-within .msg-row__actions {
  opacity: 1;
}

@media (hover: none) {
  /* На тач-экранах наведения нет — действия открываются долгим нажатием. */
  .msg-row__actions {
    display: none;
  }
}

.msg-row__actions .icon-btn {
  width: 30px;
  height: 30px;
}

.msg-row__actions .icon {
  width: 16px;
  height: 16px;
}

/* Подсветка при переходе к цитируемому сообщению */
@keyframes highlight-flash {
  0%, 100% { background: transparent; }
  25% { background: var(--accent-tint-strong); }
}

.msg-row--highlight {
  animation: highlight-flash 1.4s var(--ease);
  border-radius: var(--r-md);
}

/* ==================================================================
   Поле ввода
   ================================================================== */
.composer {
  flex: none;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}

.composer__inner {
  width: min(880px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer__box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 4px 4px 4px 6px;
  border-radius: var(--r-xl);
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: border-color var(--fast) var(--ease);
}

.composer__box:focus-within {
  border-color: var(--border-strong);
}

.composer__input {
  flex: 1;
  min-width: 0;
  max-height: 168px;
  padding: 10px 4px;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
  background: none;
  /* Меньше 16px на iOS заставляет Safari масштабировать страницу при фокусе. */
  font-size: max(15px, 1rem);
}

.composer__input::placeholder {
  color: var(--text-faint);
}

.composer__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.composer__send {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-accent);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}

.composer__send:hover {
  background: var(--accent-soft);
}

.composer__send:active {
  transform: scale(0.92);
}

/* Панель ответа над полем ввода */
.composer__reply {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(880px, 100%);
  margin: 0 auto 6px;
  padding: 7px 10px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  font-size: 13px;
}

/* Заблокированный диалог */
.composer--blocked {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ==================================================================
   Профиль собеседника
   ================================================================== */
.profile__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 20px 20px;
}

.profile__name {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.3px;
  text-align: center;
}

.profile__username {
  font-size: 14px;
  color: var(--text-dim);
}

.profile__actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 380px;
  margin-top: 6px;
}

.profile__action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent-soft);
  transition: background var(--fast) var(--ease);
}

.profile__action:hover {
  background: var(--surface-3);
}

.profile__action .icon {
  width: 21px;
  height: 21px;
}

.profile__action--danger {
  color: var(--danger);
}

/* ==================================================================
   Message gestures, multi-select and forward markers (6.2)
   ================================================================== */
.msg-row {
  position: relative;
  transform: translateX(var(--swipe-x, 0px));
  transition: transform 150ms var(--ease), background-color 150ms var(--ease);
  touch-action: pan-y;
  border-radius: var(--r-md);
}

.msg-row--reply-ready {
  --swipe-x: 58px;
}

.msg-row--swiping {
  transition: none;
}


.msg-row__reply-gesture {
  position: absolute;
  left: -36px;
  bottom: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent-soft);
  background: var(--surface-3);
  opacity: 0;
  transform: scale(.75);
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
  pointer-events: none;
}

.msg-row--reply-ready .msg-row__reply-gesture {
  opacity: 1;
  transform: scale(1);
}

.msg-row--selected {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}

.msg-row--selected .bubble {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.bubble__forwarded {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  color: var(--accent-soft);
  font-size: 12.5px;
  font-weight: 650;
}

.msg-row--own .bubble__forwarded {
  color: rgba(255, 255, 255, .82);
}

.conv-header__selection {
  flex: 1;
  min-width: 0;
  font-weight: 650;
}

.forward-picker {
  max-height: min(56vh, 480px);
  overflow: auto;
}

.forward-picker .list__item[aria-selected="true"] {
  background: var(--accent-tint);
}

.forward-picker__check {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}

@media (max-width: 720px) {
  .msg-row__actions { display: none !important; }
  .msg-row--selected { border-radius: 0; }
}

/* ==================================================================
   Поправки светлой темы
   ================================================================== */

/* Кремовый фон — белая карточка. Это и есть смысл тёплой светлой темы:
   фон приглушённый, а сообщение лежит на нём чистым белым листом.
   Одной границы здесь мало — на близких светлотах она почти не видна,
   поэтому форму держит связка «белая заливка + мягкая тёплая тень».
   У своих сообщений ничего этого не нужно: там плотный градиент. */
:root[data-theme="light"] .msg-row:not(.msg-row--own) .bubble {
  background: #ffffff;
  border: 1px solid rgba(90, 74, 48, 0.08);
  box-shadow: 0 1px 2px rgba(90, 74, 48, 0.07);
}

/* Та же логика для остальных «плавающих» поверхностей. */
:root[data-theme="light"] .day-sep,
:root[data-theme="light"] .msg-system {
  border: 1px solid var(--border-soft);
}

/* Подложка цитаты задана белым с прозрачностью — это верно внутри своего
   пузыря с плотной заливкой, но в светлой теме на пузыре собеседника белое
   по светлому исчезает. Там нужен тёмный оттенок. */
:root[data-theme="light"] .msg-row:not(.msg-row--own) .reply-quote {
  background: rgba(43, 38, 32, 0.06);
}

/* ==================================================================
   6.2.6 — реакции, эмодзи и явное групповое удаление
   ================================================================== */
.bubble__reactions {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 7px 0 -1px;
}

.bubble--bare .bubble__reactions {
  justify-content: center;
  margin-top: 8px;
}

.reaction-chip {
  min-width: 35px;
  height: 25px;
  padding: 0 8px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: color-mix(in srgb, var(--surface-3) 88%, transparent);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  transition: transform var(--fast) var(--ease), border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}

.reaction-chip:active { transform: scale(.92); }
.reaction-chip--own {
  border-color: color-mix(in srgb, var(--accent) 58%, transparent);
  background: var(--accent-tint);
  color: var(--accent-soft);
}

.msg-row--own .reaction-chip {
  border-color: rgba(255,255,255,.2);
  background: rgba(4,4,12,.18);
  color: #fff;
}

.msg-row--own .reaction-chip--own {
  border-color: rgba(255,255,255,.62);
  background: rgba(255,255,255,.2);
}

.reaction-chip__emoji { font-size: 15px; }
.reaction-chip__count { font-size: 11px; font-weight: 700; }

.reaction-strip {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 2px;
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.reaction-strip__item {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 20px;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}

.reaction-strip__item:hover,
.reaction-strip__item--active { background: var(--accent-tint); }
.reaction-strip__item:active { transform: scale(.86); }
.reaction-strip__more { color: var(--text-dim); font-size: 23px; }

.emoji-picker {
  max-height: min(62vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 12px;
}

.emoji-picker__section + .emoji-picker__section { margin-top: 14px; }
.emoji-picker__title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 4px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 650;
}

.emoji-picker__grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(34px, 1fr));
  gap: 2px;
}

.emoji-picker__item {
  min-width: 38px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  font-size: 25px;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.emoji-picker__item:hover { background: var(--surface-3); }
.emoji-picker__item:active { transform: scale(.84); }

.conv-header--selection {
  background: color-mix(in srgb, var(--surface) 84%, var(--accent-tint));
}
.conv-header--selection .selection-delete {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 11%, transparent);
}

.composer__emoji { flex: none; }
.composer__box > .icon-btn { width: 38px; height: 38px; }

@media (max-width: 700px) {
  .reaction-strip { grid-template-columns: repeat(9, 1fr); padding: 9px 12px 10px; }
  .reaction-strip__item { width: 100%; height: 38px; font-size: 22px; }
  .emoji-picker__grid { grid-template-columns: repeat(8, minmax(34px, 1fr)); }
  .emoji-picker__item { height: 43px; font-size: 27px; }
  .composer { padding-inline: 7px; }
  .composer__inner { gap: 6px; }
  .composer__box { gap: 1px; padding-left: 3px; }
  .composer__box > .icon-btn { width: 36px; height: 38px; }
  .composer__input { padding-inline: 2px; }
}

@media (max-width: 380px) {
  .emoji-picker__grid { grid-template-columns: repeat(7, minmax(34px, 1fr)); }
  .composer__emoji { display: none; }
}

/* ==================================================================
   6.2.8 — компактные эмодзи и реакции без полноэкранной модалки
   ================================================================== */
.custom-emoji {
  width: 1em;
  height: 1em;
  object-fit: contain;
  vertical-align: -0.16em;
  user-select: none;
  -webkit-user-drag: none;
}

.custom-emoji--inline {
  width: 1.42em;
  height: 1.42em;
  margin-inline: 0.04em;
  vertical-align: -0.34em;
}

.rich-text--emoji-only {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-block: 3px;
  font-size: 34px;
  line-height: 1.05;
}

.rich-text--emoji-only .custom-emoji--inline {
  width: 48px;
  height: 48px;
  margin: 0;
}

.emoji-panel {
  position: fixed;
  z-index: 940;
  width: 344px;
  max-width: calc(100vw - 20px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .34);
  overflow: hidden;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  transform-origin: bottom right;
  animation: emoji-panel-in 130ms var(--ease);
}

.emoji-panel--closing {
  opacity: 0;
  transform: translateY(5px) scale(.98);
  transition: opacity 100ms linear, transform 110ms var(--ease);
  pointer-events: none;
}

@keyframes emoji-panel-in {
  from { opacity: 0; transform: translateY(6px) scale(.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.emoji-panel__tabs {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 7px;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  overflow-x: auto;
  scrollbar-width: none;
}

.emoji-panel__tabs::-webkit-scrollbar { display: none; }

.emoji-panel__tab {
  flex: 1 0 42px;
  min-width: 42px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--text-dim);
  font-size: 20px;
  transition: color 120ms linear, background 120ms linear, transform 120ms var(--ease);
}

.emoji-panel__tab:hover,
.emoji-panel__tab[aria-selected="true"] {
  color: var(--accent-soft);
  background: var(--accent-tint);
}

.emoji-panel__tab:active { transform: scale(.9); }
.emoji-panel__tab-mark { font-size: 22px; font-weight: 800; }

.emoji-panel__viewport {
  max-height: 330px;
  min-height: 260px;
  padding: 9px 9px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.emoji-panel__section-title {
  position: sticky;
  z-index: 2;
  top: -9px;
  margin: -3px -2px 6px;
  padding: 7px 4px 5px;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  font-size: 11px;
  font-weight: 650;
}

.emoji-panel__grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
}

.emoji-panel__item {
  aspect-ratio: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 25px;
  line-height: 1;
  transition: background 100ms linear, transform 100ms var(--ease);
}

.emoji-panel__item:hover { background: var(--surface-3); }
.emoji-panel__item:active { transform: scale(.82); }
.emoji-panel__item--custom .custom-emoji { width: 30px; height: 30px; }

.emoji-panel__custom-hint {
  margin-top: 10px;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

/* Реакции — маленькие чипы под сообщением, а не отдельный тяжёлый блок. */
.bubble__reactions {
  gap: 3px;
  margin-top: 5px;
}

.reaction-chip {
  min-width: 31px;
  height: 23px;
  padding: 0 7px;
  gap: 3px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-3) 78%, transparent);
  box-shadow: none;
}

.reaction-chip__emoji {
  display: inline-grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
}

.reaction-chip__emoji .custom-emoji { width: 17px; height: 17px; }
.reaction-chip__count { font-size: 10.5px; }

/* Полоса быстрых реакций живёт прямо над действиями контекстного меню. */
.reaction-strip {
  display: flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  margin: 1px auto 6px;
  padding: 5px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-2) 94%, transparent);
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}

.reaction-strip__item {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 19px;
}

.reaction-strip__item .custom-emoji { width: 23px; height: 23px; }
.reaction-strip__item:hover,
.reaction-strip__item--active {
  background: var(--accent-tint);
  transform: translateY(-1px);
}

.reaction-strip__more .icon { width: 16px; height: 16px; }

/* Компактная панель должна оставаться доступной и на узком iPhone. */
@media (max-width: 700px) {
  .emoji-panel--mobile {
    left: calc(6px + var(--safe-left));
    right: calc(6px + var(--safe-right));
    bottom: calc(var(--visual-bottom, 0px) + 66px + var(--safe-bottom));
    width: auto;
    max-width: none;
    max-height: min(43dvh, 340px);
    border-radius: 18px;
    transform-origin: bottom center;
  }

  .emoji-panel__viewport {
    min-height: 205px;
    max-height: min(34dvh, 270px);
  }

  .emoji-panel__grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .emoji-panel__item { font-size: 27px; }
  .emoji-panel__item--custom .custom-emoji { width: 32px; height: 32px; }

  .menu--sheet .reaction-strip {
    margin: 0 auto 7px;
    border-radius: 17px;
    padding: 5px;
  }

  .reaction-strip__item {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 21px;
  }

  .composer__emoji { display: grid !important; }
}

@media (max-width: 380px) {
  .emoji-panel__grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .emoji-panel__tab { min-width: 38px; flex-basis: 38px; }
  .reaction-strip__item { width: 32px; height: 32px; flex-basis: 32px; }
}

/* ==================================================================
   6.2.9 — rich composer, emoji-only messages and detached reactions
   ================================================================== */

/* Содержимое сообщения и реакции — один стек. Реакции больше не являются
   частью цветного пузыря и не раздувают его изнутри. */
.msg-row__content {
  min-width: 0;
  max-width: min(560px, 78%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.msg-row--own .msg-row__content { align-items: flex-end; }
.msg-row__content > .bubble { max-width: 100%; }

.msg-row__content > .bubble__reactions {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  margin: -4px 8px 0;
}

.msg-row--own .msg-row__content > .bubble__reactions { align-self: flex-end; }

/* Реакция выглядит как отдельная приклеенная плашка, а не как строка текста
   внутри сообщения. */
.msg-row__content > .bubble__reactions .reaction-chip {
  background: color-mix(in srgb, var(--surface-3) 94%, transparent);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.msg-row__content > .bubble__reactions .reaction-chip--own {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  color: var(--accent-soft);
}

.msg-row--own .msg-row__content > .bubble__reactions .reaction-chip,
.msg-row--own .msg-row__content > .bubble__reactions .reaction-chip--own {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent-soft) 52%, transparent);
  color: var(--text);
}

/* Одно–три эмодзи отправляются без тяжёлого пузыря, как в Telegram. */
.bubble--emoji-only,
.msg-row--own .bubble--emoji-only,
:root[data-theme="light"] .msg-row:not(.msg-row--own) .bubble--emoji-only {
  max-width: none;
  padding: 1px 3px 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  color: var(--text);
}

.rich-text--emoji-only {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  font-size: 40px;
  line-height: 1.08;
  white-space: nowrap;
}

.rich-text--emoji-only[data-emoji-count="2"] { font-size: 38px; }
.rich-text--emoji-only[data-emoji-count="3"] { font-size: 36px; }

/* Пользовательский файл занимает ту же визуальную клетку, что и системный
   Unicode-эмодзи. Больше нет отдельного размера 48px. */
.custom-emoji--inline {
  width: 1.08em;
  height: 1.08em;
  margin-inline: .025em;
  vertical-align: -.22em;
}

.rich-text--emoji-only .custom-emoji--inline {
  width: .96em;
  height: .96em;
  margin: 0;
  vertical-align: 0;
}

.bubble--emoji-only .bubble__meta {
  float: none;
  width: max-content;
  margin: 1px 1px 0 auto;
  padding: 2px 5px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-3) 82%, transparent);
  color: var(--text-faint);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.msg-row--own .bubble--emoji-only .bubble__meta {
  color: var(--text-dim);
  background: color-mix(in srgb, var(--surface-3) 82%, transparent);
}

/* Rich-composer: custom emoji is a real visual atom, while the transport
   value remains :lexa_slug:. */
.composer__input {
  min-height: 42px;
  height: 42px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  outline: none;
  cursor: text;
}

.composer__input[data-empty="true"]::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

.composer__input[aria-disabled="true"] {
  cursor: default;
  opacity: .7;
}

.custom-emoji--composer {
  display: inline-block;
  width: 1.12em;
  height: 1.12em;
  margin: 0 .04em;
  vertical-align: -.24em;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* Во всех местах UI custom emoji и Unicode-эмодзи занимают одну клетку. */
.emoji-panel__item--custom .custom-emoji {
  width: 1em;
  height: 1em;
}

.reaction-chip__emoji .custom-emoji {
  width: 1em;
  height: 1em;
}

.reaction-strip__item .custom-emoji {
  width: 1.08em;
  height: 1.08em;
}

/* На телефоне долгое нажатие открывает наше меню. Системное выделение текста
   и синяя подсветка в этот момент запрещены; копирование остаётся в меню. */
@media (hover: none), (pointer: coarse) {
  .messages .bubble__text,
  .messages .reply-quote__text,
  .messages .file-card__name {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  .menu--sheet .reaction-strip {
    width: min(100%, 390px);
    max-width: 100%;
    justify-content: space-between;
    gap: 0;
    overflow: hidden;
  }

  .menu--sheet .reaction-strip__item {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: 36px;
  }
}

@media (max-width: 700px) {
  .msg-row__content { max-width: 84%; }
  .emoji-panel__item--custom .custom-emoji { width: 1em; height: 1em; }
}
