/* ════════════════════════════════════════════════════════════════════
   Asadram — компоненты
   ════════════════════════════════════════════════════════════════════ */

/* ── Кнопки ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  background: var(--accent);
  color: var(--accent-text);
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: scale(.975); }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 var(--sp-4); font-size: var(--text-sm); }
.btn-lg { height: 52px; padding: 0 var(--sp-6); font-size: var(--text-md); }

.btn-ghost {
  background: var(--bg-input);
  color: var(--fg);
}
.btn-ghost:hover { background: var(--bg-active); }

.btn-outline {
  background: transparent;
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-danger { background: var(--rose-500); color: #fff; }
.btn-danger:hover { background: var(--rose-600); }

.btn-quiet {
  background: transparent;
  color: var(--fg-muted);
  height: auto;
  padding: var(--sp-2);
}
.btn-quiet:hover { color: var(--fg); background: var(--bg-hover); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--r-full);
  color: var(--fg-soft);
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.is-active { color: var(--accent); background: var(--accent-soft); }

/* ── Поля ───────────────────────────────────────────────────────── */
.field {
  width: 100%;
  height: 46px;
  padding: 0 var(--sp-4);
  background: var(--bg-input);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  color: var(--fg);
  transition: box-shadow var(--dur) var(--ease-out),
              background var(--dur) var(--ease-out);
}
.field::placeholder { color: var(--fg-faint); }
.field:focus { box-shadow: 0 0 0 2px var(--accent-ring); }
.field.is-error { box-shadow: 0 0 0 2px var(--rose-500); }

textarea.field {
  height: auto;
  min-height: 92px;
  padding: var(--sp-3) var(--sp-4);
  resize: vertical;
  line-height: var(--leading-normal);
}

.label {
  display: block;
  margin: var(--sp-4) 0 var(--sp-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-muted);
}

/* Мелкие серые пояснения под полями.
   Оба класса выглядят одинаково: .field-hint — короткая строка,
   .field-note — та же подпись, но в несколько строк. */
.field-hint,
.field-note {
  margin-top: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  line-height: 1.45;
  color: var(--fg-muted);
}
.field-error { margin-top: var(--sp-2); font-size: var(--text-sm); color: var(--rose-500); }

.char-count {
  position: absolute;
  right: var(--sp-3);
  bottom: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

/* ── Переключатель ──────────────────────────────────────────────── */
.switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--line-strong);
  transition: background var(--dur) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: var(--r-full);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease-spring);
}
.switch.is-on { background: var(--accent); }
.switch.is-on::after { transform: translateX(20px); }

/* ── Сегменты ───────────────────────────────────────────────────── */
.segmented {
  display: flex;
  padding: 3px;
  background: var(--bg-input);
  border-radius: var(--r-md);
  gap: 2px;
}
.segmented button {
  flex: 1;
  height: 34px;
  border-radius: calc(var(--r-md) - 3px);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-muted);
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.segmented button.is-active {
  background: var(--bg-raised);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* ── Аватар ─────────────────────────────────────────────────────── */
.avatar {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  /* Не обрезаем: раньше кружок статуса стоял на границе и его
     срезало наполовину. Картинку скругляем ей самой. */
  overflow: visible;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: var(--text-lg);
  user-select: none;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.avatar-xs { width: 26px; height: 26px; font-size: var(--text-xs); }
.avatar-sm { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar-lg { width: 84px; height: 84px; font-size: var(--text-2xl); }
.avatar-xl { width: 116px; height: 116px; font-size: var(--text-3xl); }

/* Цвет заглушки выводится из имени — у каждого человека свой,
   и он не меняется от запуска к запуску */
:root {
  --tint-0: #3A63F0;
  --tint-1: #F0844A;
  --tint-2: #16B981;
  --tint-3: #F0546A;
  --tint-4: #3A8DF0;
  --tint-5: #8B5CF0;
  --tint-6: #D89412;
}
.avatar[data-tint="0"] { background: var(--tint-0); }
.avatar[data-tint="1"] { background: var(--tint-1); }
.avatar[data-tint="2"] { background: var(--tint-2); }
.avatar[data-tint="3"] { background: var(--tint-3); }
.avatar[data-tint="4"] { background: var(--tint-4); }
.avatar[data-tint="5"] { background: var(--tint-5); }
.avatar[data-tint="6"] { background: var(--tint-6); }

/* Кружок статуса: целиком внутри аватара, зелёный в сети,
   приглушённо-красный когда нет */
.presence-dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 13px;
  height: 13px;
  border-radius: var(--r-full);
  background: var(--rose-500);
  box-shadow: 0 0 0 2.5px var(--bg);
  opacity: 1;
  transform: none;
  transition: background var(--dur) var(--ease-out);
}
.presence-dot.is-online { background: var(--mint-500); }
.avatar-sm .presence-dot { width: 10px; height: 10px; box-shadow: 0 0 0 2px var(--bg); }
.avatar-lg .presence-dot, .avatar-xl .presence-dot { width: 18px; height: 18px; right: 6px; bottom: 6px; }

/* ── Строка списка ──────────────────────────────────────────────── */
.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  min-height: 72px;
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast) var(--ease-out);
  -webkit-user-select: none;
  user-select: none;
}
.list-row:hover { background: var(--bg-hover); }
.list-row:active { background: var(--bg-active); }
.list-row.is-active { background: var(--accent-soft); }
.list-row.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-top { display: flex; align-items: baseline; gap: var(--sp-2); }
.row-name {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-time {
  margin-left: auto;
  flex: none;
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}
.row-bottom { display: flex; align-items: center; gap: var(--sp-2); }
.row-preview {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-preview .sender { color: var(--fg-soft); }
.row-preview .draft { color: var(--rose-500); }

.unread-badge {
  flex: none;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 21px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.unread-badge.is-muted { background: var(--fg-faint); }

.section-label {
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* ── Значки ─────────────────────────────────────────────────────── */
.verified { color: var(--sky-500); flex: none; }
.premium-mark { color: var(--gold-500); flex: none; }

/* Огонёк серии: медленно дышит, потому что это живой счётчик,
   а не статичная наклейка */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 7px 1px 5px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--ember-500) 12%, transparent);
  color: var(--ember-600);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex: none;
}
[data-theme="dark"] .streak-badge { color: var(--ember-400); }
.streak-badge .flame { animation: breathe 2.6s var(--ease-in-out) infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: .92; }
  50%      { transform: scale(1.14); opacity: 1; }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 28px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-full);
  background: var(--bg-input);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-soft);
}
.chip.is-accent { background: var(--accent-soft); color: var(--accent); }

/* ── Модальные окна ─────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease-out),
              visibility 0s linear var(--dur);
}
.overlay.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }

.modal {
  width: min(440px, 100%);
  max-height: min(84dvh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  transform: translateY(14px) scale(.97);
  transition: transform var(--dur) var(--ease-spring);
}
.overlay.is-open .modal { transform: none; }

.modal-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  flex: none;
}
.modal-head h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  flex: 1;
}
.modal-body { padding: 0 var(--sp-4); overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-4);
  flex: none;
}
.modal-foot .btn { flex: 1; }

/* ── Шторка снизу (телефон) ─────────────────────────────────────── */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  box-shadow: var(--shadow-pop);
  padding-bottom: var(--safe-bottom);
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  will-change: transform;
}
.sheet.is-open { transform: none; }
.sheet-grip {
  width: 38px;
  height: 4px;
  margin: var(--sp-3) auto var(--sp-2);
  border-radius: var(--r-full);
  background: var(--line-strong);
  flex: none;
}
.sheet-title {
  padding: 0 var(--sp-5) var(--sp-3);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  text-align: center;
  flex: none;
}
.sheet-body { padding: 0 var(--sp-4) var(--sp-4); overflow-y: auto; flex: 1; min-height: 0; }

/* ── Контекстное меню ───────────────────────────────────────────── */
.menu {
  position: fixed;
  z-index: var(--z-modal);
  min-width: 208px;
  padding: var(--sp-2);
  background: var(--bg-raised);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  transform-origin: top left;
  animation: menu-in var(--dur-fast) var(--ease-spring);
}
@keyframes menu-in {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: none; }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--text-base);
  color: var(--fg);
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item.is-danger { color: var(--rose-500); }
.menu-item .ico { color: var(--fg-muted); }
.menu-item.is-danger .ico { color: var(--rose-500); }
.menu-sep { height: 1px; margin: var(--sp-2) var(--sp-2); background: var(--line); }

/* ── Всплывающие подсказки ──────────────────────────────────────── */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--sp-4));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transform: translateX(-50%);
  pointer-events: none;
  width: min(420px, calc(100vw - var(--sp-8)));
}
@media (min-width: 901px) {
  .toast-stack { bottom: var(--sp-6); left: auto; right: var(--sp-6); transform: none; }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  color: var(--fg);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease-spring);
  border-left: 3px solid var(--accent);
}
.toast.is-error { border-left-color: var(--rose-500); }
.toast.is-success { border-left-color: var(--mint-500); }
.toast.is-leaving { animation: toast-out var(--dur) var(--ease-out) forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(.97); }
}

/* ── Просмотр изображений ───────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-call);
  display: grid;
  place-items: center;
  background: rgba(4, 5, 12, .93);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease-out), visibility 0s linear var(--dur);
}
.lightbox.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
.lightbox img, .lightbox video {
  max-width: 96vw;
  max-height: 88dvh;
  border-radius: var(--r-sm);
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: calc(var(--safe-top) + var(--sp-4));
  right: var(--sp-4);
  color: #fff;
}
.lightbox-bar {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--safe-bottom) + var(--sp-4));
  display: flex;
  justify-content: center;
  gap: var(--sp-2);
  color: #fff;
}

/* ── Пустой раздел ──────────────────────────────────────────────── */
.empty-hint {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}
.empty-hint .ico { color: var(--fg-faint); }

/* Поле для кода с почты: цифры крупно и вразрядку — так их
   легче сверять с письмом и труднее ошибиться */
.code-field {
  text-align: center;
  font-size: 26px;
  letter-spacing: .38em;
  font-variant-numeric: tabular-nums;
  padding-inline: 0;
  height: 58px;
}
.code-field::placeholder { letter-spacing: .3em; opacity: .35; }

/* Согласия при регистрации */
.consent-box {
  margin-top: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.consent {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--fg-soft);
  cursor: pointer;
}
.consent input {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
}
.consent a { text-decoration: underline; }

/* ════════════════════════════════════════════════════════════════════
   Нижняя панель: жидкий пузырь под активной вкладкой

   Пузырь — псевдоэлемент позади иконки. Он не просто появляется, а
   вспухает с перелётом (cubic-bezier с выбросом за единицу) и слегка
   колышется, пока вкладка активна. Ощущение живого шарика, который
   плавает по своей оси.
   ════════════════════════════════════════════════════════════════════ */

.nav-item {
  position: relative;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  transition: color .24s ease;
}

.nav-item::before {
  content: '';
  position: absolute;
  z-index: -1;
  /* Не перехватывает нажатия: раздувшись, пузырь накрывал соседние
     вкладки и забирал их клики себе — «Контакты» и «Ещё» переставали
     работать. Псевдоэлемент декоративный, события ему не нужны. */
  pointer-events: none;
  left: 50%;
  top: 42%;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent, #5B5BF5) 22%, transparent);
  transform: scale(0);
  opacity: 0;
  transition:
    transform .42s cubic-bezier(.34, 1.56, .64, 1),
    opacity .28s ease;
}

.nav-item.is-active::before {
  transform: scale(1);
  opacity: 1;
  /* После вспухания пузырь начинает медленно дышать и качаться */
  animation: nav-bubble-float 4.2s ease-in-out .42s infinite;
}

/* Иконка чуть подпрыгивает при переключении */
.nav-item svg,
.nav-item .ico {
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

.nav-item.is-active svg,
.nav-item.is-active .ico {
  transform: translateY(-2px) scale(1.12);
}

.nav-item:active svg,
.nav-item:active .ico {
  transform: scale(.88);
}

@keyframes nav-bubble-float {
  0%, 100% {
    transform: scale(1) translate(0, 0);
    border-radius: 50%;
  }
  /* Форма гуляет между кругом и каплей — отсюда «жидкость» */
  25% {
    transform: scale(1.04) translate(.5px, -1px);
    border-radius: 54% 46% 50% 50% / 48% 52% 48% 52%;
  }
  50% {
    transform: scale(1.01) translate(-.5px, .5px);
    border-radius: 46% 54% 52% 48% / 52% 48% 52% 48%;
  }
  75% {
    transform: scale(1.05) translate(1px, .5px);
    border-radius: 52% 48% 46% 54% / 50% 50% 50% 50%;
  }
}

/* Кому мешает движение — уважаем настройку системы */
@media (prefers-reduced-motion: reduce) {
  .nav-item.is-active::before { animation: none; }
  .nav-item svg, .nav-item .ico { transition: none; }
}

/* ════════════════════════════════════════════════════════════════════
   Подсветка выбранного сообщения

   Пелена с размытием поверх ленты, выбранный пузырь — над ней. Взгляд
   остаётся на сообщении, и понятно, к чему относятся пункты меню.
   ════════════════════════════════════════════════════════════════════ */

.msg-veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .2s ease;
  /* Нажатия проходят насквозь: меню закрывается своим обработчиком,
     а пелена не должна перехватывать клики раньше него */
  pointer-events: none;
}

.msg-veil.is-on { opacity: 1; }

/* Выбранное сообщение поднимается над пеленой */
.msg.is-focused,
.message.is-focused,
[data-id].is-focused {
  position: relative;
  z-index: 41;
}

.msg.is-focused .bubble,
.message.is-focused .bubble,
[data-id].is-focused .bubble {
  transform: scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s;
}

/* Меню и панель реакций — выше пелены */
.menu, .react-row {
  z-index: 42;
}

/* ════════════════════════════════════════════════════════════════════
   Звонок: сворачивание в окошко
   ════════════════════════════════════════════════════════════════════ */

.call-collapse {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  cursor: pointer;
  transition: background .2s, transform .18s;
}

.call-collapse:hover { background: rgba(255, 255, 255, .2); }
.call-collapse:active { transform: scale(.9); }

/* Плавающее окошко свёрнутого звонка */
.call-bubble {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  right: 14px;
  z-index: 9997;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #1f6feb;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  max-width: 190px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.call-bubble:active { cursor: grabbing; }

/* Пульсирующая точка — видно, что разговор идёт */
.call-bubble-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #3fb950;
  animation: call-pulse 1.6s ease-in-out infinite;
}

@keyframes call-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

/* ── Упоминания ──────────────────────────────────────────────────── */
.mention {
  color: var(--accent, #5B5BF5);
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s;
}

.mention:hover {
  background: color-mix(in srgb, var(--accent, #5B5BF5) 16%, transparent);
}

/* Длинное меню на маленьком экране прокручивается внутри,
   а не уезжает за нижний край */
.menu {
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ════════════════════════════════════════════════════════════════════
   Загрузка файла — заглушка в ленте
   ════════════════════════════════════════════════════════════════════ */

.msg.is-uploading .bubble {
  min-width: 220px;
  opacity: .85;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-name {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-note {
  font-size: 11.5px;
  opacity: .7;
  margin-top: 2px;
}

.upload-bar {
  height: 3px;
  margin-top: 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .18);
  overflow: hidden;
}

.upload-fill {
  height: 100%;
  width: 4%;
  border-radius: 99px;
  background: currentColor;
  opacity: .9;
  transition: width .2s linear;
}

.msg.is-failed .bubble {
  border: 1px solid var(--rose-500, #f85149);
}

.msg.is-failed .upload-note {
  color: var(--rose-500, #f85149);
  opacity: 1;
}

/* ════════════════════════════════════════════════════════════════════
   Комментарии под постами канала
   ════════════════════════════════════════════════════════════════════ */

.comment-open {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  padding: 6px 11px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, .07);
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .18s;
}

.comment-open:hover { background: rgba(255, 255, 255, .13); }
.comment-open:active { transform: scale(.97); }

.comment-list {
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-row {
  display: flex;
  gap: 10px;
  position: relative;
}

.comment-avatar {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--accent, #5B5BF5);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }

.comment-body { flex: 1; min-width: 0; }

.comment-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.comment-name {
  font-size: 13px;
  font-weight: 600;
}

/* Пометка «канал» — видно, что отвечает не человек, а редакция */
.comment-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent, #5B5BF5) 24%, transparent);
  color: var(--accent, #5B5BF5);
  font-weight: 600;
}

.comment-time {
  font-size: 11px;
  color: var(--fg-faint, #4d5a67);
  margin-left: auto;
}

.comment-text {
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-kill {
  opacity: 0;
  transition: opacity .15s;
  flex: none;
}

.comment-row:hover .comment-kill { opacity: .6; }
.comment-kill:hover { opacity: 1 !important; }

/* Просмотры поста в канале — рядом со временем, приглушённо */
.bubble-meta .views {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  opacity: .75;
}

.bubble-meta .views svg {
  width: 13px;
  height: 13px;
}

/* ════════════════════════════════════════════════════════════════════
   Premium
   ════════════════════════════════════════════════════════════════════ */

.premium-pitch {
  padding: 8px 0 var(--sp-4, 16px);
}

.icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.icon-choice {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), border-color .2s;
}

.icon-choice:hover { transform: translateY(-2px) scale(1.06); }
.icon-choice:active { transform: scale(.92); }
.icon-choice.is-active { border-color: #fff; }

/* ════════════════════════════════════════════════════════════════════
   Истории: обводка аватара, лайки, просмотры

   Зелёная обводка — есть непросмотренное, серая — всё уже видел.
   Кольцо рисуется псевдоэлементом, чтобы не трогать размер аватара.
   ════════════════════════════════════════════════════════════════════ */

.has-story {
  position: relative;
  isolation: isolate;
}

.has-story::before {
  content: '';
  position: absolute;
  inset: -3px;
  z-index: -1;
  border-radius: 50%;
  /* Не перехватывает нажатия: кольцо декоративное, клик идёт аватару */
  pointer-events: none;
  background: conic-gradient(
    from 210deg,
    #3fb950, #2ee06a, #3fb950, #1f9c40, #3fb950
  );
  transition: background .3s, opacity .3s;
}

/* Всё просмотрено — кольцо гаснет до серого */
.has-story.is-seen::before {
  background: none;
  border: 2px solid var(--line, #2a3441);
  inset: -2px;
}

/* Тонкая тёмная прослойка, чтобы кольцо не сливалось с аватаром */
.has-story::after {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: 50%;
  background: var(--bg, #05070a);
  pointer-events: none;
}

.has-story.is-seen::after { inset: 0; }

/* ── Панель под историей ─────────────────────────────────────────── */
.story-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.story-like {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), background .2s;
}

.story-like:active { transform: scale(.9); }

.story-like.is-liked {
  background: rgba(248, 81, 73, .22);
  color: #ff6b63;
}

/* Сердце подпрыгивает в момент нажатия */
.story-like.is-liked svg {
  fill: currentColor;
  animation: heart-pop .34s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.story-views {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, .75);
  font-size: 13px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.story-views:hover { color: #fff; }

/* ── Кто смотрел ─────────────────────────────────────────────────── */
.viewer-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
}

.viewer-name { flex: 1; font-size: 13.5px; }

.viewer-liked {
  color: #ff6b63;
  flex: none;
}

.viewer-time {
  font-size: 11.5px;
  color: var(--fg-faint, #4d5a67);
  flex: none;
}

/* ════════════════════════════════════════════════════════════════════
   Наборы эмодзи
   ════════════════════════════════════════════════════════════════════ */

.pack-cover {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg-input, rgba(255, 255, 255, .06));
}

.pack-cover.is-empty {
  display: grid;
  place-items: center;
  color: var(--fg-faint, #4d5a67);
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 8px;
  margin-top: 14px;
  max-height: 40vh;
  overflow-y: auto;
  padding: 2px;
}

.pack-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--bg-input, rgba(255, 255, 255, .06));
  display: grid;
  place-items: center;
  padding: 5px;
}

.pack-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Крестик появляется при наведении, чтобы не мельтешил постоянно */
.pack-kill {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--rose-500, #f85149);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, transform .15s;
}

.pack-item:hover .pack-kill { opacity: 1; }
.pack-kill:active { transform: scale(.85); }

/* На телефоне наведения нет — показываем всегда */
@media (hover: none) {
  .pack-kill { opacity: .85; }
}

/* ════════════════════════════════════════════════════════════════════
   Меню сообщения — крупные кнопки, как в привычных мессенджерах

   Мелкие пункты трудно попасть пальцем, а на выделенном сообщении
   человек уже сосредоточен — можно позволить себе крупный список.
   ════════════════════════════════════════════════════════════════════ */

.menu {
  min-width: 176px;
  padding: 5px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--bg-raised, #12161c) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  border: 1px solid color-mix(in srgb, #fff 8%, transparent);
}

.menu button,
.menu .menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 11px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--fg, #e6edf3);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}

/* На телефоне кнопки крупнее — под палец, а не под курсор */
@media (pointer: coarse) {
  .menu { min-width: 210px; }
  .menu button,
  .menu .menu-item { padding: 11px 13px; font-size: 15px; gap: 13px; }
}

.menu button:hover,
.menu .menu-item:hover {
  background: color-mix(in srgb, #fff 7%, transparent);
}

.menu button:active { background: color-mix(in srgb, #fff 12%, transparent); }

.menu button svg { width: 17px; height: 17px; flex: none; opacity: .8; }

/* Разделитель перед опасным действием — чтобы не нажать сгоряча */
.menu hr,
.menu .menu-sep {
  height: 1px;
  margin: 5px 8px;
  border: 0;
  background: color-mix(in srgb, #fff 8%, transparent);
}

.menu button.is-danger,
.menu .is-danger { color: var(--rose-500, #f85149); }

/* Ряд реакций над меню — крупнее и с отскоком */
.react-row {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-raised, #12161c) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
}

.react-row button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform .22s cubic-bezier(.34, 1.56, .64, 1), background .15s;
}

.react-row button:hover {
  transform: scale(1.22);
  background: color-mix(in srgb, #fff 8%, transparent);
}

.react-row button:active { transform: scale(.88); }

/* ════════════════════════════════════════════════════════════════════
   Свайпы по чатам — подложки под строкой
   ════════════════════════════════════════════════════════════════════ */

.has-swipe {
  position: relative;
  background: var(--bg, #05070a);
  will-change: transform;
}

.swipe-under {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  pointer-events: none;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  transition: opacity .18s, background .18s;
}

.swipe-under.show-archive { opacity: 1; background: #1f6feb; }
.swipe-under.show-kill { opacity: 1; background: #d32f2f; }

/* Дошли до порога — подложка наливается цветом */
.swipe-under.is-ready { filter: brightness(1.25); }

.swipe-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity .18s;
}

.swipe-hint svg { width: 20px; height: 20px; }

.swipe-under.show-archive .is-archive { opacity: 1; }
.swipe-under.show-kill .is-kill { opacity: 1; }

/* ════════════════════════════════════════════════════════════════════
   Список чатов — вид строки

   Разделители раньше рисовались белым с прозрачностью. В тёмной теме
   это выглядело правильно, а в светлой белая линия на белом фоне
   пропадала — список сливался в полотно. Теперь берём --line из
   токенов: одна запись работает в обеих темах.

   Правила намеренно привязаны к [data-chat-id]: это разметка только
   строк чата. Контакты и настройки пользуются тем же классом
   .list-row, и их вид меняться не должен.
   ════════════════════════════════════════════════════════════════════ */

.chats-list .list-row,
[data-chat-id] {
  position: relative;
}

.chats-list .list-row::after,
[data-chat-id]::after {
  content: '';
  position: absolute;
  left: 84px;              /* начинается после аватара, а не от края */
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--line);
  pointer-events: none;
}

.chats-list .list-row:last-child::after,
[data-chat-id]:last-child::after { display: none; }

/* Аватар — главный ориентир в строке, поэтому крупнее общего */
.list-row[data-chat-id] .avatar {
  width: 56px;
  height: 56px;
  font-size: var(--text-xl);
}

/* Ритм строки: воздуха по вертикали чуть меньше, за счёт этого на
   экран помещается больше переписок */
.list-row[data-chat-id] {
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  min-height: 76px;
}

/* Имя весомее, время и предпросмотр отходят на второй план */
.list-row[data-chat-id] .row-name { font-size: var(--text-md); }
.list-row[data-chat-id] .row-time { font-size: 11px; }
.list-row[data-chat-id] .row-body { gap: 4px; }

/* Полоска слева у выбранного чата закруглена с обоих концов —
   заострённый край выглядел как обрезок */
.list-row[data-chat-id].is-active::before {
  top: 12px;
  bottom: 12px;
  border-radius: 0 var(--r-full) var(--r-full) 0;
}

/* ════════════════════════════════════════════════════════════════════
   Архив — всегда первый элемент списка чатов
   ════════════════════════════════════════════════════════════════════ */
.archive-entry {
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  min-height: 68px;
  cursor: pointer;
}
.archive-entry::after {
  left: 84px;
  right: 0;
  height: 1px;
  background: var(--line);
}
.archive-avatar {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--fg) 10%, transparent);
  color: var(--fg-soft);
}
.archive-avatar svg { width: 22px; height: 22px; }
.archive-entry .row-name { font-size: var(--text-base); font-weight: 600; }
.archive-entry .row-preview { font-size: var(--text-sm); color: var(--fg-muted); }

/* ════════════════════════════════════════════════════════════════════
   Значки у имени
   ════════════════════════════════════════════════════════════════════ */

/* Галочка — везде рядом с именем, одного размера с текстом */
.verified,
.verified-badge,
.profile-name .verified {
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #3b8cff;
  color: #fff;
  padding: 3px;
  box-shadow: 0 1px 5px rgba(59, 140, 255, .5);
}

.verified svg { width: 100%; height: 100%; stroke-width: 3.4; }

/* Алмаз премиума значком, а не эмодзи: системный смайлик рисуется
   шрифтом системы и спорит по размеру с именем */
.premium-mark {
  display: inline-flex;
  align-items: center;
  color: #6fd2ff;
  flex: none;
}

.premium-mark svg {
  width: 15px;
  height: 15px;
  fill: color-mix(in srgb, #6fd2ff 25%, transparent);
}

.name-emoji {
  font-size: .82em;
  line-height: 1;
  flex: none;
  margin-left: 2px;
}

/* Уровень — чуть мельче, чтобы не спорил со статусом */
.level-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  font-size: 10.5px;
}

/* ════════════════════════════════════════════════════════════════════
   Звонок в переписке
   ════════════════════════════════════════════════════════════════════ */

.bubble.is-call {
  background: none !important;
  box-shadow: none;
  padding: 4px 0;
}

.call-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, #fff 7%, transparent);
  color: var(--fg-muted, #8b98a5);
  font-size: 12.5px;
}

.call-note.is-bad { color: var(--rose-500, #f85149); }
.call-note svg { width: 15px; height: 15px; }

/* ════════════════════════════════════════════════════════════════════
   Канал: кнопка звука вместо поля ввода
   ════════════════════════════════════════════════════════════════════ */

/* Композер, накрытый полосой: сам остаётся на месте, просто не
   виден и не принимает нажатия. Так поле нельзя потерять насовсем. */
.composer-wrap.is-locked { position: relative; }

.composer-wrap.is-locked .composer {
  visibility: hidden;
  pointer-events: none;
}

.channel-bar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: var(--bg, #05070a);
  color: var(--fg-muted, #8b98a5);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color .18s;
  z-index: 2;
}

.channel-bar:hover { color: var(--fg, #e6edf3); }
.channel-bar:active { transform: scale(.97); }
.channel-bar svg { width: 19px; height: 19px; }

/* ════════════════════════════════════════════════════════════════════
   Упоминания
   ════════════════════════════════════════════════════════════════════ */

.mention {
  color: var(--accent, #5B5BF5);
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s;
}

.mention:hover {
  background: color-mix(in srgb, var(--accent, #5B5BF5) 16%, transparent);
}

/* ════════════════════════════════════════════════════════════════════
   Состояние сети — пузырёк сверху

   Снизу плашка закрывала поле ввода. Сверху она не мешает и уходит
   сама через несколько секунд.
   ════════════════════════════════════════════════════════════════════ */

.net-bubble {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  z-index: 9995;
  transform: translate(-50%, -140%);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
  background: var(--accent, #5B5BF5);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .38);
  opacity: 0;
  cursor: pointer;
  pointer-events: none;
  transition: transform .34s cubic-bezier(.22, 1, .36, 1), opacity .26s;
}

.net-bubble.is-on {
  transform: translate(-50%, 0);
  opacity: 1;
}

.net-bubble.is-bad { background: #c62828; }
.net-bubble.is-warn { background: #b26a00; }
.net-bubble.is-good { background: #2e7d32; }

/* ════════════════════════════════════════════════════════════════════
   Свайпы по строке чата
   ════════════════════════════════════════════════════════════════════ */

.swipe-shell {
  position: relative;
  overflow: hidden;
}

.swipe-body {
  position: relative;
  z-index: 2;
  background: var(--bg, #05070a);
  will-change: transform;
}

.swipe-pane {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  z-index: 1;
}

.swipe-pane.is-right { left: 0; }
.swipe-pane.is-left { right: 0; }

.swipe-btn {
  width: 72px;
  border: 0;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
}

.swipe-btn svg { width: 22px; height: 22px; }

.swipe-btn.is-archive { background: #1f6feb; }
.swipe-btn.is-mute { background: #4d5a67; }
.swipe-btn.is-kill { background: #d32f2f; }

.swipe-btn:active { filter: brightness(1.2); }

/* ════════════════════════════════════════════════════════════════════
   Экран загрузки
   ════════════════════════════════════════════════════════════════════ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--bg, #05070a);
  opacity: 0;
  transition: opacity .4s ease;
  cursor: pointer;
  padding: 24px;
}

.splash.is-on { opacity: 1; }

.splash-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 340px;
  text-align: center;
}

.splash-logo {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--accent, #5B5BF5);
  color: #fff;
  box-shadow: 0 10px 40px color-mix(in srgb, var(--accent, #5B5BF5) 45%, transparent);
  animation: splash-breathe 2.6s ease-in-out infinite;
}

.splash-logo svg { width: 40px; height: 40px; }

@keyframes splash-breathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.05) translateY(-4px); }
}

.splash-name {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-display, inherit);
  letter-spacing: .5px;
}

/* Полоса не показывает процент — он всё равно неизвестен, просто
   даёт понять, что процесс идёт */
.splash-bar {
  width: 130px;
  height: 3px;
  border-radius: 99px;
  background: var(--line, #16202b);
  overflow: hidden;
}

.splash-bar i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 99px;
  background: var(--accent, #5B5BF5);
  animation: splash-run 1.3s ease-in-out infinite;
}

@keyframes splash-run {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

.splash-day {
  font-size: 12px;
  color: var(--fg-faint, #4d5a67);
  margin-top: 4px;
}

.splash-fact {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--fg-muted, #8b98a5);
  transition: opacity .18s;
  min-height: 44px;
}

/* ════════════════════════════════════════════════════════════════════
   Живой фон — медленные волны

   Два слоя двигаются с разной скоростью: одна волна выглядит
   нарисованной, две дают ощущение глубины.
   ════════════════════════════════════════════════════════════════════ */

.app-bg-waves::before,
.app-bg-waves::after {
  content: '';
  position: fixed;
  inset: -20% -30%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 30% 40%,
      color-mix(in srgb, var(--accent, #5B5BF5) 10%, transparent), transparent 70%),
    radial-gradient(50% 40% at 70% 60%,
      color-mix(in srgb, var(--accent, #5B5BF5) 7%, transparent), transparent 70%);
  filter: blur(38px);
}

.app-bg-waves::before { animation: wave-a 26s ease-in-out infinite; }
.app-bg-waves::after { animation: wave-b 34s ease-in-out infinite; opacity: .7; }

@keyframes wave-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(3%, -2%) scale(1.06); }
  66% { transform: translate(-2%, 3%) scale(.98); }
}

@keyframes wave-b {
  0%, 100% { transform: translate(0, 0) scale(1.04); }
  50% { transform: translate(-4%, -3%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .app-bg-waves::before,
  .app-bg-waves::after,
  .splash-logo,
  .splash-bar i { animation: none; }
}

/* ════════════════════════════════════════════════════════════════════
   Видео в переписке

   Чёрный прямоугольник вместо кадра появлялся из-за preload="metadata":
   часть браузеров не рисует первый кадр, пока видео не тронули.
   ════════════════════════════════════════════════════════════════════ */

.attach-image {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-md, 12px);
  background: #000;
}

.attach-image video,
.attach-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  pointer-events: none;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
}

.attach-image:hover .play-badge { transform: translate(-50%, -50%) scale(1.08); }

.play-badge svg {
  width: 22px; height: 22px;
  fill: currentColor;
  margin-left: 2px;
}

.media-time {
  position: absolute;
  right: 8px; bottom: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
}

/* Медиа без подписи занимает пузырь целиком — иначе цветные края
   торчали из-под картинки рамкой */
.bubble .attach-image.is-only {
  margin: calc(var(--sp-2, 8px) * -1);
  width: calc(100% + var(--sp-2, 8px) * 2);
}

/* ════════════════════════════════════════════════════════════════════
   Эмодзи статуса рядом с именем
   ════════════════════════════════════════════════════════════════════ */

.name-emoji {
  font-size: .85em;
  line-height: 1;
  flex: none;
  margin-left: 1px;
}

/* ════════════════════════════════════════════════════════════════════
   Анимация подарка
   ════════════════════════════════════════════════════════════════════ */

.gift-layer {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .3s ease;
  cursor: pointer;
}

.gift-layer.is-on { opacity: 1; }

.gift-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: scale(.4);
  opacity: 0;
  transition: transform .5s cubic-bezier(.34, 1.56, .64, 1), opacity .3s;
}

.gift-layer.is-on .gift-body { transform: scale(1); opacity: 1; }

.gift-art {
  width: 160px;
  height: 160px;
  object-fit: contain;
  filter: drop-shadow(0 12px 40px rgba(0, 0, 0, .5));
  animation: gift-float 2.4s ease-in-out infinite;
}

.gift-art.is-emoji {
  font-size: 110px;
  line-height: 1;
  display: grid;
  place-items: center;
}

@keyframes gift-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.gift-title {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  max-width: 80vw;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}

/* ── Искры ───────────────────────────────────────────────────────── */
.gift-sparks {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.spark {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: #ffd166;
  opacity: 0;
}

.gift-layer.is-on .spark {
  animation: spark-fly .9s ease-out var(--delay, 0s) forwards;
}

/* Каждая искра летит в свою сторону — иначе выходит ровное колесо */
@keyframes spark-fly {
  0% {
    opacity: 1;
    transform: rotate(var(--angle)) translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(var(--distance)) scale(.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gift-art { animation: none; }
  .gift-layer.is-on .spark { animation: none; }
}

/* ════════════════════════════════════════════════════════════════════
   Наборы стикеров
   ════════════════════════════════════════════════════════════════════ */

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
  margin-top: 14px;
  max-height: 42vh;
  overflow-y: auto;
  padding: 2px;
}

.sticker-cell {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bg-input, rgba(255, 255, 255, .05));
  padding: 6px;
}

.sticker-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Стикер в переписке кликабелен — открывает весь набор */
.bubble.is-sticker .sticker-art {
  cursor: pointer;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
}

.bubble.is-sticker .sticker-art:active { transform: scale(.92); }

/* Пока анимация идёт — лёгкое свечение, чтобы было видно, что живой */
.sticker-art.is-animated,
.sticker-img.is-animated {
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent, #5B5BF5) 35%, transparent));
}

.sticker-img.is-frozen { filter: none; }

/* ════════════════════════════════════════════════════════════════════
   Закрепление и архив
   ════════════════════════════════════════════════════════════════════ */

/* Значок в конце имени, а не в начале: иначе сдвигает все имена
   и список выглядит рваным */
.pin-mark {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  color: var(--fg-faint, #4d5a67);
  flex: none;
}

.pin-mark svg { width: 13px; height: 13px; }

.list-row.is-pinned {
  background: color-mix(in srgb, var(--accent, #5B5BF5) 5%, transparent);
}

/* ── Натягивание к архиву ────────────────────────────────────────── */
.archive-pull {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--fg-faint, #4d5a67);
  background: var(--bg-sunken, rgba(255, 255, 255, .03));
}

.archive-pull-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-input, rgba(255, 255, 255, .08));
  transition: background .22s, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.archive-pull-icon svg { width: 16px; height: 16px; }

/* Готов отпускать — кружок синеет и подрастает */
.archive-pull.is-ready .archive-pull-icon {
  background: #1f6feb;
  color: #fff;
  transform: scale(1.15);
}

.archive-pull.is-ready span { color: var(--fg, #c3ced9); }
.archive-pull.is-ready span::after { content: ' — отпустите'; }

/* Меню и панель реакций — поверх окон и оверлеев.

   У меню и у окна профиля был одинаковый уровень наложения, и меню
   оказывалось под профилем: клик срабатывал, но увидеть его было
   нельзя. Отсюда ощущение, что кнопка не работает. */
.menu,
.react-row {
  z-index: 10000 !important;
}

/* ════════════════════════════════════════════════════════════════════
   Долгое нажатие на сообщение

   На iOS удержание текста вызывает системное меню «Копировать /
   Выделить», и оно перебивает наше. Отключаем его на пузыре —
   копирование остаётся доступным пунктом нашего меню.
   ════════════════════════════════════════════════════════════════════ */

.msg .bubble,
.message .bubble,
[data-id] .bubble {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Внутри выделения текст должен выделяться — иначе не скопировать
   кусок при обычном тапе с растягиванием */
.bubble-text.is-selectable {
  -webkit-user-select: text;
  user-select: text;
}

/* ════════════════════════════════════════════════════════════════════
   Нижняя панель — плавающая капсула

   Не приклеена к краю, а висит над ним: под ней виден фон переписки,
   и панель не спорит с системной полосой жестов на телефоне.

   Стекло собрано из трёх слоёв: размытие фона, полупрозрачная
   заливка и тонкий светлый кант сверху. Одно размытие без канта
   выглядит грязным пятном.
   ════════════════════════════════════════════════════════════════════ */

.app-nav,
nav.bottom-nav,
.nav-bar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 60;

  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;

  width: min(94vw, 420px);
  border-radius: 999px;

  /* Стекло */
  background: color-mix(in srgb, var(--bg-raised, #12161c) 72%, transparent);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);

  /* Кант сверху светлее, снизу темнее — так капсула выглядит объёмной */
  border: 1px solid color-mix(in srgb, #fff 9%, transparent);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, .45),
    inset 0 1px 0 color-mix(in srgb, #fff 10%, transparent);
}

/* ── Вкладка ─────────────────────────────────────────────────────── */
.nav-item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;

  padding: 8px 4px 6px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--fg-faint, #6b7785);

  font: inherit;
  font-size: 10.5px;
  line-height: 1.15;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  transition: color .24s ease, background .28s ease;
}

.nav-item svg,
.nav-item .ico {
  width: 22px;
  height: 22px;
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

/* ── Активная вкладка ────────────────────────────────────────────── */
.nav-item.is-active {
  color: var(--accent, #5B5BF5);
  background: color-mix(in srgb, var(--accent, #5B5BF5) 16%, transparent);
}

.nav-item.is-active svg,
.nav-item.is-active .ico {
  transform: translateY(-1px) scale(1.06);
  /* Заливка контура: активный значок должен читаться мгновенно */
  fill: color-mix(in srgb, var(--accent, #5B5BF5) 22%, transparent);
}

.nav-item:active svg,
.nav-item:active .ico { transform: scale(.9); }

/* Старый пузырь под вкладкой отключён: он налезал на соседей */
.nav-item::before { display: none !important; }

/* Экран не должен упираться в панель */
.app-shell,
.chats-list,
.contacts-list {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
}

@media (prefers-reduced-motion: reduce) {
  .nav-item, .nav-item svg, .nav-item .ico { transition: none; }
}

/* ── Замок на эмодзи без подписки ────────────────────────────────── */
.mood-emoji-row.is-locked .mood-emoji {
  opacity: .38;
  filter: grayscale(.7);
}

.mood-emoji-row.is-locked .mood-emoji:hover {
  opacity: .6;
  filter: grayscale(.3);
}

/* ════════════════════════════════════════════════════════════════════
   Стекло — общий язык интерфейса

   Один набор правил на все всплывающие поверхности: меню, окна,
   панели, кнопки звонка. Раньше каждая была сама по себе, и они
   выглядели как из разных приложений.

   Стекло собирается из трёх слоёв: размытие, полупрозрачная заливка
   и светлый кант сверху. Без канта размытие выглядит грязным пятном.
   ════════════════════════════════════════════════════════════════════ */

.glass,
.popup, .sheet, .modal,
.attach-menu, .emoji-panel {
  background: color-mix(in srgb, var(--bg-raised, #12161c) 78%, transparent);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid color-mix(in srgb, #fff 8%, transparent);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, .5),
    inset 0 1px 0 color-mix(in srgb, #fff 9%, transparent);
}

/* ════════════════════════════════════════════════════════════════════
   Профиль
   ════════════════════════════════════════════════════════════════════ */

/* Высоту обложки задаёт profile.css — там 132px. Здесь её задавать
   нельзя: min-height сильнее height независимо от порядка файлов,
   и обложка растягивалась на 46vh — почти половину экрана пустоты
   над аватаром. Осталась только заливка. */
.profile-cover {
  position: relative;
  background-size: cover;
  background-position: center;
}

/* На низких окнах обложку ужимаем ещё. Селектор из двух классов —
   чтобы правило сработало независимо от того, какой файл подключён
   первым: у profile.css там одноклассовый .profile-cover */
@media (max-height: 720px) {
  .profile-head .profile-cover { height: 104px; }
}

@media (max-height: 560px) {
  .profile-head .profile-cover { height: 84px; }
}

/* Затемнение снизу: имя поверх светлой фотографии иначе не читается */
.profile-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, .25) 0%,
    transparent 35%,
    rgba(0, 0, 0, .55) 78%,
    var(--bg, #05070a) 100%
  );
}

.profile-head { position: relative; }

.profile-name,
.profile-status-row,
.profile-actions {
  position: relative;
  z-index: 2;
}

/* ── Круглые стеклянные действия ─────────────────────────────────── */
.round-action-circle {
  background: color-mix(in srgb, #fff 12%, transparent);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid color-mix(in srgb, #fff 12%, transparent);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, .32),
    inset 0 1px 0 color-mix(in srgb, #fff 16%, transparent);
}

.round-action.is-primary .round-action-circle {
  background: color-mix(in srgb, var(--accent, #5B5BF5) 82%, transparent);
  border-color: color-mix(in srgb, #fff 22%, transparent);
}

/* ── Блоки сведений ──────────────────────────────────────────────── */
.info-line,
.profile-tabs {
  background: color-mix(in srgb, var(--bg-raised, #12161c) 62%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 14px;
}

/* ════════════════════════════════════════════════════════════════════
   Экран звонка — плавающие стеклянные кнопки
   ════════════════════════════════════════════════════════════════════ */

.call-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, #fff 14%, transparent);
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;

  background: color-mix(in srgb, #fff 13%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, .4),
    inset 0 1px 0 color-mix(in srgb, #fff 18%, transparent);

  transition: transform .24s cubic-bezier(.34, 1.56, .64, 1),
              background .2s, opacity .2s;
}

.call-btn:hover { transform: translateY(-2px) scale(1.05); }
.call-btn:active { transform: scale(.9); }

.call-btn svg { width: 24px; height: 24px; }

/* Выключенное состояние — приглушаем, но не прячем */
.call-btn.is-off {
  background: color-mix(in srgb, #fff 6%, transparent);
  opacity: .55;
}

.call-btn.is-decline {
  background: color-mix(in srgb, #e5484d 88%, transparent);
  border-color: color-mix(in srgb, #fff 20%, transparent);
}

.call-btn.is-accept {
  background: color-mix(in srgb, #3fb950 88%, transparent);
  border-color: color-mix(in srgb, #fff 20%, transparent);
}

.call-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 20px;
}

/* ════════════════════════════════════════════════════════════════════
   Наборы в выборе эмодзи
   ════════════════════════════════════════════════════════════════════ */

.emoji-pack-title {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-faint, #4d5a67);
  margin: var(--sp-3, 12px) 0 6px;
}

.emoji-pick.is-custom {
  display: grid;
  place-items: center;
  padding: 4px;
}

.emoji-pick.is-custom img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Кнопка «Пропустить» на экране загрузки ──────────────────────── */
.splash-skip {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
  transform: translateX(-50%);

  padding: 10px 26px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, #fff 12%, transparent);

  background: color-mix(in srgb, #fff 8%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  color: var(--fg-muted, #8b98a5);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s, transform .18s;
}

.splash-skip:hover {
  background: color-mix(in srgb, #fff 14%, transparent);
  color: var(--fg, #e6edf3);
}

.splash-skip:active { transform: translateX(-50%) scale(.94); }

/* Факт кликабелен — меняется на другой */
.splash-fact { cursor: pointer; }

/* ── Фоны профиля ────────────────────────────────────────────────── */
.palette-dot.is-skin {
  aspect-ratio: 1;
  border-radius: 14px;
  box-shadow: inset 0 -20px 26px -20px rgba(0, 0, 0, .85);
}

/* ════════════════════════════════════════════════════════════════════
   Пузыри сообщений

   Время и галочки стоят внутри пузыря, в правом нижнем углу, и
   обтекаются текстом. Раньше они занимали отдельную строку — пузырь
   получался выше, а короткие сообщения выглядели пустыми.
   ════════════════════════════════════════════════════════════════════ */

.bubble {
  position: relative;
  border-radius: 16px;
  padding: 7px 11px 7px;
  max-width: min(74%, 520px);
  word-break: break-word;
}

/* Свои — цветные, чужие — стеклянные */
.msg.is-mine .bubble,
.message.is-mine .bubble {
  background: var(--accent, #5B5BF5);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg:not(.is-mine) .bubble,
.message:not(.is-mine) .bubble {
  background: color-mix(in srgb, var(--bg-raised, #12161c) 88%, transparent);
  border-bottom-left-radius: 6px;
}

/* Время внутри пузыря: текст обтекает его, а не отодвигается вниз */
.bubble-meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 4px;

  margin: 6px -3px -2px 10px;
  font-size: 10.5px;
  line-height: 1;
  opacity: .65;
  white-space: nowrap;
  user-select: none;
}

.msg.is-mine .bubble-meta { opacity: .8; }

.bubble-meta svg { width: 14px; height: 14px; }

/* Прочитано — голубые галочки, как принято */
.check.is-read { color: #6fd2ff; opacity: 1; }
.check.is-pending { opacity: .5; }

/* Пузырь только с картинкой — время поверх, в углу */
.bubble.has-only-media .bubble-meta {
  position: absolute;
  right: 10px;
  bottom: 8px;
  margin: 0;
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  opacity: 1;
}

/* Имя автора в группах — цветное, чтобы различать людей взглядом */
.bubble-author {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
  color: color-mix(in srgb, var(--accent, #5B5BF5) 75%, #fff);
}

/* Цитата ответа — полоса слева, как принято */
.reply-quote {
  display: block;
  margin: 0 0 5px;
  padding: 4px 9px;
  border-left: 3px solid currentColor;
  border-radius: 6px;
  background: color-mix(in srgb, #fff 8%, transparent);
  font-size: 12.5px;
  opacity: .85;
}

/* Реакции — под пузырём, не внутри */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  clear: both;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, #fff 10%, transparent);
  color: inherit;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), background .18s;
}

.reaction:active { transform: scale(.9); }

.reaction.is-mine {
  background: color-mix(in srgb, var(--accent, #5B5BF5) 30%, transparent);
}
