/* ═══════════════════════════════════════════════════════════════
   Amorum AI Web App — Global Styles
   Design system from live_web/static/index.html
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ═══ Brand palette — neon dark, фиолетовый подтон ═══════════════
     Источник: фирменный гайд (логотип Amorum AI).
     Главные правила:
       1. Все backgrounds — холодные, с фиолетовым подтоном (никакого
          коричневого/бордового дрейфа).
       2. Главные акценты — pink-magenta + violet (логотип). Orange-warm
          существует, но используется крайне редко (горячие действия,
          премиум-эффекты, не как постоянный цвет интерфейса).
  ─────────────────────────────────────────────────────────────────── */

  /* ── Backgrounds: почти чёрный, с фиолетовым подтоном ──
     Базовый тон body совпадает с нижним стопом ambient-градиента
     (#07060B), чтобы переход edges → bg-primary не давал «полосы». */
  --bg-primary:     #07060B;   /* base body fallback (= нижний стоп ambient) */
  --bg-mid:         #0B0712;   /* средний стоп ambient                       */
  --bg-deep:        #09070F;   /* верхний стоп ambient                       */
  --bg-card:        #151020;   /* карточки/попапы                            */
  --bg-card-hover:  #1A1026;   /* hover                                      */
  --bg-elevated:    #21142F;   /* приподнятые блоки (модалки, плеер)         */
  --border:         #21142F;
  --border-accent:  #2E1B40;

  /* ── Текст ── */
  --text-primary:   #f0eff4;
  --text-secondary: #8a8694;
  --text-muted:     #5a5666;

  /* ── Brand accents — точно из логотипа Amorum AI ──
     Логотип использует 3-stop переход: coral (нижние пряди волос) →
     magenta (макушка, шея) → violet (виски, контур сердца).
     Цвета намеренно НЕ-неоновые: saturation ~70%, чтобы выглядели
     «бархатно, чувственно», как на эталонном скриншоте плеера. */
  --brand-coral:    #F25C3F;   /* самый тёплый — нижние волны волос       */
  --brand-pink:     #E63E80;   /* розовый-роза, средний слой              */
  --brand-magenta:  #C82E8C;   /* magenta — макушка, центральный hue      */
  --brand-violet:   #7B3FA8;   /* фиолет — виски, контур, тени            */

  /* Compat-алиасы (старые имена, чтобы не ломать существующий код) */
  --accent-pink:    var(--brand-pink);
  --accent-purple:  var(--brand-violet);
  --accent-orange:  var(--brand-coral);   /* coral теперь и есть наш warm */
  --accent-red:     #E11D48;              /* критические действия         */
  --accent-indigo:  #6366F1;              /* индикаторы режимов           */

  /* ── Главный градиент CTA: 3-stop как на логотипе и в эталонном плеере.
        135° даёт диагональ coral(top-left) → magenta(center) → violet(bot-right). ── */
  --gradient-main: linear-gradient(135deg, #F25C3F 0%, #C82E8C 50%, #7B3FA8 100%);
  --gradient-soft: linear-gradient(135deg, rgba(242,92,63,0.14) 0%, rgba(200,46,140,0.14) 50%, rgba(123,63,168,0.14) 100%);
  /* «Горячий» градиент — coral-доминантный (premium/редкий CTA) */
  --gradient-hot:  linear-gradient(135deg, #FF6B45 0%, #E63E80 100%);

  /* ── Единый highlight для активных/выделенных элементов
        Magenta — центральная точка градиента, родственна и coral, и violet,
        одинаково хорошо работает рядом с любым CTA-элементом. ── */
  --accent-highlight:       #C82E8C;
  --accent-highlight-bg:    rgba(200,46,140,0.12);
  --accent-highlight-track: rgba(200,46,140,0.18);

  /* ── Свечения (glow) — на основе логотипных акцентов ── */
  --shadow-glow: 0 0 20px rgba(230,62,128,0.22), 0 0 40px rgba(123,63,168,0.14);

  /* ── Геометрия ── */
  --radius: 14px;
  --radius-sm: 10px;

  /* ── Scrollbars (в гамме бренда) ── */
  --scrollbar-size: 8px;
  --scrollbar-track:       rgba(255,255,255,0.04);
  --scrollbar-thumb:       rgba(230,62,128,0.45);
  --scrollbar-thumb-hover: rgba(123,63,168,0.62);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Global scrollbar skin (applies to all scrollable containers).
   Local component rules may still override this when needed. */
html, body, * {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}
*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

/* Kill default browser tap / focus highlights */
*, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
}
button, a, img, [role="button"] {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-pink);
  outline-offset: 2px;
}

/* Prevent text selection on all UI elements except inputs/textareas */
button, .header, .seg-btn, .mode-popup-btn, .btn-mode, .btn-mic, .btn-send,
.voice-player, .voice-rec-bar, .char-card, .icon-btn, label {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Корневой элемент: гарантированно тёмный fallback, чтобы никакая прослойка
   между html и body НЕ просвечивала белым (особенно на широких экранах,
   где .app центрирован с max-width:800px и по бокам видно <body>). */
html {
  background-color: #07060B;
}

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: fixed;
  width: 100%;
  /* Ambient gradient: три фиолетово-розовых neon-«пятна» поверх
     тёмной linear-подложки. Точные координаты и прозрачности — из бренд-гайда. */
  background:
    radial-gradient(circle at 20% 0%,   rgba(155, 44, 255, 0.10) 0%, transparent 32%),
    radial-gradient(circle at 85% 18%,  rgba(255, 46, 159, 0.08) 0%, transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(80,  28, 120, 0.12) 0%, transparent 38%),
    linear-gradient(180deg, #09070F 0%, #0B0712 45%, #07060B 100%);
  background-color: #07060B;       /* fallback на случай отказа градиентов */
  background-attachment: fixed;    /* пятна не «съезжают» при скролле       */
}
a { color: var(--accent-pink); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  overflow: hidden;
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* ── Shared Loading System ───────────────────────────────── */
.app-page-loader {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 20%, rgba(230,62,128,0.26), transparent 34%),
    radial-gradient(circle at 82% 78%, rgba(123,63,168,0.3), transparent 38%),
    linear-gradient(135deg, rgba(11,7,18,0.98), rgba(36,10,43,0.96), rgba(9,7,15,0.98));
  background-size: 160% 160%;
  animation: loader-atmosphere 12s ease-in-out infinite;
  transition: opacity 0.22s ease;
}
.app-page-loader.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.app-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.3;
}
.app-loader--screen {
  width: min(360px, 100%);
  min-height: 132px;
  flex-direction: column;
  padding: 26px;
  text-align: center;
  border: 1px solid rgba(230,62,128,0.28);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(38,12,52,0.9), rgba(16,8,27,0.9));
  box-shadow: 0 24px 80px rgba(0,0,0,0.42), 0 0 42px rgba(167,54,205,0.18);
}
.app-loader--screen .app-loader-label {
  color: var(--text-primary);
}
.app-loader--inline {
  min-height: 28px;
}
.app-loader-label {
  max-width: 24ch;
}
.app-spinner,
.spinner {
  box-sizing: border-box;
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.16);
  border-top-color: var(--accent-pink);
  border-right-color: rgba(179,76,225,0.85);
  border-radius: 50%;
  animation: app-spinner-rotate 0.78s linear infinite;
}
.app-spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.app-spinner--lg { width: 34px; height: 34px; border-width: 3px; }
@keyframes app-spinner-rotate { to { transform: rotate(360deg); } }
@keyframes loader-atmosphere {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}

/* ─────────────────── Header ─────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Vertical padding убран, чтобы логотип занимал ВСЮ высоту полоски.
     Высота шапки = min-height = 56px = brand-logo-sm height. */
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  min-height: 56px;
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }
/* ── Brand logo (PNG силуэт с сердцем, neon-градиент) ───────────
   Используется в шапке (.brand-logo-sm) и на auth-экране (.brand-logo-large).
   Изображение прозрачное, поэтому достаточно display + размер;
   тонкое розово-фиолетовое свечение придаёт тот же neon-эффект,
   что был у предыдущей пульсирующей точки. */
.brand-logo {
  display: block;
  width: auto;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 0 6px rgba(230,62,128,0.35));
}
/* На всю высоту полоски: 56px = header min-height. */
.brand-logo-sm    { height: 56px; }
.brand-logo-large { height: 96px; margin-bottom: 4px; }
.header-title {
  /* Кегль подрос синхронно с логотипом: 16 → 18, чтобы текст не казался
     приземистым рядом с увеличенной иконкой. */
  font-size: 18px; font-weight: 700;
  letter-spacing: 0.3px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.balance-badge {
  /* +~15% к высоте, чтобы визуально совпадать с иконочными кнопками. */
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  background: var(--gradient-soft);
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  font-size: 14px; font-weight: 500;
}
.coin-icon { display: inline-flex; align-items: center; color: #facc15; }
.coin-icon .ic { width: 16px; height: 16px; }
.balance-value { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* На узких экранах прячем текстовое название, оставляем только логотип. */
@media (max-width: 600px) {
  .header-title { display: none; }
}

/* ─────────────────── ICON SYSTEM ─────────────────── */
/*
 * Универсальный класс для всех инлайн-иконок, ссылающихся на /static/icons.svg.
 * Цвет наследуется через currentColor из родителя.
 * Размер по умолчанию 20×20; модификаторы .ic-sm / .ic-lg / .ic-xl.
 */
.ic {
  display: inline-block;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  flex-shrink: 0;
  pointer-events: none;
  color: inherit;
}
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }
.ic-xl { width: 32px; height: 32px; }
.ic-xxl { width: 48px; height: 48px; }

/* Кнопка-иконка: убираем эмодзи-сайз, центрируем SVG. */
.icon-btn {
  background: none; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px;
  width: 36px; height: 36px;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: color 0.18s, background 0.18s;
}
.icon-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .ic { width: 22px; height: 22px; }

/* Кнопки с иконкой и текстом — выравнивание */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary .ic, .btn-secondary .ic, .btn-danger .ic { width: 18px; height: 18px; }

/* ─────────────────── ICON COLOR (GRADIENT) ───────────────────
 * Иконки в спрайте используют stroke/fill="url(#ic-grad)", поэтому по умолчанию
 * они окрашены брендовым градиентом (см. icons.svg → <linearGradient id="ic-grad">).
 *
 * Контекстные исключения, где градиент сливается с фоном:
 *  • btn-primary / btn-mic / btn-send / btn-gen-image / fab — сама кнопка
 *    имеет brand-градиент → делаем иконку чисто-белой, чтобы выделялась;
 *  • активные .seg-btn / .cat-tab / .custom-select-option — белые на градиенте;
 *  • плееры (audio-player, mini-player, vp-btn) — белая иконка на тёмном фоне;
 *  • btn-danger — красная заливка → красная иконка.
 *
 * Используем filter — простой и универсальный способ «перекрасить» SVG,
 * чьи stroke/fill заданы через url(#…) (нельзя override через color).
 *
 * Кнопки, использующие background: var(--gradient-main): держим этот список
 * синхронизированным со всеми CTA, чтобы иконка нигде не «терялась» в градиенте.
 */
.btn-primary .ic,
.btn-mic .ic,
.btn-send .ic,
.btn-gen-image .ic,
.fab .ic,
.seg-btn.active .ic,
.cat-tab.active .ic,
.custom-select-option.active .ic,
.gallery-sel-merge .ic,
.vp-btn .ic,
.audio-player .ic,
.mp-play .ic,                  /* только главная play в mini-player на brand-градиенте */
.voice-play-btn .ic,
.video-prompt-mic .ic,
.wizard-mic .ic,
.live-auto.stop-mode .ic,
.live-auto.active .ic {
  filter: brightness(0) invert(1);
}

/* Mini-player второстепенные иконки (rew/fwd/vol/close) — оставляем brand-gradient,
   но приглушаем на 60% opacity → выглядят «выключенными», но в одной палитре. */
.mp-rew .ic, .mp-fwd .ic, .mp-vol-icon, .mp-close .ic {
  opacity: 0.75;
  transition: opacity 0.15s;
}
.mp-rew:hover .ic, .mp-fwd:hover .ic, .mp-close:hover .ic { opacity: 1; }

.btn-danger .ic {
  filter: brightness(0) saturate(100%) invert(36%) sepia(91%) saturate(2576%) hue-rotate(346deg) brightness(91%) contrast(94%);
}

/* Стрелки/чевроны навигации хочется оставить нейтральными — снимаем градиент. */
.gallery-nav .ic,
.collapse-arrow .ic {
  filter: grayscale(1) brightness(0.85);
  opacity: 0.75;
}

/* ─────────────────── AUTH ─────────────────── */
.auth-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 24px;
  overflow-y: auto;
}
.auth-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
/* старая .logo-dot-large заменена на <img class="brand-logo brand-logo-large"> */
.auth-title {
  font-size: 28px; font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-subtitle {
  font-size: 14px; color: var(--text-secondary);
}
.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}
.form-input {
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent-purple); }
.form-input::placeholder { color: var(--text-muted); }
.form-error {
  font-size: 12px; color: var(--accent-red);
  min-height: 16px;
  display: none;
}
.form-error.show { display: block; }
.form-success {
  font-size: 12px; color: #22c55e;
  min-height: 16px;
  display: none;
}
.form-success.show { display: block; }

.btn-primary {
  padding: 12px 20px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  background: var(--gradient-main);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 10px 18px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { color: var(--text-primary); border-color: var(--border-accent); }

.btn-danger {
  padding: 10px 18px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  background: rgba(220,38,38,0.1);
  color: var(--accent-red);
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.btn-danger:hover { background: rgba(220,38,38,0.2); }

.auth-links {
  display: flex; justify-content: center; gap: 16px;
  font-size: 13px;
}
.auth-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 360px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.auth-disclaimer a { color: var(--text-secondary); text-decoration: underline; }

/* ─────────────────── TELEGRAM LINK (register) ─────────────────── */
.tg-link-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 2px 0;
  user-select: none;
}
.tg-link-checkbox input[type="checkbox"] {
  accent-color: #2AABEE;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex-shrink: 0;
  cursor: pointer;
}
.tg-bot-link {
  color: #2AABEE;
  text-decoration: none;
  font-weight: 500;
}
.tg-bot-link:hover { text-decoration: underline; }
.tg-id-group {
  animation: tg-slide-down 0.25s ease-out;
}
@keyframes tg-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tg-id-hint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2AABEE;
  color: #fff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1;
  transition: opacity 0.2s;
}
.tg-id-hint-btn:hover { opacity: 0.8; }
.tg-id-benefit {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 2px;
}

/* Soft informational note shown above the Register button. */
.auth-info-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  margin: 6px 0 4px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}
.auth-info-note .ic {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  opacity: 0.85;
}

/* Telegram ID help modal */
.tg-help-box {
  text-align: left;
  max-width: 360px;
}
.tg-help-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
}
.tg-help-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.tg-help-body p {
  margin-bottom: 10px;
}
.tg-help-body ol {
  padding-left: 20px;
  margin-bottom: 12px;
}
.tg-help-body ol li {
  margin-bottom: 4px;
}
.tg-help-body a {
  color: #2AABEE;
  font-weight: 500;
}
.tg-help-note {
  color: var(--accent-orange);
  font-weight: 500;
  font-size: 13px;
}

/* ─────────────────── CHARACTERS ─────────────────── */
.chars-title {
  padding: 16px 16px 8px;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}
.category-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.cat-tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.cat-tab:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.cat-tab:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.cat-tab:not(:last-child) { border-right: none; }
.cat-tab.active { background: var(--gradient-main); color: #fff; border-color: transparent; }
.cat-tab:hover:not(.active) { background: var(--bg-card-hover); color: var(--text-primary); }

.character-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  align-content: start;
  /* КРИТИЧНО: grid-auto-rows:auto (по умолчанию) при дробном devicePixelRatio
     (зум 110/125/150 %) НЕВЕРНО вычисляет высоту строки для карточек с
     aspect-ratio/процентной высотой — резервирует ~половину, из-за чего фото
     наезжают на следующий ряд. max-content форсит реальную высоту карточки и
     полностью убирает наложение на любом зуме. Проверено эмпирически (DPR 1.5).*/
  grid-auto-rows: max-content;
}
.character-grid::-webkit-scrollbar { width: 4px; }
.character-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.char-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  min-width: 0;
  /* НЕ используем overflow:hidden на самой карточке — при увеличенном
     масштабе интерфейса sub-pixel округление высоты обрезало бы последний
     элемент (описание). Текст ограничивается на уровне дочерних блоков
     (.char-card-name / .char-card-desc). */
}
/* Текстовые блоки карточки не должны выходить за её ширину по горизонтали. */
.char-card > * { max-width: 100%; overflow-wrap: anywhere; }
.char-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}
.char-card-unread {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent-pink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.char-card-emoji { font-size: 32px; line-height: 1; display: flex; align-items: center; justify-content: center; }
/* Когда .char-card-emoji содержит SVG (action-карточки «Создать», «Случайный»),
   масштабируем иконку до 40×40, чтобы визуально соответствовать font-size 32. */
.char-card-emoji--icon .ic { width: 40px; height: 40px; }
.char-card-name {
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.char-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Длинные неразрывные строки (напр. «ccccccc…») не должны выходить за рамку. */
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.char-card-type {
  font-size: 10px;
  color: #ffc107;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

/* ── Фото-режим карточки (системные/VIP персонажи «От Amorum») ──
   В обычном (emoji) режиме .char-card-photo пустой и не влияет на layout —
   карточка выглядит как раньше. Когда JS находит фото и добавляет
   .char-card--photo, обложка раскрывается на всю карточку, а .char-card-body
   превращается в нижний overlay с градиентом и текстом. */
.char-card-photo { display: none; }
.char-card-body  { display: contents; }

/* Фото-режим: высоту карточки задаёт САМО фото (в потоке, aspect-ratio),
   а текст — абсолютный overlay снизу. Так grid корректно резервирует высоту
   каждой ячейки и карточки не наезжают друг на друга. */
.char-card--photo {
  position: relative;
  padding: 0;
  overflow: hidden;
  display: block;        /* отменяем flex-column от .char-card */
  border: none;          /* убираем рамку — фото заполняет карточку до краёв */
  background: #0d0a14;   /* нейтральная подложка под фото */
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Карточка сама квадратная. Высоту строки grid резервирует корректно
     благодаря grid-auto-rows:max-content на .character-grid. */
  aspect-ratio: 1 / 1;
}
.char-card--photo .char-card-photo {
  /* Фото абсолютно заполняет всю карточку до краёв — никакого канта/зазора.
     (Высоту даёт aspect-ratio карточки, не фото.) */
  display: block;        /* переопределяем .char-card-photo{display:none} */
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transition: transform 0.25s ease;
}
.char-card--photo:hover .char-card-photo { transform: scale(1.05); }
.char-card--photo .char-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;       /* имя/описание по центру */
  gap: 2px;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
  width: 100%;
  /* Паддинги в em → масштабируются вместе с текстом, overlay остаётся
     пропорциональным при любом зуме. */
  padding: 1.6em 0.7em 0.7em;
  text-align: center;        /* текст по центру */
  background: linear-gradient(to top,
    rgba(7,6,11,0.95) 0%,
    rgba(7,6,11,0.78) 50%,
    rgba(7,6,11,0) 100%);
}
/* В фото-режиме emoji не показываем — лицо уже на обложке. */
.char-card--photo .char-card-emoji { display: none; }
.char-card--photo .char-card-name {
  font-size: 14px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  text-align: center;
  /* Имя — 1 строка, чтобы overlay был компактен и устойчив к зуму. */
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
}
/* Описание на фото-карточке: 2 строки, приглушённым (в стилистике интерфейса:
   --text-secondary), но читаемым поверх градиента. */
.char-card--photo .char-card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
  color: var(--text-secondary);
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
}
.char-card--photo .char-card-type {
  position: absolute;
  top: 8px; right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,193,7,0.92);
  color: #1a1206;
}
/* Locked-VIP карточки остаются в emoji-режиме с замком (фото не применяется,
   см. _applyCardPhoto в characters.js) — отдельных правил не требуется. */

/* Скелетон аватара custom-персонажа, пока идёт фоновая генерация. */
.char-card--avatar-loading .char-card-photo {
  background: linear-gradient(100deg,
    #1a1428 30%, #2a2140 50%, #1a1428 70%);
  background-size: 200% 100%;
  animation: avatar-skeleton 1.2s ease-in-out infinite;
}
.char-card--avatar-loading .char-card-body {
  /* во время загрузки имя видно, но без затемняющего градиента поверх скелетона */
  background: linear-gradient(to top, rgba(7,6,11,0.85) 0%, rgba(7,6,11,0) 100%);
}
@keyframes avatar-skeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.char-card--vip {
  border-color: rgba(255, 193, 7, 0.3);
}
.char-card--vip:hover {
  border-color: rgba(255, 193, 7, 0.6);
  box-shadow: 0 0 16px rgba(255, 193, 7, 0.15);
}
.char-card--action {
  border-style: dashed;
  border-color: var(--border-accent);
  opacity: 0.85;
}
.char-card--action:hover {
  opacity: 1;
}
.chars-section-header {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0 0;
  text-align: center;
  letter-spacing: 0.3px;
}
.chars-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

/* ─────────────────── CHARACTER PREVIEW MODAL ─────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
/* Reject dialog opens from the moderation tab → must stack above the panel. */
#modal-admin-reject     { z-index: 130; }

/* Moderation card — character details for review */
.mod-details {
  margin: 8px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
}
.mod-field { margin-bottom: 6px; }
.mod-field:last-child { margin-bottom: 0; }
.mod-field-text {
  margin-top: 3px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary, #b8b8c0);
  max-height: 220px;
  overflow-y: auto;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
}
.pwa-install-dialog { z-index: 140; }
.pwa-install-box { max-width: 420px; }
.pwa-install-title {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.3;
}
.pwa-install-message {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}
.pwa-install-never-show {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.pwa-install-never-show input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent, #c084fc);
}
.pwa-install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pwa-install-actions .btn-primary,
.pwa-install-actions .btn-secondary { flex: 1 1 170px; }
.char-preview-box { text-align: center; }
.char-preview-emoji { font-size: 48px; margin-bottom: 8px; }
.char-preview-name {
  font-size: 20px; font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.char-preview-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  white-space: pre-line;
}
.char-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-new-dialog {
  border-color: rgba(255, 193, 7, 0.4);
  color: #ffc107;
}
.btn-new-dialog:hover {
  background: rgba(255, 193, 7, 0.1);
}
.char-session-info {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px 0 4px;
}
.confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 4px;
}
.confirm-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 12px;
}
.btn-danger {
  background: var(--danger, #e53935) !important;
  border-color: var(--danger, #e53935) !important;
  color: #fff !important;
}
.btn-danger:hover {
  background: #c62828 !important;
}
.confirm-warning {
  background: rgba(229, 57, 53, 0.08);
  border: 1px solid rgba(229, 57, 53, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  text-align: left;
}
.confirm-warning p {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.confirm-warning ul {
  margin: 0;
  padding-left: 18px;
  list-style: none;
}
.confirm-warning li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.account-deletion-warning li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.account-deletion-cross {
  flex: 0 0 auto;
  color: var(--accent-red);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
}

/* ─────────────────── CHAT ─────────────────── */
.chat-char-emoji { font-size: 20px; }
.chat-char-name {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.chat-log-shell {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Отключаем нативный scroll-anchoring браузера: позицию при подгрузке
     истории мы держим вручную (distance-from-bottom в chat.js). Иначе
     браузер и наш JS конкурируют за scrollTop и возникают рывки. */
  overflow-anchor: none;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-scroll-bottom {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 4;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-primary);
  background: var(--bg-card);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s, background 0.18s;
}
.chat-scroll-bottom[hidden] { display: none; }
.chat-scroll-bottom.is-visible {
  opacity: 0.42;
  transform: translateY(0);
  pointer-events: auto;
}
.chat-scroll-bottom.is-visible.has-unseen { opacity: 1; }
.chat-scroll-bottom:hover { opacity: 0.78; background: var(--bg-card-hover); }
.chat-scroll-bottom.has-unseen:hover { opacity: 1; }
.chat-scroll-bottom:active { transform: scale(0.94); }
.chat-scroll-bottom .ic { width: 22px; height: 22px; }
.chat-log::-webkit-scrollbar { width: 4px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  animation: msg-in 0.25s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user {
  /* Сообщения пользователя — глубокий фиолетовый под цвет body-фона:
     ровно тон --bg-deep сверху → --bg-primary снизу с подсветкой
     логотипного фиолетового по краю. Не конкурирует с .msg-bot. */
  align-self: flex-end;
  background: linear-gradient(160deg, rgba(123,63,168,0.16) 0%, rgba(33,20,47,0.55) 60%, rgba(8,7,13,0.65) 100%);
  border: 1px solid rgba(123,63,168,0.14);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}
.chat-job-status {
  display: block;
  margin-top: 6px;
  color: var(--danger, #e53935);
  font-size: 12px;
  line-height: 1.35;
}
.chat-job-retry {
  margin-top: 8px;
  padding: 5px 10px;
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}
.chat-job-retry:disabled { opacity: 0.55; cursor: default; }
.msg-bot {
  /* Bubble персонажа — тёплый фиолетово-розовый duotone бренда, без orange.
     Раньше был purple→orange, что давало коричневатый дрейф на тёмном фоне. */
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(123,63,168,0.18) 0%, rgba(230,62,128,0.14) 100%);
  border: 1px solid rgba(123,63,168,0.22);
  border-bottom-left-radius: 4px;
}
.msg-bot .msg-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
  margin-top: 6px;
  cursor: pointer;
}

/* ── Safety block bubble (content_blocked) ─────────────── */
.msg-safety-block {
  background: linear-gradient(135deg, rgba(239,68,68,0.18) 0%, rgba(234,179,8,0.18) 100%);
  border: 1px solid rgba(239,68,68,0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg-safety-block .btn-moral-confirm {
  align-self: stretch;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  color: #fff;
  font-weight: 600;
  font-size: 0.95em;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.msg-safety-block .btn-moral-confirm:hover:not(:disabled) {
  filter: brightness(1.1);
}
.msg-safety-block .btn-moral-confirm:active:not(:disabled) {
  transform: scale(0.98);
}
.msg-safety-block .btn-moral-confirm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Media strip: separate bubble below message ─────────── */
.media-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 85%;
  padding: 6px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(123,63,168,0.10) 0%, rgba(230,62,128,0.10) 100%);
  border: 1px solid rgba(147,51,234,0.15);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: msg-in 0.25s ease-out;
}
/* Invisible anchor for media-only messages (no bubble created) */
.media-anchor {
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* 1 элемент: сама подложка занимает ~50% рабочей области, прижата влево. */
.media-strip[data-count="1"] {
  width: 50%;
  max-width: 50%;
}

/* Media-only strip (no text bubble above) — centered, larger */
.media-strip.media-only {
  align-self: center;
  max-width: 75%;
  border-radius: 14px;
  border-bottom-left-radius: 14px;
}
/* Media-only с одним элементом тоже ~50%, но по центру (как раньше). */
.media-strip.media-only[data-count="1"] {
  width: 50%;
  max-width: 50%;
}
.media-strip .media-thumb {
  flex: 1 1 auto;
  min-width: 80px;
  max-width: 100%;
  border-radius: 10px;
  cursor: pointer;
  object-fit: cover;
  transition: transform 0.15s ease, filter 0.15s ease;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  /* Плейсхолдер-фон, пока картинка грузится: место уже зарезервировано
     через aspect-ratio (см. media-strip.js), фон показывает "скелетон". */
  background: rgba(147, 51, 234, 0.06);
}
/* Все превью в чате — квадратные. Квадрат задаём на самом медиа-элементе
   (aspect-ratio: 1/1) — это надёжнее, чем на flex-обёртке, и фото/видео выглядят
   одинаково независимо от натуральных размеров. */
.media-strip .media-thumb--sized {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
/* Видео-превью — тот же квадрат, что и фото. Квадрат задаёт обёртка
   media-thumb-wrap-video (aspect-ratio: 1/1, см. ниже), видео заполняет её
   целиком. НЕ зависит от наличия width/height в БД — поэтому видео без
   метаданных тоже квадратное, а не широкий прямоугольник. */
.media-strip .media-thumb-vid-el {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
/* Обёртка видео — всегда квадрат, как и у картинок. Место резервируется через
   aspect-ratio (ширина колонки известна до загрузки metadata), поэтому layout
   не "дышит" и скролл не прыгает даже без width/height в БД. */
.media-strip .media-thumb-wrap-video {
  aspect-ratio: 1 / 1;
}
.media-strip .media-thumb:hover {
  transform: scale(1.03);
  filter: brightness(1.1);
}
/* Default: 2 per row (mobile first) */
.media-strip .media-thumb {
  width: 100%;
  flex: unset;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Media thumb wrap (with inline controls) ────────────── */
.media-thumb-wrap {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 10px;
  line-height: 0;
}
.media-strip .media-thumb-wrap {
  flex: 0 0 auto;
  min-width: 80px;
  max-width: 100%;
}
.media-strip .media-thumb-wrap .media-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  flex: unset;
}
/* Обёртка подстраивается под квадратный медиа-элемент внутри. */
/* 1 элемент → заполняет подложку целиком (ширину 50% задаёт сама .media-strip). */
.media-strip[data-count="1"] .media-thumb-wrap {
  width: 100%;
  flex: 0 0 100%;
}
/* 2 элемента → 2 в ряд (по 50%). */
.media-strip[data-count="2"] .media-thumb-wrap {
  width: calc(50% - 3px);
  flex: 0 0 calc(50% - 3px);
}
/* 3 и более → максимум 3 в ряд (по 33%), и на мобиле, и на десктопе. */
.media-strip:not([data-count="1"]):not([data-count="2"]) .media-thumb-wrap {
  width: calc(33.33% - 4px);
  flex: 0 0 calc(33.33% - 4px);
}

/* Full durable generation tile. It shares the same slow gradient movement as
   the page loader, while the spinner remains the only fast animation. */
.media-strip .media-thumb-wrap-pending {
  display: grid;
  place-items: center;
  align-self: stretch;
  min-height: 180px;
  aspect-ratio: 1 / 1;
  line-height: normal;
  background:
    radial-gradient(circle at 18% 22%, rgba(230,62,128,0.3), transparent 32%),
    radial-gradient(circle at 82% 78%, rgba(123,63,168,0.32), transparent 38%),
    linear-gradient(135deg, rgba(33,10,46,0.98), rgba(14,7,24,0.98), rgba(46,12,55,0.98));
  background-size: 165% 165%;
  border: 1px solid rgba(230,62,128,0.28);
  box-shadow: inset 0 0 36px rgba(0,0,0,0.2);
  animation: loader-atmosphere 12s ease-in-out infinite;
  pointer-events: none;
}
.media-strip .media-thumb-wrap-pending::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  pointer-events: none;
}
.media-pending-status,
.voice-pending-status {
  position: relative;
  z-index: 1;
}
.media-pending-status {
  flex-direction: column;
  color: rgba(255,255,255,0.86);
  text-shadow: 0 1px 16px rgba(0,0,0,0.5);
}
.msg-audio-pending .voice-pending-status {
  margin-top: 8px;
  justify-content: flex-start;
}
.msg-audio-pending .msg-text {
  display: none;
}

/* Thumbnail select checkbox */
.media-thumb-check {
  position: absolute;
  top: 6px; left: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-thumb-wrap:hover .media-thumb-check,
.media-select-mode .media-thumb-check {
  opacity: 1;
}
.media-thumb-wrap.selected .media-thumb-check {
  opacity: 1;
  background: var(--accent-highlight);
  border-color: var(--accent-highlight);
}
.media-thumb-wrap.selected .media-thumb-check::after {
  content: "✓";
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.media-thumb-wrap.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-highlight-bg);
  border-radius: 10px;
  pointer-events: none;
  z-index: 2;
}
/* Chat media action bar */
.chat-media-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.2s ease;
}

/* ── Media progress bar ─────────────────────────────────── */
.media-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
.media-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--accent-highlight-track);
  border-radius: 2px;
  overflow: hidden;
}
.media-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-highlight);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.media-progress-label {
  font-size: 12px;
  color: var(--accent-highlight);
  white-space: nowrap;
  min-width: 140px;
}

/* ── Media mode state on chat screen ────────────────────── */
.media-mode .chat-input-wrap {
  border-color: rgba(244,114,182,0.4);
}
.media-mode .chat-input-wrap:focus-within {
  border-color: #E63E80;
}
.media-mode .btn-send {
  background: linear-gradient(135deg, #E63E80, #7B3FA8);
}
.media-mode .chat-input::placeholder {
  color: rgba(244,114,182,0.6);
}

.msg-error {
  align-self: center;
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.3);
  color: var(--accent-red);
  font-size: 12px;
  border-radius: 10px;
}
.msg-system {
  align-self: center;
  background: var(--gradient-soft);
  border: 1px solid var(--border-accent);
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: 10px;
  text-align: center;
}

/* ── Onboarding card (new dialog flow) ────────────────────── */
.onboarding-card {
  align-self: center;
  width: 90%;
  max-width: 340px;
  padding: 18px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(123,63,168,0.08) 0%, rgba(230,62,128,0.08) 100%);
  border: 1px solid rgba(147,51,234,0.2);
  text-align: center;
  animation: msg-in 0.3s ease-out;
}
.onboarding-card .onb-title {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.onboarding-card .onb-modes {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.onboarding-card .onb-mode-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(147,51,234,0.25);
  background: rgba(147,51,234,0.06);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.onboarding-card .onb-mode-btn:hover {
  background: rgba(147,51,234,0.15);
  border-color: rgba(147,51,234,0.4);
}
.onboarding-card .onb-mode-btn.active {
  background: linear-gradient(135deg, rgba(123,63,168,0.25) 0%, rgba(230,62,128,0.2) 100%);
  border-color: rgba(147,51,234,0.5);
  box-shadow: 0 0 8px rgba(147,51,234,0.15);
}
.onboarding-card .onb-mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.onb-mode-dot.dot-text  { background: #7B3FA8; }
.onb-mode-dot.dot-voice { background: var(--accent-orange); }  /* редкий warm — для индикатора */
.onb-mode-dot.dot-media { background: #E63E80; }
.onb-mode-dot.dot-live  { background: #10b981; }

.onboarding-card .onb-mode-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 14px;
  min-height: 36px;
  transition: opacity 0.15s ease;
}

.onboarding-card .onb-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 28px;
  border-radius: 24px;
  border: none;
  background: linear-gradient(135deg, #7B3FA8 0%, #E63E80 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.onboarding-card .onb-start-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(147,51,234,0.3);
}
.onboarding-card .onb-start-btn:active {
  transform: scale(0.97);
}
.onboarding-card .onb-or {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
}
/* Fade-out animation */
.onboarding-card.onb-dismiss {
  animation: onb-fade 0.25s ease-out forwards;
}
@keyframes onb-fade {
  to { opacity: 0; transform: translateY(-8px); }
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  align-self: flex-start;
  font-size: 13px;
  color: var(--text-muted);
}
.typing-indicator .typing-label {
  white-space: nowrap;
}
.typing-indicator.typing-voice .typing-label { color: #7B3FA8; }
.typing-indicator.typing-image .typing-label { color: #E63E80; }
.typing-indicator .typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.typing-indicator .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-indicator.typing-voice .dot { background: #7B3FA8; }
.typing-indicator.typing-image .dot { background: #E63E80; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Chat input */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  position: relative;
}

/* ── Mode button (left of input) ── */
.btn-mode {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s;
}
/* Все варианты btn-mode подсвечиваются единым brand-pink: кнопка просто «активна»,
   различие режимов показывает иконка внутри + dots в попапе. */
.btn-mode.mode-text,
.btn-mode.mode-voice,
.btn-mode.mode-media,
.btn-mode.mode-live {
  border-color: var(--accent-highlight);
  color: var(--accent-highlight);
  background: var(--accent-highlight-bg);
}
.btn-mode:hover { filter: brightness(1.15); transform: scale(1.05); }

/* ── Mode popup ── */
.mode-popup {
  position: absolute;
  bottom: 62px;
  left: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 50;
  min-width: 150px;
}
.mode-popup-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.mode-popup-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
/* Активный пункт попапа — единый brand highlight, режим различается по dot/label. */
.mode-popup-btn.active {
  font-weight: 600;
  color: var(--accent-highlight);
  background: var(--accent-highlight-bg);
}

/* Mode indicator dots in popup */
.mode-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Dot-индикаторы режимов — приглушённые brand-тона (вместо random цветов).
   Сохраняем семантику «разные режимы — разные цвета», но в одной системе. */
.mode-dot-text  { background: var(--accent-indigo); }   /* indigo  — спокойный текст */
.mode-dot-voice { background: var(--accent-purple); }   /* purple                    */
.mode-dot-media { background: var(--accent-pink); }     /* pink                      */
.mode-dot-live  { background: var(--accent-orange); box-shadow: 0 0 6px var(--accent-orange); }

/* ── Mic button (Telegram-style hold/lock) ── */
.btn-mic {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-main);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  position: relative;
  z-index: 2;
}
.btn-mic:hover { opacity: 0.9; }
.btn-mic.rec-hold {
  background: #ef4444;
  transform: scale(1.18);
  box-shadow: 0 0 0 6px rgba(239,68,68,0.25);
}
.btn-mic.rec-locked {
  background: var(--gradient-main);
  animation: voice-send-pulse 1s ease-in-out infinite;
}
.btn-mic.rec-locked .mic-icon-default { display: none; }
.btn-mic.rec-locked .mic-icon-send {
  display: block !important;
  animation: voice-send-arrow 1s ease-in-out infinite;
}
@keyframes voice-send-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.42); }
  50% { box-shadow: 0 0 0 9px rgba(168, 85, 247, 0); }
}
@keyframes voice-send-arrow {
  0%,100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.55; transform: translateY(-2px); }
}

/* ── Voice recording overlay bar ── */
.voice-rec-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0; top: 0;
  background: var(--bg-card);
  border-radius: 0 0 0 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 56px 0 16px; /* right padding for mic btn */
  z-index: 1;
  animation: rec-bar-in 0.15s ease-out;
}
@keyframes rec-bar-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.voice-rec-cancel {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #ef4444;
  background: transparent;
  cursor: pointer;
  transition: background 0.18s, transform 0.15s;
}
.voice-rec-cancel:hover { background: rgba(239, 68, 68, 0.12); }
.voice-rec-cancel:active { transform: scale(0.92); }
.voice-rec-cancel .ic { width: 20px; height: 20px; }
.voice-rec-indicator {
  display: flex; align-items: center; justify-content: center;
  width: 12px; height: 12px; flex-shrink: 0;
}
.voice-rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: rec-dot-pulse 1s ease-in-out infinite;
}
@keyframes rec-dot-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.voice-rec-timer {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}
.voice-rec-hint {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  animation: rec-hint-slide 1.5s ease-in-out infinite;
}
@keyframes rec-hint-slide {
  0%,100% { transform: translateX(0); opacity: 0.7; }
  50% { transform: translateX(-6px); opacity: 1; }
}
.voice-rec-lock {
  width: 32px; height: 40px;
  display: flex; align-items: flex-start; justify-content: center;
  color: var(--text-muted);
  animation: rec-lock-bounce 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes rec-lock-bounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.voice-rec-bar.locked .voice-rec-hint { display: none; }
.voice-rec-bar.locked .voice-rec-lock { display: none; }
/* Wrapper clips scrollbar to rounded corners */
.chat-input-wrap {
  flex: 1;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.chat-input-wrap:focus-within { border-color: var(--accent-purple); }

.chat-input {
  display: block;
  width: 100%;
  padding: 11px 16px 11px 14px;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: var(--text-primary);
  border: none;
  border-radius: 0;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.chat-input::placeholder { color: var(--text-muted); }

/* Styled scrollbar — visible only on hover */
.chat-input::-webkit-scrollbar { width: 4px; }
.chat-input::-webkit-scrollbar-track { background: transparent; }
.chat-input::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.chat-input-wrap:hover .chat-input { scrollbar-color: var(--text-secondary) transparent; }
.chat-input-wrap:hover .chat-input::-webkit-scrollbar-thumb { background: var(--text-secondary); }

/* Highlight animation when pasting instruction from gallery */
.chat-input-wrap.input-highlight-wrap,
.chat-input-wrap:has(.input-highlight) {
  border-color: rgba(234,179,8,0.7);
  box-shadow: 0 0 0 2px rgba(234,179,8,0.25);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.input-highlight {
  animation: input-glow 1.5s ease-out;
}
@keyframes input-glow {
  0% { background: rgba(234,179,8,0.12); }
  100% { background: transparent; }
}

.btn-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-main);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-send:hover { opacity: 0.9; }
.btn-send:active { transform: scale(0.92); }
.btn-send:disabled { opacity: 0.35; cursor: not-allowed; }

/* ─────────────────── LIVE MODE ─────────────────── */

/* Wide PTT button — fills space between gen-image and auto btn */
.live-ptt {
  flex: 1;
  min-height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--gradient-main);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
.live-ptt:hover { filter: brightness(1.1); }
.live-ptt:active:not(.disabled) { transform: scale(0.97); }
.live-ptt:disabled { cursor: not-allowed; }

.live-ptt-icon { font-size: 18px; line-height: 1; flex-shrink: 0; display: inline-flex; align-items: center; }
.live-ptt-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* PTT icons are inlined SVGs with hard-coded white stroke/fill
   (see live-mode.js _activateLiveUI). We only set the size here. */
.live-ptt .ls-ptt-ic { width: 20px; height: 20px; display: block; }

/* Recording state — red pulse */
.live-ptt.recording {
  background: #ef4444;
  box-shadow: 0 0 0 6px rgba(239,68,68,0.25);
  animation: live-rec-pulse 1s ease-in-out infinite;
}
@keyframes live-rec-pulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(239,68,68,0.3); }
  50%     { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
}

/* Listening (VAD waiting) — soft glow */
.live-ptt.listening {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  animation: live-listen-pulse 2s ease-in-out infinite;
}
@keyframes live-listen-pulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(99,102,241,0.2); }
  50%     { box-shadow: 0 0 0 8px rgba(139,92,246,0); }
}

/* Disabled (processing/playing) — dimmed */
.live-ptt.disabled {
  opacity: 0.55;
  filter: grayscale(0.3);
  animation: none;
  box-shadow: none;
}

/* Auto-record toggle button */
.live-auto {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s;
}
.live-auto:hover { border-color: var(--text-muted); color: var(--text-primary); }
.live-auto.active {
  border-color: #22c55e;
  color: #22c55e;
  background: rgba(34,197,94,0.1);
  box-shadow: 0 0 8px rgba(34,197,94,0.3);
}
.live-auto.stop-mode {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239,68,68,0.12);
  box-shadow: 0 0 8px rgba(239,68,68,0.3);
  animation: live-pulse 1s infinite;
}
/* Inline phone glyph stays crisp white regardless of button state */
.live-auto .ls-auto-ic {
  width: 20px;
  height: 20px;
  stroke: #fff !important;
  fill: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   LIVE ONBOARDING MODAL — shown once on first Live entry
   ─────────────────────────────────────────────────────────────── */
.live-onb-overlay { z-index: 10050; }
.live-onb-box {
  max-width: 460px;
  width: calc(100% - 32px);
  padding: 24px 22px 20px;
  text-align: left;
  background: var(--bg-card, #1a1a22);
  border: 1px solid var(--border, #2a2a35);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
}
.live-onb-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin-bottom: 8px;
}
.live-onb-intro {
  font-size: 14px;
  color: var(--text-secondary, #b8b8c8);
  margin-bottom: 14px;
}
.live-onb-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.live-onb-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary, #eee);
}
.live-onb-list b { color: var(--text-primary, #fff); }
.live-onb-ico {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  font-size: 18px;
  line-height: 1;
}
.live-onb-ok {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
}
.live-onb-dontshow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary, #b8b8c8);
  cursor: pointer;
  user-select: none;
}
.live-onb-dontshow input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #e879c5;
  cursor: pointer;
  margin: 0;
}

.live-chat-image {
  max-width: 280px;
  border-radius: var(--radius);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   LIVE STAGE — full-screen overlay (components/live-stage.js)
   ───────────────────────────────────────────────────────────────
   Layout zones (top → bottom inside #screen-chat):
     [host .header]        ← never covered; settings cog stays accessible
     .live-stage
       .ls-backdrop        dark gradient base
       .ls-spacer          top padding = host header height
       .ls-status-strip    character name + state label
       .ls-hero            full-bleed image area (conditional)
       .ls-orb-wrap        orb + subtitle stack
       .ls-footer          control dock:
                             [📷 camera] [PTT + auto] [🔇 mute] [CC]
   Maintenance:
     - All selectors prefixed .live-stage / .ls-* — never bleed.
     - Orb states driven by [data-state="…"] on .ls-orb.
     - When hero is present, .ls-orb--small + wrap pinned to bottom.
   ═══════════════════════════════════════════════════════════════ */

/* Host: dim the underlying chat while the stage is active.
   We also flip the screen container to position:relative so the
   overlay can be sized against it (leaving the top app bar visible
   above the overlay). */
#screen-chat.live-stage-active {
  position: relative;
}
#screen-chat.live-stage-active .chat-log-shell,
#screen-chat.live-stage-active #typing-indicator,
#screen-chat.live-stage-active #media-progress,
#screen-chat.live-stage-active .chat-input-bar,
#screen-chat.live-stage-active #chat-media-action-bar {
  filter: blur(14px) brightness(0.35) saturate(0.7);
  pointer-events: none;
  transition: filter 0.25s ease;
}

/* Root overlay — sits BELOW the host top app bar so the user can
   always see character info + open settings (where the mode switch
   lives). The top offset is the measured header height set as an
   inline CSS var by live-stage.js (`--ls-header-h`). */
.live-stage {
  position: absolute;
  top: var(--ls-header-h, 56px);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 90;                 /* above chat content, below modal overlays (≥1000) */
  overflow: hidden;
  color: var(--text-primary);
  isolation: isolate;          /* contain blend modes for glow effects */
}

.ls-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(200,46,140,0.18) 0%, rgba(200,46,140,0) 60%),
    radial-gradient(ellipse at 50% 80%, rgba(123,63,168,0.22) 0%, rgba(123,63,168,0) 70%),
    linear-gradient(180deg, #0c0816 0%, #07050d 100%);
  z-index: 0;
}

/* ── Status strip (directly under host header) ──────────────
   Used exclusively for transient state, errors and system
   notices (e.g. "Слушаю…", "Нет соединения"). No background —
   sits transparently on the blurred backdrop so the hero image
   shows through. */
.ls-status-strip {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px 6px;
  flex: 0 0 auto;
  text-align: center;
  pointer-events: none;
  min-height: 28px;
}

.ls-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #b3a8c4);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
  text-shadow: 0 1px 4px rgba(0,0,0,0.55);   /* legibility over hero */
  transition: color 0.2s;
}
.ls-status[data-state="listening"]  { color: #6ee7ff; }
.ls-status[data-state="recording"]  { color: #ef4444; }
.ls-status[data-state="speaking"]   { color: #ec4899; }
.ls-status[data-state="generating"] { color: #f59e0b; }
.ls-status[data-state="thinking"]   { color: #a78bfa; }
.ls-status[data-state="error"]      { color: #fca5a5; }

/* ── Hero image layer ───────────────────────────────────── */
.ls-hero {
  position: absolute;
  left: 0; right: 0;
  /* sits below the status strip (overlay already starts below the
     host header, so we only need to offset by the strip height). */
  top: 30px;
  bottom: 0;
  z-index: 1;
  overflow: hidden;
}
.ls-hero[hidden] { display: none; }

.ls-hero-backdrop {
  position: absolute; inset: -10%;
  background-size: cover;
  background-position: center;
  filter: blur(40px) brightness(0.45) saturate(1.1);
  transform: scale(1.15);
  z-index: 0;
}
.ls-hero-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 1;
  pointer-events: none;
}
.ls-hero-img.is-front { opacity: 1; }

/* ── Orb + subtitle stack ───────────────────────────────── */
.ls-orb-wrap {
  position: relative;
  z-index: 3;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px 20px;
  min-height: 0;
}
/* When hero is present, push orb to bottom over the image */
.ls-orb-wrap--with-hero {
  position: absolute;
  left: 0; right: 0; bottom: 96px;   /* leave room for footer */
  top: auto;
  flex: 0 0 auto;
  padding-bottom: 0;
  pointer-events: none;              /* don't block hero clicks */
}
.ls-orb-wrap--with-hero .ls-orb,
.ls-orb-wrap--with-hero .ls-subtitle { pointer-events: auto; }

/* Orb — concentric breathing element */
.ls-orb {
  position: relative;
  width: 220px; height: 220px;
  display: flex; align-items: center; justify-content: center;
  transition: width 0.35s ease, height 0.35s ease, filter 0.35s ease;
}
.ls-orb--small { width: 96px; height: 96px; }

.ls-orb-core {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ffb8de 0%, #ec4899 40%, #7b3fa8 90%);
  box-shadow:
    0 0 40px rgba(236,72,153,0.55),
    0 0 80px rgba(123,63,168,0.45),
    inset 0 0 30px rgba(255,255,255,0.15);
  animation: ls-orb-breathe 3.6s ease-in-out infinite;
}
.ls-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(236,72,153,0.25);
  opacity: 0;
  pointer-events: none;
  animation: ls-orb-ripple 3s ease-out infinite;
}
.ls-orb-ring--1 { animation-delay: 0s; }
.ls-orb-ring--2 { animation-delay: 1s; }
.ls-orb-ring--3 { animation-delay: 2s; }

@keyframes ls-orb-breathe {
  0%, 100% { transform: scale(1);    filter: brightness(1); }
  50%      { transform: scale(1.06); filter: brightness(1.15); }
}
@keyframes ls-orb-ripple {
  0%   { transform: scale(0.85); opacity: 0; }
  20%  { opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Orb state variations */
.ls-orb[data-state="listening"] .ls-orb-core {
  background: radial-gradient(circle at 35% 30%, #b3eaff 0%, #38bdf8 45%, #1e3a8a 95%);
  box-shadow: 0 0 50px rgba(56,189,248,0.55), 0 0 90px rgba(30,58,138,0.5);
  animation-duration: 1.6s;
}
.ls-orb[data-state="listening"] .ls-orb-ring { border-color: rgba(56,189,248,0.45); animation-duration: 1.8s; }

.ls-orb[data-state="recording"] .ls-orb-core {
  background: radial-gradient(circle at 35% 30%, #fecaca 0%, #ef4444 45%, #7f1d1d 95%);
  box-shadow: 0 0 50px rgba(239,68,68,0.65), 0 0 100px rgba(127,29,29,0.5);
  animation-duration: 0.9s;
}
.ls-orb[data-state="recording"] .ls-orb-ring { border-color: rgba(239,68,68,0.55); animation-duration: 1.2s; }

.ls-orb[data-state="thinking"] .ls-orb-core {
  background: radial-gradient(circle at 35% 30%, #ddd6fe 0%, #a78bfa 45%, #4c1d95 95%);
  animation-duration: 2.4s;
}
.ls-orb[data-state="thinking"] .ls-orb-ring { border-color: rgba(167,139,250,0.4); animation-duration: 2.4s; }

.ls-orb[data-state="speaking"] .ls-orb-core {
  background: radial-gradient(circle at 35% 30%, #ffd1e8 0%, #ec4899 40%, #831843 95%);
  box-shadow: 0 0 60px rgba(236,72,153,0.7), 0 0 110px rgba(131,24,67,0.55);
  animation-duration: 1.1s;
}
.ls-orb[data-state="speaking"] .ls-orb-ring { border-color: rgba(236,72,153,0.5); animation-duration: 1.4s; }

.ls-orb[data-state="generating"] .ls-orb-core {
  background: radial-gradient(circle at 35% 30%, #fde68a 0%, #f59e0b 45%, #7c2d12 95%);
  box-shadow: 0 0 55px rgba(245,158,11,0.6), 0 0 100px rgba(124,45,18,0.5);
  animation-duration: 1.8s;
}
.ls-orb[data-state="generating"] .ls-orb-ring { border-color: rgba(245,158,11,0.45); animation-duration: 2s; }

/* Subtitle */
.ls-subtitle {
  max-width: min(640px, 90vw);
  padding: 10px 16px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
  color: #f6f1ff;
  transition: opacity 0.25s;
}
.ls-subtitle[hidden] { display: none; }

/* ── Footer dock (all interactive controls) ─────────────── */
/* `margin-top: auto` keeps the footer pinned to the bottom of the
   flex column even when .ls-orb-wrap is pulled out of flow via
   position:absolute (hero-present mode). */
.ls-footer {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(12,8,22,0.75);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-top: 1px solid rgba(255,255,255,0.06);
  min-height: 64px;
}

/* PTT + auto-record slot — receives the buttons live-mode.js
   builds. Stretches between the camera (left) and mute/CC (right). */
.ls-footer-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

/* Dock buttons (camera/mute/CC) — circular, similar to .live-auto
   but slightly tighter so the footer fits 5+ controls on mobile. */
.ls-dock-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text-secondary, #b3a8c4);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.ls-dock-btn:hover  { border-color: var(--text-muted); color: var(--text-primary); }
.ls-dock-btn:active { transform: scale(0.93); }
.ls-dock-btn .ic    { width: 18px; height: 18px; }

.ls-dock-btn.is-active {
  border-color: #ec4899;
  color: #ff8fc8;
  background: rgba(236,72,153,0.15);
  box-shadow: 0 0 8px rgba(236,72,153,0.3);
}

/* Mute "on" state stays red to make the muted state unmistakable */
.ls-btn-mute.is-active {
  border-color: #ef4444;
  color: #fca5a5;
  background: rgba(239,68,68,0.15);
  box-shadow: 0 0 8px rgba(239,68,68,0.3);
}

/* PTT button (.live-ptt) inherits its existing styling — no overrides
   here so the footer matches the visual language of the standard
   chat input bar. */

/* ── Mobile portrait tweaks ─────────────────────────────── */
@media (max-width: 480px) {
  .ls-orb            { width: 180px; height: 180px; }
  .ls-orb--small     { width: 80px;  height: 80px;  }
  .ls-subtitle       { font-size: 15px; }
  .ls-dock-btn       { width: 38px; height: 38px; }
  .ls-dock-btn .ic   { width: 16px; height: 16px; }
  .ls-footer         { gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .ls-orb-wrap--with-hero { bottom: 88px; }
  .ls-status-strip   { padding: 6px 10px 4px; min-height: 24px; }
  .ls-status         { font-size: 12px; }
}

/* Desktop: keep stage centered with a max width so it doesn't sprawl */
@media (min-width: 900px) {
  .live-stage { max-width: 760px; margin: 0 auto; left: 0; right: 0; box-shadow: 0 0 60px rgba(0,0,0,0.6); }
}

/* ─────────────────── SETTINGS MODAL ─────────────────── */
.settings-modal {
  position: relative;
  width: 94%;
  max-width: 480px;
  max-height: 88vh;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.settings-modal-close .ic { width: 18px; height: 18px; }
.settings-modal-close:hover { background: rgba(255,255,255,0.12); }
.settings-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.settings-modal-body::-webkit-scrollbar { width: 4px; }
.settings-modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* ── Collapsible accordion ── */
.settings-section.collapsible > .settings-section-title {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color 0.15s;
}
.settings-section.collapsible > .settings-section-title:hover {
  color: var(--text-secondary);
}
.collapse-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}
.collapse-arrow .ic { width: 18px; height: 18px; }
.settings-section.collapsible:not(.collapsed) > .settings-section-title .collapse-arrow {
  transform: rotate(90deg);
}
.settings-section.collapsible > .settings-section-body {
  overflow: visible;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  max-height: 600px;
  opacity: 1;
}
.settings-section.collapsible.collapsed > .settings-section-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.settings-section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-section-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-label {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  font-weight: 500;
  white-space: nowrap;
}
.settings-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Help button + tooltip ── */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  padding: 0;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.help-btn .ic { width: 16px; height: 16px; }
.help-btn:hover {
  color: var(--text-primary);
  background: rgba(147,51,234,0.12);
}
.help-tooltip {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: max-content;
  max-width: 320px;
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  padding: 0;
  z-index: 11000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  animation: tooltip-in 0.15s ease-out;
}
@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.help-tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.help-tooltip-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.help-tooltip-close {
  width: 24px; height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}
.help-tooltip-close .ic { width: 14px; height: 14px; }
.help-tooltip-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}
.help-tooltip-text {
  padding: 10px 12px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.65;
  white-space: pre-line;
}

/* ── Custom dropdown (replaces native select) ── */
.custom-select {
  position: relative;
  width: 100%;
}
.custom-select-display {
  width: 100%;
  padding: 10px 36px 10px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-select-display::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-muted);
  transition: transform 0.2s;
}
.custom-select.open .custom-select-display {
  border-color: var(--accent-purple);
}
.custom-select.open .custom-select-display::after {
  transform: translateY(-50%) rotate(180deg);
}
.custom-select-dropdown {
  display: none;
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 110;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.custom-select.open .custom-select-dropdown {
  display: block;
  animation: dropdown-in 0.15s ease-out;
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.custom-select-dropdown::-webkit-scrollbar { width: 4px; }
.custom-select-dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.custom-select-option {
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-select-option:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.custom-select-option.active {
  background: var(--gradient-main);
  color: #fff;
}
/* Системные опции с SVG-иконкой (gallery folder filter: «Галерея», «Все», «Корзина»).
   svg + текст в одну строку, иконка получает чуть отступ справа от текста. */
.custom-select-option--with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}
.custom-select-option--with-icon .ic { width: 16px; height: 16px; flex-shrink: 0; }
/* ─────────────────── ФОРМЫ: CHECKBOX / RADIO / RANGE ───────────────────
   Все стандартные формы подчиняются brand-палитре через CSS-переменные.
   1) accent-color — современный CSS-свойство, перекрашивает родные элементы
      форм во всех браузерах (Chrome 93+, Safari 15.4+, Firefox 92+).
   2) Кастомные стили range thumb/track ниже — fallback и тонкая настройка
      внешнего вида.
   Чтобы поменять цвет переключателей во всём приложении — измените
   --accent-highlight в :root. ─────────────────────────────────────────── */
input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  accent-color: var(--accent-highlight);
}

.settings-range {
  /* Ползунок-настройки ведёт себя как progress-fill голосового сообщения:
     ЛЕВАЯ часть (прокрученная) — яркий brand-градиент,
     ПРАВАЯ часть (оставшаяся) — тусклый track.
     Граница задаётся CSS-переменной --val (0..100%), которую обновляет
     JS-helper initRangeFills() при каждом 'input'-событии.
     Если JS не загрузился — корректно отрабатывает default 50%. */
  --val: 50%;
  width: 100%;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background:
    linear-gradient(
      to right,
      var(--accent-highlight) 0%,
      var(--accent-highlight) var(--val),
      var(--accent-highlight-track) var(--val),
      var(--accent-highlight-track) 100%
    );
  outline: none;
}
/* Webkit: thumb */
.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 0 0 1px rgba(200,46,140,0.6);
  transition: transform 0.15s;
  /* Центрируем ползунок по линии трека: (track 6px - thumb 16px) / 2 = -5px.
     Без этого webkit выравнивает thumb по верху трека → визуально смещён вниз. */
  margin-top: -5px;
}
.settings-range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.settings-range::-webkit-slider-runnable-track {
  background: transparent;  /* track-фон уже на самом input */
  height: 6px;
  border-radius: 3px;
}
/* Firefox: track + filled progress + thumb */
.settings-range::-moz-range-track {
  background: var(--accent-highlight-track);
  border-radius: 3px;
  height: 6px;
}
.settings-range::-moz-range-progress {
  background: var(--accent-highlight);   /* нативный filled-track в Firefox */
  border-radius: 3px;
  height: 6px;
}
.settings-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 0 0 1px rgba(200,46,140,0.6);
}
.settings-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 60px;
  max-height: 160px;
  transition: border-color 0.15s;
}
.settings-textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
}
.settings-textarea::placeholder {
  color: var(--text-muted);
}
.btn-reset {
  font-size: 13px;
  padding: 10px 20px;
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-reset:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}
.btn-reset.is-done {
  background: linear-gradient(135deg, rgba(34,197,94,0.18), rgba(16,185,129,0.18));
  border-color: rgba(34,197,94,0.55);
  color: #b7f7c8;
  cursor: default;
  pointer-events: none;
  animation: btn-reset-pop 0.35s ease;
}
.btn-reset.is-done .ic {
  color: #4ade80;
  animation: btn-reset-check 0.4s ease;
}
@keyframes btn-reset-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes btn-reset-check {
  0%   { transform: scale(0.4) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(0deg);   opacity: 1; }
  100% { transform: scale(1)   rotate(0deg);   opacity: 1; }
}

/* ── Toggle switch (кастомный, под brand-палитру) ──
   ON-состояние — brand-градиент с лёгким glow.
   OFF-состояние — нейтральная тёмная подложка с тонкой обводкой.
   Чтобы перекрасить во всём приложении — поменять --gradient-main / --accent-highlight. */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s, box-shadow 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--gradient-main);
  border-color: transparent;
  box-shadow: 0 0 10px rgba(200,46,140,0.35);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}
.settings-account-info {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.seg-group {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-wrap: nowrap;
}
.seg-btn {
  padding: 8px 14px;
  font-size: 12px; font-weight: 500; font-family: inherit;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.seg-btn:not(:last-child) { border-right: 1px solid var(--border); }
.seg-btn.active { background: var(--gradient-main); color: #fff; }
.seg-btn:hover:not(.active) { background: var(--bg-card-hover); color: var(--text-primary); }

/* Mode selector: grid 2×2 when narrow, single row when wide */
#seg-mode {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: none;
  gap: 6px;
  overflow: visible;
}
#seg-mode .seg-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: 8px 6px;
}
#seg-mode .seg-btn:not(:last-child) { border-right: 1px solid var(--border); }
#seg-mode .seg-btn.active { border-color: transparent; }
@media (max-width: 340px) {
  #seg-mode {
    grid-template-columns: repeat(2, 1fr);
  }
}

.seg-group-wrap { flex-wrap: wrap; gap: 4px; border: none; }
.seg-group-wrap .seg-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  padding: 6px 10px;
}
.seg-group-wrap .seg-btn:not(:last-child) { border-right: 1px solid var(--border); }
.seg-group-wrap .seg-btn.active { border-color: transparent; }

/* ─────────────────── IMAGE MODAL ─────────────────── */
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  cursor: pointer;
  z-index: 101;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close .ic { width: 18px; height: 18px; }

/* Gallery pin + download (top-right of viewer column) */
/* ── Overlay action buttons ── */
.gallery-img-actions {
  position: relative;
  display: flex;
  gap: 8px;
  align-self: flex-end;
  z-index: 105;
  min-height: 36px;
}
/* Кнопки закрепить/скачать в полноэкранном viewer'е.
   Стиль — точно как у .gallery-sel-btn (top-bar множественного выбора):
   нейтральный тёмный фон + brand-gradient иконка.
   Активное состояние закрепа — magenta-fill с белой иконкой. */
.gallery-img-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
}
.gallery-img-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.20);
  transform: scale(1.06);
}
.gallery-img-btn-active {
  background: var(--accent-pink) !important;
  border-color: var(--accent-pink) !important;
  color: #fff;
}
.gallery-img-btn-active .ic { filter: brightness(0) invert(1) saturate(0); }   /* иконка белая на pink-fill */
.gallery-img-btn-error {
  background: rgba(220,38,38,0.4) !important;
  border-color: rgba(220,38,38,0.6) !important;
}

/* ── Toast label (anchored to pin button) ── */
.gallery-pin-toast {
  position: absolute;
  top: 50%;
  right: 100%;
  margin-right: 6px;
  transform: translateY(-50%) translateX(20px) scaleX(0);
  transform-origin: right center;
  pointer-events: none;
  white-space: nowrap;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 16px;
  background: rgba(34,197,94,0.18);
  color: #4ade80;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 105;
}
.gallery-pin-toast.show {
  opacity: 1;
  transform: translateY(-50%) translateX(0) scaleX(1);
}

/* ── Checkmark pop ── */
@keyframes pinPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.3); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.gallery-img-btn.pop { animation: pinPop 0.4s ease; }

/* ── Gallery media column (image + button below) ─ */
.gallery-media-col {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 90%;
  max-height: 92vh;
  z-index: 101;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

/* ── Viewer action buttons row ─────────────────── */
.gallery-viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.gallery-viewer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 24px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(160,32,255,0.18);    /* brand violet edge baseline */
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  white-space: nowrap;
  background: rgba(21,16,32,0.55);            /* тёмная glass-подложка baseline */
}
.gallery-viewer-btn:hover {
  background: rgba(33,20,47,0.85);
  border-color: rgba(255,46,159,0.35);
  box-shadow: 0 0 12px rgba(200,46,140,0.20);
  transform: scale(1.04);
}
.gallery-viewer-btn:disabled { opacity: 0.4; pointer-events: none; }
.gvb-icon { display: inline-flex; align-items: center; justify-content: center; }
.gvb-icon .ic { width: 18px; height: 18px; }
.gvb-loading { display: flex; align-items: center; gap: 8px; }
/* Все viewer-кнопки (Пересоздать / Изменить / Создать видео) теперь в одной
   нейтральной brand-палитре: тёмный glass-фон + brand violet-edge.
   Различия — только в иконке (refresh-cw / edit / film). Это убирает старую
   разноцветную систему (blue / yellow / violet), которая ломала бренд-гармонию. */
.gvb-regen,
.gvb-edit,
.gvb-video {
  background: rgba(21,16,32,0.55);
  border-color: rgba(160,32,255,0.18);
}
.gvb-regen:hover,
.gvb-edit:hover,
.gvb-video:hover {
  background: rgba(33,20,47,0.85);
  border-color: rgba(255,46,159,0.35);
}
.gallery-vid-spin-sm {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ── Custom Video Player ──────────────────────── */
.vp-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.vp-wrap.vp-fullscreen {
  max-height: 100vh;
  border-radius: 0;
  width: 100%;
  height: 100%;
}
.vp-video {
  display: block;
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  outline: none;
}
.vp-wrap.vp-fullscreen .vp-video {
  max-height: 100vh;
}

/* ── Poster overlay (crossfade while video loads) ── */
.vp-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.vp-poster.vp-poster-hide {
  opacity: 0;
}

/* ── Big play overlay ── */
.vp-overlay.vp-play-big {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 2;
  cursor: pointer;
}
.vp-play-big { pointer-events: none; }
.vp-paused .vp-play-big { opacity: 1; pointer-events: auto; }
.vp-play-big svg {
  width: 56px;
  height: 56px;
  color: rgba(255,255,255,0.85);
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}

/* ── Bottom controls bar ── */
.vp-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 5;
}
.vp-show-controls .vp-controls {
  opacity: 1;
  transform: translateY(0);
}
/* Show controls when video is paused */
.vp-paused .vp-controls {
  opacity: 1;
  transform: translateY(0);
}

/* ── Control buttons ── */
.vp-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
}
.vp-btn:hover { background: rgba(255,255,255,0.15); }
.vp-btn svg { width: 22px; height: 22px; }
.vp-btn-play svg { width: 26px; height: 26px; }

/* ── Progress bar ── */
.vp-prog {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  touch-action: none;
  transition: height 0.15s;
}
.vp-prog:hover,
.vp-prog:active { height: 7px; }
.vp-prog-buf {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
  pointer-events: none;
}
.vp-prog-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--gradient-main);
  border-radius: 4px;
  pointer-events: none;
  will-change: transform;
}

/* ── Time label ── */
.vp-time {
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 64px;
  text-align: center;
}

/* ── Volume control ── */
.vp-volume {
  display: flex;
  align-items: center;
  gap: 4px;
}
.vp-vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: width 0.2s;
}
.vp-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.vp-vol-slider::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.vp-vol-slider::-moz-range-track {
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}
@media (max-width: 480px) {
  .vp-vol-slider { width: 40px; }
}

/* ── Legacy (keep for backwards compat) ── */
.modal-video-full {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
  object-fit: contain;
  outline: none;
}

/* ── Video generating placeholder in chat ─────── */
.media-thumb-wrap-video.generating {
  pointer-events: none;
}
.media-thumb-wrap-video.generating::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  border-radius: 10px;
  animation: pulse-overlay 1.5s ease-in-out infinite;
}
.media-thumb-wrap-video .gen-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 2;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
}
.media-thumb-wrap-video .gen-overlay .gen-spin {
  width: 24px; height: 24px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes pulse-overlay {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.7; }
}

/* ── Video prompt dialog (media mode) ─────────── */
.video-prompt-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}
.video-prompt-dialog {
  background: #1e1e2e;
  border-radius: 16px;
  padding: 20px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.video-prompt-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}
.video-prompt-subtitle {
  font-size: 0.82rem;
  color: #aaa;
  margin-bottom: 14px;
  line-height: 1.35;
}
.video-prompt-input {
  width: 100%;
  background: #2a2a3e;
  border: 1px solid #444;
  border-radius: 10px;
  color: #fff;
  padding: 10px 12px;
  font-size: 0.92rem;
  resize: none;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.video-prompt-input::-webkit-scrollbar { width: 4px; }
.video-prompt-input::-webkit-scrollbar-track { background: transparent; }
.video-prompt-input::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.video-prompt-input:focus { border-color: #E63E80; }
.video-prompt-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.video-prompt-input-row .video-prompt-input {
  flex: 1;
  margin-bottom: 0;
}
.video-prompt-mic {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #2a2a3e;
  color: #aaa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.video-prompt-mic:hover { background: #353550; color: #fff; }
.video-prompt-mic.recording {
  background: #ef4444;
  color: #fff;
  animation: vpm-pulse 1.2s ease-in-out infinite;
}
.video-prompt-mic:disabled { opacity: 0.5; pointer-events: none; }
.video-prompt-mic svg { width: 20px; height: 20px; }
.vpm-spin {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes vpm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.video-prompt-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.video-prompt-btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.video-prompt-skip {
  background: #333;
  color: #ccc;
}
.video-prompt-skip:active { background: #444; }
.video-prompt-send {
  background: linear-gradient(135deg, #E63E80, #7B3FA8);
  color: #fff;
}
.video-prompt-send:active { filter: brightness(0.9); }

/* ── Video thumbnails in media-strip ──────────── */
.media-thumb-wrap-video {
  position: relative;
  flex: 1 1 auto;
  min-width: 80px;
  max-width: 100%;
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.media-thumb-wrap-video:hover {
  transform: scale(1.03);
  filter: brightness(1.1);
}
.media-thumb-vid-el {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.media-thumb-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.modal-image-full {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
  object-fit: contain;
  transition: transform 0.28s ease, opacity 0.28s ease;
  touch-action: manipulation;
  -webkit-user-drag: none;
  user-select: none;
}
/* Zoomed state (double-tap) */
.modal-image-full.zoomed {
  cursor: grab;
  touch-action: none;
}

/* ── Image wrapper for regen overlay ──────────── */
.gallery-img-wrap {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  max-height: 80vh;
}
/* ── Regen loading overlay on image ───────────── */
.gallery-regen-overlay {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  z-index: 2;
  background: rgba(0,0,0,0.35);
}
.gallery-regen-overlay::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 44px; height: 44px;
  margin: -22px 0 0 -22px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.gallery-img-wrap.regen-active .gallery-regen-overlay {
  display: block;
}

/* ── Gallery navigation ────────────────────────── */
.gallery-overlay { cursor: default; }
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  z-index: 102;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
}
.gallery-nav .ic { width: 22px; height: 22px; }
.gallery-nav:hover { background: rgba(255,255,255,0.2); }
.gallery-nav:disabled { opacity: 0.25; pointer-events: none; }
.gallery-prev { left: 12px; }
.gallery-next { right: 12px; }
.gallery-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}
/* Slide animations */
.gallery-slide-left  { transform: translateX(-110%) !important; opacity: 0 !important; }
.gallery-slide-right { transform: translateX(110%) !important;  opacity: 0 !important; }
.gallery-no-transition { transition: none !important; }

/* ── Mobile gallery: fullscreen, no arrows ─────── */
@media (max-width: 600px) {
  .gallery-media-col {
    max-width: 100%;
  }
  .modal-image-full {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 0;
  }
  .modal-video-full {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 0;
  }
  .vp-wrap {
    border-radius: 0;
    max-height: 80vh;
  }
  .vp-video {
    max-height: 80vh;
  }
  .gallery-nav {
    display: none;
  }
  .gallery-counter {
    bottom: env(safe-area-inset-bottom, 12px);
  }
  .gallery-viewer-btn {
    padding: 9px 14px;
    font-size: 13px;
  }
  .gallery-viewer-btn .gvb-text { display: none; }
  .gallery-viewer-btn .gvb-loading .gvb-text { display: none; }
}

/* ── Generate image button (left of input) ──
   Главный CTA — brand-градиент, как .btn-mic / .btn-send.
   Иконка автоматически становится белой через .btn-gen-image .ic правило выше. */
.btn-gen-image {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-main);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 10px rgba(200,46,140,0.25);
}
.btn-gen-image:hover  { filter: brightness(1.10); }
.btn-gen-image:active { transform: scale(0.94); }
.btn-gen-image.loading {
  animation: pulse-gen 1.2s infinite;
  pointer-events: none;
}
@keyframes pulse-gen {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%      { opacity: 0.6; transform: scale(0.94); }
}

/* ─────────────────── UTILITIES ─────────────────── */
.hidden { display: none !important; }

/* Animations */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.fade-in { animation: fade-in 0.3s ease-out; }

/* Responsive */
@media (max-width: 480px) {
  .character-grid { grid-template-columns: repeat(2, 1fr); }
  .char-card { padding: 12px 8px; }
  .chat-char-name { max-width: 120px; }
}

/* ── Voice message player (Telegram-style) ────────────────── */
.msg-voice {
  width: 70%;
  max-width: 70%;
}

.voice-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-main);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.voice-play-btn:hover { opacity: 0.85; }
.voice-play-btn:active { transform: scale(0.95); }

.voice-progress {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.voice-progress-bar {
  width: 100%;
  height: 3px;
  background: var(--accent-highlight-track);
  border-radius: 2px;
  position: relative;
}

.voice-progress-fill {
  height: 100%;
  background: var(--accent-highlight);
  border-radius: 2px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.voice-progress-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  will-change: left;
}

.voice-time {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 65px;
  text-align: center;
}

.voice-transcript-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-accent);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.voice-transcript-btn:hover {
  border-color: var(--accent-highlight);
  color: var(--accent-highlight);
}
.voice-transcript-btn.active {
  background: var(--accent-highlight);
  border-color: var(--accent-highlight);
  color: #fff;
}

.voice-transcript {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (max-width: 480px) {
  .msg-voice { width: 85%; max-width: 85%; }
  .voice-time { font-size: 10px; min-width: 55px; }
}

/* ── Voice message selection ─────────────────────────────────
   Стиль идентичен .media-thumb-check и .gallery-card-check для
   визуального единства: белая полупрозрачная обводка на тёмном фоне.
   В выделенном состоянии заливается brand-magenta (см. ниже). */
.voice-select-check {
  position: absolute;
  top: 6px;
  left: -8px;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s, transform 0.15s, background 0.2s, border-color 0.2s;
  transform: scale(0.8);
}
.msg-voice { position: relative; }
.media-select-mode .voice-select-check { opacity: 1; transform: scale(1); }
.msg-voice:hover .voice-select-check { opacity: 0.7; transform: scale(1); }
.msg-voice.voice-selected .voice-select-check {
  opacity: 1;
  transform: scale(1);
  background: var(--accent-highlight);
  border-color: var(--accent-highlight);
}
.msg-voice.voice-selected .voice-select-check::after {
  content: "✓";
  color: #fff;
  font-size: 13px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.msg-voice.voice-selected {
  outline: 2px solid var(--accent-highlight);
  outline-offset: 2px;
  border-radius: 12px;
  background: var(--accent-highlight-bg);
}

/* ── Merge button in action bar ──────────────────────────── */
.gallery-sel-merge {
  background: linear-gradient(135deg, #7B3FA8, #E63E80) !important;
  color: #fff !important;
  font-size: 16px;
  border: none;
  animation: mergeButtonPulse 1.5s ease-in-out infinite;
}
.gallery-sel-merge:hover {
  transform: scale(1.1);
}
@keyframes mergeButtonPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(167, 139, 250, 0); }
}

/* ── Tutorial popup (reusable) ────────────────────────────── */
.tut-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.tut-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 320px;
  text-align: center;
  animation: slideUp 0.3s ease;
}
.tut-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.tut-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.tut-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}
.tut-inline-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7B3FA8, #E63E80);
  color: #fff;
  font-size: 14px;
  vertical-align: middle;
}
.tut-gallery-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-highlight);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.tut-gallery-link .ic {
  width: 15px;
  height: 15px;
}
.tut-dismiss-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
}
.tut-dismiss-cb {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-highlight);
  cursor: pointer;
}
.tut-ok {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--gradient-main);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.tut-ok:hover { opacity: 0.85; }

/* ═══════════════════════════════════════════════════════════════
   Gallery Screen
   ═══════════════════════════════════════════════════════════════ */

/* ── Type tabs ── */
/* ── Filters row ── */
.gallery-filters {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.gallery-csel {
  flex: 1 1 0;
  min-width: 0;
}
.gallery-csel .custom-select-display {
  width: 100%;
  padding: 7px 4px;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  /* Когда внутри display находится SVG-иконка (placeholder filter state),
     выравниваем её по центру и задаём единый размер. */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.gallery-csel .custom-select-display .ic {
  width: 18px;
  height: 18px;
}
.gallery-csel .custom-select-display::after {
  display: none;
}
.gallery-csel .custom-select-dropdown {
  min-width: 160px;
}
.gallery-csel .custom-select-option {
  padding: 8px 10px;
  font-size: 12px;
}
.gallery-btn-folders {
  flex: 1 1 0;
  min-width: 0;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.gallery-btn-folders .ic { width: 18px; height: 18px; }
.gallery-btn-folders:hover {
  border-color: var(--accent-pink);
  color: var(--text-primary);
}

/* ── Grid scroll wrapper ── */
.gallery-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.gallery-scroll::-webkit-scrollbar { width: 4px; }
.gallery-scroll::-webkit-scrollbar-track { background: transparent; }
.gallery-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ── Grid ── */
.gallery-grid {
  padding: 0 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.gallery-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}
.gallery-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
}

.gallery-card-media {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  display: block;
}

.gallery-card-duration {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.gallery-card-audio {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  background: var(--gradient-soft);
}
.gallery-audio-icon { font-size: 28px; }
.gallery-audio-label {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
}

.gallery-card-info {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gallery-card-char {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-card-date {
  font-size: 10px;
  color: var(--text-muted);
}

.gallery-card-actions {
  display: flex;
  gap: 2px;
  padding: 0 6px 6px;
}
.gallery-action-btn {
  flex: 1;
  padding: 4px 0;
  border: none;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  color: var(--text-secondary);
}
.gallery-action-btn:hover {
  background: rgba(255,255,255,0.06);
}
.gallery-action-del:hover {
  background: rgba(220,38,38,0.15);
  color: var(--accent-red);
}
.gallery-action-restore {
  color: #22c55e;
}
.gallery-action-restore:hover {
  background: rgba(34,197,94,0.15);
}
.gallery-card-trash-days {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 6px;
  opacity: 0.8;
}
.gallery-folder-trash-opt {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 4px;
  padding-top: 8px;
}

/* Remove animation */
.gallery-card-removing {
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.3s;
}

/* ── Empty & Loading ── */
.gallery-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 16px;
}
.gallery-empty-icon { opacity: 0.5; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.gallery-empty-icon .ic { width: 48px; height: 48px; }
.gallery-empty-text { font-size: 15px; color: var(--text-secondary); }
.gallery-empty-hint { font-size: 12px; color: var(--text-muted); text-align: center; }

.gallery-loading {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-sentinel { height: 1px; }

/* ── Gallery toast ── */
.gallery-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,35,0.95);
  color: var(--text-primary);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border-accent);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90vw;
  text-align: center;
}
.gallery-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── Multi-select action bar ── */
.gallery-action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.gallery-sel-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.gallery-sel-btn .ic { width: 18px; height: 18px; }
.gallery-sel-btn:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.gallery-sel-cancel { padding: 6px 8px; }
.gallery-sel-del:hover { background: rgba(220,38,38,0.2); color: var(--accent-red); }
.gallery-sel-restore:hover { background: rgba(34,197,94,0.2); color: #22c55e; }
.gallery-sel-purge:hover { background: rgba(220,38,38,0.2); color: var(--accent-red); }
.gallery-sel-count {
  font-size: 13px;
  color: var(--accent-pink);
  font-weight: 600;
  margin-right: 4px;
}
.gallery-sel-spacer { flex: 1; }

/* ── Card selection states ──
   Стиль идентичен .media-thumb-check (чек в чате) для визуального единства.
   Галочка рисуется через ::after content, чтобы iconizer (emoji-icons.js)
   не превратил textContent='✓' в SVG раньше времени. */
.gallery-card-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.3);
  z-index: 3;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s, border-color 0.2s;
  opacity: 0;
  pointer-events: none;
}
.gallery-card.selected .gallery-card-check::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
/* Desktop hover: show checkbox on card hover */
.gallery-card:hover .gallery-card-check,
.gallery-card.selected .gallery-card-check {
  opacity: 1;
  pointer-events: auto;
}
/* In select-mode: always show checkboxes */
.gallery-grid.select-mode .gallery-card-check {
  opacity: 1;
  pointer-events: auto;
}
/* Selected card — единый brand-highlight (как у voice/media-thumb). */
.gallery-card.selected .gallery-card-check {
  background: var(--accent-highlight);
  border-color: var(--accent-highlight);
  color: #fff;
}
.gallery-card.selected {
  border-color: var(--accent-highlight);
  box-shadow: 0 0 0 2px var(--accent-highlight-track);
}
.gallery-card.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-highlight-bg);
  pointer-events: none;
  z-index: 2;
}

/* ── Folders Modal ── */
.folders-modal {
  width: 100%;
  max-width: 360px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.folders-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.folders-modal-title {
  font-size: 16px;
  font-weight: 600;
}
.folders-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.folders-modal-close .ic { width: 20px; height: 20px; }
.folders-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.folders-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 16px;
  font-size: 13px;
}
.folder-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  transition: background 0.15s;
}
.folder-row:hover { background: rgba(255,255,255,0.04); }
.folder-row-pick { cursor: pointer; }
.folder-row-pick:hover { background: rgba(147,51,234,0.12); }
.folder-row-emoji { font-size: 18px; flex-shrink: 0; }
.folder-row-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-row-count {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.folder-row-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.folder-row-del .ic { width: 16px; height: 16px; }
.folder-row-del:hover {
  background: rgba(220,38,38,0.15);
  color: var(--accent-red);
}
.folders-add-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.folder-name-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}
.folder-name-input::placeholder { color: var(--text-muted); }
.btn-add-folder {
  padding: 8px 14px;
  min-width: 42px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-add-folder .ic { width: 18px; height: 18px; }
.move-folder-modal {
  width: 100%;
  max-width: 340px;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
}

@media (max-width: 380px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-filters { gap: 4px; padding: 6px 10px; }
  .gallery-csel .custom-select-display { padding: 6px 4px; font-size: 15px; }
}

/* ═══════════════════════════════════════════════════════════════
   Mini Audio Player — bottom bar
   ═══════════════════════════════════════════════════════════════ */
.mini-player {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  z-index: 9000;
  width: 100%;
  max-width: 800px;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
}
.mini-player--visible { transform: translateX(-50%) translateY(0); }

.mp-body {
  /* Подложка плеера — тот же стиль, что у full-screen viewer'а голосовых:
     тёмно-фиолетовый radial + linear gradient в brand-палитре.
     Цвета синхронизированы с :root (--brand-violet, --brand-magenta). */
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0 8px;
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(circle at 20% 0%,   rgba(160,32,255,0.10) 0%, transparent 38%),
    radial-gradient(circle at 85% 100%, rgba(255,46,159,0.08) 0%, transparent 35%),
    linear-gradient(135deg,
      rgba(21,16,32,0.92) 0%,
      rgba(33,20,47,0.90) 50%,
      rgba(21,16,32,0.92) 100%
    );
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(160,32,255,0.16);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow:
    0 -4px 24px rgba(0,0,0,0.5),
    0 -1px 0 rgba(255,46,159,0.12) inset;     /* тонкая «розовая искра» сверху */
}

.mp-left { flex: 1; min-width: 0; }

.mp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.mp-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}
.mp-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  border-radius: 50%;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.mp-close:hover {
  color: var(--accent-highlight);
  background: var(--accent-highlight-bg);
}
.mp-close .ic { width: 16px; height: 16px; }

.mp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-bottom: 10px;
}
.mp-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.18s, background 0.18s, transform 0.12s;
}
.mp-btn:hover  { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.mp-btn:active { transform: scale(0.92); }
.mp-rew, .mp-fwd {
  width: 38px; height: 38px;
  border: 1px solid rgba(160,32,255,0.18);   /* тонкий violet-обод — как у full-screen viewer'а */
}
.mp-rew:hover, .mp-fwd:hover {
  border-color: rgba(255,46,159,0.30);
  background: rgba(255,46,159,0.06);
}
/* Главная play-кнопка — полноценный brand-CTA с glow.
   Иконка автоматически становится белой через .mini-player .ic правило выше. */
.mp-play {
  color: #fff;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--gradient-main);
  border: none;
  box-shadow:
    0 4px 16px rgba(200,46,140,0.35),
    0 0 0 1px rgba(255,255,255,0.10) inset;
}
.mp-play:hover  { filter: brightness(1.08); }
.mp-play:active { transform: scale(0.95); }

.mp-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mp-time {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 32px;
  font-variant-numeric: tabular-nums;
}
.mp-time-total { text-align: right; }
.mp-progress {
  flex: 1;
  height: 4px;
  background: var(--accent-highlight-track);  /* тусклый brand-track, тот же что у voice-progress */
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  touch-action: none;
}
.mp-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--gradient-main);            /* coral→magenta→violet — как у voice-progress-fill */
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(255,46,159,0.4);    /* тонкое свечение от прогресса */
}
.mp-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow:
    0 1px 3px rgba(0,0,0,0.5),
    0 0 0 1px rgba(200,46,140,0.6);            /* brand-ободок вокруг белого шарика */
}

/* ── Vertical volume slider (right column) ──
   Стиль синхронизирован с .settings-range и .voice-progress:
   • тёмный track,
   • заполненная часть снизу — brand magenta,
   • thumb — белый шарик с brand-ободком. */
.mp-vol-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-left: 14px;
  margin-left: 10px;
  border-left: 1px solid rgba(160,32,255,0.14);
  width: 32px;
  flex-shrink: 0;
}
.mp-vol-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.15s;
}
.mp-vol-col:hover .mp-vol-icon { color: var(--accent-highlight); }
.mp-vol {
  /* --vol-val обновляется из JS аналогично --val для .settings-range
     (см. mini-player.js _onVolChange → el.style.setProperty). */
  --vol-val: 80%;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 4px;
  height: 64px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(
    to top,
    var(--accent-highlight)        0%,
    var(--accent-highlight)        var(--vol-val),
    var(--accent-highlight-track)  var(--vol-val),
    var(--accent-highlight-track)  100%
  );
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.mp-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow:
    0 1px 3px rgba(0,0,0,0.5),
    0 0 0 1px rgba(200,46,140,0.6);
}
.mp-vol::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
  box-shadow:
    0 1px 3px rgba(0,0,0,0.5),
    0 0 0 1px rgba(200,46,140,0.6);
}
.mp-vol::-moz-range-progress {
  background: var(--accent-highlight);
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   App Toast — global notification toasts
   ═══════════════════════════════════════════════════════════════ */
.app-toast {
  position: fixed;
  top: env(safe-area-inset-top, 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 100000;
  max-width: min(90vw, 400px);
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(.4,0,.2,1), opacity 0.35s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.app-toast.show {
  transform: translateX(-50%) translateY(12px);
  opacity: 1;
  pointer-events: auto;
}
/* Error (red) */
.app-toast-error {
  background: rgba(220, 38, 38, 0.18);
  color: #f87171;
  border: 1px solid rgba(220, 38, 38, 0.3);
}
/* Warning (amber) */
.app-toast-warning {
  background: rgba(217, 119, 6, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(217, 119, 6, 0.3);
}
/* Info (blue) */
.app-toast-info {
  background: rgba(37, 99, 235, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(37, 99, 235, 0.3);
}
/* Success (green) */
.app-toast-success {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* ─────────────────── BILLING ─────────────────── */
.balance-badge { transition: transform 0.1s, box-shadow 0.2s; }
.balance-badge[data-billing-trigger="true"] {
  cursor: pointer;
  user-select: none;
}
.balance-badge[data-billing-trigger="true"]:hover {
  box-shadow: 0 0 0 2px var(--border-accent);
}
.balance-badge[data-billing-trigger="true"]:active {
  transform: scale(0.96);
}

.billing-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.billing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.billing-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.billing-balance-row {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 14px;
}
.billing-balance-amount {
  font-size: 32px; font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-variant-numeric: tabular-nums;
}
.billing-balance-suffix {
  font-size: 14px;
  color: var(--text-muted);
}
.billing-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.billing-card-actions .btn-primary,
.billing-card-actions .btn-secondary {
  flex: 1; min-width: 140px;
}

.billing-stats {
  display: flex; flex-direction: column; gap: 6px;
}
.billing-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.billing-stat-row:last-child { border-bottom: none; }
.billing-stat-label { color: var(--text-secondary); }
.billing-stat-value {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.billing-orders {
  display: flex; flex-direction: column; gap: 8px;
}
.billing-order-row {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.billing-order-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px;
}
.billing-order-coins {
  font-weight: 600;
  color: var(--text-primary);
}
.billing-order-status {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.billing-order-status.s-succeeded { background: rgba(34,197,94,0.15); color: #4ade80; }
.billing-order-status.s-pending,
.billing-order-status.s-awaiting_payment { background: rgba(251,191,36,0.15); color: #facc15; }
.billing-order-status.s-failed,
.billing-order-status.s-cancelled,
.billing-order-status.s-expired { background: rgba(220,38,38,0.15); color: #f87171; }
.billing-order-status.s-refunded { background: rgba(148,163,184,0.18); color: #cbd5e1; }
.billing-order-meta {
  display: flex; justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}
.billing-order-actions {
  display: flex; gap: 6px; margin-top: 4px;
}
.billing-order-actions .btn-link {
  background: none; border: none;
  color: var(--accent-purple, #7B3FA8);
  font-size: 12px; cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  font-family: inherit;
}
.billing-order-actions .btn-link:hover { opacity: 0.8; }

.billing-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 16px 0;
}

/* Pricing table */
.pricing-table {
  display: flex; flex-direction: column; gap: 6px;
}
.pricing-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.pricing-row:last-child { border-bottom: none; }
.pricing-service { color: var(--text-primary); }
.pricing-cost {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  text-align: right;
}
.pricing-note {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─────────────────── BILLING TOP-UP MODAL ─────────────────── */
.billing-topup-box {
  max-width: 460px;
  width: 100%;
  position: relative;
  /* Cap the modal height on small screens and scroll the modal as a
     whole, so the package grid itself never gets its own scrollbar
     that would clip discount badges. */
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-close {
  position: absolute;
  top: 10px; right: 10px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 18px; cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text-primary); }

.topup-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.topup-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
}

.topup-packages {
  display: grid;
  /* 3 columns on a 440px-wide modal, 2 on narrow phones (<380px). */
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
  /* No fixed height / scrollbar — everything fits in the viewport. */
}
@media (max-width: 380px) {
  .topup-packages { grid-template-columns: repeat(2, 1fr); }
}
.topup-package {
  /* Reset <button> defaults so the card looks identical on every browser. */
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 78px;
  padding: 14px 6px 12px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-align: center;
  outline: none;
}
.topup-package:hover {
  border-color: var(--border-accent);
  background: var(--bg-card);
}
.topup-package:active { transform: scale(0.98); }
.topup-package:focus-visible {
  border-color: var(--accent-purple, #7B3FA8);
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.35);
}
.topup-package.selected {
  border-color: var(--accent-purple, #7B3FA8);
  background: rgba(167, 139, 250, 0.10);
  box-shadow: 0 0 0 1px var(--accent-purple, #7B3FA8);
}

.topup-package-coins {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
}
.topup-package-coins-num {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.topup-package-price {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.topup-package-discount {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--gradient-main);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.topup-package.selected .topup-package-discount {
  /* Keep the badge readable on the highlighted card. */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.topup-provider-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.topup-provider-label {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.topup-provider-select {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.topup-error {
  font-size: 12px;
  color: #f87171;
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.25);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.topup-actions {
  display: flex; gap: 8px;
  margin-bottom: 12px;
}
.topup-actions .btn-primary { flex: 2; }
.topup-actions .btn-secondary { flex: 1; }

.topup-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}

/* Payment-return screen */
.payment-return-body {
  align-items: center;
  justify-content: center;
}
.payment-return-card {
  text-align: center;
  max-width: 420px;
  width: 100%;
}
.payment-return-spinner { margin-bottom: 14px; }
.payment-return-spinner .spinner {
  display: inline-block;
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-purple, #7B3FA8);
  border-radius: 50%;
  animation: pr-spin 0.9s linear infinite;
}
@keyframes pr-spin { to { transform: rotate(360deg); } }
.payment-return-title {
  font-size: 18px; font-weight: 700;
  margin-bottom: 8px;
}
.payment-return-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}
.payment-return-actions {
  display: flex; flex-direction: column; gap: 8px;
}

/* Checkout screen */
.checkout-body {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}
.checkout-card { width: 100%; }
.checkout-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.checkout-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 12px;
}
.checkout-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.checkout-hero-amount {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(167, 139, 250, 0.28);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(167,139,250,0.16), rgba(236,72,153,0.10));
}
.checkout-hero-amount span {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.checkout-hero-amount strong {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.checkout-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.checkout-summary-chip {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
}
.checkout-summary-chip span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}
.checkout-summary-chip strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.checkout-providers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkout-provider-card {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  background: var(--bg-card-hover);
  transition: border-color 0.15s, background 0.15s;
}
.checkout-provider-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card);
}
.checkout-provider-logo {
  width: 76px;
  height: 30px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.checkout-provider-logo-fallback {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--gradient-main);
  font-weight: 800;
}
.checkout-provider-title {
  font-weight: 800;
  font-size: 14px;
  color: var(--text-primary);
}
.checkout-provider-desc {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
}
.checkout-provider-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.checkout-provider-methods span {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.10);
  color: var(--accent-purple, #7B3FA8);
}
.checkout-provider-button {
  min-width: 110px;
}
@media (max-width: 640px) {
  .checkout-body { max-width: none; }
  .checkout-hero-amount { align-items: flex-start; flex-direction: column; }
  .checkout-hero-amount strong { font-size: 24px; }
  .checkout-summary-grid { grid-template-columns: 1fr; }
  .checkout-provider-card {
    grid-template-columns: 64px 1fr;
    align-items: start;
  }
  .checkout-provider-logo { width: 64px; height: 26px; }
  .checkout-provider-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* Toast helper button */
.app-toast .app-toast-action {
  margin-left: 12px;
  background: rgba(255,255,255,0.18);
  border: none;
  color: inherit;
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.app-toast .app-toast-action:hover { background: rgba(255,255,255,0.28); }

/* ─────────────────── BILLING (extra) ─────────────────── */
.billing-stats-section-title {
  margin: 14px 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.billing-stat-row--accent .billing-stat-value {
  color: #4ade80;
}
.pricing-group-title {
  margin: 12px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.pricing-group-title:first-child { margin-top: 0; }
.pricing-row .pricing-service { padding-left: 6px; }
.pricing-unit {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.pricing-cost { line-height: 1.5; }

/* ─────────────────── TARIFF CARD ─────────────────── */
.tariff-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  line-height: 1.4;
}
.tariff-section {
  margin-bottom: 16px;
}
.tariff-section:last-child { margin-bottom: 0; }
.tariff-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.tariff-section-subtitle {
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}
.tariff-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 4px;
}
.tariff-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  padding: 4px 0;
}
.tariff-row::before {
  content: "•";
  color: var(--text-muted);
  margin-right: 4px;
  flex-shrink: 0;
}
.tariff-name {
  color: var(--text-secondary);
  flex: 1;
}
.tariff-price {
  color: var(--text-primary);
  font-style: italic;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  text-align: right;
}

/* ─────────────────── BILLING — collapsible expense sections ─────────────────── */
.billing-stat-section {
  /* `<details>` removes the native marker; we draw our own caret. */
  border-bottom: 1px solid var(--border);
}
.billing-stat-section:last-child { border-bottom: none; }
.billing-stat-section > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  outline: none;
  padding: 8px 0;
  border-bottom: none;
  transition: color 0.15s;
}
.billing-stat-section > summary::-webkit-details-marker { display: none; }
.billing-stat-section > summary:hover .billing-stat-label { color: var(--text-primary); }

.billing-stat-row--section .billing-stat-label {
  display: inline-flex;
  align-items: center;
}
.billing-stat-label-icon {
  display: inline-flex;
  margin-right: 6px;
  flex-shrink: 0;
}
/* Caret находится внутри label, сразу после текста раздела.
   Размер 22×22, чуть крупнее обычной .ic-sm — заметнее как индикатор раскрытия. */
.billing-stat-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.billing-stat-caret .ic { width: 22px; height: 22px; }
.billing-stat-section[open] > summary .billing-stat-caret {
  transform: rotate(90deg);   /* стрелка → вниз при раскрытии */
}

.billing-stat-children {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 6px 18px;
  border-top: 1px solid var(--border);
}
.billing-stat-row--child {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(167, 139, 250, 0.12);
  font-size: 12px;
}
.billing-stat-row--child:last-child { border-bottom: none; }
.billing-stat-row--child .billing-stat-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
}
.billing-stat-child-marker {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--gradient-main);
  box-shadow: 0 0 7px rgba(236, 72, 153, 0.28);
}
.billing-stat-row--child .billing-stat-value { font-weight: 500; }

/* ─── Custom Character cards ───────────────────────────────── */
.char-card--custom {
  border: 1px solid var(--accent, #c2a06b);
  background: linear-gradient(145deg, rgba(194,160,107,0.08), rgba(0,0,0,0));
}
.char-card--create {
  border: 1px dashed var(--accent, #c2a06b);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; cursor: pointer;
  background: rgba(194,160,107,0.04);
}
.char-card--create:hover { background: rgba(194,160,107,0.10); }
.char-card-type--custom {
  background: var(--accent, #c2a06b);
  color: #fff;
}

/* ─── Custom Character Wizard ──────────────────────────────── */
#modal-custom-wizard .modal-content,
#modal-custom-delete .modal-content { max-width: 540px; width: 92%; }
.wizard-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.wizard-title { font-size: 18px; font-weight: 600; flex: 1; }
.wizard-step-indicator {
  font-size: 12px; color: var(--text-secondary);
  padding: 4px 10px; border-radius: 12px;
  background: var(--bg-secondary, rgba(255,255,255,0.05));
}
.wizard-step { display: flex; flex-direction: column; gap: 12px; }
.wizard-step h3 { margin: 0 0 4px 0; font-size: 16px; }
.wizard-step-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.05rem; font-weight: 600; color: #fff;
  line-height: 1.35;
}
.wizard-label { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.wizard-input,
.wizard-step select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid #444;
  background: #2a2a3e;
  color: #fff;
  font-size: 14px; font-family: inherit;
  box-sizing: border-box; outline: none;
}
.wizard-input:focus,
.wizard-step select:focus { border-color: #E63E80; }
.wizard-radio-group { display: flex; flex-wrap: wrap; gap: 10px; }
.wizard-radio-group label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid #444;
  background: #2a2a3e;
  font-size: 14px;
}

/* ── Hint icon — unified site-wide via .help-btn (components/help-tooltip.js) ── */

/* ── Prompt input (textarea + round mic) — same look as
   media-mode video-prompt-input ─────────────────── */
.wizard-prompt-row {
  display: flex; gap: 8px; align-items: flex-end;
}
.wizard-prompt-input {
  flex: 1;
  background: #2a2a3e;
  border: 1px solid #444;
  border-radius: 10px;
  color: #fff;
  padding: 10px 12px;
  font-size: 0.92rem;
  resize: vertical;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
  min-height: 80px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.wizard-prompt-input::-webkit-scrollbar { width: 4px; }
.wizard-prompt-input::-webkit-scrollbar-track { background: transparent; }
.wizard-prompt-input::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.wizard-prompt-input:focus { border-color: #E63E80; }

.wizard-mic {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: #2a2a3e;
  color: #aaa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.wizard-mic:hover { background: #353550; color: #fff; }
.wizard-mic.recording {
  background: #ef4444;
  color: #fff;
  animation: vpm-pulse 1.2s ease-in-out infinite;
}
.wizard-mic:disabled { opacity: 0.5; pointer-events: none; }
.wizard-mic svg { width: 20px; height: 20px; }
.wizard-mic .wm-spin {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.wizard-ai-btn {
  align-self: flex-start;
  background: var(--accent, #c2a06b);
  color: #fff; border: none;
  padding: 8px 14px; border-radius: 10px;
  font-size: 13px; cursor: pointer;
}
.wizard-ai-btn:hover { filter: brightness(1.1); }
.wizard-ai-btn:disabled { opacity: 0.5; cursor: wait; }
.wizard-ai-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px;
}
.wizard-hint {
  font-size: 11px; color: var(--text-secondary);
  font-style: italic;
}
.wizard-error {
  background: rgba(220, 53, 69, 0.15);
  color: #ff8585;
  padding: 8px 12px; border-radius: 6px;
  font-size: 13px;
}
.wizard-nav {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 18px;
}
.wizard-nav button { flex: 1; }
.wizard-face-status {
  font-size: 13px; color: var(--text-secondary);
  margin-top: 4px;
}
.wizard-face-candidates {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 8px;
}
.face-candidate {
  width: 96px; cursor: pointer;
  border: 2px solid transparent; border-radius: 8px;
  padding: 4px; text-align: center;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  transition: border-color 0.15s;
}
.face-candidate img {
  width: 100%; height: 96px; object-fit: cover; border-radius: 6px;
}
.face-candidate.selected { border-color: var(--accent, #c2a06b); }
.face-candidate-label { font-size: 11px; margin-top: 4px; }

/* ─── VIP locked character card ─────────────────────────────── */
.char-card--locked {
  position: relative;
}
.char-card--locked .char-card-emoji {
  opacity: 0.85;
}
.char-card--locked .char-card-emoji .ic {
  width: 36px;
  height: 36px;
  stroke: #ffc107;
}
.char-card--locked .char-card-name,
.char-card--locked .char-card-desc {
  opacity: 0.65;
}

/* ─── VIP activate modal ────────────────────────────────────── */
.vip-activate-box {
  max-width: 360px;
  text-align: center;
}
.vip-activate-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.vip-activate-title .ic {
  width: 20px;
  height: 20px;
  stroke: #ffc107;
}
.vip-activate-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.4;
}
.vip-activate-target {
  color: #ffc107;
  font-weight: 600;
}
.vip-activate-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border-accent);
  border-radius: 10px;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.vip-activate-input:focus {
  outline: none;
  border-color: #ffc107;
  box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.2);
}
.vip-activate-error {
  color: #ff6b6b;
  font-size: 13px;
  margin: 4px 0 12px;
  min-height: 18px;
  line-height: 1.3;
}
.vip-activate-note {
  font-size: 10px;
  color: rgba(185, 185, 195, 0.65);
  line-height: 1.35;
  margin: 1px 0 9px;
}
.vip-activate-note a {
  color: var(--accent-pink);
  text-underline-offset: 1px;
  text-decoration-color: rgba(230, 62, 128, 0.55);
}
.vip-activate-note a:hover {
  color: var(--brand-magenta);
}
.vip-activate-box .btn-primary,
.vip-activate-box .btn-secondary {
  width: 100%;
  margin-top: 8px;
}

/* ═════════════════ Phase 4: character publications & sharing ═════════════════ */

/* Shared cards (полученные по коду) */
.char-card--shared {
  border: 1px solid rgba(123,63,168,0.55);
  background: linear-gradient(145deg, rgba(123,63,168,0.08), rgba(0,0,0,0));
  position: relative;
}
.char-card--shared:hover {
  border-color: rgba(123,63,168,0.85);
}
/* Автор «От: X» — приглушённая подпись, без яркой плашки. */
.char-card-type--shared {
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.char-card-trash {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px;
  background: rgba(0,0,0,0.55); color: #fff;
  cursor: pointer; opacity: 0; transition: opacity .15s;
  z-index: 2;
}
.char-card--shared:hover .char-card-trash { opacity: 1; }
.char-card-trash:hover { background: rgba(220,53,69,0.85); }
.char-card-trash .ic { width: 16px; height: 16px; }

/* «Активировать по коду» action-card на вкладке «Мои» */
.char-card--activate {
  border: 1px dashed #4a9eff;
  background: rgba(74,158,255,0.06);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; cursor: pointer;
}
.char-card--activate:hover { background: rgba(74,158,255,0.12); }
.char-card--activate .char-card-emoji--icon { color: #4a9eff; }

/* Share-code block в модалке (большой моноширинный) */
.share-code-block {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 28px; letter-spacing: 4px;
  text-align: center;
  padding: 18px 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  margin: 12px 0;
  user-select: all;
  word-break: break-all;
}
.share-code-inline {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 2px;
  background: rgba(0,0,0,0.3);
  padding: 4px 10px; border-radius: 6px;
  font-weight: 600;
  user-select: all;
}

/* Publications list (My / Admin) */
.my-pubs-list {
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 2px;
}
.my-pubs-empty {
  color: var(--text-secondary, #aaa);
  text-align: center; padding: 20px 12px;
  font-size: 14px;
}
.pub-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  display: flex; flex-direction: column; gap: 8px;
}
.pub-card--inactive { opacity: 0.7; }
.pub-card-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.pub-card-title { font-weight: 600; font-size: 15px; flex: 1 1 auto; }
.pub-card-meta {
  font-size: 12px; color: var(--text-secondary, #aaa);
}
.pub-card-reject {
  font-size: 13px; color: #ff8b8b;
  background: rgba(220,53,69,0.08);
  border: 1px solid rgba(220,53,69,0.3);
  padding: 8px 10px; border-radius: 8px;
}
.pub-card-code { padding: 4px 0; }
.pub-card-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px;
}
.pub-card-actions .btn-secondary,
.pub-card-actions .btn-primary {
  font-size: 13px; padding: 6px 12px;
}

/* Status badges */
.pub-status {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.pub-status--pending  { background: rgba(255,193,7,0.15);  color: #ffc107; border: 1px solid rgba(255,193,7,0.4); }
.pub-status--approved { background: rgba(40,167,69,0.15);  color: #4ddc7e; border: 1px solid rgba(40,167,69,0.4); }
.pub-status--rejected { background: rgba(220,53,69,0.15);  color: #ff7d8a; border: 1px solid rgba(220,53,69,0.4); }
.pub-status--inactive { background: rgba(150,150,150,0.15); color: #bbb;   border: 1px solid rgba(150,150,150,0.4); }

/* Copied tooltip on copy button */
.btn-copied { background: rgba(40,167,69,0.2) !important; color: #4ddc7e !important; }

/* ═════════════════════════════════════════════════════════════
   ADMIN PANEL — большой модал с сайдбаром
   ═════════════════════════════════════════════════════════════ */

.admin-panel {
  position: relative;
  width: 96%;
  max-width: 1100px;
  height: 92vh;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: modal-in 0.2s ease-out;
}
.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-panel-title {
  font-size: 16px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
}
.admin-panel-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-tab {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.admin-tab:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.admin-tab.active {
  background: var(--gradient-soft);
  color: var(--text-primary);
  border: 1px solid var(--border-accent);
}
.admin-tab .ic { width: 16px; height: 16px; }
.admin-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 18px 22px;
}
.admin-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 8px;
  text-align: center;
}
.admin-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 4px 0 10px;
}
.admin-section { display: flex; flex-direction: column; gap: 14px; }
.admin-h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 6px 0 8px;
}

/* toolbar */
.admin-toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}

/* table */
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table th {
  background: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  color: var(--text-primary);
}

/* small button variant */
.btn-xs {
  padding: 6px 12px !important;
  font-size: 12px !important;
}

/* pagination */
.admin-pagination {
  display: flex; gap: 12px; align-items: center;
  font-size: 12px; color: var(--text-secondary);
  padding: 4px 0;
}

/* card / KV */
.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.admin-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}
.admin-kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 18px;
  margin-bottom: 12px;
}
.admin-kv {
  display: flex; gap: 8px;
  font-size: 12px;
  border-bottom: 1px dashed var(--border);
  padding: 4px 0;
}
.admin-kv-k { color: var(--text-muted); min-width: 110px; }
.admin-kv-v { color: var(--text-primary); }

.admin-actions { display: flex; flex-direction: column; gap: 8px; }
.admin-action-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* runtime configuration */
.admin-config-root { gap: 18px; }
.admin-config-band {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.admin-config-band h3 {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-size: 14px;
}
.admin-config-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-config-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 18px;
}
.admin-config-json {
  width: 100%;
  min-height: 420px;
  max-height: 65vh;
  resize: vertical;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}
.admin-config-validation { margin-top: 8px; }
.admin-config-sections { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.admin-config-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.admin-config-section > summary { cursor: pointer; color: var(--text-primary); font-size: 13px; font-weight: 600; }
.admin-config-field-input { width: 100%; box-sizing: border-box; }
.admin-config-field-check { width: 18px; height: 18px; }
.admin-config-table-wrap { margin-top: 12px; }
.admin-config-table { table-layout: fixed; }
.admin-config-table thead th:first-child,
.admin-config-table tbody th { width: 34%; }
.admin-config-table tbody th {
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.admin-config-param-label { display: inline-flex; align-items: center; gap: 3px; }
.admin-config-param-label .help-btn { margin-left: 0; }
.admin-config-param-label .help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.admin-config-table tbody td { width: 66%; }
.admin-config-table textarea { min-height: 92px; resize: vertical; }
.admin-config-providers { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.admin-config-provider { min-width: 0; }
.admin-config-provider h4 { margin: 0; color: var(--text-primary); font-size: 12px; font-weight: 600; }
.admin-config-aux-task + .admin-config-aux-task { border-top: 1px solid var(--border); padding-top: 14px; }
.admin-config-route-value { display: grid; grid-template-columns: minmax(120px, 0.7fr) minmax(180px, 1.3fr) auto; gap: 8px; align-items: center; }
.admin-config-aux-actions { margin-top: 10px; }
.admin-config-aux-actions .admin-hint { flex: 1 1 100%; line-height: 1.5; }
.admin-icon-btn { width: 32px; min-width: 32px; padding: 6px; }
.admin-config-advanced { margin-top: 12px; }
.admin-config-advanced > summary { cursor: pointer; color: var(--text-secondary); font-size: 12px; margin-bottom: 8px; }
.admin-config-ok,
.admin-config-error,
.admin-config-warning {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.admin-config-ok { color: var(--success); }
.admin-config-error { color: var(--danger); }
.admin-config-warning { color: #fbbf24; }

@media (max-width: 760px) {
  .admin-config-status { grid-template-columns: 1fr; }
  .admin-config-table thead th:first-child,
  .admin-config-table tbody th { width: 40%; }
  .admin-config-table tbody td { width: 60%; }
  .admin-config-table th,
  .admin-config-table td { padding: 8px; }
  .admin-config-json { min-height: 320px; }
  .admin-config-route-value { grid-template-columns: 1fr auto; }
  .admin-config-route-value .admin-config-field-input:first-child { grid-column: 1 / -1; }
}

/* stats output */
.admin-stats-out {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  max-height: 560px;
  overflow: auto;
}
.admin-stats-out pre {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.admin-stats-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.admin-stats-body {
  white-space: pre-wrap;
  word-break: break-word;
}
.admin-stats-body b { color: var(--text-primary); }
.admin-stats-body code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 12px;
}

/* role chips */
.admin-list-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 0;
}
.admin-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}
.admin-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.admin-chip-x:hover { color: var(--accent-red); background: rgba(220,38,38,0.1); }

/* character form */
.admin-char-form-modal { max-width: 720px; }
.char-form-avatar {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 4px 0 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.char-form-avatar-preview {
  flex: 0 0 auto;
  width: 200px;
  height: 200px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-elev, rgba(255,255,255,0.05));
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-form-avatar-preview img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.char-form-avatar-placeholder { color: var(--text-muted); opacity: 0.6; }
.char-form-avatar-ctrl {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.char-form-avatar-ctrl .hint { color: var(--text-muted); font-size: 11px; }
.char-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}
.char-form-grid .span-2 { grid-column: 1 / -1; }
.char-form-grid textarea.form-input { font-family: inherit; resize: vertical; }
.admin-checkrow {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  padding: 6px 0;
  font-size: 13px;
}
.admin-checkrow .hint { color: var(--text-muted); font-size: 11px; }

/* mobile */
@media (max-width: 720px) {
  .admin-panel { width: 100%; height: 100dvh; max-width: none; border-radius: 0; }
  .admin-panel-body { flex-direction: column; }
  .admin-sidebar {
    width: 100%; flex-direction: row; border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto; padding: 8px;
  }
  .admin-tab { white-space: nowrap; }
  .admin-content { padding: 12px; }
  .admin-kv-grid { grid-template-columns: 1fr; }
  .char-form-grid { grid-template-columns: 1fr; }
  .char-form-grid .span-2 { grid-column: auto; }
  .char-form-avatar { flex-direction: column; align-items: center; }
}

/* ═════════════════ SUPPORT CHAT ═════════════════ */

/* icon-button with badge */
.icon-btn.icon-btn-badge { position: relative; }
.icon-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #e54b6a; color: #fff;
  border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 16px;
  text-align: center;
  pointer-events: none;
}

/* ── User support modal ── */
.support-modal {
  max-width: 560px;
  width: 96%;
  height: 80vh;
  max-height: 720px;
  display: flex;
  flex-direction: column;
}
.support-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
}
.support-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 12px;
  font-size: 14px;
}
.support-empty-error { color: #e54b6a; }

/* messages */
.support-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}
.support-msg-mine {
  align-self: flex-end;
  background: linear-gradient(135deg, #7b5cff, #a06bff);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.support-msg-theirs {
  align-self: flex-start;
  background: var(--bg-secondary, #2a2a35);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.support-msg-system {
  align-self: center;
  max-width: 92%;
  background: rgba(123, 92, 255, 0.12);
  color: var(--text-primary);
  border: 1px solid rgba(123, 92, 255, 0.35);
  text-align: left;
}
.support-msg-system .support-msg-meta {
  color: #a06bff;
  font-weight: 600;
}
.support-msg-meta {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 2px;
}
/* tabs (user: Поддержка / Уведомления) */
.support-tabs {
  display: flex; gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
}
.support-tab {
  position: relative;
  flex: 1;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary, #9a9aa5);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.support-tab:hover { color: var(--text-primary); }
.support-tab.active {
  color: #a06bff;
  border-bottom-color: #a06bff;
}
.support-tab-badge {
  display: inline-block;
  min-width: 18px; padding: 0 5px;
  margin-left: 6px;
  font-size: 11px; line-height: 18px;
  text-align: center;
  color: #fff; background: #e54b6a;
  border-radius: 9px;
}

.support-msg-body { white-space: pre-wrap; }
.support-msg-body code {
  background: rgba(0, 0, 0, 0.28);
  padding: 1px 5px; border-radius: 4px;
  font-size: 0.92em;
}
.support-msg-body pre {
  background: rgba(0, 0, 0, 0.28);
  padding: 8px 10px; border-radius: 8px;
  overflow-x: auto; white-space: pre;
}
.support-msg-body a { color: #a06bff; text-decoration: underline; }
.support-msg-body .tg-spoiler {
  background: currentColor; border-radius: 3px;
  transition: background 0.15s;
}
.support-msg-body .tg-spoiler:hover { background: transparent; }
.support-msg-attach { display: block; margin-top: 6px; }
.support-msg-attach img {
  max-width: 220px; max-height: 220px;
  border-radius: 8px; display: block;
}
/* media gallery (broadcast / system messages) */
.support-msg-gallery {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.support-msg-gallery-multi .support-msg-attach img,
.support-msg-gallery-multi .support-msg-video {
  max-width: 140px; max-height: 140px;
}
.support-msg-video {
  max-width: 240px; max-height: 240px;
  border-radius: 8px; display: block; background: #000;
}

/* input row */
.support-input-row {
  display: flex; align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.support-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 64px; max-height: 180px;
  /* extra padding-right so the inner scrollbar never touches the rounded corner */
  padding: 12px 18px 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-secondary, #1f1f29);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  /* thin, custom-styled scrollbar that stays inside the rounded box */
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted, #555) transparent;
  overflow-y: auto;
}
.support-input-row textarea::-webkit-scrollbar { width: 6px; }
.support-input-row textarea::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
.support-input-row textarea::-webkit-scrollbar-thumb {
  background: var(--text-muted, #555);
  border-radius: 6px;
}
.support-input-row textarea::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary, #888);
}
.support-input-row textarea:focus {
  outline: none;
  border-color: var(--accent-purple, #7b5cff);
}
.support-attach-btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg-secondary, #2a2a35);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s, transform 0.1s;
}
.support-attach-btn:hover {
  background: var(--bg-card-hover, var(--border));
  color: var(--text-primary);
}
.support-attach-btn:active { transform: scale(0.94); }
.support-attach-btn .ic { width: 20px; height: 20px; }

/* attachment preview */
.support-attach-preview {
  position: relative;
  margin: 0 12px 8px;
  display: inline-block;
}
.support-attach-preview img {
  max-width: 120px; max-height: 80px;
  border-radius: 8px; display: block;
}
.support-attach-clear {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px;
  border: none; border-radius: 50%;
  background: #e54b6a; color: #fff;
  font-size: 14px; font-weight: 700; line-height: 18px;
  cursor: pointer;
}

/* ── Admin support modal ── */
.support-admin-modal {
  max-width: 1000px;
  width: 96%;
  height: 86vh;
  max-height: 820px;
  display: flex;
  flex-direction: column;
}
.support-admin-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.support-admin-list {
  width: 280px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg-card);
}
.support-admin-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-card);
}

.support-thread-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.support-thread-item:hover { background: var(--bg-secondary, rgba(255,255,255,0.04)); }
.support-thread-item.active {
  background: linear-gradient(135deg, rgba(123,92,255,0.18), rgba(160,107,255,0.12));
  border-left: 3px solid #7b5cff;
  padding-left: 9px;
}
.support-thread-item.has-unread .support-thread-who { font-weight: 700; }
.support-thread-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.support-thread-who {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.support-thread-badge {
  min-width: 18px; height: 18px; padding: 0 6px;
  background: #e54b6a; color: #fff;
  border-radius: 9px;
  font-size: 11px; font-weight: 700; line-height: 18px;
  text-align: center;
}
.support-thread-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.support-thread-meta {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  margin-top: 4px;
}

.support-admin-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
}
.support-admin-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* mobile */
@media (max-width: 720px) {
  .support-modal,
  .support-admin-modal {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .support-admin-body { flex-direction: column; }
  .support-admin-list {
    width: 100%;
    max-height: 35vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

/* ─── Change-password "don't show again" checkbox row ─── */
.form-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary, #a0a0b8);
  cursor: pointer;
  user-select: none;
}
.form-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: #7b5cff;
}

/* ─── Image lightbox (fullscreen viewer for support attachments) ─── */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.image-lightbox-img {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  transform-origin: center center;
  cursor: zoom-in;
  -webkit-user-drag: none;
  pointer-events: auto;
  transition: transform 0.05s linear;
  will-change: transform;
}
.image-lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  transition: background 0.15s, transform 0.1s;
}
.image-lightbox-close:hover { background: rgba(0, 0, 0, 0.8); }
.image-lightbox-close:active { transform: scale(0.92); }
.image-lightbox-close .ic { width: 22px; height: 22px; }

/* support attachment thumbnails should hint clickability */
.support-msg-attach { cursor: zoom-in; }
.support-msg-attach img { transition: transform 0.15s; }
.support-msg-attach:hover img { transform: scale(1.02); }

/* ─────────────────── LEGAL DOCUMENT MODAL ─────────────────── */
.legal-modal {
  max-width: 820px;
  max-height: 92vh;
}
.legal-body {
  padding: 20px 28px 32px;
  gap: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  scroll-behavior: smooth;
}
.legal-body::-webkit-scrollbar { width: 8px; }
.legal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.legal-body::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
.legal-body .legal-loading,
.legal-body .legal-error {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
}
.legal-body .legal-error { color: #f08080; }
.legal-body h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 18px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.legal-body h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 24px 0 8px;
  color: var(--text-primary);
}
.legal-body h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 18px 0 6px;
  color: var(--text-primary);
}
.legal-body p { margin: 0 0 12px; }
.legal-body ul,
.legal-body ol {
  margin: 0 0 14px;
  padding-left: 22px;
}
.legal-body li { margin-bottom: 6px; }
.legal-body strong { color: var(--text-primary); font-weight: 600; }
.legal-body a {
  color: var(--accent-pink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.legal-body code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.legal-body blockquote {
  border-left: 3px solid var(--border);
  padding: 4px 0 4px 14px;
  margin: 0 0 14px;
  color: var(--text-secondary);
}
.legal-body table.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 22px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  overflow: hidden;
}
.legal-body table.legal-table th,
.legal-body table.legal-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
  line-height: 1.45;
}
.legal-body table.legal-table thead th {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
}
.legal-body table.legal-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.025);
}
.legal-body table.legal-table tbody td:first-child {
  font-weight: 600;
  color: var(--text-primary);
  width: 28%;
  min-width: 160px;
}
@media (max-width: 600px) {
  .legal-body table.legal-table {
    display: block;
    overflow-x: auto;
  }
  .legal-body table.legal-table th,
  .legal-body table.legal-table td {
    padding: 8px 10px;
    font-size: 13px;
  }
}
.legal-link {
  color: var(--accent-pink);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-link:hover { color: var(--brand-magenta); opacity: 1; }

/* Index list shown when navigating to /legal (no slug). */
.legal-body ul.legal-index {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legal-body ul.legal-index li {
  margin: 0;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.legal-body ul.legal-index li:hover {
  background: rgba(230, 62, 128, 0.08);
  border-color: var(--accent-pink);
}
.legal-body ul.legal-index a {
  display: block;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
}
.legal-body ul.legal-index li:hover a {
  color: var(--accent-pink);
}

/* Register / support consent checkboxes */
.consent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 14px;
}
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.consent-row input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #c084fc);
  cursor: pointer;
}
.consent-row label {
  cursor: pointer;
}
.consent-row.required label::after {
  content: " *";
  color: #f08080;
}

/* Support form: consent block sits just above the input row */
.support-consent {
  padding: 10px 14px 0;
  border-top: 1px solid var(--border);
}
.support-consent .consent-row { font-size: 12px; }
.btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─────────────────── COOKIE BANNER & FOOTER ─────────────────── */
.cookie-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card, #1a1622);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.55);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.cookie-banner-text { max-width: 1100px; margin: 0 auto; width: 100%; }
.cookie-banner-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.cookie-banner-actions .btn-primary,
.cookie-banner-actions .btn-secondary {
  padding: 8px 16px;
  font-size: 13px;
  min-width: 140px;
}
@media (min-width: 720px) {
  .cookie-banner {
    flex-direction: row;
    align-items: center;
    padding: 14px 24px;
  }
  .cookie-banner-text { flex: 1; padding-right: 16px; }
  .cookie-banner-actions { width: auto; justify-content: flex-end; }
}

/* Settings modal for granular cookie categories */
.cookie-settings-modal { max-width: 640px; }
.cookie-settings-body { gap: 16px; }
.cookie-settings-intro {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}
.cookie-cat-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.cookie-cat-row input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent, #c084fc);
  cursor: pointer;
}
.cookie-cat-row input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.6; }
.cookie-cat-info { flex: 1; }
.cookie-cat-info label { display: block; margin-bottom: 4px; cursor: pointer; }
.cookie-cat-desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.cookie-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
.cookie-settings-actions .btn-primary,
.cookie-settings-actions .btn-secondary {
  padding: 8px 16px;
  font-size: 13px;
}

/* Auth-screen legal footer (compact, separated from main disclaimer).
   Pinned to the bottom of the auth screen via flex column on #screen-auth. */
.auth-footer {
  flex-shrink: 0;
  padding: 20px 24px 16px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}
.auth-footer-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 32px;
  max-width: 720px;
  margin: 0 auto 14px;
}
.auth-footer-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.auth-footer-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-primary);
  opacity: 0.85;
}
.auth-footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auth-footer-col li { margin: 0; }
.auth-footer .legal-link {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-block;
  text-align: left;
  line-height: 1.5;
}
.auth-footer .legal-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}
.auth-footer-bottom {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-secondary);
  opacity: 0.75;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  max-width: 720px;
  margin: 0 auto;
}

/* Narrow screens: collapse to two columns, then a single column. */
@media (max-width: 640px) {
  .auth-footer-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 20px;
  }
}
@media (max-width: 420px) {
  .auth-footer-cols {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .auth-footer { padding: 16px 18px 14px; }
}

/* ─────────────────── BIOMETRIC CONSENT MODAL ─────────────────── */
.biometric-modal { max-width: 560px; }
.biometric-body {
  gap: 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.biometric-body p { margin: 0; }
.biometric-body strong { color: var(--text-primary); }
.biometric-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.biometric-actions .btn-primary,
.biometric-actions .btn-secondary {
  padding: 9px 18px;
  font-size: 13px;
}
.biometric-actions .btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* ═══════════════ PARTNER PROGRAM MODAL ═══════════════ */
.partner-loading {
  color: var(--text-secondary);
  text-align: center;
  padding: 24px 12px;
  font-size: 14px;
}
.partner-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.partner-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 12px 8px 4px;
}
.partner-intro-icon { width: 40px; height: 40px; }
.partner-intro-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}
.partner-intro-text b { color: var(--accent-highlight); }

.partner-block {
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.partner-block-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Referral links */
.partner-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.partner-link-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 78px;
}
.partner-link-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.partner-copy-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.partner-copy-btn:hover { background: var(--bg-card-hover); }

/* Stats */
.partner-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.partner-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}
.partner-stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.partner-stat-lbl {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

/* Balance */
.partner-balance-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.partner-balance-val {
  font-size: 26px;
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.partner-balance-hint { font-size: 12px; color: var(--text-secondary); }
.partner-balance-sub {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.partner-balance-sub b { color: var(--text-primary); }
.partner-withdraw-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Inline messages */
.partner-error {
  color: var(--accent-red);
  font-size: 13px;
  padding: 8px 10px;
  background: rgba(225,29,72,0.08);
  border-radius: var(--radius-sm);
}
.partner-success {
  color: #34d399;
  font-size: 13px;
  padding: 8px 10px;
  background: rgba(52,211,153,0.08);
  border-radius: var(--radius-sm);
}

/* Plain input reused by the withdraw modal */
.settings-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.settings-input:focus {
  outline: none;
  border-color: var(--accent-purple);
}
.settings-input::placeholder { color: var(--text-muted); }

/* ── Withdraw method selection ── */
.pw-step { display: flex; flex-direction: column; gap: 12px; }
.pw-step-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}
.pw-methods {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pw-method-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.pw-method-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-purple);
}
.pw-method-btn .ic { flex: 0 0 auto; }

.pw-method-chosen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: 4px;
}
.pw-change-link {
  background: none;
  border: none;
  color: var(--accent-pink);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.pw-change-link:hover { text-decoration: underline; }

.pw-fields { display: flex; flex-direction: column; gap: 12px; }
.pw-field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Hide the native number-input spinners on the withdraw amount field —
   they look out of place in this UI. */
#pw-amount::-webkit-outer-spin-button,
#pw-amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#pw-amount {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ═════════════════ Two-level character catalog (От Amorum / Сообщество / Мои) ═════════════════ */

.category-tabs--top { padding-bottom: 8px; }
.category-tabs--top .cat-tab--top {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}

/* Second-level filter bar — shared by «От Amorum» sub-tabs and «Сообщество».
   Set apart from the first-level segmented tabs with a subtle inset panel
   so the two levels don't blend together. */
.subfilter-bar {
  margin: 0 16px 12px;
  padding: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
}
.subfilter-row {
  display: flex; gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Community controls (filter + sort + search) */
.community-controls {
  display: flex; flex-direction: column; gap: 8px;
}
.community-filter-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.comm-filter {
  padding: 6px 14px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 999px;
  cursor: pointer; transition: all 0.2s;
}
.comm-filter.active { background: var(--gradient-main); color: #fff; border-color: transparent; }
.comm-filter:hover:not(.active) { background: var(--bg-card-hover); color: var(--text-primary); }

.community-tools-row { display: flex; gap: 8px; align-items: center; }
.community-sort { display: flex; gap: 0; flex-shrink: 0; }
.comm-sort {
  padding: 6px 12px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.comm-sort:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.comm-sort:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.comm-sort:not(:last-child) { border-right: none; }
.comm-sort.active { background: var(--gradient-main); color: #fff; border-color: transparent; }
.comm-sort:hover:not(.active) { background: var(--bg-card-hover); color: var(--text-primary); }

.community-search {
  flex: 1; display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.community-search .ic { color: var(--text-secondary); flex-shrink: 0; }
.community-search input {
  flex: 1; border: none; background: transparent;
  color: var(--text-primary); font-family: inherit; font-size: 13px;
  padding: 8px 0; outline: none;
}

/* Community cards */
.char-card--community {
  border: 1px solid rgba(123,63,168,0.55);
  background: linear-gradient(145deg, rgba(123,63,168,0.08), rgba(0,0,0,0));
  cursor: pointer;
}
.char-card--community:hover {
  border-color: rgba(123,63,168,0.85);
}
.char-card-meta { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* Publish modal: description + audience */
.publish-textarea {
  resize: vertical; min-height: 60px;
  font-family: inherit; line-height: 1.4;
}
.publish-char-counter {
  display: block; text-align: right;
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.publish-audience { display: flex; gap: 6px; }
.publish-aud-btn {
  flex: 1; padding: 8px 4px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s;
}
.publish-aud-btn.active { background: var(--gradient-main); color: #fff; border-color: transparent; }
.publish-aud-btn:hover:not(.active) { background: var(--bg-card-hover); color: var(--text-primary); }

/* My-publications intro + add button */
.my-pubs-intro {
  font-size: 13px; line-height: 1.45;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
}
.my-pubs-add { width: 100%; margin-bottom: 14px; }

/* ═════════════ Modal button spacing (fix merged/flush buttons) ═════════════
   Loose action buttons placed directly inside a .modal-box stack full-width
   with a gap — matches the .vip-activate-box pattern. Covers publish,
   share-code, regen, delete-confirm, admin-reject, admin-confirm, etc. */
.modal-box > .btn-primary,
.modal-box > .btn-secondary,
.modal-box > .btn-danger {
  width: 100%;
  margin-top: 8px;
}
.modal-box > .btn-primary:first-of-type {
  margin-top: 4px;
}

/* .modal-actions wrapper (change-password, link-telegram) had no styling,
   so its buttons collapsed together. Give them a consistent row with gap. */
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.modal-actions .btn-primary,
.modal-actions .btn-secondary,
.modal-actions .btn-danger {
  flex: 1;
}

/* ── Bonus modal ── */
.bonus-options { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.bonus-option {
  font-family: inherit; appearance: none; -webkit-appearance: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 16px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; font-weight: 600; text-align: center;
  background: var(--bg-card-hover); color: var(--text-primary);
  border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.bonus-option:hover { border-color: var(--border-accent); background: var(--bg-card); }
.bonus-option:active { transform: scale(0.98); }
.bonus-option span { font-weight: 700; color: var(--text-secondary); font-size: 13px; }
.bonus-input {
  font-family: inherit; font-size: 13px;
  width: 100%; margin: 8px 0; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border); box-sizing: border-box; outline: none;
}
.bonus-input:focus { border-color: var(--accent-purple, #7B3FA8); }
.bonus-stars { display: flex; gap: 6px; margin: 8px 0; justify-content: center; }
.bonus-star { background: none; border: none; font-size: 28px; cursor: pointer; color: #f5c542; line-height: 1; padding: 0; }
.bonus-channel {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 11px 14px; margin: 8px 0; border-radius: var(--radius-sm);
  background: var(--bg-card-hover); color: var(--text-primary);
  text-decoration: none; border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s; text-align: center;
}
.bonus-channel:hover { border-color: var(--border-accent); background: var(--bg-card); }
.bonus-channel-name { font-size: 14px; font-weight: 600; }
.bonus-channel-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.3; }
.bonus-channels-note { font-size: 12px; color: var(--text-muted); text-align: center; margin: 12px 0 4px; }
