/* ============ Dialog · Matrix design system ============ */
/* Токены ----------------------------------------------------------- */
:root {
  /* --primary-rgb — RGB-каналы акцента текущей темы. Все ниже-объявленные тоны
     (--accent-700 / --accent-glow / --accent-soft / --accent-faint / --surface-*
     / --border-* / --glow-* / твёрдо-зелёные rgba в body и UI) читают эту переменную
     и автоматически переводятся в палитру активной темы. Каждая тема
     переназначает --primary-rgb в своём блоке body[data-theme="..."]; по умолчанию
     (High Contrast = matrix) это неон #00ff5a. */
  --primary-rgb: 0, 255, 90;
  /* Фоны — чистый чёрный (high-contrast default; лёгкая зеленца проступает только
     как тонкие surface/border rgba-наложения, чтобы панели читались). Раньше были
     #000300/#000700 и пр. — matrix-дымка, устаревший дефолт. */
  --bg-0: #000000;
  --bg-1: #000000;
  --bg-2: #000604;
  --bg-3: #000c08;
  --bg-4: #00130c;

  /* Зелёная палитра (matrix) */
  --accent-100: #e9ffec;
  --accent-200: #b6ffd2;
  --accent-300: #3df58a;
  --accent-400: #00ff5a;
  --accent-500: #138a4a;
  --accent-600: #0a6e3d;
  --accent-700: rgba(var(--primary-rgb), 0.35);
  --accent-glow: rgba(var(--primary-rgb), 0.55);
  --accent-soft: rgba(var(--primary-rgb), 0.16);
  --accent-faint: rgba(var(--primary-rgb), 0.08);

  /* Акценты */
  --cyan-300: #5ac8ff;
  --danger: #ff5252;
  --warn: #ffb84d;

  /* Поверхности / границы */
  --surface-1: rgba(var(--primary-rgb), 0.035);
  --surface-2: rgba(var(--primary-rgb), 0.07);
  --surface-3: rgba(var(--primary-rgb), 0.13);

  --border-1: rgba(var(--primary-rgb), 0.18);
  --border-2: rgba(var(--primary-rgb), 0.32);
  --border-3: rgba(var(--primary-rgb), 0.55);

  /* Текст */
  --text: var(--accent-300);
  --text-strong: var(--accent-100);
  --text-dim: var(--accent-500);

  /* Эффекты */
  --glow-sm: 0 0 6px rgba(var(--primary-rgb), 0.45);
  --glow-md: 0 0 14px rgba(var(--primary-rgb), 0.35);
  --glow-lg: 0 0 24px rgba(var(--primary-rgb), 0.45);
  --shadow-sm: 0 1px 0 rgba(var(--primary-rgb), 0.04) inset, 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 0 0 1px rgba(var(--primary-rgb), 0.12) inset, 0 12px 38px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 0 0 1px rgba(var(--primary-rgb), 0.16) inset, 0 22px 64px rgba(0, 0, 0, 0.6);

  /* Радиусы */
  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;
  --r-4: 14px;
  --r-pill: 999px;

  /* Тайминги */
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 320ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Шрифты (UI Inter fallback для читабельности; mono для акцентов) */
  --font-ui: "Segoe UI", "Segoe UI Variable Text", "Segoe UI Variable", "Segoe", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif, "JetBrains Mono", ui-monospace, monospace;
  --display: "Segoe UI", "Segoe UI Variable Display", "Segoe UI Variable", "Segoe", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif, "JetBrains Mono", ui-monospace, monospace;
}

/* Базовый сброс -------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { scrollbar-color: var(--border-2) transparent; }
body {
  font-family: var(--font-ui);
  background: var(--bg-1);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  text-rendering: optimizeLegibility;
  text-shadow: 0 0 1px rgba(var(--primary-rgb), 0.18);
  /* Сверхтонкая кинолента поверх всего + мягкая виньетка */
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(var(--primary-rgb), 0.06), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(var(--primary-rgb), 0.04), transparent 60%);
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: repeating-linear-gradient(rgba(var(--primary-rgb), 0.035) 0 1px, transparent 1px 3px);
  opacity: 0.4;
  animation: scanShift 36s linear infinite;
}
/* Скан-лайн НЕ перекрывает попап-оверлеи: ставим на z-index 0 (фоновый слой)
   и на чате (не на логине) гасим совсем — на чате он съедает FPS поверх тяжёлых шиммеров. */
body[data-page="chat"]::before { display: none; }
@keyframes scanShift { to { transform: translateY(3px); } }

button, input, textarea, select { font: inherit; color: inherit; caret-color: var(--accent-400); }
a { color: var(--accent-200); text-decoration: none; }
a:hover { color: var(--accent-100); text-shadow: 0 0 6px rgba(var(--primary-rgb), 0.5); }
img { display: block; max-width: 100%; }
::selection { background: rgba(var(--primary-rgb), 0.32); color: var(--accent-100); }
:focus-visible { outline: none; }

/* === Keyboard focus rings — global outline:none is intentional === */
/* We style focus per-control so the design language stays cohesive. Every
   tabbable control gets a green focus ring + subtle glow — keyboard users
   always see where they are, even when the browser default would have
   fired (because we killed it above). */
.icon-btn:focus-visible,
.hicon-btn:focus-visible,
.ma-btn:focus-visible,
.call-btn:focus-visible,
.call-drop:focus-visible,
.ci-btn:focus-visible,
.chat-menu button:focus-visible,
.fp-chip:focus-visible,
.room-chip:focus-visible,
.status-opt:focus-visible,
.auth-tab:focus-visible,
.contact-row button:focus-visible,
.contact-row .c-name:focus-visible,
.hub-close:focus-visible,
.emoji-tabs button:focus-visible,
.emoji-grid button:focus-visible,
.react-picker button:focus-visible,
.tile .tile-expand:focus-visible,
.member:focus-visible,
.gif-item:focus-visible,
.field-wrap .toggle-eye:focus-visible,
.chat-item:focus-visible,
.lang-select:focus-visible,
.dd-item:focus-visible,
.dd-toggle:focus-visible,
.tile-ctrl .tctrl-mute:focus-visible,
.back-btn:focus-visible,
.me-status:focus-visible,
.settings-tab:focus-visible,
.theme-opt:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.22);
}
/* Suppress hover transforms when focusing — predictability for keyboard users */
.icon-btn:focus-visible, .hicon-btn:focus-visible, .ma-btn:focus-visible,
.call-btn:focus-visible, .call-drop:focus-visible, .hub-close:focus-visible,
.emoji-grid button:focus-visible, .emoji-tabs button:focus-visible,
.react-picker button:focus-visible, .gif-item:focus-visible,
.chat-menu button:focus-visible, .contact-row button:focus-visible {
  transform: none;
}
/* Call-bar focus: brighter glow, more obvious */
.call-btn:focus-visible { box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.32), 0 0 18px rgba(var(--primary-rgb), 0.35); }
.chat-menu button:focus-visible { padding-left: 16px; }
/* Inputs / selects: clean outline, no extra shadow (they already glow on focus) */
#msgInput:focus-visible, #searchInput:focus-visible, #gifSearch:focus-visible,
#reqInput:focus-visible, #gsName:focus-visible,
.dd-select:focus-visible, .edit-box textarea:focus-visible,
.lang-select:focus-visible, input[type="file"]:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 2px;
}
/* File inputs are visually hidden — keep their focus ring on the trigger button instead */
#gsAvaFile:focus-visible, #avaFile:focus-visible, #fileInput:focus-visible {
  outline: none; /* the parent upload button already gets the focus ring */
  box-shadow: none;
}
/* .tile-expand sits inside .tile which has overflow:hidden — outline-offset:2px
   would be clipped by the parent. Use an inset ring (box-shadow only, no outline)
   so keyboard focus on the screen-share enlarge button is always visible. */
.tile .tile-expand:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent-400), 0 0 0 4px rgba(var(--primary-rgb), 0.32);
  opacity: 1; /* keep visible — normally reveals on hover only */
}
/* Links — chat mentions, link previews, footer */
a:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 2px;
  border-radius: 2px;
  text-shadow: 0 0 6px rgba(var(--primary-rgb), 0.55);
}

/* Form action buttons (login submit, register, group save, send-request).
   These have hover lift + shimmer overlays, so focus overlap must be predictable:
   keep outline + ring, kill the hover translate and shimmer pseudo-motion. */.btn-primary:focus-visible, .btn-ghost:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.28),
              inset 0 -2px 0 rgba(0, 0, 0, 0.2);
  transform: none;
  /* keep :disabled filter (grayscale+brightness) intact so a focused-but-disabled
     button still reads as inactive. Outline + ring + cursor:not-allowed is enough. */
}
/* Pin the .btn-primary shimmer pseudo off-focus so the focus ring isn't blinded by motion */
.btn-primary:focus-visible::after { transform: translateX(-120%); transition: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 2px solid transparent; background-clip: padding-box;
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  background-clip: padding-box;
}
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }

.hidden { display: none !important; }

/* Утилиты для подписей и микро-эффектов */
.t-dim { color: var(--text-dim); }
.t-bright { color: var(--text-strong); }
.uppercase-tag {
  font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700;
}

/* Базовые формы -------------------------------------------------- */
.field {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  color: var(--text-strong);
  font-size: 14px;
  border-radius: var(--r-2);
  outline: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease), background var(--t-fast) var(--ease);
}
.field::placeholder { color: var(--text-dim); opacity: 0.7; }
.field:hover { border-color: var(--border-2); }
.field:focus {
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15), var(--glow-sm);
  background: var(--bg-4);
}
.field-wrap { position: relative; display: block; }
.field-wrap .field { padding-right: 40px; }
.field-wrap .toggle-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px;
  background: transparent; border: none; cursor: pointer; color: var(--text-dim);
  display: grid; place-items: center; border-radius: var(--r-2);
  transition: color var(--t-fast) var(--ease);
}
.field-wrap .toggle-eye:hover { color: var(--accent-300); }
.field-wrap .toggle-eye svg { width: 16px; height: 16px; }

.btn-primary {
  position: relative;
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--accent-400), var(--accent-600));
  color: #001a08;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  border: none;
  border-radius: var(--r-2);
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease), filter var(--t-fast) var(--ease);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 8px 22px rgba(var(--primary-rgb), 0.25);
}
.btn-primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.4) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.6s var(--ease);
  pointer-events: none;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 12px 28px rgba(var(--primary-rgb), 0.45);
  filter: brightness(1.06);
}
.btn-primary:hover::after { transform: translateX(120%); }
.btn-primary:active { transform: translateY(0); filter: brightness(0.96); }
.btn-primary:disabled { filter: grayscale(0.6) brightness(0.7); cursor: not-allowed; transform: none; }
.btn-primary.loading { opacity: 0.7; pointer-events: none; }
.btn-primary.loading::before {
  content: "";
  position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border: 2px solid rgba(0, 26, 8, 0.55); border-top-color: #001a08; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  width: 100%; padding: 11px;
  background: transparent;
  border: 1px solid var(--border-1);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--r-2);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn-ghost:hover { border-color: var(--accent-400); color: var(--accent-300); background: var(--accent-faint); }
.btn-ghost:active { transform: translateY(1px); }
.form-error { color: var(--danger); font-size: 12px; min-height: 14px; }

/* ============ Login ============ */
.login {
  position: fixed; inset: 0; display: grid; place-items: center; overflow: hidden;
}
.login::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.16), transparent 70%),
    radial-gradient(ellipse at 50% 100%, rgba(var(--primary-rgb), 0.08), transparent 60%);
}
.login-card {
  position: relative; z-index: 2;
  width: min(400px, 94vw);
  padding: 36px 32px;
  background: linear-gradient(180deg, rgba(0, 14, 6, 0.85), rgba(0, 7, 0, 0.92));
  border-radius: 14px;
  display: flex; flex-direction: column; gap: 14px;
  isolation: isolate;
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(var(--primary-rgb), 0.16);
  animation: cardIn 0.55s var(--ease-out);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
/* (вращающаяся conic-рамка убрана — отвлекала и портила вид логина; тонкая подсветка через .login-card box-shadow остаётся) */
.login-card > * { position: relative; z-index: 1; }

/* Loading dots inside the login card — shown while we check the stored session */
.login-loading {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 30px 0;
}
.lds-dot { display: flex; gap: 8px; }
.lds-dot span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary);
  animation: ldsDot 1.2s ease-in-out infinite;
}
.lds-dot span:nth-child(2) { animation-delay: 0.16s; }
.lds-dot span:nth-child(3) { animation-delay: 0.32s; }
@keyframes ldsDot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.75); }
  40% { opacity: 1; transform: scale(1); }
}
.login-loading p { color: var(--text-2); font-size: 14px; margin: 0; }
.login-auth { display: flex; flex-direction: column; gap: 14px; }

.brand {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  margin-bottom: 2px;
}
.brand-logo {
  position: relative;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--bg-4), var(--bg-3));
  border: 1px solid var(--border-2);
  box-shadow: var(--glow-sm);
  color: var(--accent-400);
  font-size: 22px;
  text-shadow: 0 0 12px var(--accent-glow);
}
.brand-logo svg,
.brand-logo img { width: 32px; height: 32px; object-fit: contain; display: block; position: relative; z-index: 1; }
.brand-logo::after {
  content: ""; position: absolute; inset: -4px;
  border: 1px solid rgba(var(--primary-rgb), 0.35); border-radius: 16px;
  animation: ringPulse 2.6s var(--ease) infinite;
}
@keyframes ringPulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(1.08); }
}
.brand h1 { font-size: 26px; letter-spacing: 4px; color: var(--accent-100); font-weight: 800; }
.brand-sub {
  text-align: center; color: var(--text-dim); font-size: 11px;
  letter-spacing: 1.4px; text-transform: uppercase; margin-bottom: 2px;
}

.auth-tabs {
  display: flex; gap: 4px;
  padding: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  margin-bottom: 4px;
}
.auth-tab {
  flex: 1; padding: 9px 10px;
  background: transparent; border: none;
  color: var(--text-dim);
  font-weight: 700; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  cursor: pointer; border-radius: var(--r-1);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.auth-tab:hover { color: var(--accent-300); }
.auth-tab.active {
  background: linear-gradient(180deg, var(--accent-400), var(--accent-600));
  color: #001a08;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 4px 18px rgba(var(--primary-rgb), 0.18);
}
.auth-form { display: flex; flex-direction: column; gap: 10px; }

.lang-select {
  position: absolute; top: 16px; right: 16px;
  background: rgba(0, 7, 0, 0.6); color: var(--text); border: 1px solid var(--border- scolor, var(--border-1));
  font-size: 11px; padding: 4px 8px; border-radius: var(--r-2); cursor: pointer; z-index: 3;
  outline: none; backdrop-filter: blur(6px);
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.lang-select:hover { border-color: var(--accent-400); color: var(--accent-300); }
.lang-select.small { position: static; }

/* ============ App grid (Telegram-style) ============ */
.app { display: grid; grid-template-columns: 340px 1fr; height: 100vh; height: 100dvh; overflow: hidden; }
.app:has(#infoPanel:not(.hidden)) { grid-template-columns: 340px 1fr 280px; }

.chatlist {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-right: 1px solid var(--border-1);
  display: flex; flex-direction: column; min-width: 0; position: relative;
  /* Тонкая «киноплёнка» слева */
}
.chatlist > * { position: relative; z-index: 1; }
.chatlist::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--accent-400), var(--cyan-300), var(--accent-400), transparent);
  background-size: 200% 100%;
  animation: neonSlide 6s linear infinite;
  opacity: 0.85;
}
@keyframes neonSlide { to { background-position: 200% 0; } }

.cl-head {
  display: flex; align-items: center; gap: 6px;
  padding: 12px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-1);
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.04), transparent);
}
.cl-head .me-name {
  flex: 1; font-weight: 700; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--accent-100);
  letter-spacing: 0.3px;
}
/* Аватар и имя в хедере чатлиста — кликабельные: открывают свой профиль (см. openMyProfile в app.js).
   .me-trigger общий селектор для любых "triggers" в cl-head; фокус-кольцо — единый стиль. */
.cl-head .me-trigger {
  cursor: pointer;
  user-select: none;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease),
              transform var(--t-fast) var(--ease), text-shadow var(--t-fast) var(--ease);
}
.cl-head .avatar.me-trigger:hover {
  border-color: var(--accent-400);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
  transform: scale(1.08);
}
.cl-head .avatar.me-trigger:active { transform: scale(0.96); }
.cl-head .me-name.me-trigger:hover {
  color: var(--accent-300);
  text-shadow: 0 0 8px rgba(var(--primary-rgb), 0.5);
}
.cl-head .me-name.me-trigger:active { color: var(--accent-100); }
/* Кольцо клавиатурного фокуса для обеих триггеров. > 0 один outline (браузерный :focus-visible
   глобально убит выше в :focus-visible { outline: none } — нужен явный аналог для chatlist header). */
.cl-head .me-trigger:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.22);
}
.hicon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); cursor: pointer; border-radius: var(--r-2);
  font-size: 16px; flex-shrink: 0;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.hicon-btn:hover {
  color: var(--accent-300);
  background: var(--accent-faint);
  border-color: var(--border-1);
}
.hicon-btn:active { transform: scale(0.94); }
.hicon-btn svg { width: 18px; height: 18px; }

.cl-search { margin: 10px 12px; width: auto; }
.cl-search:focus { box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18), 0 0 20px rgba(var(--primary-rgb), 0.3); }

.chats { list-style: none; flex: 1; overflow-y: auto; padding: 4px 6px 8px; }
.chats-empty {
  color: var(--text-dim); font-size: 13px; text-align: center;
  padding: 28px 18px; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.chats-empty .es-mini { color: var(--accent-300); font-size: 36px; text-shadow: var(--glow-sm); margin-bottom: 4px; }

.chat-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px 9px 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  border-radius: var(--r-2);
  position: relative;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.chat-item:hover {
  background: var(--surface-2);
  transform: translateX(2px);
  border-left-color: var(--accent-500);
}
.chat-item.active {
  background: linear-gradient(90deg, var(--surface-3), transparent 70%);
  border-left-color: var(--accent-400);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.16);
}
.chat-item.active .ci-name { color: var(--accent-100); }

.ci-body { flex: 1; min-width: 0; }
.ci-top { display: flex; gap: 8px; align-items: center; }
.ci-name {
  font-weight: 700; font-size: 14px; color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: 0.2px;
}
.ci-time { color: var(--text-dim); font-size: 11px; flex-shrink: 0; margin-left: auto; opacity: 0.8; }
.chat-item.active .ci-time { color: var(--accent-300); opacity: 1; }

.ci-bot {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; align-items: center;
}
.ci-last {
  color: var(--text-dim); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
  line-height: 1.35;
}
.chat-item.has-unread .ci-last { color: var(--accent-200); font-weight: 600; }
.ci-bot .badge {
  background: linear-gradient(180deg, var(--accent-400), var(--accent-600));
  color: #001a08; font-size: 10px; font-weight: 800;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: var(--r-pill);
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.45);
  animation: badgePop 0.4s var(--ease-out);
}
@keyframes badgePop {
  from { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); }
  to { transform: scale(1); opacity: 1; }
}
.ci-del {
  opacity: 0; color: var(--text-dim); cursor: pointer; font-size: 13px;
  padding: 3px 6px; flex-shrink: 0; border-radius: var(--r-1);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), opacity var(--t-base) var(--ease);
}
.chat-item:hover .ci-del { opacity: 0.7; }
.ci-del:hover { color: var(--danger); background: rgba(255, 82, 82, 0.12); opacity: 1; }
.ci-pin { cursor: pointer; padding: 0 4px; opacity: 0; display: flex; align-items: center; flex-shrink: 0; border-radius: var(--r-1); transition: opacity var(--t-base) var(--ease), background var(--t-base) var(--ease); }
.chat-item:hover .ci-pin { opacity: 0.5; }
.chat-item.pinned .ci-pin { opacity: 1; }
.ci-pin:hover { opacity: 1; background: rgba(var(--primary-rgb), 0.1); }

/* ===== Filter tabs ===== */
.cl-filters { display: flex; gap: 4px; padding: 0 12px 6px; }
.clf-btn {
  flex: 1; font-size: 12px; font-weight: 700; padding: 5px 0;
  border: none; border-radius: var(--r-1); cursor: pointer;
  background: transparent; color: var(--text-dim);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.clf-btn:hover { background: var(--surface-1); color: var(--text-strong); }
.clf-btn.active { background: var(--surface-2); color: var(--accent-100); }

/* pulse для новых сообщений в списке */
.chat-item.flash { animation: rowFlash 1.4s var(--ease-out); }
@keyframes rowFlash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* ============ Avatars + status ============ */
.avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--bg-4), var(--bg-3));
  border: 1px solid var(--border-1);
  display: grid; place-items: center;
  color: var(--accent-300); font-weight: 800;
  overflow: hidden; flex-shrink: 0; position: relative;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.grp { color: var(--accent-300); border-radius: 8px; }
.avatar[data-login="dref1x"], .tile-avatar[data-login="dref1x"] { border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; }

.chat-item .avatar { box-shadow: 0 0 0 0 transparent; }
.chat-item:hover .avatar { border-color: var(--accent-400); box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.08); }
.ava-wrap { position: relative; flex-shrink: 0; display: flex; align-items: center; }

.st-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  position: relative;
}
.st-online {
  background: var(--accent-400);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25), 0 0 8px var(--accent-400);
  animation: stPulse 2.4s var(--ease) infinite;
}
.st-dnd { background: var(--danger); box-shadow: 0 0 0 2px rgba(255, 82, 82, 0.2); }
.st-offline { background: var(--text-dim); opacity: 0.7; }
@keyframes stPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.92); }
}
.ci-status {
  position: absolute; right: -5px; bottom: -5px;
  border: 2px solid var(--bg-2);
  border-radius: 50%;
}
.ch-status {
  position: absolute; right: -3px; bottom: -3px;
  border: 2px solid var(--bg-2);
  border-radius: 50%;
}

/* ============ Chat (thread) ============ */
.chat {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; min-width: 0;
  overflow: hidden; position: relative;
  background: var(--bg-1);
  isolation: isolate;
}
.chat.has-wallpaper {
  background: var(--chat-wallpaper-url) center / cover no-repeat, var(--bg-1);
}
.chat.has-wallpaper .messages {
  background: rgba(0, 0, 0, 0.35);
}
.empty-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  color: var(--text-dim);
}
.empty-state .back-btn { position: absolute; top: 8px; left: 8px; }
.es-logo {
  font-size: 64px;
  color: var(--accent-300);
  text-shadow: var(--glow-md);
  animation: stPulse 2.5s var(--ease) infinite;
  letter-spacing: 6px;
}
.es-logo img { height: 64px; width: auto; max-width: 80vw; object-fit: contain; filter: drop-shadow(var(--glow-md)); display: block; }
.es-cta {
  font-size: 12px; letter-spacing: 4px; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700;
}

/* === Chat head === */
.chat-head {
  padding: 14px 24px;
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-1);
  background: linear-gradient(180deg, var(--bg-2) 0%, rgba(2, 10, 4, 0.6) 100%);
  display: flex; align-items: center; gap: 12px; overflow: hidden;
  /* z-index 3 — выше #messages (1) и #callStage (2). Без этого .chat-menu (внутри .chat-menu-wrap
     с isolation:isolate, z-index:1900) ловится стэкинг-контекстом .chat-head с z=1, и при
     DOM-тай-брейкере messages (тоже z=1, но позже в DOM) перекрывает чат-меню — кнопки меню
     не кликабельны, "i cant press buttons". */
  position: relative; z-index: 3;
}
.chat-head .avatar.ch-ava {
  width: 36px; height: 36px;
  border-color: var(--border-2);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
.chat-head .avatar.ch-ava:hover {
  transform: scale(1.06); border-color: var(--accent-400);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.1);
}
.chat-head .avatar.ch-ava:active { transform: scale(0.96); }
/* Keyboard focus ring — глобальный :focus-visible { outline:none } выше убивает дефолт, так что
   добавляем вручную для tab-навигации по #chatAva (открывает мини-профиль / settings). */
.chat-head .avatar.ch-ava:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.22);
}
.ch-info { min-width: 0; flex: 1; }
.chat-title {
  font-weight: 700; font-size: 15px; color: var(--accent-100);
  text-shadow: 0 0 8px rgba(var(--primary-rgb), 0.2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: 0.3px;
}
.chat-sub { color: var(--text-dim); font-size: 11px; letter-spacing: 0.4px; }
.typing {
  color: var(--accent-300); font-size: 11px; height: 14px;
  display: inline-flex; align-items: center; gap: 3px;
}
.typing::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-400); box-shadow: 0 0 6px var(--accent-400);
  animation: stPulse 1.1s var(--ease) infinite;
}

.call-go { font-size: 17px; }
.call-go.in-call {
  border-color: var(--danger); color: var(--danger);
  background: rgba(255, 82, 82, 0.12);
  animation: inCallBlink 1.6s var(--ease) infinite;
}
@keyframes inCallBlink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(255, 82, 82, 0); }
}
.call-go.join-call {
  border-color: var(--accent-400); color: var(--accent-300);
  background: rgba(var(--primary-rgb), 0.14);
  animation: joinPulse 1.4s var(--ease) infinite;
}
@keyframes joinPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(var(--primary-rgb), 0); }
}

.return-pill {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(140%); z-index: 300;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 18px;
  background: linear-gradient(180deg, var(--accent-400), var(--accent-600));
  color: #001a08;
  border: none; border-radius: var(--r-pill);
  font-weight: 800; font-size: 13px; cursor: pointer;
  box-shadow: 0 12px 38px rgba(var(--primary-rgb), 0.45), var(--glow-sm);
  opacity: 0; transition: transform var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease-out);
  letter-spacing: 0.3px;
}
.return-pill.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.return-pill:hover { filter: brightness(1.08); }
.return-pill svg { width: 18px; height: 18px; }
.return-pill::before {
  content: ""; position: absolute; inset: -4px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(var(--primary-rgb), 0.6);
  animation: ringPulse 1.6s var(--ease) infinite;
  pointer-events: none;
}

.m-incall { color: var(--accent-300); display: grid; place-items: center; }
.m-incall svg { width: 16px; height: 16px; }
.member .st-dot { margin-left: auto; }
/* Inline-remove для овнера группы в сайдпанели #infoPanel. Маленькая круглая кнопка справа от
   status-точки: в покое — серая и незаметная, на hover — красная (delete-семантика), чтобы случайно
   не зацепить. flex-shrink:0 иначе flex-row её схлопнет до нуля; focus-visible — глобальный reset
   `:focus-visible { outline: none }` снимает нативное кольцо, поэтому рисуем своё. cursor:pointer +
   user-select:none нужны чтобы одиночное нажатие не выделяло "✕" как текст (мешает touch UX). */
.member-remove {
  flex-shrink: 0;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  padding: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.member-remove:hover {
  background: rgba(255, 90, 90, .14);
  border-color: rgba(255, 90, 90, .4);
  color: #ff7878;
}
.member-remove:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 1px;
}

.chat-menu-wrap { position: relative; flex-shrink: 0; display: flex; align-items: center; isolation: isolate; }
.chat-menu {
  position: fixed; z-index: 1900; min-width: 220px;
  background: rgba(2, 10, 4, 0.92);
  border: 1px solid rgba(var(--primary-rgb), 0.4); border-radius: var(--r-3);
  padding: 6px 0; box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px) saturate(140%);
  animation: menuPop 0.18s var(--ease-out);
  transform-origin: top right;
}
@keyframes menuPop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.chat-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: var(--text);
  font-size: 13px; padding: 9px 14px; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), padding-left var(--t-fast) var(--ease);
}
.chat-menu button:hover { background: var(--accent-faint); color: var(--accent-300); padding-left: 18px; }
.chat-menu button.danger:hover { color: var(--danger); background: rgba(255, 82, 82, 0.12); }
.chat-menu button svg { width: 16px; height: 16px; }

.pick-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.friend-pick { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow-y: auto; padding: 4px 0; }
.friend-pick:empty::after { content: "—"; color: var(--text-dim); font-size: 12px; padding: 4px; }
.fp-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-1); color: var(--text);
  font-size: 12px; padding: 5px 10px;
  border-radius: var(--r-pill); cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.fp-chip:hover { color: var(--accent-300); border-color: var(--accent-400); }
.fp-chip.on {
  border-color: var(--accent-400);
  background: rgba(var(--primary-rgb), 0.18);
  color: var(--accent-100); font-weight: 700;
  box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.25);
}
.fp-chip:active { transform: scale(0.95); }

#settingsOverlay:not(.is-owner) .gs-owner { display: none; }
.gs-danger { color: var(--danger); border-color: rgba(255, 82, 82, 0.4); }
.gs-danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(255, 82, 82, 0.12); }
#gsMembers .contact-row .owner-tag { font-size: 10px; color: var(--text-dim); letter-spacing: 0.5px; }

.link-preview {
  display: flex; gap: 10px; margin-top: 6px;
  max-width: 380px;
  background: var(--bg-3); border: 1px solid var(--border-1);
  border-left: 3px solid var(--accent-400); border-radius: var(--r-2);
  padding: 8px 10px; text-decoration: none; color: var(--text);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.link-preview:hover { background: var(--bg-4); transform: translateX(2px); }
.lp-body { min-width: 0; flex: 1; }
.lp-site { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.lp-title {
  font-size: 13px; font-weight: 700; color: var(--accent-200); margin: 2px 0;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.lp-desc {
  font-size: 12px; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.lp-img { width: 64px; height: 64px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }
.yt-embed {
  margin-top: 6px; max-width: 400px; width: 100%;
  aspect-ratio: 16/9;
  border: 1px solid var(--border-1); border-radius: var(--r-2);
  overflow: hidden; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.yt-embed iframe { width: 100%; height: 100%; border: 0; display: block; }
.back-btn {
  background: transparent; border: none;
  color: var(--accent-300); font-size: 26px; cursor: pointer; line-height: 1;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-2);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.back-btn:hover { background: var(--accent-faint); }
.back-btn:active { transform: translateX(-2px); }

/* === messages === */
.messages {
  flex: 1; min-width: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 14px 24px 8px;
  display: flex; flex-direction: column;
  position: relative; z-index: 1;
  scroll-behavior: smooth;
  /* Bottom-fade mask убран \u2014 он создавал \u00ab\u0442\u0435\u043d\u044c\u00bb \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u0445, \u043c\u0435\u0448\u0430\u044f \u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u044c. */
}
.system-msg {
  align-self: center;
  color: var(--text-dim); font-size: 10px;
  margin: 14px 0;
  text-transform: uppercase; letter-spacing: 1.5px;
  padding: 4px 14px;
  border-radius: var(--r-pill);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
}

.sys-line {
  align-self: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 14px;
  text-align: center;
  user-select: none;
}
.sys-line.call { color: var(--green); }
.sys-line.call.missed { color: var(--red, #f55); }
.sys-line.join, .sys-line.leave { color: var(--text-dim); opacity: 0.8; }

.msg {
  position: relative;
  max-width: 78%;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 3px; margin-top: 8px;
  animation: msgIn 0.34s var(--ease-out);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.msg.me { align-self: flex-end; align-items: flex-end; }
/* Story tail-consecutive messages без аватара сверху */
.msg.continuation { margin-top: 2px; }
.msg.continuation .who { display: none; }

.msg .who {
  font-size: 11px; color: var(--text-dim);
  padding: 0 6px 2px;
  letter-spacing: 0.3px;
  display: flex; align-items: center; gap: 6px;
}
.msg .who::after { content: ":~$"; opacity: 0.6; color: var(--accent-500); }
.msg.me .who { display: none; }

.bubble {
  position: relative;
  max-width: 100%;
  padding: 9px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.04) 0%, rgba(var(--primary-rgb), 0.02) 100%);
  border: 1px solid var(--border-1);
  color: var(--text); font-size: 14px; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
  animation: bubbleIn 0.32s var(--ease-out);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
@keyframes bubbleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.bubble::before, .bubble::after {
  content: ""; position: absolute; pointer-events: none;
  width: 10px; height: 10px;
}
/* Tail: theirs bottom-left, mine bottom-right */
.bubble::after {
  bottom: -1px;
}
.msg.me .bubble {
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.16), rgba(var(--primary-rgb), 0.08));
  border-color: var(--accent-400);
  color: var(--accent-100);
  box-shadow: 0 4px 18px rgba(var(--primary-rgb), 0.16);
}
.msg.me .bubble::after { right: -1px; border-bottom-left-radius: 14px; background: var(--bg-1); clip-path: path("M 0 10 L 0 0 L 10 0 Z"); }
.msg:not(.me) .bubble::after { left: -1px; border-bottom-right-radius: 14px; background: var(--bg-1); clip-path: path("M 10 10 L 10 0 L 0 0 Z"); }

.bubble.media { padding: 4px; background: transparent; border: none; box-shadow: none; }
.bubble.media::before, .bubble.media::after { display: none; }
.bubble img, .bubble video {
  width: auto; max-width: 280px; max-height: 280px;
  border-radius: 10px; display: block;
  border: 1px solid var(--border-1); object-fit: contain;
  background: var(--bg-3);
}
.bubble.media img { cursor: zoom-in; transition: transform var(--t-base) var(--ease); }
.bubble.media img:hover { transform: scale(1.015); }
.bubble.audio {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; min-width: 220px;
}
.bubble.audio audio { height: 36px; max-width: 240px; }

/* File attachment bubble (zf, pdf, exe, …): кликабельная вся, не только имя — download attribute
   на <a> сохраняет файл локально под оригинальным именем, не открывая dataURL в новой вкладке. */
.bubble.file {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; min-width: 240px; max-width: 360px;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.04) 0%, rgba(var(--primary-rgb), 0.02) 100%);
  border: 1px solid var(--border-1);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
.bubble.file:hover {
  border-color: var(--accent-400);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.18);
}
.bubble.file:active { transform: translateY(0); }
.bubble.file .file-icon {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  font-size: 18px;
}
.bubble.file .file-meta {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.bubble.file .file-name {
  font-weight: 600;
  color: var(--accent-100);
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bubble.file .file-size {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}
.bubble.file .file-dl {
  flex-shrink: 0;
  font-size: 18px;
  color: var(--accent-300);
  transition: transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.bubble.file:hover .file-dl { color: var(--accent-100); transform: translateY(2px); }
.msg.me .bubble.file {
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.16), rgba(var(--primary-rgb), 0.08));
  border-color: var(--accent-400);
}

.msg .time {
  font-size: 10px; color: var(--text-dim); padding: 0 6px;
  display: inline-flex; align-items: center; gap: 4px;
  opacity: 0.85;
  transition: opacity var(--t-fast) var(--ease);
}
.msg:hover .time { opacity: 1; }

.msg-status {
  display: inline-flex; align-items: center; margin-left: 4px; line-height: 0;
  transition: filter var(--t-base) var(--ease), color var(--t-base) var(--ease), transform var(--t-base) var(--ease-out);
}
.msg-status svg { width: 13px; height: 13px; }
.msg-status[data-status="pending"] {
  color: var(--text-dim);
  animation: statusBlink 1.4s var(--ease) infinite;
}
.msg-status[data-status="sent"] { color: var(--text-dim); }
.msg-status[data-status="delivered"] {
  color: var(--accent-300);
  filter: drop-shadow(0 0 4px rgba(var(--primary-rgb), 0.4));
  animation: statusPop 0.4s var(--ease-out);
}
.msg-status[data-status="read"] {
  color: var(--cyan-300);
  filter: drop-shadow(0 0 6px rgba(90, 200, 255, 0.7));
  animation: statusPop 0.4s var(--ease-out);
}
@keyframes statusBlink { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.95; } }
@keyframes statusPop {
  from { transform: scale(0.6); }
  65% { transform: scale(1.18); }
  to { transform: scale(1); }
}

.mention {
  color: var(--accent-200); background: rgba(var(--primary-rgb), 0.16);
  padding: 1px 4px; border-radius: 3px; font-weight: 700;
}
.msg.ping .bubble {
  border-color: var(--accent-400);
  background: rgba(var(--primary-rgb), 0.12);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.25), 0 0 22px rgba(var(--primary-rgb), 0.16);
  animation: pingIn 0.5s var(--ease-out);
}
@keyframes pingIn {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.7); }
  60% { transform: scale(1.04); box-shadow: 0 0 0 16px rgba(var(--primary-rgb), 0); }
  100% { transform: scale(1); }
}

.msg.blocked > .bubble, .msg.blocked > .time, .msg.blocked > .reactions { display: none; }
.msg.blocked .msg-actions { display: none; }
.msg.blocked::after {
  content: attr(data-blocklabel);
  display: inline-block; margin-top: 2px;
  padding: 9px 14px;
  border: 1px dashed var(--border-2);
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  border-radius: 10px;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.msg.blocked:hover::after { color: var(--accent-300); border-color: var(--accent-400); }
.msg.blocked.revealed > .bubble, .msg.blocked.revealed > .time { display: block; }
.msg.blocked.revealed::after { display: none; }

/* Hover actions над сообщением */
.msg-actions {
  position: absolute; top: -16px;
  z-index: 5;
  display: flex; gap: 2px;
  padding: 3px;
  background: rgba(2, 10, 4, 0.94);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  transform: translateY(4px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md);
}
.msg:not(.me) .msg-actions { right: 8px; }
.msg.me .msg-actions { left: 8px; }
.msg:hover .msg-actions { opacity: 1; pointer-events: auto; transform: translateY(0); }

.ma-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: none; background: transparent;
  color: var(--text-dim); cursor: pointer;
  border-radius: 5px;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.ma-btn:hover { background: var(--accent-faint); color: var(--accent-300); }
.ma-btn:active { transform: scale(0.9); }
.ma-btn svg { width: 15px; height: 15px; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reactions:empty { display: none; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
  padding: 2px 10px;
  cursor: pointer; font-size: 13px; color: var(--text);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  animation: reactionPop 0.34s var(--ease-out);
}
@keyframes reactionPop { from { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.15); } to { transform: scale(1); opacity: 1; } }
.reaction:hover { background: var(--surface-3); transform: translateY(-1px); }
.reaction.mine {
  border-color: var(--accent-400);
  background: rgba(var(--primary-rgb), 0.16);
  color: var(--accent-100); font-weight: 600;
  box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.18);
}
.reaction .r-count { font-weight: 700; font-size: 11px; }

.react-picker {
  position: fixed; z-index: 300;
  display: flex; gap: 2px;
  padding: 6px;
  background: rgba(2, 10, 4, 0.94);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  animation: menuPop 0.18s var(--ease-out);
}
.react-picker button {
  border: none; background: transparent; cursor: pointer;
  font-size: 22px; padding: 5px;
  border-radius: 6px; line-height: 1;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.react-picker button:hover { background: var(--accent-faint); transform: scale(1.25) translateY(-2px); }

.edit-box { display: flex; flex-direction: column; gap: 3px; width: 100%; animation: bubbleIn 0.22s var(--ease-out); }
.edit-box textarea {
  width: 100%; min-width: 200px; resize: none;
  font-family: inherit; font-size: 14px; line-height: 1.5;
  background: var(--bg-3); border: 1px solid var(--accent-400);
  border-radius: var(--r-2);
  color: var(--accent-100); padding: 9px 14px; outline: none;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}
.edit-hint { font-size: 10px; color: var(--text-dim); padding: 0 6px; letter-spacing: 0.4px; }

/* Typing dots */
.typing-dots { display: inline-flex; gap: 3px; margin-right: 6px; align-items: center; }
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent-400);
  animation: typingDot 1.2s var(--ease) infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* === Composer === */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 12px 24px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-1);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  position: relative; z-index: 1;
}
.composer::before {
  content: ""; position: absolute; top: -1px; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-400), transparent);
  opacity: 0.4;
}
.block-notice {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-1);
  background: var(--bg-2);
  color: var(--text-dim); font-size: 13px; letter-spacing: 0.3px;
  text-align: center;
}
.chat.has-call > .block-notice { grid-area: comp; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border-1);
  color: var(--text-dim); cursor: pointer;
  border-radius: var(--r-2);
  font-size: 16px;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent-300); border-color: var(--accent-400); background: var(--accent-faint); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.send {
  color: var(--accent-400); border-color: var(--accent-400);
  background: linear-gradient(180deg, var(--accent-faint), rgba(var(--primary-rgb), 0.06));
  box-shadow: 0 0 14px rgba(var(--primary-rgb), 0.25);
}
.icon-btn.send:hover { background: var(--accent-soft); box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.45); }
.icon-btn.recording {
  color: var(--danger); border-color: var(--danger);
  background: rgba(255, 82, 82, 0.12);
  animation: recPulse 1s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.6); }
  50% { box-shadow: 0 0 0 8px rgba(255, 82, 82, 0); }
}

/* Mobile composer dropdown */
.composer-more {
  position: absolute; bottom: 100%; left: 14px; z-index: 50;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
}
.cm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: transparent; border: none; border-radius: var(--r-2);
  color: var(--text); font-family: inherit; font-size: 14px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.cm-item:hover { background: var(--surface-2); }
.cm-item:active { background: var(--surface-3); }
.cm-gif-label { font-weight: 700; letter-spacing: 1px; font-size: 13px; }

.input-wrap { flex: 1; min-width: 0; }
#msgInput {
  width: 100%; resize: none;
  max-height: 130px;
  padding: 11px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  color: var(--text-strong);
  font-family: inherit; font-size: 14px;
  border-radius: var(--r-2); outline: none;
  line-height: 1.4;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
#msgInput:focus {
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* Эмодзи / GIF панели */
.emoji-picker, .gif-panel {
  position: absolute; bottom: 70px; left: 24px;
  width: 340px; height: 320px;
  background: rgba(2, 10, 4, 0.92);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-md);
  z-index: 20;
  display: flex; flex-direction: column;
  backdrop-filter: blur(10px) saturate(140%);
  animation: menuPop 0.2s var(--ease-out);
}
.emoji-tabs {
  display: flex; gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border-1);
  overflow-x: auto; scrollbar-width: none;
}
.emoji-tabs button {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; padding: 4px 8px;
  border-radius: var(--r-1);
  transition: background var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.emoji-tabs button:hover { background: var(--accent-faint); }
.emoji-tabs button.active { background: var(--surface-3); color: var(--accent-300); }
.emoji-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 6px;
}
.emoji-grid button {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; padding: 4px;
  border-radius: 5px;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.emoji-grid button:hover { background: var(--accent-faint); transform: scale(1.18); }
.gif-panel { padding: 8px; gap: 8px; }
.gif-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.gif-item {
  width: 100%; border-radius: 5px; cursor: pointer;
  border: 1px solid transparent;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  background: var(--bg-3);
}
.gif-item:hover { border-color: var(--accent-400); transform: scale(1.03); }
.gif-note { color: var(--text-dim); font-size: 12px; text-align: center; padding: 8px; }

/* Side panels */
.info-panel {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-left: 1px solid var(--border-1);
  width: 280px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.info-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;
  color: var(--accent-300);
  font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; font-size: 12px;
}
.members { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.member {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.member:hover { background: var(--surface-2); transform: translateX(2px); }
.m-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.m-crown { font-size: 14px; flex-shrink: 0; filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.6)); }

/* ============ Modals ============ */
.modal {
  position: fixed; inset: 0; z-index: 250;
  display: grid; place-items: center;
  background: rgba(0, 4, 0, 0.7);
  backdrop-filter: blur(14px) saturate(140%);
  animation: modalIn 0.18s var(--ease-out);
}
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: min(420px, 92vw);
  max-height: 88vh; overflow-y: auto;
  padding: 28px 26px 24px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border-2);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 12px;
  animation: cardIn 0.34s var(--ease-out);
}
.modal-card.wide { width: min(480px, 94vw); }
.modal-title {
  font-weight: 800; font-size: 16px; color: var(--accent-200);
  text-align: center; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 4px;
  text-shadow: 0 0 8px rgba(var(--primary-rgb), 0.25);
}
.modal-sep {
  text-align: center; color: var(--text-dim); font-size: 11px;
  margin: 4px 0; letter-spacing: 1px; text-transform: uppercase;
}
.modal-actions { display: flex; gap: 8px; }
.hub-close {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px;
  background: transparent; border: 1px solid var(--border-1);
  color: var(--text-dim); font-size: 16px; cursor: pointer;
  display: grid; place-items: center; border-radius: var(--r-2);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.hub-close:hover { color: var(--accent-300); background: var(--accent-faint); border-color: var(--accent-400); }
.hub-close:active { transform: rotate(90deg) scale(0.94); }


.req-add { display: flex; gap: 6px; }
.req-add .field { flex: 1; }
.req-add .btn-primary { width: auto; padding: 0 16px; flex: none; }

.contacts-sec-title {
  color: var(--text-dim); font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.6px; margin-top: 8px;
  display: flex; align-items: center; gap: 8px;
}
.contacts-sec-title::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border-1), transparent);
}
.contacts-list { display: flex; flex-direction: column; gap: 4px; }
.contacts-empty { color: var(--text-dim); font-size: 12px; padding: 6px; text-align: center; }
.contact-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.contact-row:hover { background: var(--surface-2); border-color: var(--border-2); }
.contact-row .c-name { flex: 1; font-size: 13px; cursor: pointer; transition: color var(--t-fast) var(--ease); }
.contact-row .c-name:hover { color: var(--accent-300); }
.contact-row button {
  background: transparent; border: 1px solid var(--border-1);
  color: var(--text-dim);
  font-size: 11px; padding: 4px 10px;
  border-radius: var(--r-1); cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.contact-row button:hover { border-color: var(--accent-400); color: var(--accent-300); background: var(--accent-faint); }
.contact-row button.danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(255, 82, 82, 0.12); }

.room-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.room-chip {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  color: var(--text);
  font-size: 12px; padding: 6px 12px;
  border-radius: var(--r-pill); cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.room-chip:hover { border-color: var(--accent-400); color: var(--accent-300); transform: translateY(-1px); }

.profile-ava { width: 96px; height: 96px; font-size: 36px; align-self: center; }
.profile-ava img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
/* .ava-fallback — буква-заглушка (initials) для profile / mp / gs аватаров. Раньше стояло только
   `position: absolute` без top/left — статичная позиция в grid-контексте в Chromium часто
   приземляется в ВЕРХНИЙ-ЛЕВЫЙ угол ячейки, после чего .avatar { overflow: hidden } её
   обрезает → пользователь видит пустой квадрат вместо буквы. Делаем span во весь аватар
   (inset:0) с собственным grid-центрированием; img.z-index:1 выше, поэтому загруженная картинка
   реально перекрывает букву, но при ошибке /src img удаляется через onerror — буква снова
   видна и центрирована. */
.profile-ava .ava-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent-300);
  z-index: 0;
  pointer-events: none;
}
/* Логотип-заглушка для групп (group.svg). Спан остаётся grid-контейнером с place-items:center,
   img внутри занимает 65% ячейки и центрируется. Скрывается тем же display:none, что и раньше
   для .ava-fallback span — так обработчики загрузки/очистки аватара работают без правок. */
.ava-fallback img {
  width: 65%;
  height: 65%;
  object-fit: contain;
  display: block;
}
.profile-login {
  text-align: center; color: var(--text-dim); font-size: 12px;
  letter-spacing: 1.2px;
}
.profile-login::before { content: "@"; color: var(--accent-400); }
.status-pick { display: flex; flex-direction: column; gap: 4px; }
.status-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid var(--border-1);
  color: var(--text);
  font-size: 13px; cursor: pointer;
  border-radius: var(--r-2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.status-opt:hover { background: var(--surface-2); }
.status-opt.active {
  border-color: var(--accent-400);
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--accent-100); font-weight: 600;
  box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.16);
}

.mp-card { align-items: center; text-align: center; }

/* === Create-group modal (пост-way создания групп с друзьями). Вынес
   из #settingsOverlay, чтобы flow был коротким и дискретным: вход из
   хедера чатлиста (#newGroupBtn «+») или empty-state (#emptyNewGroup).
   Структурно похож на #addMemberModal но крупнее и интерактивнее: аватар
   + поиск + мультивыбор с подсчётом + селект-всё. === */
.cg-card {
  width: min(440px, 94vw);
  padding: 26px 26px 22px;
  gap: 14px;
}
.cg-hero {
  display: flex; align-items: center; gap: 14px;
  align-self: center;
  margin-bottom: 4px;
}
.cg-ava {
  width: 72px; height: 72px;
  font-size: 28px;
  border-color: var(--accent-400);
  border-radius: 14px;
}
.cg-hero-side {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.cg-compact { width: auto; padding: 8px 14px; font-size: 12px; }
.cg-clear {
  width: 28px; height: 28px;
  border: 1px solid var(--border-1);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  border-radius: 50%;
  display: grid; place-items: center;
  padding: 0;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.cg-clear:hover { color: var(--danger); border-color: var(--danger); background: rgba(255, 82, 82, 0.12); }
.cg-search-row {
  display: flex; align-items: center; gap: 8px;
}
.cg-search-row .field { flex: 1; }
.cg-count {
  font-size: 11px; color: var(--text-dim);
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.cg-count.full { color: var(--accent-300); border-color: var(--accent-400); background: rgba(var(--primary-rgb), 0.16); }
.cg-bulk {
  font-size: 11px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border-1);
  color: var(--text-dim);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.cg-bulk:hover { color: var(--accent-300); border-color: var(--accent-400); background: var(--accent-faint); }
.cg-bulk.hidden { display: none; }
.cg-picker {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 240px;
  min-height: 64px;
  overflow-y: auto;
  padding: 2px 0;
}
.cg-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.cg-row:hover { background: var(--surface-2); transform: translateX(2px); }
.cg-row:active { transform: translateX(2px) scale(0.99); }
.cg-row.on {
  background: rgba(var(--primary-rgb), 0.14);
  border-color: var(--accent-400);
  box-shadow: 0 0 14px rgba(var(--primary-rgb), 0.18);
}
.cg-ava-mini {
  width: 28px; height: 28px; font-size: 11px;
  border-radius: 8px;
}
.cg-row-name {
  flex: 1; min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cg-row.on .cg-row-name { color: var(--accent-100); font-weight: 700; }
.cg-tick {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  color: var(--accent-300);
  font-size: 16px;
  font-weight: 800;
  border-radius: 50%;
  background: transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.cg-row.on .cg-tick {
  background: linear-gradient(180deg, var(--accent-400), var(--accent-600));
  color: #001a08;
  box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.4);
}

/* Add-member mini-modal: компактнее обычного модала, ровно одна колонка выбора друзей + Add. */
.am-card {
  width: min(380px, 94vw);
  padding: 24px 22px 18px;
  gap: 12px;
}
.am-card .friend-pick {
  max-height: 240px;
  min-height: 60px;
}
/* + над списком участников (info panel); группы-владелец видит, иначе скрыт. Спиннер-стейт
   совпадает с другими hicon-btn — тот же hover/focus. */
.info-add-btn { font-size: 18px; line-height: 1; font-weight: 700; }
.info-add-btn.hidden { display: none; }
.mp-name {
  font-weight: 800; font-size: 20px; color: var(--accent-100);
  text-shadow: 0 0 8px rgba(var(--primary-rgb), 0.2);
}
.mp-status { font-size: 12px; color: var(--text-dim); }
.mp-desc { font-size: 13px; color: var(--text); max-width: 32ch; }
.mp-joined { font-size: 11px; color: var(--text-dim); letter-spacing: 0.5px; }

/* ============ Звонок (Discord + Matrix) ============ */
.call-stage {
  position: relative;
  display: flex; flex-direction: column;
  max-height: 46vh; overflow: hidden;
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.04), var(--bg-2));
  border-bottom: 1px solid var(--border-1);
  z-index: 2;
  isolation: isolate;
}
.call-stage.fullscreen {
  position: relative; max-height: none;
  background: var(--bg-1);
}
.chat.has-call.fullscreen-call { --call-w: 66%; --call-h: 78%; }
.call-stage::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-400), transparent);
  opacity: 0.45;
}

/* По умолчанию (ПК): стейдж звонка дока в колонку чата */
.chat.has-call { display: grid; --call-w: 36%; --call-h: 44%; }
.chat.has-call.dock-left {
  grid-template-columns: clamp(290px, var(--call-w), 70%) 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "call head" "call msgs" "call comp";
}
.chat.has-call.dock-right {
  grid-template-columns: 1fr clamp(290px, var(--call-w), 70%);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "head call" "msgs call" "comp call";
}
.chat.has-call.dock-top {
  grid-template-columns: 1fr;
  grid-template-rows: clamp(140px, var(--call-h), 75%) auto 1fr auto;
  grid-template-areas: "call" "head" "msgs" "comp";
}
.chat.has-call > #callStage { grid-area: call; max-height: none; height: 100%; border-bottom: none; }
.chat.has-call.dock-left > #callStage { border-right: 1px solid var(--border-2); }
.chat.has-call.dock-right > #callStage { border-left: 1px solid var(--border-2); }
.chat.has-call.dock-top > #callStage { border-bottom: 1px solid var(--border-2); }
.chat.has-call > .chat-head { grid-area: head; }
.chat.has-call > #messages { grid-area: msgs; }
.chat.has-call > .composer { grid-area: comp; }
.chat.has-call > .emoji-picker, .chat.has-call > .gif-panel { grid-area: msgs; }

/* Убираем нижнюю линию у стейджа внутри чата (заменяется grid-бордером) */
.chat.has-call > #callStage::after { display: none; }

.pip-notice {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 12px;
  background: rgba(var(--primary-rgb), 0.12);
  border-bottom: 1px solid var(--accent-400);
  font-size: 11px; font-weight: 700; color: var(--accent-300);
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.pip-notice button {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  color: var(--accent-200);
  padding: 2px 10px;
  border-radius: var(--r-2);
  font-size: 10px; font-weight: 700; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.pip-notice button:hover { background: var(--accent-soft); color: var(--accent-100); }

.call-matrix {
  position: absolute; inset: 0;
  z-index: 0; opacity: 0.14; pointer-events: none;
  filter: blur(0.4px);
}

.call-count {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  padding: 2px 10px;
  color: var(--accent-300); font-weight: 800; font-size: 11px;
  border-radius: var(--r-pill);
  letter-spacing: 0.5px;
}
.call-status { font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase; font-weight: 700; }
.call-status.ok { color: var(--accent-300); }
.call-status.bad { color: var(--danger); }
.call-status:not(:empty)::before { content: "● "; animation: stPulse 1.6s var(--ease) infinite; }

.call-grip {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 18px; cursor: grab; flex-shrink: 0;
  border-bottom: 1px solid var(--border-1);
  transition: background var(--t-fast) var(--ease);
}
.call-grip:hover { background: var(--accent-faint); }
.call-grip span {
  width: 22px; height: 3px;
  border-radius: 3px;
  background: var(--border-2);
  transition: background var(--t-fast) var(--ease);
}
.call-grip:hover span { background: var(--accent-400); }
.call-grip:active { cursor: grabbing; }
.call-stage.fullscreen .call-grip { display: none; }

.call-resizer {
  position: absolute; z-index: 4; display: none;
}
.chat.has-call.dock-left > #callStage > .call-resizer { display: block; top: 0; bottom: 0; right: -3px; width: 7px; cursor: col-resize; }
.chat.has-call.dock-right > #callStage > .call-resizer { display: block; top: 0; bottom: 0; left: -3px; width: 7px; cursor: col-resize; }
.chat.has-call.dock-top > #callStage > .call-resizer { display: block; left: 0; right: 0; bottom: -3px; height: 7px; cursor: row-resize; }
.call-resizer { background: transparent; transition: background var(--t-fast) var(--ease); }
.call-resizer:hover { background: rgba(var(--primary-rgb), 0.45); }

.video-grid {
  position: relative; z-index: 1;
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
  overflow-y: auto;
}
.video-grid .tile { width: 100%; }
.call-stage.fullscreen .video-grid { flex-direction: column; align-content: stretch; justify-content: flex-start; padding: 8px; gap: 6px; }
.call-stage.fullscreen .video-grid .tile { width: 100%; }
.call-stage.fullscreen .video-grid .tile.screen { max-height: 55vh; }
.call-stage.fullscreen .video-grid .tile.screen:only-child { min-height: 0; }
.call-stage.fullscreen .call-btn { width: 42px; height: 42px; font-size: 16px; }
.call-stage.fullscreen .call-btn svg { width: 18px; height: 18px; }
.call-stage.fullscreen .call-btn.end { width: 50px; border-radius: 24px; }
.call-stage.fullscreen .call-bar { padding: 6px 12px; gap: 4px; }
.call-stage.fullscreen .call-actions { gap: 5px; }
.call-stage.fullscreen .call-meta { font-size: 10px; }
.call-stage.fullscreen .participants-wrap .tile { width: 140px; height: 80px; }
.call-stage.fullscreen .participants-wrap { padding: 4px 0; gap: 6px; }
.chat.has-call.dock-top .video-grid { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; justify-content: center; }
.chat.has-call.dock-top .video-grid .tile { width: auto; height: 100%; aspect-ratio: 16/9; }

.dock-hint {
  position: absolute; z-index: 150;
  background: rgba(var(--primary-rgb), 0.16);
  border: 2px dashed var(--accent-400);
  border-radius: var(--r-3); pointer-events: none;
  transition: all 0.08s var(--ease);
  display: none; box-shadow: 0 0 24px rgba(var(--primary-rgb), 0.25);
}
.dock-hint.show { display: block; }

/* === Tile (участник звонка) === */
.tile {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--bg-4), var(--bg-3));
  border: 2px solid var(--border-1);
  border-radius: var(--r-3);
  aspect-ratio: 16/9;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease-out);
  animation: tileIn 0.32s var(--ease-out);
  isolation: isolate;
}
@keyframes tileIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.tile video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  background: var(--bg-3);
  transition: filter var(--t-base) var(--ease);
}
.tile.me video { transform: scaleX(-1); }
.tile.show-avatar video { opacity: 0; }
.tile .tile-name {
  position: absolute; bottom: 8px; left: 10px;
  background: rgba(0, 4, 0, 0.78);
  border: 1px solid var(--border-1);
  padding: 3px 10px;
  border-radius: var(--r-2);
  font-size: 12px; color: var(--text); font-weight: 700; z-index: 3;
  backdrop-filter: blur(4px);
  display: flex; align-items: center; gap: 6px;
}
.tile.speaking {
  border-color: var(--accent-400);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.35), 0 0 22px rgba(var(--primary-rgb), 0.25);
}
.tile.speaking::before {
  content: "";
  position: absolute; inset: -2px;
  border-radius: var(--r-3);
  border: 2px solid rgba(var(--primary-rgb), 0.55);
  animation: speakingPulse 1.4s ease-out infinite;
  pointer-events: none; z-index: 4;
}
@keyframes speakingPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.06); opacity: 0; }
}

.tile.screen {
  width: 100%;
  aspect-ratio: 16/9; max-height: 36vh;
  order: -1;
  border-color: var(--accent-400);
  box-shadow: 0 0 22px rgba(var(--primary-rgb), 0.18);
}
.tile.screen video { object-fit: contain; cursor: zoom-in; }
.tile.screen .tile-name { color: var(--accent-200); border-color: var(--border-2); }

.tile-expand {
  position: absolute; top: 8px; right: 8px;
  z-index: 5;
  width: 30px; height: 30px;
  border: none; border-radius: 6px;
  background: rgba(0, 4, 0, 0.72);
  color: var(--accent-300); cursor: pointer; font-size: 14px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  display: grid; place-items: center;
}
.tile.screen:hover .tile-expand { opacity: 1; }
.tile-expand:hover { background: rgba(var(--primary-rgb), 0.25); }
.win-btn.active { border-color: var(--accent-400); color: var(--accent-300); box-shadow: var(--glow-sm); }

.tile-avatar {
  position: relative; z-index: 1;
  width: 88px; height: 88px;
  border-radius: var(--r-3);
  display: none; place-items: center;
  font-size: 36px; font-weight: 800;
  color: var(--accent-300);
  background: linear-gradient(160deg, var(--bg-4), var(--bg-3));
  border: 3px solid var(--border-2);
  text-shadow: 0 0 12px var(--accent-glow);
  overflow: hidden; flex-shrink: 0;
}
.tile.show-avatar .tile-avatar { display: grid; }
.tile.speaking .tile-avatar { border-color: var(--accent-400); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.3); }
.tile-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.tile-avatar span { position: relative; z-index: 1; }
.tile-avatar::before {
  content: "";
  position: absolute; inset: -6px;
  border-radius: var(--r-3);
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  pointer-events: none;
}

.participants-wrap {
  display: flex; flex-direction: row; gap: 8px;
  padding: 8px 0; overflow-x: auto; flex-shrink: 0;
}
.participants-wrap .tile {
  width: 170px; height: 96px; flex: 0 0 auto;
}
.participants-wrap.hidden-tiles { display: none; }
.hide-tiles-btn {
  border: 1px solid var(--border-1);
  background: var(--surface-2); color: var(--text-dim);
  cursor: pointer; border-radius: var(--r-2);
  padding: 4px 12px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; flex-shrink: 0;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  align-self: center;
}
.hide-tiles-btn:hover { color: var(--accent-300); background: var(--accent-faint); }

.tile-ctrl {
  position: absolute; bottom: 8px; right: 8px;
  z-index: 5;
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 4, 0, 0.84);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: 4px 8px;
  opacity: 0; transition: opacity var(--t-fast) var(--ease);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.tile:hover .tile-ctrl { opacity: 1; }
.tctrl-mute {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; padding: 2px;
  color: var(--text);
  transition: color var(--t-fast) var(--ease);
}
.tctrl-mute.muted { color: var(--danger); }
.tctrl-vol { width: 64px; accent-color: var(--accent-400); cursor: pointer; }

.call-bar {
  position: relative; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(0, 8, 2, 0.86), rgba(0, 4, 0, 0.94));
  border-top: 1px solid var(--border-1);
  backdrop-filter: blur(10px);
}
.call-meta {
  display: flex; align-items: center; gap: 8px; color: var(--text-dim);
  font-size: 11px; letter-spacing: 0.5px;
}
.call-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }

.call-btn {
  position: relative;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border-1);
  background: var(--surface-2);
  color: var(--accent-200);
  font-size: 20px; cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease);
}
.call-btn svg { width: 22px; height: 22px; }
.call-btn::before {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translate(-50%, 4px);
  background: rgba(2, 10, 4, 0.94);
  border: 1px solid var(--border-2);
  color: var(--accent-100);
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase;
  padding: 4px 8px; border-radius: 4px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  z-index: 6;
}
.call-btn:hover::before { opacity: 1; transform: translate(-50%, 0); }
.call-btn:hover { background: var(--surface-3); transform: translateY(-2px) scale(1.05); border-color: var(--accent-400); box-shadow: 0 6px 18px rgba(var(--primary-rgb), 0.2); }
.call-btn:active { transform: translateY(0) scale(0.96); }
.call-btn.off {
  background: rgba(255, 82, 82, 0.18);
  color: var(--danger);
  border-color: rgba(255, 82, 82, 0.4);
}
.call-btn.off:hover { background: rgba(255, 82, 82, 0.28); box-shadow: 0 6px 18px rgba(255, 82, 82, 0.25); }
.call-btn.active {
  background: var(--accent-soft);
  color: var(--accent-100);
  border-color: var(--accent-400);
  box-shadow: 0 0 14px rgba(var(--primary-rgb), 0.35);
}
.call-btn.end {
  background: linear-gradient(180deg, #ff5252, #cc2a2a);
  color: #fff;
  width: 60px;
  border-radius: 26px;
  border-color: rgba(255, 82, 82, 0.7);
  box-shadow: 0 6px 20px rgba(255, 82, 82, 0.35);
}
.call-btn.end:hover { background: linear-gradient(180deg, #ff7070, #dd4040); transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 28px rgba(255, 82, 82, 0.45); }

.call-btn-group { position: relative; display: flex; align-items: center; }
.call-btn-group .call-btn { border-radius: 24px 0 0 24px; border-right: none; }
.call-drop {
  width: 26px; height: 50px;
  border: 1px solid var(--border-1);
  border-radius: 0 24px 24px 0;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text-dim); font-size: 10px;
  display: grid; place-items: center;
  border-left: 1px solid rgba(var(--primary-rgb), 0.12);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.call-drop:hover { background: var(--surface-3); color: var(--accent-300); }
.call-dropdown {
  position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(2, 10, 4, 0.94);
  border: 1px solid var(--border-2);
  border-radius: var(--r-3);
  padding: 8px 0;
  min-width: 240px; max-width: 86vw;
  z-index: 10;
  box-shadow: var(--shadow-md);
  display: none;
  backdrop-filter: blur(10px);
  animation: menuPop 0.18s var(--ease-out);
}
.call-dropdown.open { display: block; }
.dd-label {
  padding: 4px 14px 2px;
  font-size: 10px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700;
}
.dd-select {
  width: calc(100% - 20px); margin: 0 10px 4px;
  padding: 7px 9px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  color: var(--text-strong);
  font-size: 12px; cursor: pointer; outline: none;
}
.dd-select:focus { border-color: var(--accent-400); }
.dd-sep { height: 1px; background: var(--border-1); margin: 6px 0; }
.dd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px; cursor: pointer;
  font-size: 13px; color: var(--text);
  border: none; background: none;
  width: 100%; text-align: left;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.dd-item:hover { background: var(--accent-faint); color: var(--accent-300); }
.dd-toggle {
  width: 36px; height: 20px; border-radius: 10px;
  border: 1px solid var(--border-1); cursor: pointer;
  background: var(--surface-2); position: relative;
  transition: background var(--t-base) var(--ease);
  flex-shrink: 0;
}
.dd-toggle.on { background: var(--accent-400); }
.dd-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff;
  transition: transform var(--t-base) var(--ease);
}
.dd-toggle.on::after { transform: translateX(16px); }

.settings-device-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.settings-device-row .dd-label { padding: 0; flex-shrink: 0; }
.settings-device-row .dd-select { width: 200px; margin: 0; flex-shrink: 0; }
#settingsNoiseRow { padding: 6px 0; font-size: 13px; color: var(--text); }

.tile-mic {
  position: absolute; top: 8px; right: 8px;
  z-index: 4;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0, 4, 0, 0.78);
  border: 1px solid var(--danger);
  display: grid; place-items: center;
  color: var(--danger);
  backdrop-filter: blur(4px);
  animation: recPulse 1.4s infinite;
}
.tile-mic svg { width: 14px; height: 14px; }

.voice-bar {
  display: flex; align-items: center; gap: 6px;
  margin: 8px 10px 0;
  padding: 8px 10px;
  background: rgba(var(--primary-rgb), 0.1);
  border: 1px solid var(--accent-400);
  border-radius: var(--r-3);
  position: relative;
  overflow: hidden;
}
.voice-bar::before {
  content: ""; position: absolute; inset: -2px;
  border-radius: var(--r-3);
  background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb), 0.25), transparent);
  background-size: 200% 100%;
  animation: barSlide 3s linear infinite;
  pointer-events: none;
}
@keyframes barSlide { to { background-position: 200% 0; } }
.vb-info {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  color: var(--accent-300); font-size: 12px; font-weight: 700;
}
.vb-info .vb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vb-info .vb-label::before { content: "🔊 "; }
.vb-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-400);
  box-shadow: 0 0 8px var(--accent-400);
  animation: stPulse 1.6s infinite; flex-shrink: 0;
}
.vb-btn {
  width: 30px; height: 30px;
  border: none; border-radius: 6px;
  background: var(--surface-2); color: var(--text);
  cursor: pointer; display: grid; place-items: center; flex-shrink: 0;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.vb-btn svg { width: 16px; height: 16px; }
.vb-btn:hover { background: var(--surface-3); color: var(--accent-300); }
.vb-btn.off { color: var(--danger); }
.vb-btn.end { background: var(--danger); color: #fff; }
.vb-btn.end:hover { background: #ff6666; }

/* === Входящий звонок (полноэкранный) === */
.call-incoming {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 4, 0, 0.92);
  backdrop-filter: blur(18px) saturate(140%);
  animation: ciFade 0.32s var(--ease-out);
}
@keyframes ciFade { from { opacity: 0; } to { opacity: 1; } }
.cava { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.6; }
.ci-card {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 32px calc(40px + env(safe-area-inset-bottom));
  text-align: center;
  width: 100%; max-width: 420px;
  animation: cardIn 0.5s var(--ease-out);
}
.ci-ava-wrap {
  position: relative; margin-bottom: 14px;
}
.ci-ava-wrap::before, .ci-ava-wrap::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-400);
  animation: ciRing 1.8s ease-out infinite;
  pointer-events: none;
}
.ci-ava-wrap::after { animation-delay: 0.9s; }
@keyframes ciRing { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.9); opacity: 0; } }
.ci-ava {
  width: 132px; height: 132px;
  font-size: 52px;
  position: relative; z-index: 1;
  border: 3px solid var(--accent-400);
  box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.45);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--bg-4), var(--bg-3));
}
.ci-ava img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ci-name {
  font-weight: 800; font-size: 26px; color: var(--accent-100);
  text-shadow: 0 0 12px rgba(var(--primary-rgb), 0.35);
  letter-spacing: 1.5px;
}
.ci-sub {
  color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 3px;
  font-weight: 700;
  animation: stPulse 1.4s var(--ease) infinite;
}
.ci-actions { display: flex; gap: 64px; margin-top: 40px; }

.ci-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: none; cursor: pointer;
  display: grid; place-items: center;
  color: #fff;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-base) var(--ease), filter var(--t-fast) var(--ease);
}
.ci-btn svg { width: 30px; height: 30px; }
.ci-btn.accept {
  background: linear-gradient(180deg, var(--accent-300), var(--accent-500));
  color: #001a08;
  box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.55), 0 12px 28px rgba(var(--primary-rgb), 0.4);
  animation: ciPulse 1.2s var(--ease) infinite;
}
.ci-btn.accept:hover { transform: scale(1.15); filter: brightness(1.06); }
.ci-btn.decline {
  background: linear-gradient(180deg, #ff5252, #b22020);
  color: #fff;
}
.ci-btn.decline svg { transform: rotate(135deg); }
.ci-btn.decline:hover { transform: scale(1.1) rotate(0); filter: brightness(1.1); }
@keyframes ciPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.55), 0 12px 28px rgba(var(--primary-rgb), 0.4); }
  50% { box-shadow: 0 0 0 22px rgba(var(--primary-rgb), 0), 0 12px 28px rgba(var(--primary-rgb), 0.4); }
}
/* Подпись кнопок */
.ci-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; margin-top: 8px; opacity: 0.7; }

/* Лайтбокс */
.lightbox {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0, 2, 0, 0.96);
  display: grid; place-items: center; overflow: hidden;
  cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 88vh; cursor: grab; transition: transform 0.08s linear; border-radius: 4px; }
.lightbox-hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: var(--text-dim); font-size: 12px; letter-spacing: 1px;
  background: rgba(0, 7, 0, 0.7); padding: 4px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border-1);
}

/* Тосты / индикаторы */
.notify-toast {
  position: fixed; top: 18px; right: 18px; z-index: 210;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--accent-400);
  color: var(--accent-100);
  font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--r-2);
  box-shadow: var(--shadow-md), 0 0 22px rgba(var(--primary-rgb), 0.32);
  transform: translateX(130%); opacity: 0;
  transition: transform var(--t-slow) var(--ease-out), opacity var(--t-slow) var(--ease-out);
}
.notify-toast.show { transform: none; opacity: 1; }
.notify-toast::before { content: "✉ "; color: var(--accent-300); }
.conn-status {
  position: fixed; top: 0; left: 50%; transform: translate(-50%, -100%); z-index: 200;
  background: var(--bg-1);
  border: 1px solid var(--danger);
  border-top: none;
  color: var(--danger); font-size: 12px; font-weight: 800;
  padding: 7px 18px;
  transition: transform var(--t-slow) var(--ease-out);
  text-transform: uppercase; letter-spacing: 1.6px;
  box-shadow: 0 6px 18px rgba(255, 82, 82, 0.25);
}
.conn-status.show { transform: translate(-50%, 0); }
.conn-status::before { content: "◈ "; color: var(--danger); }

/* Ping meter */
#pingMeter {
  position: absolute; top: 8px; right: 8px; z-index: 10;
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--border-1);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; gap: 4px;
  opacity: 0.75;
  transition: color var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  pointer-events: none;
  user-select: none;
}
#pingMeter.ping-green { color: var(--accent-300); border-color: rgba(61, 245, 138, 0.35); }
#pingMeter.ping-orange { color: var(--warn); border-color: rgba(255, 184, 77, 0.35); }
#pingMeter.ping-red { color: var(--danger); border-color: rgba(255, 82, 82, 0.35); }

/* HUD-эффекты */
.chat::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(var(--primary-rgb), 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--primary-rgb), 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000, transparent 92%);
          mask-image: radial-gradient(circle at 50% 40%, #000, transparent 92%);
}
.chat-head::after {
  content: ""; position: absolute; left: -30%; bottom: 0; width: 30%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-400), transparent);
  box-shadow: var(--glow-sm);
  animation: scanBeam 5s linear infinite;
}
@keyframes scanBeam { to { left: 130%; } }

.desktop-only { display: inline-flex; } .mobile-only { display: none; }

/* === Drag & drop overlay === */
/* Полноэкранный dimmed layer над сообщениями/композером когда пользователь тащит файл в
   активный чат. Показывается через .chat.dragover (из JS handleDragEnter / Counter). */
.drop-overlay {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0, 4, 0, 0.62);
  border: 2px dashed var(--accent-400);
  border-radius: var(--r-3);
  z-index: 15;
  pointer-events: none;
  backdrop-filter: blur(4px) saturate(140%);
  animation: dropOverlayIn 0.18s var(--ease-out);
}
@keyframes dropOverlayIn { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }
.chat.dragover .drop-overlay { display: flex; }
.drop-overlay-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 22px 28px;
  background: linear-gradient(180deg, rgba(0, 14, 6, 0.85), rgba(0, 7, 0, 0.92));
  border: 1px solid var(--accent-400);
  border-radius: var(--r-3);
  box-shadow: 0 0 28px rgba(var(--primary-rgb), 0.4);
  animation: dropPulse 1.4s var(--ease) infinite;
}
@keyframes dropPulse {
  0%, 100% { box-shadow: 0 0 28px rgba(var(--primary-rgb), 0.4); }
  50% { box-shadow: 0 0 44px rgba(var(--primary-rgb), 0.7); }
}
.drop-overlay-icon {
  font-size: 38px;
  color: var(--accent-300);
  text-shadow: 0 0 12px var(--accent-glow);
}
.drop-overlay-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-100);
  text-shadow: 0 0 8px rgba(var(--primary-rgb), 0.45);
}

/* Sticky day separator */
.day-sep {
  align-self: center;
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 8px;
  color: var(--text-dim); font-size: 11px;
  letter-spacing: 1.4px; text-transform: uppercase; font-weight: 700;
}
.day-sep::before, .day-sep::after {
  content: ""; height: 1px;
  width: 60px;
  background: linear-gradient(90deg, transparent, var(--border-2), transparent);
}

/* Presence ring on chat list avatar */
.chat-item .avatar::before {
  content: ""; position: absolute; inset: -3px;
  border-radius: inherit;
  border: 2px solid transparent;
  transition: border-color var(--t-base) var(--ease);
  pointer-events: none;
}
.chat-item.has-friend-online .avatar::before { border-color: rgba(var(--primary-rgb), 0.45); }

/* Tooltip — универсальный [data-tip] */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 6px);
  transform: translate(-50%, 4px) scale(0.96);
  background: rgba(2, 10, 4, 0.94);
  border: 1px solid var(--border-2);
  color: var(--accent-100);
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 5px;
  white-space: nowrap; letter-spacing: 0.4px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  z-index: 999;
}
[data-tip]:hover::after { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* === Settings overlay mobile (≤720px) — bottom-sheet style, scrollable tabs === */
@media (max-width: 720px) {
  .settings-overlay { padding: 0; align-items: end; }
  .settings-card {
    width: calc(100vw - 16px);
    height: min(96dvh, 880px);
    border-radius: 16px 16px 4px 4px;
    border-bottom: none;
    animation: sheetIn 0.32s var(--ease-out);
  }
  @keyframes sheetIn { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
  .settings-head { padding: 12px 18px; }
  .settings-head h2 { font-size: 14px; letter-spacing: 1.6px; }
  .settings-tabs {
    padding: 6px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .settings-tabs::-webkit-scrollbar { display: none; }
  .settings-tab {
    flex-shrink: 0;
    min-height: 44px;
    padding: 11px 14px;
    font-size: 11px;
    letter-spacing: 1px;
  }
  .settings-panes { padding: 16px 14px calc(20px + env(safe-area-inset-bottom)); }
  .settings-pane { gap: 11px; }
  /* Profile pane: bigger touch targets, ringtone row stacks */
  .profile-ava { width: 88px; height: 88px; font-size: 32px; }
  .field-wrap .toggle-eye, #profileName, #profileDesc { padding: 14px; font-size: 16px; } /* iOS no-zoom */
  #ringtoneMeta { flex-direction: column; align-items: flex-start; }
  .ringtone-actions { flex-wrap: wrap; }
  .ringtone-btn { min-height: 44px; padding: 10px 14px; flex: 1 0 auto; }
  /* Theme grid: 2 columns instead of variable-fill so touch targets stay visible */
  .theme-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .theme-opt { padding: 10px; gap: 6px; }
  .theme-opt .theme-swatch { height: 28px; }
  .theme-opt .theme-name { font-size: 12px; }
  .theme-opt .theme-desc { font-size: 10px; -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
  /* Contacts + Groups row contents: friend-pick wraps but bigger chips */
  .fp-chip { padding: 8px 12px; font-size: 13px; min-height: 36px; }
  .contact-row { padding: 10px 12px; gap: 12px; }
  .contact-row button { min-height: 40px; padding: 8px 14px; font-size: 12px; }
  .btn-primary, .btn-ghost { min-height: 48px; font-size: 14px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn-primary, .modal-actions .btn-ghost { flex: 1 1 140px; }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .chatlist { display: flex; }
  .app.in-chat .chatlist { display: none; }
  .chat { display: none; }
  .app.in-chat .chat { display: flex; }
  .info-panel { position: fixed; inset: 0; width: auto; z-index: 120; }
  .emoji-picker, .gif-panel { width: calc(100vw - 28px); left: 14px; height: 60vh; }
  .messages, .composer { padding-left: 14px; padding-right: 14px; }
  .chat-head { padding-left: 8px; padding-right: 8px; gap: 6px; }
  .chat-head .avatar.ch-ava { width: 36px; height: 36px; }
  .msg { max-width: 92%; }
  .desktop-only { display: none !important; }
  .back-btn.mobile-only { display: grid; }
  .win-btn.mobile-only { display: inline-flex; }
  .icon-btn { width: 46px; height: 46px; }
  .hicon-btn { width: 42px; height: 42px; }
  .hicon-btn svg { width: 20px; height: 20px; }
  .chat-title { font-size: 14px; }
  /* Звонок на телефоне — всегда на полный экран. background: var(--bg-1)
     обязателен: базовый .call-stage имеет градиент с rgba(.04) первым цветом,
     и без override сквозь него проглядывал чат + matrix-канвас (см. "background
     transparent on mobile"). На десктопе .fullscreen уже использует тот же фон. */
  .call-stage:not(.hidden) { position: fixed; inset: 0; z-index: 200; max-height: none; border-radius: 0; background: var(--bg-1); }
  .video-grid .tile { width: 100%; }
  .tile-avatar { width: 70px; height: 70px; font-size: 28px; }
  .call-btn { width: 48px; height: 48px; }
  .call-btn.end { width: 56px; }
  .call-btn.mobile-only { display: grid; }
  .call-grip, .call-resizer { display: none !important; }
  .lang-select { top: 10px; right: 10px; }
  .return-pill { bottom: calc(90px + env(safe-area-inset-bottom)); }
  /* стейдж отменяет has-call grid (док не работает на мобиле) */
  .chat.has-call > #callStage { grid-area: call; }
  .login-card { padding: 24px 18px; }
  .brand h1 { font-size: 22px; }
  .ci-actions { margin-top: 28px; gap: 36px; }
}

/* ============ Status pill — хедер чатлиста, рядом с никнеймом ============ */
.me-name-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.me-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  color: var(--text-dim);
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 700;
  cursor: pointer;
  border-radius: var(--r-pill);
  align-self: flex-start;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  margin-top: 1px;
}
.me-status:hover { color: var(--accent-300); background: var(--accent-faint); border-color: var(--accent-400); }
.me-status::after { content: "▾"; opacity: 0.5; margin-left: 2px; font-size: 9px; }
.me-status .ms-dot { width: 7px; height: 7px; }
.me-status-dnd { border-color: var(--danger); color: var(--danger); }
.me-status-dnd .ms-dot { box-shadow: 0 0 0 2px rgba(255, 82, 82, 0.2); }
.me-status-invisible { opacity: 0.65; }

.me-status-menu {
  position: fixed; z-index: 1400;
  min-width: 220px;
  background: rgba(2, 10, 4, 0.94);
  border: 1px solid var(--border-2); border-radius: var(--r-3);
  padding: 6px 0;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  animation: menuPop 0.18s var(--ease-out);
}
.me-status-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 14px;
  background: none; border: none; color: var(--text);
  font-size: 13px; cursor: pointer; text-align: left;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), padding-left var(--t-fast) var(--ease);
}
.me-status-menu button:hover { background: var(--accent-faint); color: var(--accent-300); padding-left: 18px; }
.me-status-menu button.on { font-weight: 700; color: var(--accent-100); }

/* ============ Settings overlay (Discord-style, 80% экрана) ============ */
.settings-overlay {
  position: fixed; inset: 0; z-index: 205;
  display: grid; place-items: center;
  background: rgba(0, 4, 0, 0.7);
  backdrop-filter: blur(14px) saturate(140%);
  animation: modalIn 0.18s var(--ease-out);
}
.settings-card {
  position: relative;
  width: min(80vw, 980px);
  height: min(80vh, 720px);
  display: grid;
  /* Rows: flashbang-banner (auto, may be hidden), settings-head, settings-tabs, settings-panes (1fr, scrollable) */
  grid-template-rows: auto auto auto 1fr;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border-2);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cardIn 0.34s var(--ease-out);
}
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-1);
  background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.06), transparent);
}
.settings-head h2 {
  font-weight: 800; font-size: 16px; color: var(--accent-200);
  letter-spacing: 2px; text-transform: uppercase;
  text-shadow: 0 0 8px rgba(var(--primary-rgb), 0.25);
  margin: 0;
}
.settings-tabs {
  display: flex; gap: 4px; padding: 8px 22px;
  border-bottom: 1px solid var(--border-1);
  background: rgba(0, 7, 0, 0.4);
}
.settings-tab {
  padding: 9px 14px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim);
  font-weight: 700; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  cursor: pointer; border-radius: var(--r-2);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.settings-tab:hover { color: var(--accent-300); background: var(--accent-faint); }
.settings-tab.active {
  background: linear-gradient(180deg, var(--accent-400), var(--accent-600));
  color: #001a08;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 4px 18px rgba(var(--primary-rgb), 0.18);
}
.settings-panes { overflow-y: auto; padding: 22px; min-height: 0; }
.settings-pane { display: none; flex-direction: column; gap: 12px; }
.settings-pane.active { display: flex; }
.settings-pane h3 {
  font-weight: 800; font-size: 13px; color: var(--accent-300);
  letter-spacing: 1.6px; text-transform: uppercase;
  margin: 0 0 6px 0;
  text-shadow: 0 0 6px rgba(var(--primary-rgb), 0.18);
}

/* Themes grid — живые свотчи превью */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.theme-opt {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  color: var(--text); font: inherit;
}
.theme-opt:hover { background: var(--surface-2); border-color: var(--accent-400); transform: translateY(-2px); }
.theme-opt.active {
  border-color: var(--accent-400);
  background: rgba(var(--primary-rgb), 0.12);
  box-shadow: 0 0 18px rgba(var(--primary-rgb), 0.18);
}
.theme-opt:active { transform: translateY(0); }
.theme-opt .theme-swatch {
  display: flex; gap: 3px; height: 36px; border-radius: var(--r-2);
  overflow: hidden; border: 1px solid var(--border-1);
}
.theme-opt .theme-swatch span { flex: 1; height: 100%; }
.theme-opt .theme-name { font-weight: 700; font-size: 13px; color: var(--accent-100); letter-spacing: 0.4px; }
.theme-opt .theme-desc { color: var(--text-dim); font-size: 11px; }

/* ============ Themes ============ */
/* :root задаёт базовые токены (legacy «High Contrast» / Matrix). Все темы СЕЙЧАС
   пребилт-стайл — :root это дефолт-фон, а bоdy[data-theme="..."] переключает акценты и
   декоративные слои (matrix/mono/midnight/dracula/flashbang). Никаких пользовательских
   тем: swatch и пресеты зашиты в THEMES[] в app.js.
   Тоны :root — это явный чёрный + неон, без зеленцовой дымки в --bg-* — поверх него
   остальные темы — это переназначения токенов + (опц.) локальных декоративных слоёв. */

/* Matrix — дефолт. Чёрный фон + неоновые акценты #00ff5a,
   без движущейся скан-плёнки на чате (функциональные modalIn/cardIn/menuPop глушить нельзя —
   это «появилось/открылось» сигналы UI; их оставляем как есть). Матричный rAF-дождь из
   matrix.js сидит на логине поверх, а здесь его CSS-след выключен явно. */
body[data-theme="matrix"] {
  --primary-rgb: 0, 255, 90;                       /* matrix neon — primary #00ff5a */
  --accent-100: #ffffff; --accent-200: #d6ffe0; --accent-300: #88ffaa;
  --accent-400: #00ff5a; --accent-500: #00cc48; --accent-600: #009938;
  --accent-glow: rgba(var(--primary-rgb), 0.7); --accent-soft: rgba(var(--primary-rgb), 0.22);
  --bg-0: #000000; --bg-1: #000000; --bg-2: #000604; --bg-3: #000c08; --bg-4: #00130c;
  --cyan-300: #66ddff;
}
body[data-theme="matrix"]::before { display: none; }                 /* без скан-линий на чате */
body[data-theme="matrix"] { background-image: none; text-shadow: none; }
body[data-theme="matrix"] .chat::before { display: none; }            /* без фоновой сетки */
body[data-theme="matrix"] .chatlist::before { display: none; }        /* без neon-strip сверху */
body[data-theme="matrix"] .brand-logo::after { display: none; }      /* без пульса логотипа */
body[data-theme="matrix"] .chat-head::after { display: none; }        /* без scan-beam */
body[data-theme="matrix"] .composer::before { display: none; }       /* без shimmer-полосы */
body[data-theme="matrix"] .voice-bar::before { display: none; }       /* без shimmer */
body[data-theme="matrix"] .ci-ava-wrap::before,
body[data-theme="matrix"] .ci-ava-wrap::after { display: none; }      /* без волн входящего звонка */
body[data-theme="matrix"] .tile-avatar::before { display: none; }     /* без торцевых колец */
body[data-theme="matrix"] .msg { animation: none; }
body[data-theme="matrix"] .bubble { animation: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
body[data-theme="matrix"] .msg.me .bubble { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }
body[data-theme="matrix"] .chat-title { text-shadow: none; }
body[data-theme="matrix"] .msg.ping .bubble { animation: none; }
body[data-theme="matrix"] .call-go.in-call { animation: none; }
body[data-theme="matrix"] .call-go.join-call { animation: none; }
body[data-theme="matrix"] .typing::before { animation: none; }
body[data-theme="matrix"] .typing-dots span { animation: none; }
body[data-theme="matrix"] .icon-btn.recording { animation: none; }
body[data-theme="matrix"] .ci-bot .badge { box-shadow: none; animation: none; }
body[data-theme="matrix"] .msg-status[data-status="delivered"],
body[data-theme="matrix"] .msg-status[data-status="read"] { filter: none; animation: none; }
body[data-theme="matrix"] .call-matrix { opacity: 0.05; }
body[data-theme="matrix"] .ci-btn.accept { animation: none; }
body[data-theme="matrix"] .reaction { animation: none; }
body[data-theme="matrix"] .reaction.mine { box-shadow: none; }
body[data-theme="matrix"] [data-tip]::after { transition: opacity var(--t-fast) var(--ease); transform: translate(-50%, 0) scale(1); }
body[data-theme="matrix"] .es-logo { animation: none; text-shadow: none; }

/* Amber CRT — янтарный фосфор */
body[data-theme="midnight"] {
  --primary-rgb: 90, 138, 255;                    /* icy blue — primary #5a8aff */
  --accent-100: #e5f0ff; --accent-200: #b6d2ff; --accent-300: #88aedb;
  --accent-400: #5a8aff; --accent-500: #3868d8; --accent-600: #2a4ea8;
  --accent-glow: rgba(90, 138, 255, 0.55); --accent-soft: rgba(90, 138, 255, 0.16);
  --bg-0: #06080f; --bg-1: #0a0e1c; --bg-2: #0f1428; --bg-3: #141c34; --bg-4: #1d2748;
  --cyan-300: #6ed8ff;
}
/* Vice City — неоновый Майами 80-х: розовый как primary + бирюза как cyan. На пурпурной
   ночи, без оранжево-зелёного tone. .msg.me .bubble получает ярко-малиновую подложку. */
body[data-theme="dracula"] {
  --primary-rgb: 189, 147, 249;                   /* Dracula Purple — primary #bd93f9 */
  --accent-100: #f8f8f2; --accent-200: #ffb86c; --accent-300: #bd93f9;
  --accent-400: #bd93f9; --accent-500: #8be9fd; --accent-600: #6272a4;
  --accent-glow: rgba(189, 147, 249, 0.5); --accent-soft: rgba(189, 147, 249, 0.16);
  --bg-0: #191a21; --bg-1: #21222c; --bg-2: #282a36; --bg-3: #343746; --bg-4: #44475a;
  --cyan-300: #8be9fd;
  --danger: #ff5555;
}
/* Dracula собственные бампы: зелёная галочка доставки заменилась на cyan-Dracula,
   потому что primary-зелёного #50fa7b у нас нет в палитре green-* (там фиолет). */
body[data-theme="dracula"] .msg.me .bubble { color: #f8f8f2; background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.22), rgba(var(--primary-rgb), 0.12)); border-color: #bd93f9; }
body[data-theme="dracula"] .msg-status[data-status="delivered"] { color: #8be9fd; }
body[data-theme="dracula"] .msg-status[data-status="read"] { color: #50fa7b; }

/* Nord — официальная палитра Nord (https://www.nordtheme.com). Polar Night для фона,
   Frost для акцентов. primary = Frost-3 #88c0d0 (тёплый ледяной циан). */
body[data-theme="flashbang"] {
  --primary-rgb: 22, 163, 74;                     /* fresh green — primary #16a34a (Tailwind green-600) */
  --accent-100: #111827; --accent-200: #1f2937; --accent-300: #1f2937;
  --accent-400: #16a34a; --accent-500: #15803d; --accent-600: #166534;
  --accent-glow: rgba(var(--primary-rgb), 0.3); --accent-soft: rgba(var(--primary-rgb), 0.14);
  --accent-faint: rgba(var(--primary-rgb), 0.07);
  --bg-0: #ffffff; --bg-1: #ffffff; --bg-2: #ffffff; --bg-3: #ffffff; --bg-4: #f5f5f5;
  --surface-1: rgba(var(--primary-rgb), 0.04); --surface-2: rgba(var(--primary-rgb), 0.08);
  --surface-3: rgba(var(--primary-rgb), 0.14);
  --border-1: rgba(17, 24, 39, 0.10); --border-2: rgba(17, 24, 39, 0.18); --border-3: rgba(17, 24, 39, 0.32);
  --text: #1f2937; --text-strong: #111827; --text-dim: #6b7280;
  --glow-sm: 0 0 0 1px rgba(var(--primary-rgb), 0.18);
  --glow-md: 0 0 0 1px rgba(var(--primary-rgb), 0.22);
  --glow-lg: 0 0 0 1px rgba(var(--primary-rgb), 0.28);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06), 0 2px 6px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.08), 0 2px 4px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 18px 46px rgba(17, 24, 39, 0.12), 0 6px 16px rgba(17, 24, 39, 0.06);
  --cyan-300: #0891b2;
  --danger: #dc2626;
  background: var(--bg-1);
  background-image: none;
  color: var(--text);
  text-shadow: none;
}
/* Flashbang-специфичные перебивки: матричный дождь, неоновые полосы и глоу-текст-shadow
   на светлом фоне смотрятся грязно/чужеродно — глушим. Логин-карточка получает светлый градиент
   и более тонкую рамку (зелёная rgba на белом — рабочая). */
body[data-theme="flashbang"]::before { display: none; }
body[data-theme="flashbang"] .chat::before { display: none; }
body[data-theme="flashbang"] .chatlist::before { display: none; }
body[data-theme="flashbang"] .brand-logo::after { display: none; }
body[data-theme="flashbang"] .chat-head::after { display: none; }
body[data-theme="flashbang"] .composer::before { display: none; }
body[data-theme="flashbang"] .voice-bar::before { display: none; }
body[data-theme="flashbang"] .ci-ava-wrap::before,
body[data-theme="flashbang"] .ci-ava-wrap::after { display: none; }
body[data-theme="flashbang"] .tile-avatar::before { display: none; }
body[data-theme="flashbang"] .call-matrix { display: none; }
/* Plain-light overrides — логин-карточка, фирменные модалы, баблы, кнопки и состояния в "нормальной" светлой теме — flat white/светло-серые фоны,
   тонкие серые границы, зелёные акценты и обычные тени. Без неоновых glow, gradient оверлеев и фоновых текстовых shadow. */
body[data-theme="flashbang"] .login-card {
  background: linear-gradient(180deg, #ffffff, #f8f9fb);
  border: 1px solid var(--border-1);
  box-shadow: var(--shadow-lg);
}
body[data-theme="flashbang"] .login::before {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(var(--primary-rgb), 0.08), transparent 70%),
    radial-gradient(ellipse at 50% 100%, rgba(var(--primary-rgb), 0.04), transparent 60%);
}
body[data-theme="flashbang"] .brand h1 { color: var(--text-strong); }
body[data-theme="flashbang"] .brand-logo { color: var(--accent-400); text-shadow: none; box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08); }
/* Field/input selection — голубой фон, тёмный текст (high contrast на белом). */
body[data-theme="flashbang"] ::selection { background: rgba(var(--primary-rgb), 0.18); color: var(--text-strong); }
/* Incoming bubble — обычный текст на белом (тёмный текст на светлом = нормально). */
body[data-theme="flashbang"] .bubble { background: #ffffff; border-color: var(--border-1); color: var(--text); box-shadow: var(--shadow-sm); }
/* «Our» bubble — solid blue, белый текст (typical light-theme messenger look). */
body[data-theme="flashbang"] .msg.me .bubble { background: var(--accent-400); border-color: var(--accent-500); color: #ffffff; box-shadow: 0 2px 8px rgba(22, 163, 74, 0.16); }
/* Send-button: solid blue, без неонового glow. */
body[data-theme="flashbang"] .icon-btn.send { background: var(--accent-400); color: #ffffff; box-shadow: 0 0 0 1px rgba(var(--primary-rgb),.2) inset, 0 2px 8px rgba(22, 163, 74, 0.18); }
body[data-theme="flashbang"] .btn-primary { color: #ffffff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.22), 0 4px 14px rgba(var(--primary-rgb),0.22); }
/* Active chat-item, badges — без неоновых shadow на светлом. */
body[data-theme="flashbang"] .chat-item { background: #f5f5f5; }
body[data-theme="flashbang"] .chat-item.active { background: #e8e8e8; box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb),.22); }
body[data-theme="flashbang"] .chat-item:hover { background: #ebebeb; }
body[data-theme="flashbang"] .chat-item.pinned { background: #ececec; }
body[data-theme="flashbang"] .ci-bot .badge { box-shadow: 0 1px 4px rgba(var(--primary-rgb),.22); }
/* Plain chat list/head — без neon-strip, flat light. */
body[data-theme="flashbang"] .chatlist { background: var(--bg-1); }
body[data-theme="flashbang"] .chat-head { background: #ffffff; border-bottom-color: var(--border-1); }
body[data-theme="flashbang"] .composer { background: #ffffff; border-top-color: var(--border-1); }
body[data-theme="flashbang"] .chat.has-wallpaper .messages { background: rgba(255, 255, 255, 0.75); }
body[data-theme="flashbang"] .info-panel { background: var(--bg-1); border-left-color: var(--border-1); }
/* Кнопки — flat hover без прозрачных overlays. */
body[data-theme="flashbang"] .icon-btn:hover { background: var(--surface-2); }
body[data-theme="flashbang"] .theme-opt:hover { background: var(--surface-2); }
body[data-theme="flashbang"] .theme-opt.active { box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.35); }
/* Modal-card / settings-card / panels — flat white с нормальной тенью. */
body[data-theme="flashbang"] .modal-card { background: #ffffff; border-color: var(--border-2); box-shadow: var(--shadow-md); }
body[data-theme="flashbang"] .settings-card { background: #ffffff; border-color: var(--border-2); box-shadow: var(--shadow-lg); }
body[data-theme="flashbang"] .emoji-picker,
body[data-theme="flashbang"] .gif-panel { background: #ffffff; border-color: var(--border-2); box-shadow: var(--shadow-lg); }
body[data-theme="flashbang"] .chat-menu { background: #ffffff; border-color: var(--border-2); box-shadow: var(--shadow-lg); }
body[data-theme="flashbang"] .react-picker { background: #ffffff; border-color: var(--border-2); box-shadow: var(--shadow-lg); }
body[data-theme="flashbang"] .me-status-menu { background: #ffffff; border-color: var(--border-2); box-shadow: var(--shadow-lg); }
body[data-theme="flashbang"] .notify-toast { background: #ffffff; border-color: var(--accent-400); color: var(--text-strong); box-shadow: var(--shadow-lg); }
/* .mention on outgoing bubble: dark text on blue = low contrast — flip to white on flashbang. */
body[data-theme="flashbang"] .msg.me .mention { color: #ffffff; }

/* Monochrome — чисто чёрно-белая светлая тема («newspaper» style): только серые тона + чистый чёрный текст.
   Удобно для печати/чтения — ни одного цветного акцента, только градации серого. primary-rgb — чисто чёрный (R=G=B=24), так что все rgba(—primary-rgb,··) оверлеи тоже становятся чисто серыми. */
body[data-theme="mono"] {
  --primary-rgb: 255, 255, 255;
  --bg-0: #000000;
  --bg-1: #050505;
  --bg-2: #0a0a0a;
  --bg-3: #111111;
  --bg-4: #181818;

  --accent-100: #ffffff;
  --accent-200: #f5f5f5;
  --accent-300: #d4d4d4;
  --accent-400: #ffffff;
  --accent-500: #e4e4e4;
  --accent-600: #a1a1aa;
  --accent-700: rgba(255, 255, 255, 0.35);
  --accent-glow: rgba(255, 255, 255, 0.5);
  --accent-soft: rgba(255, 255, 255, 0.16);
  --accent-faint: rgba(255, 255, 255, 0.08);

  --cyan-300: #ffffff;
  --danger: #ffffff;

  --surface-1: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-3: rgba(255, 255, 255, 0.14);

  --border-1: rgba(255, 255, 255, 0.14);
  --border-2: rgba(255, 255, 255, 0.28);
  --border-3: rgba(255, 255, 255, 0.55);

  --text: #d4d4d4;
  --text-strong: #ffffff;
  --text-dim: #71717a;

  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 4px 14px rgba(0, 0, 0, 0.7);
  --shadow-md: 0 0 0 1px rgba(255, 255, 255, 0.1) inset, 0 12px 38px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.14) inset, 0 22px 64px rgba(0, 0, 0, 0.85);

  --glow-sm: 0 0 6px rgba(255, 255, 255, 0.3);
  --glow-md: 0 0 14px rgba(255, 255, 255, 0.22);
  --glow-lg: 0 0 24px rgba(255, 255, 255, 0.3);

  background: var(--bg-1);
  color: var(--text);
}
body[data-theme="mono"]::before { display: none; }
body[data-theme="mono"] .chat::before { display: none; }
body[data-theme="mono"] .chatlist::before { display: none; }
body[data-theme="mono"] .brand-logo::after { display: none; }
body[data-theme="mono"] .chat-head::after { display: none; }
body[data-theme="mono"] .composer::before { display: none; }
body[data-theme="mono"] .voice-bar::before { display: none; }
body[data-theme="mono"] .ci-ava-wrap::before,
body[data-theme="mono"] .ci-ava-wrap::after { display: none; }
body[data-theme="mono"] .tile-avatar::before { display: none; }
body[data-theme="mono"] .call-matrix { display: none; }
body[data-theme="mono"] .modal-card,
body[data-theme="mono"] .settings-card,
body[data-theme="mono"] .chat-menu,
body[data-theme="mono"] .react-picker,
body[data-theme="mono"] .me-status-menu,
body[data-theme="mono"] .emoji-picker,
body[data-theme="mono"] .gif-panel { background: var(--bg-2); border-color: var(--border-2); box-shadow: var(--shadow-md); color: var(--text); }
body[data-theme="mono"] .chat-head { background: var(--bg-1); border-bottom-color: var(--border-1); color: var(--text-strong); }
body[data-theme="mono"] .composer { background: var(--bg-1); border-top-color: var(--border-1); color: var(--text); }
body[data-theme="mono"] .info-panel { background: var(--bg-1); border-left-color: var(--border-1); color: var(--text); }
body[data-theme="mono"] .bubble { background: var(--bg-3); color: var(--text); border-color: var(--border-1); box-shadow: var(--shadow-sm); }
body[data-theme="mono"] .msg.me .bubble { background: #ffffff; color: #000000; border-color: #ffffff; box-shadow: var(--shadow-md); }
body[data-theme="mono"] .msg.me .mention { color: rgba(0, 0, 0, 0.85); }
body[data-theme="mono"] .login-card { background: var(--bg-2); border-color: var(--border-2); box-shadow: var(--shadow-lg); color: var(--text); }
body[data-theme="mono"] .bubble, body[data-theme="mono"] .msg, body[data-theme="mono"] .chat-title,
body[data-theme="mono"] .es-logo, body[data-theme="mono"] .mention, body[data-theme="mono"] .setting-tab { animation: none; text-shadow: none; }
/* Monochrome deliberately nukes the theme palette to greyscale, which would also flatten
   the .st-online / .st-dnd dots to white-on-white. Force them back to their canonical
   red/green so users can still tell "online" vs "do not disturb" at a glance. */
body[data-theme="mono"] .st-online {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3), 0 0 8px #22c55e;
}
body[data-theme="mono"] .st-dnd {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
}
/* ============ MSN / Windows Live Messenger (2009) ============
   Flat pale-blue background, white panels, classic #0a78d3 blue accents.
   Triangle bubble tails (WLM wedge) rendered via ::before + ::after.
   No glassmorphism, no bokeh, no animations — calm and readable. */
/* Mono Light — зеркальный близнец mono. Чёрный фон / белый текст → белый фон / чёрный текст,
   все декоративные overlays отключены. Используется как «пара» к mono (dark + light версии
   одной чёрно-белой палитры). primary = 0,0,0 → rgba(--primary-rgb) для свечений работает как
   полупрозрачный чёрный, не зелёный/синий. */
body[data-theme="mono-light"] {
  --primary-rgb: 0, 0, 0;                          /* mono counterpart of --primary-rgb */
  --accent-100: #ffffff; --accent-200: #f4f4f4; --accent-300: #e5e5e5;
  --accent-400: #111111; --accent-500: #404040; --accent-600: #555555;
  --accent-glow: rgba(0, 0, 0, 0.18); --accent-soft: rgba(0, 0, 0, 0.10);
  --accent-faint: rgba(0, 0, 0, 0.04);
  --bg-0: #ffffff; --bg-1: #ffffff; --bg-2: #f7f7f7; --bg-3: #ececec; --bg-4: #e0e0e0;
  --surface-1: rgba(0, 0, 0, 0.02); --surface-2: rgba(0, 0, 0, 0.05);
  --surface-3: rgba(0, 0, 0, 0.10);
  --border-1: rgba(0, 0, 0, 0.10); --border-2: rgba(0, 0, 0, 0.18); --border-3: rgba(0, 0, 0, 0.36);
  --text: #1a1a1a; --text-strong: #000000; --text-dim: #6a6a6a;
  --glow-sm: 0 0 0 1px rgba(0, 0, 0, 0.06);
  --glow-md: 0 0 0 1px rgba(0, 0, 0, 0.10);
  --glow-lg: 0 0 0 1px rgba(0, 0, 0, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 18px 46px rgba(0, 0, 0, 0.10), 0 6px 16px rgba(0, 0, 0, 0.05);
  --cyan-300: #404040;
  --danger: #b00020;
  background: var(--bg-1);
  background-image: none;
  color: var(--text);
  text-shadow: none;
}
body[data-theme="mono-light"]::before { display: none; }
body[data-theme="mono-light"] .chat::before { display: none; }
body[data-theme="mono-light"] .chatlist::before { display: none; }
body[data-theme="mono-light"] .brand-logo::after { display: none; }
body[data-theme="mono-light"] .chat-head::after { display: none; }
body[data-theme="mono-light"] .composer::before { display: none; }
body[data-theme="mono-light"] .voice-bar::before { display: none; }
body[data-theme="mono-light"] .ci-ava-wrap::before,
body[data-theme="mono-light"] .ci-ava-wrap::after { display: none; }
body[data-theme="mono-light"] .tile-avatar::before { display: none; }
body[data-theme="mono-light"] .call-matrix { display: none; }
body[data-theme="mono-light"] .modal-card,
body[data-theme="mono-light"] .settings-card,
body[data-theme="mono-light"] .chat-menu,
body[data-theme="mono-light"] .react-picker,
body[data-theme="mono-light"] .me-status-menu,
body[data-theme="mono-light"] .emoji-picker,
body[data-theme="mono-light"] .gif-panel { background: var(--bg-2); border-color: var(--border-2); box-shadow: var(--shadow-md); color: var(--text); }
body[data-theme="mono-light"] .chat-head { background: var(--bg-1); border-bottom-color: var(--border-1); color: var(--text-strong); }
body[data-theme="mono-light"] .composer { background: var(--bg-1); border-top-color: var(--border-1); color: var(--text); }
body[data-theme="mono-light"] .chat.has-wallpaper .messages { background: rgba(255, 255, 255, 0.75); }
body[data-theme="mono-light"] .info-panel { background: var(--bg-1); border-left-color: var(--border-1); color: var(--text); }
body[data-theme="mono-light"] .bubble { background: var(--bg-3); color: var(--text); border-color: var(--border-1); box-shadow: var(--shadow-sm); }
body[data-theme="mono-light"] .msg.me .bubble { background: #000000; color: #ffffff; border-color: #000000; box-shadow: var(--shadow-md); }
body[data-theme="mono-light"] .msg.me .mention { color: #ffffff; }
body[data-theme="mono-light"] .login-card { background: var(--bg-2); border-color: var(--border-2); box-shadow: var(--shadow-lg); color: var(--text); }
body[data-theme="mono-light"] .bubble, body[data-theme="mono-light"] .msg, body[data-theme="mono-light"] .chat-title,
body[data-theme="mono-light"] .es-logo, body[data-theme="mono-light"] .mention, body[data-theme="mono-light"] .setting-tab { animation: none; text-shadow: none; }
body[data-theme="mono-light"] .icon-btn.send { background: #000000; color: #ffffff; border-color: #000000; box-shadow: 0 0 0 1px rgba(0,0,0,.2) inset, 0 2px 8px rgba(0,0,0,0.18); }
body[data-theme="mono-light"] .btn-primary { color: #ffffff; box-shadow: inset 0 -2px 0 rgba(255,255,255,.15), 0 4px 14px rgba(0,0,0,0.22); }
/* ============ Custom Theme Editor: 2-column layout + live preview ============ */
/* Default tokens for the preview pane. The live-preview <style> injects the user's
   CSS under .ct-preview-scope so these are what the sample looks like BEFORE they
   type. We mirror the matrix-theme palette so the empty preview still feels like
   part of the app. Override these in your custom CSS to recolor the sample. */
.ct-preview-scope {
  --primary-rgb: 0, 255, 90;
  --bg-0: #000000; --bg-1: #001200; --bg-2: #001a06; --bg-3: #002a0d;
  --text: #b6ffd2; --text-dim: #5fa37a;
  --accent-100: #00ff5a; --accent-300: #88ffaa; --accent-500: #00cc6a;
  --r-2: 6px; --r-4: 10px;
  display: block;
}
/* 2-column editor layout. The CSS textarea sits on the left, the preview sample
   on the right. Falls back to a single column under 720px so the textarea remains
   usable on mobile. */
.ct-editor-grid {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 14px;
  align-items: stretch;
}
.ct-editor-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ct-editor-col .field.ct-css { flex: 1; min-height: 180px; font-family: var(--mono, ui-monospace, Menlo, Consolas, monospace); font-size: 12.5px; line-height: 1.45; }
/* Preview pane border + background fall back to current theme tokens so the pane
   blends in. Users can re-skin within via their .ct-preview-scope CSS. */
.ct-preview-scope {
  background: var(--bg-1);
  color: var(--text);
  border: 1px solid var(--bg-3);

/* ============ Custom-theme cards (edit/delete actions) + ringtone UI ============ */
/* Custom-theme rows used to live in a single shared block with theme-opt-add and the
   ringtone pane. Custom themes are gone; the action-button / theme-badge CSS went with
   them. We still need .ringtone-* styles below because the profile pane's ringtone
   picker (HTML + JS) is still wired up. */
.ringtone-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  margin-top: 6px;
}
.ringtone-row .ringtone-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-dim);
}
.ringtone-row .ringtone-meta strong { color: var(--text-strong); }
.ringtone-row .ringtone-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ringtone-row .ringtone-btn {
  flex: 1; min-width: 90px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid var(--border-1);
  color: var(--text);
  border-radius: var(--r-2);
  cursor: pointer; font-size: 12px;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.ringtone-row .ringtone-btn:hover { color: var(--accent-300); border-color: var(--accent-400); background: var(--accent-faint); }
.ringtone-row .ringtone-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: rgba(255, 82, 82, 0.12); }
.ringtone-row audio { width: 100%; margin-top: 6px; }



@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ============ Flashbang confirm dialog ============ */
/* Centered warning modal that asks the user to confirm the destructive flashbang effect.
   Reuses .modal / .modal-card / .hub-close / .modal-actions — no overrides needed there. */
.btn-danger {
  background: linear-gradient(180deg, #ff5252, #b22020);
  color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 8px 22px rgba(255, 82, 82, 0.28);
}
.btn-danger:hover {
  /* keep :hover lift consistent with .btn-primary; brightness boost + slightly stronger shadow */
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 12px 28px rgba(255, 82, 82, 0.45);
}
.btn-danger:active { transform: translateY(0); filter: brightness(0.96); }
.btn-danger:disabled { filter: grayscale(0.6) brightness(0.7); cursor: not-allowed; transform: none; }
.fb-dont-show {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  padding: 4px 12px 0; font-size: 12px; cursor: pointer; color: var(--text-dim);
  user-select: none;
}
.fb-dont-show input { accent-color: var(--accent-400); }
.btn-danger:focus-visible {
  outline: 2px solid #ff7878;
  outline-offset: 3px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(255, 82, 82, 0.32);
  transform: none;
}
.fb-confirm-card { width: min(420px, 92vw); }
.fb-confirm-body {
  margin: 0;
  padding: 8px 12px;
  color: var(--text-strong);
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
  /* Pinned to literal red so the warning stays visible in monochrome theme (where --danger
     is overridden to white by the mono palette). Matches the precedent set by the
     .st-online / .st-dnd force-color overrides. */
  border-left: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.08);
  border-radius: 4px;
}

/* ============ Upload progress bar ============ */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  flex-shrink: 0;
  animation: upIn 0.2s var(--ease-out);
}
@keyframes upIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}
.upload-progress.hidden { display: none; }
.up-bar {
  flex: 1;
  height: 6px;
  min-width: 60px;
  background: var(--bg-3);
  border: 1px solid var(--border-1);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.up-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-400), var(--accent-300));
  border-radius: var(--r-pill);
  transition: width 0.15s var(--ease);
}
.up-text {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 32px;
  text-align: right;
  letter-spacing: 0.3px;
}
.up-cancel {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-1);
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.up-cancel:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(255, 82, 82, 0.12);
}

/* ============ PWA Install button ============ */
#installBtn {
  animation: installPulse 2s var(--ease) infinite;
}
#installBtn.hidden { display: none; }
@keyframes installPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.3); }
  50% { box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.08); }
}
