/* Reset + base */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}

body {
  /* Prevent rubber-band background flash on iOS */
  overflow: hidden;
}

img, svg { display: block; max-width: 100%; }

button, input, textarea, select {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

a { color: var(--c-red-text); text-decoration: none; }
a:hover { color: var(--c-accent-hover); }

:focus-visible {
  outline: 2px solid var(--c-ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Типографика заголовков (экраны могут опционально вешать .h1/.h2/.h3). */
h1, h2, h3, h4 { letter-spacing: var(--ls-heading); line-height: var(--lh-tight); }
.h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-heading); line-height: var(--lh-tight); }
.h2 { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: var(--lh-tight); }
.h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: -0.015em; line-height: var(--lh-tight); }
.title { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.num, .tabular { font-variant-numeric: tabular-nums; }

/* App shell layout */
#root {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  /* Ведущая раскладка: [назад] [действия] [заголовок]. Действия держим слева,
     т.к. нативные кнопки Telegram (закрыть/меню) висят в правом верхнем углу и
     перекрывали наши иконки. */
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: max(var(--sp-3), var(--safe-left));
  padding-right: max(var(--sp-3), var(--safe-right));
  /* Сплошной фон без backdrop-filter: blur липкого топбара пересчитывался
     каждый кадр при прокрутке — это давало «дёрганье». */
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border-soft);
}

.topbar__title {
  margin: 0 0 0 var(--sp-1);
  flex: 1;
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__back { flex-shrink: 0; }
.topbar__actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}
.topbar__back,
.topbar__action {
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--c-fg);
  border-radius: var(--r-pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--d-fast) var(--ease-out),
              transform var(--d-press) var(--ease-out);
}
.topbar__back:hover,
.topbar__action:hover { background: var(--c-surface); }
.topbar__back:active,
.topbar__action:active { transform: scale(0.94); }
/* В ведущей раскладке скрытую кнопку «назад» убираем из потока, иначе перед
   действиями остаётся пустой отступ. */
.topbar__back[hidden] { display: none; }

.topbar__back svg,
.topbar__action svg { width: 22px; height: 22px; stroke-width: 2; }

/* Звоночек уведомлений + бейдж непрочитанных: 16px акцентный кружок с
   обводкой в цвет фона, 9px/800. */
.topbar__bell { position: relative; }
.topbar__badge {
  position: absolute;
  top: 7px; right: 7px;
  min-width: 16px; height: 16px;
  padding: 0 3px;
  border-radius: var(--r-pill);
  background: var(--c-accent);
  color: var(--c-on-accent);
  font-size: 9px;
  font-weight: 800;
  line-height: 12px;
  text-align: center;
  border: 2px solid var(--c-bg);
  font-variant-numeric: tabular-nums;
  animation: dot-in var(--d-base) var(--ease-spring);
}
.topbar__badge[hidden] { display: none; }

/* Screen container */
.screen {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: var(--sp-4) max(var(--sp-4), var(--safe-left));
  padding-right: max(var(--sp-4), var(--safe-right));
  padding-bottom: calc(var(--sp-6) + var(--bottomnav-h) + var(--safe-bottom));
  scroll-behavior: smooth;
}

/* ============================================================
   Bottom navigation — плавающая капсула.
   Разметка неизменна (пункты — прямые дети .bottomnav), поэтому капсула
   рисуется псевдоэлементом ::before, а внешние отступы (6px 12px 10px+safe)
   и внутренние (6px 4px) сложены в padding самой навигации.
   .bottomnav__pill — один элемент-индикатор (создаёт router.js), который
   скользит между вкладками; без JS активная вкладка подсвечивается ::before
   (см. .bottomnav:not(.has-pill)). */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding: 12px 16px calc(16px + var(--safe-bottom));
  background: var(--c-bg);
  z-index: 20;
  isolation: isolate;
}
.bottomnav::before {
  content: "";
  position: absolute;
  top: 6px; left: 12px; right: 12px;
  bottom: calc(10px + var(--safe-bottom));
  background: var(--c-surface);
  border-radius: 28px;
  box-shadow: var(--shadow-card), 0 -6px 24px rgba(0, 0, 0, 0.35);
  z-index: 0;
  pointer-events: none;
}

.bottomnav__item {
  position: relative;
  z-index: 2;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  padding: 0 2px;
  color: var(--c-fg-muted);
  font-size: 10.5px;
  font-weight: var(--fw-semibold);
  line-height: 13px;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--r-md);
  -webkit-tap-highlight-color: transparent;
  transition: color var(--d-fast) var(--ease-out),
              transform var(--d-press) var(--ease-out);
}
.bottomnav__item > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Иконка 21px в слоте 48×30: слот образуют вертикальные поля иконки. */
.bottomnav__item svg,
.bottomnav__item i[data-lucide] {
  position: relative;
  z-index: 1;
  width: 21px; height: 21px;
  margin: 4.5px 0;
  stroke-width: 2;
  transition: transform var(--d-base) var(--ease-spring),
              color var(--d-fast) var(--ease-out);
}
.bottomnav__item:hover { color: var(--c-fg); }
.bottomnav__item:active { transform: scale(0.97); }
.bottomnav__item.is-active { color: var(--c-fg); font-weight: var(--fw-bold); }
.bottomnav__item.is-active svg { color: #fff; }

/* Скользящая «таблетка» под иконкой активной вкладки (позицию ставит JS). */
.bottomnav__pill {
  position: absolute;
  top: 0; left: 0;
  width: 48px; height: 30px;
  border-radius: 15px;
  background: var(--grad-red);
  box-shadow: var(--glow-accent);
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  will-change: transform;
  transition: transform var(--d-slow) var(--ease-spring),
              width var(--d-slow) var(--ease-spring),
              height var(--d-slow) var(--ease-spring),
              opacity var(--d-fast) var(--ease-out);
}
.bottomnav__pill.is-visible { opacity: 1; }
.bottomnav__pill.is-jump { transition: opacity var(--d-fast) var(--ease-out); }

/* Fallback без JS-индикатора: статичная таблетка на активном пункте. */
.bottomnav:not(.has-pill) .bottomnav__item.is-active::before {
  content: "";
  position: absolute;
  top: 3px;
  left: calc(50% - 24px);
  width: 48px; height: 30px;
  border-radius: 15px;
  background: var(--grad-red);
  box-shadow: var(--glow-accent);
  z-index: 0;
  animation: dot-in var(--d-base) var(--ease-spring);
}

@keyframes dot-in {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Узкие телефоны: шесть подписей («Переписки», «Настройки») иначе режутся. */
@media (max-width: 430px) {
  .bottomnav { padding-left: 12px; padding-right: 12px; }
  .bottomnav::before { left: 8px; right: 8px; }
  .bottomnav__item { font-size: 9.5px; padding: 0; letter-spacing: -0.02em; }
}

/* ============================================================
   Motion
   ============================================================ */

/* Вход экрана: только на новом экране, без анимации выхода. `contain`
   изолирует раскладку поддерева, чтобы паинт списка не дёргал соседей. */
.screen > .screen-content { contain: content; }
.page-enter { animation: pgIn var(--d-base) var(--ease-out) both; }
@keyframes pgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Каскад списка: UI.stagger вешает .stagger-in на первые N детей .list и
   задаёт animation-delay через инлайн-стиль. */
.stagger-in { animation: stIn 240ms var(--ease-out) both; }
@keyframes stIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Нажатие: лёгкое сжатие + подсветка на hover. Экраны могут вешать .pressable
   на любой элемент. */
.pressable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--d-press) var(--ease-out),
              filter var(--d-fast) var(--ease-out);
}
.pressable:hover { filter: brightness(1.08); }
.pressable:active { transform: scale(0.97); }

/* Тряска при ошибке: UI.shake() вешает .shake на #screen (или на узел). */
.shake { animation: shake 0.46s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* Спиннер: кольцо 16px, верхний сегмент — currentColor. */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}
.spinner--lg { width: 24px; height: 24px; border-width: 3px; }

/* Живой статус: точка с «пингом». */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  color: var(--c-fg-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  white-space: nowrap;
}
.live-pill__dot {
  position: relative;
  width: 7px; height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
}
.live-pill__dot::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
}
.live-pill.on  { color: var(--c-green); background: var(--c-green-soft); }
.live-pill.off { color: var(--c-fg-dim); }
.live-pill.warn { color: var(--c-warn); background: var(--c-warn-soft); }
.live-pill.on .live-pill__dot::after,
.live-pill.warn .live-pill__dot::after { animation: ping 1.8s var(--ease-out) infinite; }
@keyframes ping {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(2.6); opacity: 0; }
}

@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes scale-in {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Loading skeleton: проявляется мягко (сам показ откладывает UI.setScreen на
   350 мс — на быстрых загрузках заглушки вообще не мелькают). */
.skeleton {
  position: relative;
  background: var(--c-surface);
  border-radius: var(--r-md);
  overflow: hidden;
  animation: sk-in 200ms var(--ease-out) both;
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  animation: shimmer 1.4s linear infinite;
}
@keyframes sk-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .page-enter, .stagger-in, .skeleton { animation: none !important; opacity: 1; }
  .live-pill__dot::after { animation: none !important; }
}

/* ============================================================
   Toast — карточка с иконкой в кружке цвета типа.
   ============================================================ */
.toast-region {
  position: fixed;
  left: var(--shell-left); right: 0;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + var(--sp-3));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
  z-index: 30;
  padding: 0 var(--sp-4);
}
.toast {
  --toast-kind: var(--c-blue);
  --toast-kind-soft: var(--c-info-soft);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--c-surface);
  color: var(--c-fg);
  border-radius: var(--r-toast);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-pop), 0 0 0 1px var(--toast-kind-soft) inset;
  animation: toast-in 420ms var(--ease-sheet) both;
  will-change: transform, opacity;
}
.toast.is-success { --toast-kind: var(--c-green); --toast-kind-soft: var(--c-green-soft); }
.toast.is-error   { --toast-kind: var(--c-accent); --toast-kind-soft: var(--c-accent-soft); }
.toast.is-warn    { --toast-kind: var(--c-warn); --toast-kind-soft: var(--c-warn-soft); }
.toast__icon {
  width: 34px; height: 34px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--toast-kind-soft);
  color: var(--toast-kind);
}
.toast__icon svg, .toast > svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--toast-kind); }
.toast__body { flex: 1; min-width: 0; }
.toast__title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--toast-kind);
  line-height: 1.3;
  letter-spacing: 0;
}
.toast__text { line-height: 1.35; overflow-wrap: anywhere; }
.toast.is-leaving { animation: toast-out 273ms var(--ease-sheet) forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(12px) scale(0.97); }
}

/* Push — всплывашка СВЕРХУ (в отличие от .toast, который снизу).
   Показывается, пока Mini App открыт: «пришло сообщение — ответьте руками».
   Кликабельна: тап уводит в чат контакта. */
.push-region {
  position: fixed;
  left: var(--shell-left); right: 0;
  top: calc(var(--safe-top) + var(--sp-2));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  pointer-events: none;
  z-index: 40;
  padding: 0 var(--sp-3);
}
.push {
  pointer-events: auto;
  cursor: pointer;
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--c-surface);
  color: var(--c-fg);
  padding: var(--sp-3);
  border-radius: var(--r-toast);
  box-shadow: var(--shadow-pop), 0 0 0 1px var(--c-accent-soft) inset, inset 3px 0 0 var(--c-accent);
  animation: push-in 420ms var(--ease-sheet) both;
  will-change: transform, opacity;
}
.push__icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--c-accent-soft);
  color: var(--c-red-text);
}
.push__icon svg { width: 18px; height: 18px; }
.push__body { min-width: 0; flex: 1; }
.push__title {
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.push__sub {
  font-size: var(--fs-xs); color: var(--c-fg-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.push.is-leaving { animation: push-out 273ms var(--ease-sheet) forwards; }

@keyframes push-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes push-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.97); }
}

/* Появление сообщения в чате.
   Класс вешается только на ДОБАВЛЕННЫЕ пузыри (см. appendBubbles) — при первом
   рендере списка анимации нет, иначе весь диалог «оживает» разом. */
.dialog-bubble.is-entering {
  animation: bubble-in var(--d-base) var(--ease-sheet);
}
.dialog-bubble.is-temp.is-pending { opacity: 0.62; }
.dialog-bubble { transition: opacity var(--d-fast) ease; }
.dialog-bubble.is-leaving {
  animation: bubble-out var(--d-base) var(--ease-in, ease-in) forwards;
  pointer-events: none;
}
/* Длинный тап по сообщению не должен выделять текст и звать меню WebView. */
.dialog-bubble {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.dialog-bubble.is-selectable { -webkit-user-select: text; user-select: text; }

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes bubble-out {
  to { opacity: 0; transform: scale(0.96); max-height: 0; margin: 0; padding: 0; }
}

/* Запись голосового в композере */
.composer__mic.is-recording {
  color: var(--c-danger);
  animation: mic-pulse 1.1s ease-in-out infinite;
}
.voice-rec {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-2) var(--sp-1);
}
.voice-rec__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--c-danger); flex-shrink: 0;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
.voice-rec__time { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.voice-rec__hint { color: var(--c-fg-muted); font-size: var(--fs-xs); flex: 1; }

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* Уведомления: «Подробнее» + панель полного текста причины */
.notif-more {
  flex-shrink: 0;
  align-self: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--c-red-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  padding: 2px 10px;
  white-space: nowrap;
}
.notif-details {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--c-fg);
  background: var(--c-input);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}

/* ============================================================
   Адаптив — планшет и десктоп
   • Телефон (<768px): одна колонка + нижняя навигация (базовые стили выше).
   • Планшет (768–1023px): шире гутеры и читаемая колонка, навигация снизу.
   • Десктоп (≥1024px): нижняя навигация превращается в левый сайдбар,
     оболочка занимает весь экран, читаемая колонка центрируется, чтобы
     длина строки оставалась комфортной (line-length-control).
   Скрытый на телефоне/планшете бренд сайдбара. */
.bottomnav__brand { display: none; }

/* ---------- Планшет ---------- */
@media (min-width: 768px) and (max-width: 1023.98px) {
  :root { --content-max: 860px; }
  .screen { padding-left: var(--sp-8); padding-right: var(--sp-8); }
  .screen > .screen-content { max-width: 760px; margin: 0 auto; }
}

/* ---------- Десктоп ---------- */
@media (min-width: 1024px) {
  :root {
    /* Читаемая колонка (composer/sheet/screen-content ориентируются на неё). */
    --content-max: 980px;
    /* Fixed-элементы центрируются справа от сайдбара. */
    --shell-left: var(--sidebar-w);
  }

  /* Мягкая красноватая подсветка сверху — как у 777 GAMES на ПК. */
  html, body { background: var(--c-bg); }
  body { background-image: var(--grad-desktop-bg); background-attachment: fixed; }

  /* Оболочка на весь экран: сайдбар слева, топбар + контент справа. */
  #root {
    max-width: none;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "nav topbar"
      "nav screen";
  }
  .topbar { grid-area: topbar; background: transparent; }
  .screen { grid-area: screen; }

  /* Нижняя навигация → вертикальный сайдбар. position: relative нужен для
     абсолютно позиционированной таблетки .bottomnav__pill. */
  .bottomnav {
    grid-area: nav;
    position: relative;
    left: auto; right: auto; bottom: auto;
    height: auto;
    min-height: 0;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
    padding: var(--sp-3);
    padding-bottom: calc(var(--sp-3) + var(--safe-bottom));
    border-right: 1px solid var(--c-border-soft);
    background: var(--c-surface);
    overflow-y: auto;
  }
  .bottomnav::before { display: none; }

  .bottomnav__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-3) var(--sp-5);
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    letter-spacing: -0.02em;
    color: var(--c-fg);
  }
  .bottomnav__brand svg { width: 22px; height: 22px; color: var(--c-accent); }

  .bottomnav__item {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--sp-3);
    height: 46px;
    min-height: 46px;
    padding: 0 var(--sp-3);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1.2;
    color: var(--c-fg-muted);
    transition: color var(--d-fast) var(--ease-out),
                background var(--d-fast) var(--ease-out),
                transform var(--d-press) var(--ease-out);
  }
  .bottomnav__item svg,
  .bottomnav__item i[data-lucide] { width: 20px; height: 20px; margin: 0; }
  .bottomnav__item:hover { background: var(--c-surface-2); color: var(--c-fg); }
  .bottomnav__item.is-active {
    color: var(--c-fg);
    font-weight: var(--fw-semibold);
  }
  /* Фон hover не должен закрывать скользящую таблетку под активным пунктом. */
  .bottomnav.has-pill .bottomnav__item.is-active:hover { background: transparent; }
  .bottomnav__item.is-active svg { transform: none; color: #fff; }

  /* Таблетка на сайдбаре покрывает весь пункт (размер ставит JS). */
  .bottomnav__pill { border-radius: var(--r-md); }
  /* Fallback без JS-индикатора: статичный градиент на активном пункте. */
  .bottomnav:not(.has-pill) .bottomnav__item.is-active {
    background: var(--grad-red);
    box-shadow: var(--glow-accent);
  }
  .bottomnav:not(.has-pill) .bottomnav__item.is-active::before { display: none; }

  /* Топбар внутри колонки контента (уже не на всю ширину). */
  .topbar {
    padding-left: var(--sp-6);
    padding-right: var(--sp-6);
  }

  /* Читаемая колонка: заполняем оболочку, но держим комфортную меру строки. */
  .screen {
    padding: var(--sp-6) var(--sp-8);
    padding-bottom: var(--sp-8);
  }
  .screen > .screen-content {
    max-width: var(--content-max);
    margin: 0 auto;
  }
}

/* ---------- ПК: сплит-вью «Переписки» (как Telegram Desktop) ----------
   Три колонки: фильтры | список чатов | открытый диалог. Внешний скролл
   экрана отключаем — каждая колонка скроллится независимо. */
@media (min-width: 1024px) {
  .screen.is-split {
    padding: 0;
    overflow: hidden;
  }
  .screen.is-split > .screen-content {
    max-width: none;
    margin: 0;
    height: 100%;
  }

  .chats-split {
    display: grid;
    /* Фильтры переехали в шапку списка — отдельная колонка под них больше не
       нужна, освободившиеся ~170px уходят переписке. */
    grid-template-columns: minmax(292px, 340px) 1fr;
    height: 100%;
    min-height: 0;
  }

  .chats-split__list {
    border-right: 1px solid var(--c-border-soft);
    overflow-y: auto;
    min-height: 0;
    scrollbar-gutter: stable;
    padding: var(--sp-4);
  }

  /* Шапка списка: ряды кнопок «сеть» и «категория». Липкая — при прокрутке
     длинного списка категории остаются под рукой. */
  .chats-list-head {
    position: sticky;
    top: calc(var(--sp-4) * -1);
    z-index: 5;
    margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) var(--sp-3);
    padding: var(--sp-3) var(--sp-4) var(--sp-2);
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border-soft);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
  }
  .chats-filter-row {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
  }
  .chats-filter-row .btn {
    flex: 1 1 auto;
    justify-content: center;
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
    white-space: nowrap;
  }

  .chats-split__convo {
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .chats-split__convo .convo-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--sp-5) var(--sp-6);
    scrollbar-gutter: stable;
  }
  /* Крупнее шрифт в истории чата (правая колонка) — на ПК мелкий fs-sm читается
     тяжело. У пузырей fontSize задан инлайном, поэтому !important. */
  .chats-split__convo .dialog-bubble {
    font-size: var(--fs-md) !important;
    max-width: 74% !important;
  }

  /* Открытый в панели чат подсвечен в списке. */
  #chats-list-body .row.is-open {
    background: var(--c-accent-soft);
    box-shadow: inset 0 0 0 1px var(--c-accent);
  }

  /* Композер в правой колонке — обычный поток, прижат к низу (не fixed).
     Селектор .composer.composer--pane (специфичность 0,2,0) обязателен: базовое
     `.composer { position: fixed }` живёт в components.css, который грузится
     ПОЗЖЕ app.css, и при равной специфичности перебивал бы одиночный
     `.composer--pane` — тогда композер оставался fixed и перекрывал список чатов. */
  .composer.composer--pane {
    position: static;
    left: auto; right: auto; bottom: auto;
    max-width: none;
    margin: 0;
    padding: var(--sp-3) var(--sp-4);
    background: var(--c-bg);
    border-top: 1px solid var(--c-border-soft);
    pointer-events: auto;
  }
}

/* ============================================================
   Загрузка: семёрка 777 с бегущим бликом (как в 777 GAMES)
   ============================================================ */
.logo7 path { fill: #ffffff; transform-box: fill-box; transform-origin: center; }
.logo7 .logo-facet { animation: logoFacet 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes logoFacet {
  0%   { fill: #ffffff; filter: none; }
  18%  { fill: #ff5c85; filter: drop-shadow(0 0 6px rgba(255, 46, 99, 0.95)); transform: scale(1.06); }
  40%  { fill: #ffd6e0; filter: drop-shadow(0 0 3px rgba(255, 46, 99, 0.5)); transform: scale(1); }
  100% { fill: #ffffff; filter: none; }
}

/* Компактный лоадер внутри экрана / шторки */
.loader-777 {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 22px 0 14px;
  animation: fade-in 220ms var(--ease-out) both;
}
.loader-777 .logo7 { position: relative; filter: drop-shadow(0 0 14px rgba(254, 0, 55, 0.75)); }
.loader-777__glow {
  position: absolute; width: 140px; height: 140px; border-radius: 50%;
  top: 50%; left: 50%; transform: translate(-50%, -56%);
  background: radial-gradient(circle, rgba(254, 0, 55, 0.28) 0%, rgba(254, 0, 55, 0) 66%);
  filter: blur(6px); pointer-events: none;
  animation: loaderPulse 1.5s ease-in-out infinite;
}
@keyframes loaderPulse { 0%, 100% { opacity: 0.55; transform: translate(-50%, -56%) scale(0.92); } 50% { opacity: 1; transform: translate(-50%, -56%) scale(1.06); } }
.loader-777__text { font-size: var(--fs-xs); color: var(--c-fg-dim); letter-spacing: 0.04em; }
.list > .loader-777 + .skeleton { margin-top: 4px; }

/* Сплэш при старте */
.splash {
  position: fixed; inset: 0; z-index: 9999; background: var(--c-bg);
  display: grid; place-items: center; overflow: hidden;
  transition: opacity 450ms ease-in-out, transform 450ms ease-in-out;
}
.splash.is-out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.splash__glow {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(254, 0, 55, 0.22) 0%, rgba(254, 0, 55, 0) 65%);
  filter: blur(10px);
}
.splash__stack { position: relative; display: flex; flex-direction: column; align-items: center; gap: 24px; width: min(340px, 86vw); }
.splash__row { display: flex; gap: 14px; align-items: center; height: 130px; }
.splash__seven {
  position: relative; width: 78px; height: 96px; display: grid; place-items: center;
  transform: scale(0.9); opacity: 0.42;
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1), opacity 520ms ease;
}
.splash__seven .logo7 { position: relative; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6)); transition: filter 300ms ease; }
.splash__seven.is-on { transform: scale(1.14) translateY(-6px); opacity: 1; }
.splash__seven.is-on .logo7 { filter: drop-shadow(0 0 16px rgba(254, 0, 55, 0.85)); }
.splash__halo {
  position: absolute; inset: -18px; border-radius: 28px; opacity: 0;
  background: radial-gradient(circle, rgba(254, 0, 55, 0.55) 0%, rgba(254, 0, 55, 0.18) 45%, rgba(254, 0, 55, 0) 72%);
  filter: blur(4px); transition: opacity 420ms ease;
}
.splash__seven.is-on .splash__halo { opacity: 1; }
.splash__brand { font-weight: 700; font-size: 22px; letter-spacing: 0.22em; color: rgba(255, 255, 255, 0.92); margin-top: -8px; }
.splash__bar { width: 100%; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.10); overflow: hidden; }
.splash__bar-fill {
  height: 100%; width: 12%; border-radius: 999px;
  background: var(--grad-red); box-shadow: var(--glow-accent);
  animation: splashBar 2.8s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
@keyframes splashBar { 0% { width: 8%; } 60% { width: 72%; } 100% { width: 92%; } }
.splash__hint { font-size: var(--fs-xs); color: var(--c-fg-dim); letter-spacing: 0.04em; }
@media (prefers-reduced-motion: reduce) {
  .logo7 .logo-facet, .splash__bar-fill, .loader-777__glow { animation: none !important; }
}
