/*
 * Общие стили проекта. Правила дизайна — в CLAUDE.md:
 * чёрный фон, белые основные кнопки, серые поверхности, без теней, обводок и свечений.
 * Кнопки и поля — 14px, мелкие контролы — 12px, блоки — 24–28px, кнопка отправки — круглая.
 * Сетка десктопа — 1200px (--ui-container).
 *
 * Порядок слоёв совпадает с Tailwind v4: утилиты Tailwind перекрывают компоненты ниже.
 */
@layer theme, base, components, utilities;

:root {
  color-scheme: dark;
  --ui-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ui-font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;

  --ui-bg: #000000;
  --ui-surface-1: #0f0f0f;
  --ui-surface-2: #161616;
  --ui-surface-3: #1d1d1d;
  --ui-surface-4: #262626;
  --ui-surface-5: #303030;
  --ui-fg: #ececec;
  --ui-fg-strong: #ffffff;
  --ui-muted: #8f8f8f;
  --ui-subtle: #5f5f5f;
  --ui-danger: #f87171;

  --ui-radius-xs: 10px;     /* маленькие кнопки 28px: копировать, вкладки кода */
  --ui-radius-sm: 12px;     /* контролы 32–36px: пункты меню, чипы, сегменты */
  --ui-radius-btn: 14px;    /* кнопки 38–48px и поля ввода */
  --ui-radius-block: 24px;  /* карточки и блоки */
  --ui-radius-panel: 28px;  /* поле ввода чата, модалки, крупные секции */
  --ui-container: 1200px;   /* сетка десктопа */
  --ui-ease: cubic-bezier(.22, 1, .36, 1);
  --ui-ease-in: cubic-bezier(.4, 0, 1, 1);  /* ease-in из Tailwind: закрытие модалок */
}

/* ================= База ================= */
@layer base {
  html { background: var(--ui-bg); -webkit-text-size-adjust: 100%; }
  body {
    margin: 0;
    min-height: 100dvh;
    background: var(--ui-bg);
    color: var(--ui-fg);
    font-family: var(--ui-font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  body[data-layout="app"] { overflow: hidden; }
  [hidden] { display: none !important; }
  button, input, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; -webkit-tap-highlight-color: transparent; }
  button:disabled { cursor: default; }
  a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
  :focus-visible { outline: none; }
  ::selection { background: #3a3a3a; color: #fff; }
  svg.lucide { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.75; }
  * { scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
}

@layer components {
  /* ================= Кнопки ================= */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--ui-radius-btn);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
    transition: background-color .2s, color .2s, opacity .2s;
  }
  .btn svg.lucide { width: 17px; height: 17px; }
  .btn:disabled, .btn.is-loading { opacity: .55; pointer-events: none; }
  .btn-primary { background: #fff; color: #000; }
  .btn-primary:hover, .btn-primary:focus-visible { background: #e2e2e2; }
  .btn-secondary { background: var(--ui-surface-3); color: var(--ui-fg); }
  .btn-secondary:hover, .btn-secondary:focus-visible { background: var(--ui-surface-4); }
  .btn-ghost { color: var(--ui-muted); }
  .btn-ghost:hover, .btn-ghost:focus-visible { background: var(--ui-surface-3); color: var(--ui-fg); }
  .btn-danger { background: rgb(248 113 113 / .1); color: #fca5a5; }
  .btn-danger:hover, .btn-danger:focus-visible { background: rgb(248 113 113 / .18); }
  .btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--ui-radius-sm); }
  .btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }

  .icon-btn {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: var(--ui-radius-btn);
    color: var(--ui-muted);
    flex-shrink: 0;
    transition: background-color .2s, color .2s;
  }
  .icon-btn:hover, .icon-btn:focus-visible, .icon-btn.is-open { background: var(--ui-surface-3); color: var(--ui-fg); }
  .icon-btn svg.lucide { width: 20px; height: 20px; }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 8px;
    background: var(--ui-surface-3);
    color: var(--ui-muted);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .01em;
    white-space: nowrap;
  }
  .badge svg.lucide { width: 12px; height: 12px; }
  .badge-light { background: #fff; color: #000; }

  /* ================= Формы ================= */
  .field-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--ui-muted); }
  .field {
    display: block;
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-3);
    color: var(--ui-fg);
    font-size: 15px;
    outline: none;
    transition: background-color .2s;
  }
  .field::placeholder { color: var(--ui-subtle); }
  .field:hover { background: #212121; }
  .field:focus { background: var(--ui-surface-4); }
  .field[readonly] { color: var(--ui-muted); background: var(--ui-surface-2); }
  .field.is-invalid { background: rgb(248 113 113 / .1); }
  .field-error { margin-top: 6px; font-size: 13px; color: #fca5a5; }
  .field-wrap { position: relative; }
  .field-wrap .field { padding-right: 48px; }
  .field-wrap .icon-btn { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); }
  /* iOS не увеличивает страницу при фокусе, только если шрифт поля не меньше 16px */
  @media (pointer: coarse) { .field { font-size: 16px; } }

  /*
   * Плавающая подпись: подсказка внутри поля, при вводе уменьшается и уходит наверх поля.
   * Разметка: <div class="float-field"><input class="field" placeholder=" "><label>Подпись</label></div>
   */
  .float-field { position: relative; }
  .float-field .field { padding-top: 18px; padding-bottom: 2px; }
  .float-field .field::placeholder { color: transparent; }
  .float-field > label {
    position: absolute;
    left: 16px;
    top: 50%;
    max-width: calc(100% - 64px);
    overflow: hidden;
    color: var(--ui-subtle);
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
    pointer-events: none;
    transform: translateY(-50%);
    transition: top .22s var(--ui-ease), font-size .22s var(--ui-ease), transform .22s var(--ui-ease), color .2s;
  }
  .float-field .field:focus + label,
  .float-field .field:not(:placeholder-shown) + label,
  .float-field .field[readonly] + label { top: 7px; font-size: 11px; color: var(--ui-muted); transform: none; }
  /* Автозаполнение браузера: подпись тоже уезжает наверх (отдельные правила — неизвестный селектор ломает весь список) */
  .float-field .field:-webkit-autofill + label { top: 7px; font-size: 11px; color: var(--ui-muted); transform: none; }
  .float-field .field:autofill + label { top: 7px; font-size: 11px; color: var(--ui-muted); transform: none; }
  /* Автозаполнение не перекрашивает поле в цвет браузера */
  .field:-webkit-autofill { -webkit-text-fill-color: var(--ui-fg); caret-color: var(--ui-fg); transition: background-color 9999s ease-out 0s; }

  /* Компактные формы входа и регистрации */
  .auth-card { width: 100%; max-width: 360px; }
  .auth-card .field { height: 46px; }
  /* Email с первого шага: плашка, по нажатию — назад к первому шагу */
  .auth-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-2);
    color: var(--ui-fg);
    font-size: 14px;
    transition: background-color .2s;
  }
  .auth-identity:hover, .auth-identity:focus-visible { background: var(--ui-surface-3); }
  .auth-identity svg.lucide { width: 16px; height: 16px; color: var(--ui-muted); }
  /* Прогресс регистрации: два шага */
  .auth-progress { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
  .auth-progress span { height: 3px; border-radius: 3px; background: var(--ui-surface-4); transition: background-color .35s var(--ui-ease); }
  .auth-progress span.is-done { background: #fff; }
  .step-back { animation: step-back .35s var(--ui-ease) both; }
  .form-error {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--ui-radius-btn);
    background: rgb(248 113 113 / .1);
    color: #fca5a5;
    font-size: 14px;
    line-height: 1.5;
  }
  .form-error svg.lucide { width: 17px; height: 17px; margin-top: 1px; }

  .checkbox {
    appearance: none;
    -webkit-appearance: none;
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin: 0;
    border-radius: 7px;
    background: var(--ui-surface-4);
    flex-shrink: 0;
    cursor: pointer;
    transition: background-color .2s;
  }
  .checkbox:checked {
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 14px no-repeat;
  }
  .checkbox:focus-visible { background-color: var(--ui-surface-5); }
  .checkbox:checked:focus-visible { background-color: #e2e2e2; }

  /* Переключатель: кружок едет через transform, фон и цвет кружка плавно меняются.
     При нажатии кружок чуть вытягивается (scaleX) в сторону, куда поедет */
  .switch {
    position: relative;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: var(--ui-surface-5);
    flex-shrink: 0;
    transition: background-color .35s var(--ui-ease);
  }
  .switch::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #9a9a9a;
    transform-origin: left center;
    transition: transform .45s var(--ui-ease), background-color .35s var(--ui-ease);
  }
  .switch[aria-checked="true"] { background: #fff; }
  .switch[aria-checked="true"]::after { transform: translateX(18px); background: #000; transform-origin: right center; }
  .switch:active::after, .params-toggle:active .switch::after { transform: scaleX(1.18); }
  .switch[aria-checked="true"]:active::after, .params-toggle[aria-checked="true"]:active .switch::after { transform: translateX(18px) scaleX(1.18); }
  .switch:focus-visible { background: #3a3a3a; }
  .switch[aria-checked="true"]:focus-visible { background: #e2e2e2; }

  /* Кнопка-селект (выпадающий список на popover) */
  .select-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 42px;
    min-width: 200px;
    max-width: 100%;
    padding: 0 12px 0 14px;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-3);
    color: var(--ui-fg);
    font-size: 14px;
    transition: background-color .2s;
  }
  .select-btn:hover, .select-btn:focus-visible, .select-btn.is-open { background: var(--ui-surface-4); }
  .select-btn .select-value { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
  .select-btn .select-value span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .select-btn > svg.lucide { width: 16px; height: 16px; color: var(--ui-subtle); transition: transform .2s var(--ui-ease); }
  .select-btn.is-open > svg.lucide { transform: rotate(180deg); }

  /* ================= Бренд и навигация ================= */
  .brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ui-fg-strong); min-width: 0; }
  .brand-mark { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; }

  /* ================= Логотип (core/logo.js) ================= */
  .logo-mark { display: block; flex-shrink: 0; overflow: visible; color: #fff; }
  .logo-mark .logo-spin { transform-box: fill-box; transform-origin: center; transition: transform .9s var(--ui-ease); }
  .logo-mark .logo-bar { transform-box: fill-box; transform-origin: center; }

  /* Наведение на логотип в шапке: пол-оборота (форма симметрична, поэтому встаёт как была), лучи «дышат» */
  .brand:hover .logo-spin, .brand:focus-visible .logo-spin { transform: rotate(180deg); }
  .brand:hover .logo-stub, .brand:focus-visible .logo-stub { animation: logo-stub-pulse .9s var(--ui-ease); }
  .brand:hover .logo-bar, .brand:focus-visible .logo-bar { animation: logo-bar-pulse .9s var(--ui-ease); }

  /* Лендинг и пустой чат: логотип собирается из лучей, потом раз в несколько секунд делает пол-оборота */
  .logo-intro .logo-bar { animation: logo-bar-in 1s var(--ui-ease) both; }
  .logo-intro .logo-stub { animation: logo-stub-in .9s var(--ui-ease) both; animation-delay: calc(.2s + var(--i) * .09s); }
  .logo-intro .logo-spin { animation: logo-idle 9s var(--ui-ease) 1.6s infinite; }
  .brand-name { font-size: 17px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--ui-radius-sm);
    color: var(--ui-muted);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .2s, color .2s;
  }
  .nav-link:hover, .nav-link:focus-visible { color: var(--ui-fg); background: var(--ui-surface-2); }
  .nav-link.is-active { color: var(--ui-fg-strong); background: var(--ui-surface-3); }

  /* Сетка: на десктопе весь контент выровнен по колонке 1200px */
  .container-x { width: min(var(--ui-container), calc(100% - 32px)); margin-inline: auto; }
  @media (min-width: 768px) { .container-x { width: min(var(--ui-container), calc(100% - 48px)); } }

  /* ================= Публичный лейаут ================= */
  .public-header { position: sticky; top: 0; z-index: 40; background: var(--ui-bg); }
  .public-mobile-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    padding: 8px 16px 20px;
    background: var(--ui-bg);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity .25s var(--ui-ease), transform .3s var(--ui-ease);
  }
  .public-mobile-menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
  .public-mobile-menu .nav-link { width: 100%; height: 44px; font-size: 15px; }
  .public-main { min-height: calc(100dvh - 64px); }
  .section { scroll-margin-top: 80px; }

  /* ================= Лейаут входа ================= */
  .auth-shell { min-height: 100dvh; display: flex; flex-direction: column; }
  /* Форма чуть выше центра экрана: нижний отступ уравновешивает шапку (64px),
     свободное место делится 2:3, поэтому сверху его меньше, чем снизу. */
  .auth-main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 24px 16px 88px; }
  .auth-main::before { content: ''; flex: 2 1 0; }
  .auth-main::after { content: ''; flex: 3 1 0; }

  /* ================= Лейаут кабинета ================= */
  .app-shell { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  .topbar { position: relative; z-index: 20; flex-shrink: 0; background: var(--ui-bg); }
  .topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 60px;
  }
  @media (max-width: 767px) { .topbar-inner { width: calc(100% - 20px); } }
  .topbar-side { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .topbar-nav { display: none; align-items: center; gap: 2px; margin-left: 16px; }
  .topbar .brand-name { font-size: 16px; }
  .app-main { position: relative; flex: 1; min-height: 0; }

  .plan-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-2);
    color: var(--ui-fg);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .2s;
  }
  .plan-pill:hover, .plan-pill:focus-visible { background: var(--ui-surface-3); }
  .plan-pill svg.lucide { width: 15px; height: 15px; color: var(--ui-muted); }
  .plan-pill small { color: var(--ui-muted); font-size: 12px; font-weight: 400; }
  .plan-pill.is-inactive { color: var(--ui-muted); }
  /*
   * Активный тариф: радужная обводка 1.5px, приглушённая, медленно вращается.
   * Исключение из правила «без обводок». ::before — крупный квадрат с конусным градиентом (крутится
   * через transform), ::after — фон плашки поверх, оставляет от градиента только кант.
   */
  .plan-pill.is-premium { position: relative; isolation: isolate; overflow: hidden; background: transparent; }
  .plan-pill.is-premium::before {
    content: "";
    position: absolute;
    z-index: -2;
    left: 50%;
    top: 50%;
    width: max(240%, 280px);
    aspect-ratio: 1;
    background: conic-gradient(#ff9b9b, #ffd59b, #fff3a1, #a6f3b8, #9fd8ff, #b4a6ff, #ffa6e6, #ff9b9b);
    opacity: .55;
    transform: translate(-50%, -50%) rotate(0deg);
    animation: plan-rainbow 6s linear infinite;
  }
  .plan-pill.is-premium::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 1.5px;
    border-radius: calc(var(--ui-radius-sm) - 1.5px);
    background: var(--ui-surface-2);
    transition: background-color .2s;
  }
  .plan-pill.is-premium:hover::after, .plan-pill.is-premium:focus-visible::after { background: var(--ui-surface-3); }

  /*
   * Праздничное окно нового тарифа (core/welcome.js). Пузырь растёт из центра верхнего края (scale 0 → 1),
   * затем по очереди проявляется содержимое (--d — номер в очереди).
   * Закрытие в обратном порядке: содержимое гаснет, пузырь сворачивается к верхнему краю.
   */
  .pw-lock, .pw-lock body { overflow: hidden; }
  .pw { position: fixed; inset: 0; z-index: 95; }
  /* Край пузыря размыт: сплошной цвет до 78% радиуса, дальше мягко тает (радиус с запасом, см. BUBBLE_FEATHER) */
  .pw-bubble {
    position: fixed;
    border-radius: 50%;
    background: radial-gradient(closest-side, #0b0b0b 78%, rgb(11 11 11 / .6) 90%, rgb(11 11 11 / 0) 100%);
    transform: scale(0);
    transition: transform 1s cubic-bezier(.65, 0, .35, 1) .2s;   /* закрытие */
    will-change: transform;
  }
  .pw.is-open .pw-bubble { transform: scale(1); transition: transform 1s var(--ui-ease); }   /* раскрытие */
  .pw-confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
  /* Колонка не шире экрана: иначе сетка растягивается по сумме ширин всех слайдов и текст обрезается на телефоне */
  .pw-body { position: fixed; inset: 0; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; overflow-x: hidden; overflow-y: auto; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)); }
  .pw-panel { display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; max-width: 440px; text-align: center; }
  .pw-reveal { opacity: 0; transform: translateY(14px); transition: opacity .2s ease, transform .2s ease; }
  .pw.is-open .pw-reveal {
    opacity: 1;
    transform: none;
    transition: opacity .6s var(--ui-ease), transform .7s var(--ui-ease);
    transition-delay: calc(.55s + var(--d, 0) * .14s);
  }
  .pw-logo { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--ui-surface-3); color: var(--ui-fg-strong); }
  .pw-kicker { margin-top: 20px; color: var(--ui-muted); font-size: 14px; font-weight: 500; }
  .pw-title { margin-top: 6px; color: var(--ui-fg-strong); font-size: clamp(26px, 6vw, 34px); font-weight: 600; line-height: 1.15; letter-spacing: -.02em; text-wrap: balance; }
  .pw-plan { background: linear-gradient(90deg, #ffc2c2, #ffe6b3, #c4f5d0, #b8e2ff, #d6c9ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .pw-sub { margin-top: 10px; color: var(--ui-muted); font-size: 15px; line-height: 1.5; text-wrap: pretty; }
  /* Преимущества тарифа: просто текст без подложки, листается свайпом, стрелками и точками */
  .pw-slider { width: 100%; min-width: 0; margin-top: 20px; }
  .pw-track {
    display: flex;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-radius: var(--ui-radius-block);
    transition: background-color .2s;
  }
  .pw-track::-webkit-scrollbar { display: none; }
  .pw-track:focus-visible { outline: none; background: rgb(255 255 255 / .04); }
  .pw-slide { flex: 0 0 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 104px; padding: 12px 20px; scroll-snap-align: center; }
  .pw-slide-title { color: var(--ui-fg-strong); font-size: 18px; font-weight: 600; line-height: 1.3; text-wrap: balance; }
  .pw-slide-text { color: var(--ui-muted); font-size: 14px; line-height: 1.5; text-wrap: pretty; }
  .pw-nav { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; }
  .pw-nav .icon-btn:disabled { opacity: .3; pointer-events: none; }
  .pw-dots { display: flex; align-items: center; }
  .pw-dot { display: grid; place-items: center; width: 18px; height: 28px; }
  .pw-dot span { width: 6px; height: 6px; border-radius: 50%; background: var(--ui-fg-strong); opacity: .25; transition: opacity .3s var(--ui-ease), transform .3s var(--ui-ease); }
  .pw-dot:hover span { opacity: .5; }
  .pw-dot.is-active span { opacity: 1; transform: scale(1.25); }
  .pw-ok { width: 100%; margin-top: 24px; }
  /* Без анимаций (prefers-reduced-motion): пузырь сразу на весь экран, всё только проявляется */
  .pw.is-calm .pw-bubble { transform: none; opacity: 0; transition: opacity .2s ease; }
  .pw.is-calm.is-open .pw-bubble { opacity: 1; }
  .pw.is-calm .pw-reveal { transform: none; }

  .avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ui-surface-4);
    color: var(--ui-fg-strong);
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    text-transform: uppercase;
  }
  .avatar-lg { width: 48px; height: 48px; font-size: 18px; }
  .avatar-btn { display: inline-flex; align-items: center; gap: 6px; padding: 3px; border-radius: var(--ui-radius-btn); transition: background-color .2s; }
  .avatar-btn:hover, .avatar-btn:focus-visible, .avatar-btn.is-open { background: var(--ui-surface-3); }

  @media (min-width: 1024px) {
    .topbar-inner { height: 64px; }
    .topbar-nav { display: flex; }
  }

  /* Обычные страницы кабинета прокручиваются внутри app-main и стоят на той же сетке 1200px */
  .page-scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; }
  .page { padding: 28px 0 72px; animation: fade-in .35s ease both; }
  .page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
  .page-title { font-size: clamp(26px, 3vw, 32px); font-weight: 600; letter-spacing: -.03em; color: var(--ui-fg-strong); line-height: 1.2; }
  .page-subtitle { margin-top: 6px; color: var(--ui-muted); font-size: 15px; }

  .card { background: var(--ui-surface-1); border-radius: var(--ui-radius-block); padding: 24px; }
  .card-title { font-size: 17px; font-weight: 600; color: var(--ui-fg-strong); letter-spacing: -.01em; }
  .card-text { margin-top: 4px; color: var(--ui-muted); font-size: 14px; line-height: 1.55; }
  .card-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-3);
    color: var(--ui-fg);
    flex-shrink: 0;
  }
  @media (max-width: 639px) { .card { padding: 20px; border-radius: 22px; } }

  .setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; }
  .setting-row + .setting-row { margin-top: 2px; }
  .setting-row strong { display: block; font-size: 15px; font-weight: 500; color: var(--ui-fg); }
  .setting-row small { display: block; margin-top: 2px; font-size: 13px; color: var(--ui-muted); }
  @media (max-width: 639px) {
    .setting-row.stack-sm { flex-direction: column; align-items: stretch; }
    .setting-row.stack-sm .select-btn { width: 100%; }
  }

  .empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 64px 16px; color: var(--ui-muted); }
  .empty-state .card-icon { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 16px; }
  .empty-state strong { color: var(--ui-fg); font-size: 17px; font-weight: 600; }
  .empty-state p { margin-top: 6px; font-size: 14px; max-width: 360px; }

  .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-2);
    color: var(--ui-muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .2s, color .2s;
  }
  .chip:hover, .chip:focus-visible { background: var(--ui-surface-3); color: var(--ui-fg); }
  .chip[aria-pressed="true"], .chip.is-active { background: #fff; color: #000; }

  /* ================= Мобильная шторка (как в ChatGPT) ================= */
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgb(0 0 0 / .65);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s var(--ui-ease);
  }
  .drawer-backdrop.is-visible { opacity: 1; pointer-events: auto; }
  .drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 71;
    display: flex;
    flex-direction: column;
    width: 300px;
    max-width: calc(100vw - 48px);
    padding: 12px 12px max(12px, env(safe-area-inset-bottom));
    background: var(--ui-surface-1);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .4s var(--ui-ease), visibility 0s .4s;
  }
  .drawer.is-open { transform: translateX(0); visibility: visible; transition: transform .4s var(--ui-ease), visibility 0s; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 44px; padding-left: 6px; margin-bottom: 12px; }
  .drawer-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
  .drawer-nav .nav-link { height: 42px; font-size: 15px; }
  .drawer-nav .nav-link svg.lucide { width: 18px; height: 18px; }
  .drawer-label { margin: 20px 12px 6px; font-size: 12px; font-weight: 500; color: var(--ui-subtle); }
  .drawer-chats { flex: 1; min-height: 60px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
  .drawer-foot { display: flex; align-items: center; gap: 4px; padding-top: 10px; }
  .user-card { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 8px; border-radius: 16px; transition: background-color .2s; }
  .user-card:hover, .user-card:focus-visible { background: var(--ui-surface-3); }
  .user-card strong { display: block; font-size: 14px; font-weight: 500; color: var(--ui-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-card small { display: block; font-size: 12px; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--ui-radius-sm);
    color: #bdbdbd;
    font-size: 14px;
    transition: background-color .15s, color .15s;
  }
  .recent-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .recent-item svg.lucide { width: 16px; height: 16px; color: var(--ui-subtle); }
  .recent-item:hover, .recent-item:focus-visible { background: var(--ui-surface-3); color: var(--ui-fg); }
  .recent-item.is-active { background: var(--ui-surface-4); color: var(--ui-fg-strong); }
  .empty-note { padding: 10px 12px; font-size: 13px; line-height: 1.6; color: var(--ui-subtle); }

  /* ================= Поповеры (меню в body, позиция fixed) ================= */
  .popover {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 80;
    min-width: 220px;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 6px;
    border-radius: 20px;
    background: var(--ui-surface-3);
    will-change: opacity, transform;
  }
  .popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: var(--ui-radius-btn);
    color: var(--ui-fg);
    font-size: 14px;
    text-align: left;
    transition: background-color .15s;
  }
  .popover-item:hover, .popover-item:focus-visible { background: var(--ui-surface-4); outline: none; }
  .popover-item > svg.lucide { width: 17px; height: 17px; color: var(--ui-muted); }
  .popover-item-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
  .popover-item-text strong { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .popover-item-text small { margin-top: 1px; font-size: 12px; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .popover-item > svg.lucide.popover-check { width: 16px; height: 16px; margin-left: auto; color: var(--ui-fg); visibility: hidden; }
  .popover-item[aria-checked="true"] > svg.lucide.popover-check { visibility: visible; }
  .popover-item.is-danger { color: #fca5a5; }
  .popover-item.is-danger > svg.lucide { color: #fca5a5; }
  .popover-label { padding: 8px 10px 4px; font-size: 12px; font-weight: 500; color: var(--ui-subtle); }
  .popover-gap { height: 6px; }
  .popover-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; }
  .popover-head strong { display: block; font-size: 14px; font-weight: 600; color: var(--ui-fg-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .popover-head small { display: block; font-size: 12px; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .model-menu { width: 340px; padding: 6px; }
  .model-tabs { display: flex; gap: 3px; padding: 3px; margin-bottom: 6px; border-radius: 16px; background: var(--ui-surface-2); }
  .model-tab {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    height: 30px;
    padding: 0 8px;
    border-radius: var(--ui-radius-sm);
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .15s, color .15s;
  }
  .model-tab span { overflow: hidden; text-overflow: ellipsis; }
  .model-tab svg.lucide { width: 13px; height: 13px; }
  .model-tab:hover, .model-tab:focus-visible { color: var(--ui-fg); background: var(--ui-surface-3); }
  .model-tab[aria-pressed="true"] { color: var(--ui-fg-strong); background: var(--ui-surface-5); }
  .model-list { max-height: min(360px, 48dvh); overflow-y: auto; }

  .params-menu { width: 320px; padding: 10px; }
  .params-group + .params-group { margin-top: 10px; }
  .params-label { display: flex; align-items: center; gap: 7px; padding: 4px 4px 8px; font-size: 12px; font-weight: 500; color: var(--ui-muted); }
  .params-label svg.lucide { width: 14px; height: 14px; }
  .segmented { display: flex; flex-wrap: wrap; gap: 4px; }
  .segment {
    height: 32px;
    padding: 0 12px;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-4);
    color: #bdbdbd;
    font-size: 13px;
    font-weight: 500;
    transition: background-color .15s, color .15s;
  }
  .segment:hover, .segment:focus-visible { background: var(--ui-surface-5); color: var(--ui-fg); outline: none; }
  .segment[aria-checked="true"] { background: #fff; color: #000; }
  .segment:disabled { opacity: .3; cursor: not-allowed; }
  .segment:disabled:hover { background: var(--ui-surface-4); color: #bdbdbd; }

  /* Переключатель в меню параметров (веб-поиск, звук): вся строка — кнопка */
  .params-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 6px 4px 6px 0;
    border-radius: var(--ui-radius-sm);
    text-align: left;
  }
  .params-group + .params-toggle, .params-toggle + .params-toggle, .params-toggle + .params-group, .params-note + .params-group, .params-group + .params-note, .params-toggle + .params-note, .params-note + .params-toggle { margin-top: 8px; }
  .params-toggle .params-label { padding: 0 4px; color: var(--ui-fg); font-size: 13px; }
  .params-toggle:focus-visible { background: var(--ui-surface-4); outline: none; }
  .params-toggle[aria-checked="true"] .switch { background: #fff; }
  .params-toggle[aria-checked="true"] .switch::after { transform: translateX(18px); background: #000; transform-origin: right center; }
  .params-note { display: flex; gap: 8px; padding: 6px 4px; color: var(--ui-muted); font-size: 12px; line-height: 1.5; }
  .params-note svg.lucide { width: 14px; height: 14px; margin-top: 2px; }
  .params-value { margin-left: auto; color: var(--ui-fg-strong); font-size: 13px; font-weight: 600; }
  .params-scale { display: flex; justify-content: space-between; padding: 2px 2px 0; color: var(--ui-subtle); font-size: 11px; }

  /* Ползунок (длительность видео): заполненная часть — через --fill */
  .range { display: block; width: 100%; height: 26px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
  .range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, #fff var(--fill, 0%), var(--ui-surface-5) var(--fill, 0%)); }
  .range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; transition: transform .15s var(--ui-ease); }
  .range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--ui-surface-5); }
  .range::-moz-range-progress { height: 4px; border-radius: 4px; background: #fff; }
  .range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; }
  .range:active::-webkit-slider-thumb { transform: scale(1.12); }
  .range:focus-visible { outline: none; }
  .range:focus-visible::-webkit-slider-thumb { background: #e2e2e2; }

  /* ================= Модалки ================= */
  /*
   * Анимация как у модалок Tailwind UI: scale + fade.
   * Открытие (.is-open): scale(.95) → 1 и прозрачность, 300 мс ease-out.
   * Закрытие: обратно в scale(.95), 200 мс ease-in (--ui-ease-in). Длительность закрытия
   * совпадает с LEAVE_MS в core/modal.js. Во время закрытия окно уже не ловит клики.
   */
  .modal-root { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; }
  .modal-root:not(.is-open) { pointer-events: none; }
  .modal-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / .72); opacity: 0; transition: opacity .2s var(--ui-ease-in); }
  .modal-panel {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 28px;
    border-radius: var(--ui-radius-panel);
    background: var(--ui-surface-2);
    outline: none;
    opacity: 0;
    transform: scale(.95);
    transition: opacity .2s var(--ui-ease-in), transform .2s var(--ui-ease-in);
  }
  .modal-root.is-open .modal-backdrop { opacity: 1; transition: opacity .3s var(--ui-ease); }
  .modal-root.is-open .modal-panel { opacity: 1; transform: scale(1); transition: opacity .3s var(--ui-ease), transform .3s var(--ui-ease); }
  .modal-sm { max-width: 400px; }
  .modal-lg { max-width: 560px; }
  .modal-close { position: absolute; top: 14px; right: 14px; }
  .modal-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px; border-radius: 16px; background: var(--ui-surface-4); color: var(--ui-fg-strong); }
  .modal-icon svg.lucide { width: 22px; height: 22px; }
  .modal-title { font-size: 20px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; color: var(--ui-fg-strong); }
  .modal-text { margin-top: 8px; color: var(--ui-muted); font-size: 15px; line-height: 1.6; }
  .modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
  .modal-actions .btn { flex: 1 1 auto; }

  /* Анимированные стикеры (core/sticker.js): пока Lottie не загрузился, виден эмодзи-заглушка */
  .sticker { position: relative; display: grid; place-items: center; width: 96px; height: 96px; }
  .sticker > svg { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
  .sticker-fallback { font-size: 64px; line-height: 1; transition: opacity .2s ease; }
  .sticker.is-loaded .sticker-fallback { opacity: 0; }

  /* Окно «Тариф не подключён» (core/session.js → openPaywall) */
  .paywall { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 4px; }
  .paywall-sticker { width: 112px; height: 112px; margin-bottom: 14px; animation: paywall-sticker-in .6s var(--ui-ease) .08s both; }
  .paywall .modal-text { max-width: 320px; text-wrap: pretty; }
  .paywall .modal-actions { width: 100%; flex-direction: column; }
  .paywall-note { margin-top: 14px; color: var(--ui-subtle); font-size: 13px; }
  @media (max-width: 639px) {
    .modal-root { place-items: end center; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
    /* Окно прижато к низу экрана, поэтому масштабируется от нижнего края */
    .modal-panel { padding: 24px 20px; border-radius: 26px; transform-origin: 50% 100%; }
  }

  .progress { height: 4px; border-radius: 4px; background: var(--ui-surface-4); overflow: hidden; }
  .progress > span { display: block; height: 100%; border-radius: inherit; background: #fff; transition: width .4s var(--ui-ease); }
  .choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 16px;
    background: var(--ui-surface-3);
    color: var(--ui-fg);
    font-size: 15px;
    text-align: left;
    transition: background-color .15s, color .15s;
  }
  .choice:hover, .choice:focus-visible { background: var(--ui-surface-4); }
  .choice svg.lucide { width: 16px; height: 16px; visibility: hidden; }
  .choice[aria-pressed="true"] { background: #fff; color: #000; }
  .choice[aria-pressed="true"] svg.lucide { visibility: visible; }
  .step-in { animation: step-in .35s var(--ui-ease) both; }

  /* ================= Тост ================= */
  .toast {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 12px 16px;
    border-radius: 16px;
    background: var(--ui-surface-4);
    color: var(--ui-fg);
    font-size: 14px;
    opacity: 0;
    transform: translate(-50%, 10px);
    pointer-events: none;
    transition: opacity .2s ease, transform .3s var(--ui-ease);
  }
  .toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
  .toast svg.lucide { width: 17px; height: 17px; color: var(--ui-muted); }

  /* ================= Иконки моделей ================= */
  .model-icon {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ui-surface-4);
    color: var(--ui-fg-strong);
    flex-shrink: 0;
    overflow: hidden;
  }
  .model-icon img { width: 56%; height: 56%; object-fit: contain; filter: brightness(0) invert(1); }
  .model-icon img + svg { display: none; }
  .model-icon svg.lucide { width: 55%; height: 55%; }
  .model-icon-xs { width: 22px; height: 22px; }
  .model-icon-sm { width: 28px; height: 28px; }
  .model-icon-lg { width: 44px; height: 44px; }

  /* ================= Чат ================= */
  .chat-view { position: absolute; inset: 0; display: flex; flex-direction: column; --composer-height: 180px; }
  .chat-view:not(.chat-active) { overflow-y: auto; }
  .chat-stage { position: relative; width: min(780px, calc(100% - 32px)); margin: auto; padding-bottom: 56px; flex-shrink: 0; }
  .welcome { margin-bottom: 28px; text-align: center; animation: fade-in .35s ease both; }
  .welcome-title { font-size: clamp(26px, 3.4vw, 36px); font-weight: 500; letter-spacing: -.035em; line-height: 1.2; color: var(--ui-fg-strong); }
  .welcome-text { margin-top: 10px; font-size: 15px; color: var(--ui-muted); }

  .composer-wrap { position: relative; z-index: 3; }
  .composer {
    padding: 16px 12px 10px;
    border-radius: var(--ui-radius-panel);
    background: var(--ui-surface-2);
    overflow: hidden;
    transition: background-color .25s;
  }
  .composer:focus-within { background: #1a1a1a; }
  .composer textarea {
    display: block;
    width: 100%;
    height: 48px;
    min-height: 48px;
    max-height: 220px;
    padding: 2px 10px 14px;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--ui-fg);
    font-size: 16px;
    line-height: 24px;
    overflow-y: hidden;
    transition: height .28s var(--ui-ease);
  }
  .composer textarea::placeholder { color: var(--ui-subtle); }
  .composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .composer-tools { display: flex; align-items: center; gap: 4px; min-width: 0; }
  .composer-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--ui-radius-btn);
    color: var(--ui-muted);
    flex-shrink: 0;
    transition: background-color .2s, color .2s;
  }
  .composer-icon:hover, .composer-icon:focus-visible { background: var(--ui-surface-4); color: var(--ui-fg); }
  .composer-icon svg.lucide { width: 20px; height: 20px; }
  .composer-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    min-width: 0;
    max-width: 230px;
    padding: 0 10px 0 7px;
    border-radius: var(--ui-radius-btn);
    color: #cfcfcf;
    font-size: 13px;
    font-weight: 500;
    transition: background-color .2s, color .2s;
  }
  .composer-chip:hover, .composer-chip:focus-visible, .composer-chip.is-open { background: var(--ui-surface-4); color: var(--ui-fg-strong); }
  .composer-chip > svg.lucide { width: 17px; height: 17px; color: var(--ui-muted); }
  .composer-chip > svg.lucide.chip-chevron { width: 14px; height: 14px; color: var(--ui-subtle); transition: transform .2s var(--ui-ease); }
  .composer-chip.is-open > svg.lucide.chip-chevron { transform: rotate(180deg); }
  .chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .composer-params { padding-left: 10px; }

  .send-button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    color: #000;
    flex-shrink: 0;
    transition: background-color .2s, color .2s;
  }
  .send-button:hover:not(:disabled), .send-button:focus-visible { background: #e2e2e2; }
  .send-button:disabled { background: var(--ui-surface-4); color: var(--ui-subtle); }
  .send-button svg.lucide { width: 19px; height: 19px; stroke-width: 2.2; }
  .send-button.is-generating svg.lucide { width: 13px; height: 13px; fill: currentColor; }

  .composer-caption { margin-top: 10px; text-align: center; font-size: 12px; color: var(--ui-subtle); line-height: 1.5; }
  .suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
  .suggestion {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-1);
    color: var(--ui-muted);
    font-size: 13px;
    font-weight: 500;
    transition: background-color .2s, color .2s;
  }
  .suggestion:hover, .suggestion:focus-visible { background: var(--ui-surface-3); color: var(--ui-fg); }
  .suggestion svg.lucide { width: 16px; height: 16px; }

  /* Вложения: анимируется высота обёртки, а не самого списка */
  .attachment-shell { height: 0; overflow: hidden; transition: height .4s var(--ui-ease); }
  .attachments { display: flex; gap: 10px; padding: 4px 6px 14px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .attachments::-webkit-scrollbar { display: none; }
  .attachment {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 76px;
    height: 76px;
    border-radius: 18px;
    background: var(--ui-surface-4);
    flex-shrink: 0;
  }
  .attachment img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
  .attachment > svg.lucide { width: 24px; height: 24px; color: var(--ui-muted); }
  .attachment-name { width: 100%; padding: 0 6px; font-size: 10px; text-align: center; color: var(--ui-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .attachment-file-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 6px 6px;
    border-radius: 0 0 18px 18px;
    background: linear-gradient(transparent, rgb(0 0 0 / .75));
    color: #fff;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .attachment.is-readonly { width: 96px; height: 96px; }
  .remove-file {
    position: absolute;
    top: -4px;
    right: -4px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    color: #000;
  }
  .remove-file svg.lucide { width: 12px; height: 12px; stroke-width: 2.6; }

  /* Переписка прокручивается под формой ввода */
  .chat-active .welcome, .chat-active .suggestions { display: none; }
  .chat-active .chat-stage { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; margin: 0 auto; padding: 8px 0 max(14px, env(safe-area-inset-bottom)); }
  .chat-active .composer-caption { margin-top: 8px; }
  .conversation { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px 16px 30px; scrollbar-gutter: stable both-edges; outline: none; }
  .chat-active .conversation { padding-bottom: calc(var(--composer-height) + 24px); }
  .messages { max-width: 740px; margin: 0 auto; }
  .composer-fade { display: none; }
  .chat-active .composer-fade {
    display: block;
    position: absolute;
    inset: auto 0 0;
    z-index: 1;
    height: calc(var(--composer-height) + 40px);
    pointer-events: none;
    background: linear-gradient(to bottom, rgb(0 0 0 / 0), rgb(0 0 0 / .85) 45%, #000 80%);
  }
  .scroll-bottom {
    position: absolute;
    left: 50%;
    bottom: calc(var(--composer-height) + 12px);
    z-index: 4;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-left: -19px;
    border-radius: 50%;
    background: var(--ui-surface-4);
    color: var(--ui-fg);
    animation: fade-in .2s ease;
    transition: background-color .2s;
  }
  .scroll-bottom:hover, .scroll-bottom:focus-visible { background: var(--ui-surface-5); }

  .message { margin-bottom: 32px; animation: message-in .6s var(--ui-ease) both; overflow-wrap: anywhere; }
  .user-message { display: flex; justify-content: flex-end; }
  .user-payload { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; max-width: 85%; min-width: 0; }
  .user-bubble { padding: 12px 18px; border-radius: var(--ui-radius-block); background: var(--ui-surface-3); color: var(--ui-fg); font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
  .message-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  .assistant-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; font-weight: 500; color: var(--ui-fg); }
  .assistant-content { padding-left: 38px; color: #d6d6d6; font-size: 15px; line-height: 1.75; }
  .message-actions { display: flex; gap: 2px; margin-top: 8px; padding-left: 32px; }
  .message-action {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--ui-radius-sm);
    color: var(--ui-subtle);
    transition: background-color .2s, color .2s;
  }
  .message-action:hover, .message-action:focus-visible { background: var(--ui-surface-3); color: var(--ui-fg); }
  .message-action svg.lucide { width: 16px; height: 16px; }
  .message-note { margin-top: 10px; font-size: 13px; color: var(--ui-subtle); }

  .thinking { display: flex; align-items: center; gap: 12px; padding: 6px 0; color: var(--ui-muted); font-size: 14px; }
  .thinking-dots { display: flex; gap: 4px; }
  .thinking-dots span { width: 5px; height: 5px; border-radius: 50%; background: #cfcfcf; animation: pulse 1.2s infinite; }
  .thinking-dots span:nth-child(2) { animation-delay: .15s; }
  .thinking-dots span:nth-child(3) { animation-delay: .3s; }
  .thinking-label { animation: fade-in .3s ease; }

  .media-card {
    position: relative;
    width: min(100%, calc(440px * var(--ratio, 1)));
    aspect-ratio: var(--ratio, 1);
    margin: 4px 0 0;
    border-radius: 22px;
    background-color: var(--ui-surface-2);
    background-image: radial-gradient(rgb(255 255 255 / .05) 1px, transparent 1px);
    background-size: 18px 18px;
    overflow: hidden;
    animation: media-in .7s var(--ui-ease) both;
  }
  /* Готовый результат: файл-образец из assets/media, без файла видна подсказка .media-missing */
  .media-card > img, .media-card > video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; background: var(--ui-surface-2); }
  .media-missing { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; color: var(--ui-muted); font-size: 13px; }
  .media-missing svg.lucide { width: 24px; height: 24px; color: var(--ui-fg); }
  .media-card.is-missing > img, .media-card.is-missing > video { visibility: hidden; }
  .media-card.is-missing .media-missing { display: flex; }

  /* Идёт генерация (как в newsite): на карточке только градиент core/flow.js. is-done гасит его перед заменой на результат */
  .media-flow { position: absolute; inset: 0; display: block; width: 100%; height: 100%; opacity: 0; transition: opacity .9s var(--ui-ease); }
  .media-flow.is-ready { opacity: 1; }
  .media-card.is-done .media-flow { opacity: 0; transition-duration: .35s; }
  .media-card.is-swapped { animation: none; }
  .media-card.is-swapped > img, .media-card.is-swapped > video, .media-card.is-swapped .media-missing { animation: fade-in .45s ease both; }

  .drop-overlay {
    position: fixed;
    inset: 12px;
    z-index: 85;
    display: grid;
    place-items: center;
    border-radius: var(--ui-radius-panel);
    background: rgb(15 15 15 / .96);
    text-align: center;
    pointer-events: none;
    animation: fade-in .2s ease;
  }
  .drop-overlay svg.lucide { width: 44px; height: 44px; margin: 0 auto 20px; color: var(--ui-fg); }
  .drop-overlay h2 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; color: var(--ui-fg-strong); }
  .drop-overlay p { margin-top: 6px; font-size: 14px; color: var(--ui-muted); }

  @media (max-width: 639px) {
    .chat-stage { width: calc(100% - 24px); padding-bottom: 28px; }
    .composer { padding: 14px 10px 8px; border-radius: 26px; }
    .composer-chip { max-width: 150px; }
    .chip-summary { display: none; }
    .composer-params { padding: 0; width: 36px; justify-content: center; }
    .composer-caption { font-size: 11px; }
    .conversation { padding: 16px 12px 20px; }
    .assistant-content { padding-left: 0; }
    .message-actions { padding-left: 0; margin-left: -6px; }
    .user-payload { max-width: 92%; }
    .message { margin-bottom: 26px; }
    .suggestions { gap: 6px; }
  }
  @media (max-height: 560px) {
    .chat-active .composer-caption { display: none; }
    .welcome { margin-bottom: 16px; }
  }

  /* ================= Markdown в ответах ================= */
  .markdown > :first-child { margin-top: 0; }
  .markdown > :last-child { margin-bottom: 0; }
  .markdown p { margin: 0 0 14px; }
  .markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 24px 0 10px; color: var(--ui-fg-strong); font-weight: 600; letter-spacing: -.01em; line-height: 1.35; }
  .markdown h1 { font-size: 22px; }
  .markdown h2 { font-size: 19px; }
  .markdown h3 { font-size: 17px; }
  .markdown h4 { font-size: 15px; }
  .markdown strong { color: var(--ui-fg-strong); font-weight: 600; }
  .markdown a { color: var(--ui-fg-strong); text-decoration: underline; text-decoration-color: #555; text-underline-offset: 3px; }
  .markdown ul, .markdown ol { margin: 0 0 14px; padding-left: 22px; }
  .markdown ul { list-style: disc; }
  .markdown ol { list-style: decimal; }
  .markdown li { margin: 4px 0; padding-left: 2px; }
  .markdown li::marker { color: var(--ui-subtle); }
  .markdown blockquote { margin: 0 0 14px; padding: 12px 16px; border-radius: 16px; background: var(--ui-surface-1); color: var(--ui-muted); }
  .markdown blockquote p:last-child { margin-bottom: 0; }
  .markdown hr { height: 1px; margin: 20px 0; border: 0; background: var(--ui-surface-3); }
  .markdown :not(pre) > code { padding: 2px 6px; border-radius: 6px; background: var(--ui-surface-3); color: #e5e5e5; font-family: var(--ui-font-mono); font-size: .88em; }

  .code-block { margin: 16px 0; border-radius: 18px; background: var(--ui-surface-1); overflow: hidden; }
  .code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 16px; background: var(--ui-surface-2); color: var(--ui-muted); font-size: 12px; font-family: var(--ui-font-mono); }
  .code-copy { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--ui-radius-xs); color: var(--ui-muted); font-family: var(--ui-font); font-size: 12px; transition: background-color .2s, color .2s; }
  .code-copy:hover, .code-copy:focus-visible { background: var(--ui-surface-4); color: var(--ui-fg); }
  .code-copy svg.lucide { width: 14px; height: 14px; }
  .code-block pre { margin: 0; padding: 16px; overflow-x: auto; }
  .code-block code { font-family: var(--ui-font-mono); font-size: 13px; line-height: 1.65; color: #e5e5e5; white-space: pre; }

  .table-wrap { margin: 0 0 14px; overflow-x: auto; border-radius: 16px; background: var(--ui-surface-1); }
  .table-wrap table, .data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .table-wrap th, .table-wrap td, .data-table th, .data-table td { padding: 10px 14px; text-align: left; vertical-align: top; }
  .table-wrap th, .data-table th { color: var(--ui-muted); font-weight: 500; font-size: 13px; background: var(--ui-surface-2); white-space: nowrap; }
  .table-wrap tr:nth-child(even) td, .data-table tr:nth-child(even) td { background: rgb(255 255 255 / .02); }

  /* ================= Лендинг ================= */
  .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s var(--ui-ease), transform .8s var(--ui-ease); }
  .reveal.is-visible { opacity: 1; transform: none; }
  .hero-title { font-size: clamp(40px, 7vw, 76px); font-weight: 600; letter-spacing: -.045em; line-height: 1.02; color: var(--ui-fg-strong); }
  .section-title { font-size: clamp(30px, 4.2vw, 48px); font-weight: 600; letter-spacing: -.04em; line-height: 1.08; color: var(--ui-fg-strong); }
  .section-text { margin-top: 14px; font-size: 17px; line-height: 1.6; color: var(--ui-muted); }
  .eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ui-muted); }

  .marquee { overflow: hidden; -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); }
  /* Два ряда: первый едет влево, второй (is-reverse) вправо; медленно, пауза при наведении */
  .marquee-track { display: flex; gap: 12px; width: max-content; padding-right: 12px; animation: marquee 110s linear infinite; }
  .marquee-track.is-reverse { animation-direction: reverse; animation-duration: 120s; }
  .marquee:hover .marquee-track { animation-play-state: paused; }
  .marquee-item { display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 20px 0 12px; border-radius: 20px; background: var(--ui-surface-1); color: var(--ui-fg); font-size: 14px; font-weight: 500; white-space: nowrap; }

  .model-card { display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: 22px; background: var(--ui-surface-1); transition: background-color .2s; }
  .model-card:hover { background: var(--ui-surface-2); }
  .feature-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 28px; border-radius: var(--ui-radius-panel); background: var(--ui-surface-1); overflow: hidden; }
  .feature-card h3 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; color: var(--ui-fg-strong); }
  .feature-card p { font-size: 15px; line-height: 1.6; color: var(--ui-muted); }

  .price-card { display: flex; flex-direction: column; gap: 20px; padding: 28px; border-radius: var(--ui-radius-panel); background: var(--ui-surface-1); }
  .price-card.is-featured { background: var(--ui-surface-2); }
  .price-list { display: flex; flex-direction: column; gap: 10px; font-size: 15px; color: #cfcfcf; }
  .price-list li { display: flex; align-items: center; gap: 10px; }
  .price-list svg.lucide { width: 17px; height: 17px; color: var(--ui-fg-strong); }

  /* ================= Документация API ================= */
  .docs-nav-link { display: block; padding: 7px 12px; border-radius: var(--ui-radius-sm); color: var(--ui-muted); font-size: 14px; transition: background-color .15s, color .15s; }
  .docs-nav-link:hover, .docs-nav-link:focus-visible { color: var(--ui-fg); background: var(--ui-surface-2); }
  .docs-nav-link.is-active { color: var(--ui-fg-strong); background: var(--ui-surface-3); }
  .docs-section { scroll-margin-top: 84px; padding-top: 12px; }
  .docs-section + .docs-section { margin-top: 56px; }
  .docs-h2 { font-size: 26px; font-weight: 600; letter-spacing: -.03em; color: var(--ui-fg-strong); }
  .docs-section .docs-p, .docs-section .docs-list { max-width: 780px; }
  .docs-h3 { margin-top: 28px; font-size: 17px; font-weight: 600; color: var(--ui-fg-strong); }
  .docs-p { margin-top: 12px; font-size: 15px; line-height: 1.7; color: #bdbdbd; }
  .docs-p code, .data-table code, .docs-list code { padding: 2px 6px; border-radius: 6px; background: var(--ui-surface-3); color: #e5e5e5; font-family: var(--ui-font-mono); font-size: .86em; white-space: nowrap; }
  .docs-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; padding-left: 20px; list-style: decimal; color: #bdbdbd; font-size: 15px; line-height: 1.6; }

  /* Документы (/terms, /privacy): вкладки и текст */
  .legal-tab { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: var(--ui-radius-sm); color: var(--ui-muted); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background-color .2s, color .2s; }
  .legal-tab:hover, .legal-tab:focus-visible { background: var(--ui-surface-3); color: var(--ui-fg); outline: none; }
  .legal-tab.is-active { background: #fff; color: #000; }
  @media (max-width: 419px) { .legal-tab svg.lucide { display: none; } }
  .legal-doc { margin-top: 28px; }
  .legal-doc h2 { margin-top: 36px; font-size: 19px; font-weight: 600; letter-spacing: -.02em; color: var(--ui-fg-strong); }
  .legal-doc p, .legal-doc li { font-size: 15px; line-height: 1.7; color: #bdbdbd; }
  .legal-doc p { margin-top: 12px; }
  .legal-doc .legal-intro { margin-top: 0; font-size: 17px; line-height: 1.6; color: var(--ui-fg); }
  .legal-doc ul { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; padding-left: 20px; list-style: disc; }
  .legal-doc li::marker { color: var(--ui-subtle); }

  .endpoint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding: 12px 14px; border-radius: 16px; background: var(--ui-surface-1); font-family: var(--ui-font-mono); font-size: 14px; color: var(--ui-fg); }
  .method { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 8px; font-family: var(--ui-font); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
  .method-post { background: #fff; color: #000; }
  .method-get { background: var(--ui-surface-4); color: var(--ui-fg); }
  .callout { display: flex; gap: 12px; margin-top: 20px; padding: 16px 18px; border-radius: 18px; background: var(--ui-surface-2); color: #cfcfcf; font-size: 14px; line-height: 1.6; }
  .callout svg.lucide { width: 18px; height: 18px; margin-top: 2px; color: var(--ui-fg-strong); }
  .code-tabs { display: flex; gap: 2px; }
  .code-tab { height: 28px; padding: 0 10px; border-radius: var(--ui-radius-xs); color: var(--ui-muted); font-family: var(--ui-font); font-size: 12px; font-weight: 500; transition: background-color .15s, color .15s; }
  .code-tab:hover { color: var(--ui-fg); }
  .code-tab.active { background: var(--ui-surface-4); color: var(--ui-fg-strong); }

  /* ================= Скелетон при переходе между разделами ================= */
  .skeleton {
    display: block;
    max-width: 100%;
    border-radius: var(--ui-radius-sm);
    background: linear-gradient(90deg, var(--ui-surface-1) 0%, var(--ui-surface-3) 45%, var(--ui-surface-1) 90%);
    background-size: 220% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
  }
  .sk-card .skeleton { background-image: linear-gradient(90deg, var(--ui-surface-2) 0%, var(--ui-surface-4) 45%, var(--ui-surface-2) 90%); }
  .skeleton-screen { animation: fade-in .18s ease both; pointer-events: none; }
  .view-enter { animation: fade-in .35s ease both; }
  .sk-stack { display: flex; flex-direction: column; gap: 10px; }
  .sk-row { display: flex; align-items: center; gap: 12px; }
  .sk-row > .skeleton { flex-shrink: 0; }
  .sk-center { align-items: center; text-align: center; }
  .sk-grid { display: grid; gap: 12px; }
  .sk-card { display: flex; flex-direction: column; gap: 12px; padding: 24px; border-radius: var(--ui-radius-block); background: var(--ui-surface-1); }
  @media (min-width: 640px) { .sk-grid-3 { grid-template-columns: repeat(2, 1fr); } }
  /* Тарифы: как planGridClass() в views/pricing.js */
  @media (min-width: 768px) { .sk-grid-4 { grid-template-columns: repeat(2, 1fr); } }
  @media (min-width: 1280px) { .sk-grid-4 { grid-template-columns: repeat(4, 1fr); } }
  @media (min-width: 1024px) {
    .sk-grid-2 { grid-template-columns: repeat(2, 1fr); }
    .sk-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .sk-grid-aside { grid-template-columns: 360px minmax(0, 1fr); }
    .sk-grid-docs { grid-template-columns: 220px minmax(0, 1fr); }
  }
  .sk-hide-mobile { display: none; }
  @media (min-width: 1024px) { .sk-hide-mobile { display: flex; } }

  /* config.php → blur: 'on': название и домен размыты (core/blur.js). В em, чтобы крупные заголовки тоже не читались */
  .brand-blur { filter: blur(.32em); }
  .noscript { position: fixed; left: 16px; bottom: 16px; z-index: 100; padding: 14px 18px; border-radius: 16px; background: var(--ui-surface-3); color: var(--ui-fg); }

  /* ================= Переключатель языка (layouts.js: подвал, вход и регистрация, шторка, меню профиля) ================= */
  .lang-flag { display: block; flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
  .lang-btn { gap: 6px; }
  .lang-btn svg.lucide.lang-chevron { width: 14px; height: 14px; opacity: .7; transition: transform .2s cubic-bezier(.22,1,.36,1); }
  .lang-btn.is-open svg.lucide.lang-chevron { transform: rotate(180deg); }
  .icon-btn > .lang-flag, .popover-item > .lang-flag { width: 18px; height: 18px; }
  .popover-item > svg.lucide.lang-chevron { width: 16px; height: 16px; color: var(--ui-subtle); }
}

/* ================= Анимации ================= */
@keyframes message-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes media-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes step-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes step-back { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes logo-stub-pulse { 0% { transform: none; } 45% { transform: translateX(7px); } 100% { transform: none; } }
@keyframes logo-bar-pulse { 0% { transform: none; } 45% { transform: scaleX(.88); } 100% { transform: none; } }
@keyframes logo-bar-in { from { opacity: 0; transform: scaleX(0); } to { opacity: 1; transform: none; } }
@keyframes logo-stub-in { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes logo-idle { 0%, 72% { transform: rotate(0deg); } 88%, 100% { transform: rotate(180deg); } }
@keyframes paywall-sticker-in { from { opacity: 0; transform: scale(.6) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes plan-rainbow { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes skeleton-shimmer { from { background-position: 100% 0; } to { background-position: -120% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .marquee-track { animation: none; }
}
