/*
 * Общие стили проекта: дизайн-система перенесена из useai.
 * Чёрный фон, белые основные кнопки, серые поверхности, без теней, обводок и свечений.
 * Цвет есть только у статусов: зелёный (пополнения, «Успешно») и красный (ошибки, «Отклонено»).
 * Компоненты кошелька (карты, операции, сервисы) лежат в wallet.css.
 * Кнопки и поля — 14px, мелкие контролы — 12px, блоки — 28–32px, кнопка отправки — круглая.
 * Сетка десктопа — 1200px (--ui-container).
 *
 * Порядок слоёв совпадает с Tailwind v4: утилиты Tailwind перекрывают компоненты ниже.
 */
@layer theme, base, components, utilities;

:root {
  color-scheme: dark;
  --ui-font: "Golos Text", 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-success: #4ade80;

  --ui-radius-xs: 10px;     /* маленькие кнопки 28px: копировать, вкладки кода */
  --ui-radius-sm: 11px;     /* контролы 32–36px: пункты меню, чипы, сегменты */
  --ui-radius-btn: 14px;    /* кнопки 38–48px и поля ввода */
  --ui-radius-block: 28px;  /* карточки и блоки */
  --ui-radius-panel: 32px;  /* модалки, крупные секции */
  --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-color: #000; -webkit-text-size-adjust: 100%; }
  /* Без зума двойным касанием: прокрутка и жесты остаются, но Safari не увеличивает страницу при быстром втором нажатии */
  *, *::before, *::after { touch-action: manipulation; }
  body {
    margin: 0;
    min-height: 100dvh;
    background: var(--ui-bg);
    color: var(--ui-fg);
    font-family: var(--ui-font);
    font-size: 14px;
    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; }
  /* Иконки из спрайта (core/dom.js → icon): линия Solar — 1.5 на сетке 24px */
  .icon { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.5; }
  * { 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: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--ui-radius-btn);
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
    transition: background-color .2s, color .2s, opacity .2s;
  }
  .btn .icon { width: 16px; height: 16px; }
  .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: 30px; padding: 0 10px; font-size: 12px; border-radius: var(--ui-radius-sm); }
  .btn-lg { height: 42px; padding: 0 20px; font-size: 14px; border-radius: 16px; }

  .icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: var(--ui-radius-sm);
    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 .icon { width: 18px; height: 18px; }

  .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 .icon { width: 12px; height: 12px; }
  .badge-light { background: #fff; color: #000; }

  /* ================= Формы ================= */
  .field-label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 500; color: var(--ui-muted); }
  .field {
    display: block;
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-3);
    color: var(--ui-fg);
    font-size: 14px;
    outline: none;
    transition: background-color .2s;
  }
  /* Подсказка гаснет, пока поле в фокусе, и возвращается, если фокус ушёл с пустого поля */
  .field::placeholder { color: var(--ui-subtle); transition: color .25s var(--ui-ease); }
  .field:focus::placeholder { color: transparent; }
  .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: 5px; font-size: 12px; color: #fca5a5; }
  .field-wrap { position: relative; }
  .field-wrap .field { padding-right: 44px; }
  .field-wrap .icon-btn { position: absolute; top: 50%; right: 5px; translate: 0 -50%; }
  /* iOS не увеличивает страницу при фокусе, только если шрифт поля не меньше 16px */
  @media (pointer: coarse) { .field { font-size: 16px; } }

  /*
   * Подпись внутри поля: видна, пока поле пустое и не в фокусе. В фокусе плавно гаснет и остаётся скрытой,
   * пока в поле есть текст; если фокус ушёл с пустого поля — плавно возвращается. Наверх не уезжает.
   * Разметка: <div class="float-field"><input class="field" placeholder=" "><label>Подпись</label></div>
   * (placeholder из пробела нужен, чтобы :placeholder-shown отличал пустое поле от заполненного).
   */
  .float-field { position: relative; }
  .float-field .field::placeholder { color: transparent; }
  .float-field > label {
    position: absolute;
    left: 14px;
    top: 50%;
    max-width: calc(100% - 60px);
    overflow: hidden;
    color: var(--ui-subtle);
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
    pointer-events: none;
    transform: translateY(-50%);
    transition: opacity .25s var(--ui-ease);
  }
  .float-field .field:focus + label,
  .float-field .field:not(:placeholder-shown) + label { opacity: 0; }
  /* Автозаполнение браузера: подпись тоже скрыта (отдельные правила — неизвестный селектор ломает весь список) */
  .float-field .field:-webkit-autofill + label { opacity: 0; }
  .float-field .field:autofill + label { opacity: 0; }
  /* На телефоне шрифт поля 16px (см. выше), подпись того же размера */
  @media (pointer: coarse) { .float-field > label { font-size: 16px; } }
  /* Автозаполнение не перекрашивает поле в цвет браузера */
  .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: 340px; }
  .auth-card .field { height: 44px; }
  /* Email с первого шага: плашка, по нажатию — назад к первому шагу */
  .auth-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-2);
    color: var(--ui-fg);
    font-size: 13px;
    transition: background-color .2s;
  }
  .auth-identity:hover, .auth-identity:focus-visible { background: var(--ui-surface-3); }
  .auth-identity .icon { 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; }

  .form-error {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: var(--ui-radius-btn);
    background: rgb(248 113 113 / .1);
    color: #fca5a5;
    font-size: 13px;
    line-height: 1.5;
  }
  .form-error .icon { 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='M5 13l4 4L19 7'/%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: 40px;
    height: 24px;
    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: 16px;
    height: 16px;
    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(16px); 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(16px) 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: 38px;
    min-width: 180px;
    max-width: 100%;
    padding: 0 10px 0 12px;
    border-radius: var(--ui-radius-btn);
    background: var(--ui-surface-3);
    color: var(--ui-fg);
    font-size: 13px;
    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 > .icon { width: 16px; height: 16px; color: var(--ui-subtle); transition: transform .2s var(--ui-ease); }
  .select-btn.is-open > .icon { 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: 28px; height: 28px; flex-shrink: 0; }
  .brand-name { font-size: 16px; 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: 34px;
    padding: 0 12px;
    border-radius: var(--ui-radius-sm);
    color: var(--ui-muted);
    font-size: 13px;
    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)); } }

  /* ================= Публичный лейаут ================= */
  /* Фон меняется плавно при прокрутке; при загрузке главной мигания нет — класс is-landing-top уже стоит в разметке от index.php. */
  /*
   * Стекло шапки лежит в ::before, а не на самой шапке. Фильтр на предке делает его «корнем фона»: размытие потомков
   * (стекло мобильного меню) тогда считается только по содержимому этого предка и в Safari на iPhone не работает,
   * пока предок меняет фильтр или прозрачность. Соседний слой этого не касается.
   */
  .public-header { position: sticky; top: 0; z-index: 40; }
  .public-header::before { content: ""; position: absolute; inset: 0; z-index: -1; background-color: color-mix(in srgb, var(--ui-bg) 62%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.4); backdrop-filter: blur(22px) saturate(1.4); transition: opacity .45s var(--ui-ease); }
  /* Лендинг в самом верху страницы: шапка прозрачная, чтобы под ней было видно свечение первого экрана. */
  .is-landing-top .public-header::before { opacity: 0; }
  /* Меню открыто: стекло шапки убирается сразу, дальше шапку и меню закрывает стекло самого меню */
  .public-header.is-menu-open::before { opacity: 0; transition: none; }
  /* Само меню не двигается и не меняет прозрачность: Safari не размывает фон под предком, который анимируется. Выезжает только содержимое. */
  .public-mobile-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    padding: 8px 16px 20px;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s .3s;
  }
  .public-mobile-menu.is-open { visibility: visible; pointer-events: auto; transition-delay: 0s; }
  .public-mobile-menu > * { opacity: 0; transform: translateY(-8px); will-change: transform; transition: opacity .25s var(--ui-ease), transform .3s var(--ui-ease); }
  .public-mobile-menu.is-open > * { opacity: 1; transform: none; }
  /*
   * Размытое стекло меню — один слой на меню и полосу шапки сразу (поднят на высоту шапки с запасом на выезд),
   * поэтому при открытии между ними нет шва. Содержимое шапки стоит выше этого слоя.
   */
  .public-mobile-menu::before { content: ""; position: absolute; inset: -72px 0 0; z-index: -1; border-radius: 0 0 28px 28px; background: rgb(0 0 0 / .58); -webkit-backdrop-filter: blur(24px) saturate(1.2); backdrop-filter: blur(24px) saturate(1.2); opacity: 0; transition: opacity .2s var(--ui-ease); }
  .public-mobile-menu.is-open::before { opacity: 1; }
  .public-header > .container-x { position: relative; z-index: 1; }
  .public-mobile-menu .nav-link { width: 100%; height: 40px; font-size: 14px; }
  .public-main { min-height: calc(100dvh - 56px); }
  .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; }


  .avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ui-surface-4);
    color: var(--ui-fg-strong);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    text-transform: uppercase;
  }
  .avatar-lg { width: 44px; height: 44px; font-size: 16px; }
  .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; scrollbar-gutter: stable both-edges; }
  .page { padding: 20px 0 64px; animation: fade-in .35s ease both; }
  .page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
  .page-title { font-size: clamp(20px, 2.4vw, 24px); font-weight: 600; letter-spacing: -.03em; color: var(--ui-fg-strong); line-height: 1.2; }
  .page-subtitle { margin-top: 4px; color: var(--ui-muted); font-size: 13px; }

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

  .setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; }
  .setting-row + .setting-row { margin-top: 2px; }
  .setting-row strong { display: block; font-size: 14px; font-weight: 500; color: var(--ui-fg); }
  .setting-row small { display: block; margin-top: 1px; font-size: 12px; 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: 40px 16px; color: var(--ui-muted); }
  .empty-state .card-icon { width: 46px; height: 46px; border-radius: 15px; margin-bottom: 14px; }
  .empty-state strong { color: var(--ui-fg); font-size: 15px; font-weight: 600; }
  .empty-state p { margin-top: 4px; font-size: 13px; max-width: 340px; }

  .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-2);
    color: var(--ui-muted);
    font-size: 12px;
    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 .icon { 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; }

  .empty-note { padding: 10px 12px; font-size: 13px; line-height: 1.6; color: var(--ui-subtle); }

  /* ================= Подсказка над элементом: <span class="tip" tabindex="0" data-tip="Текст"> ================= */
  /* Появляется при наведении и в фокусе (на телефоне — по нажатию), прижата к правому краю элемента. */
  .tip { position: relative; border-radius: 6px; cursor: help; outline: none; }
  .tip::after {
    content: attr(data-tip);
    position: absolute;
    right: -8px;
    bottom: calc(100% + 8px);
    z-index: 5;
    width: max-content;
    max-width: min(260px, 70vw);
    padding: 7px 10px;
    border-radius: 12px;
    background: var(--ui-surface-5);
    color: var(--ui-fg-strong);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity .18s, transform .18s var(--ui-ease);
  }
  .tip:hover::after, .tip:focus::after { opacity: 1; transform: none; }
  .tip:focus-visible { box-shadow: 0 0 0 2px var(--ui-surface-5); }

  /* ================= Поповеры (меню в body, позиция fixed) ================= */
  .popover {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 96;   /* выше модалок (90): выпадающие списки открываются и внутри окон */
    min-width: 220px;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 5px;
    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: 36px;
    padding: 6px 10px;
    border-radius: var(--ui-radius-sm);
    color: var(--ui-fg);
    font-size: 13px;
    text-align: left;
    transition: background-color .15s;
  }
  .popover-item:hover, .popover-item:focus-visible { background: var(--ui-surface-4); outline: none; }
  /* Компактный список: низкие строки, не выше семи с половиной строк — дальше прокрутка */
  /*
   * Прокрутка — у внутреннего блока, а не у самого меню: Safari на iPhone не анимирует прозрачность и сдвиг
   * у элемента с настоящей прокруткой, и длинный список появлялся и исчезал рывком.
   */
  .popover.is-compact { max-height: none; padding: 0; overflow: hidden; border-radius: 16px; }
  .popover-scroll { max-height: min(254px, calc(100dvh - 24px)); padding: 5px; overflow-y: auto; overscroll-behavior: contain; }
  .popover.is-compact .popover-item { min-height: 32px; padding: 4px 10px; }
  .popover-item > .icon { 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: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .popover-item-text small { margin-top: 1px; font-size: 11px; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .popover-item > .icon.popover-check { width: 16px; height: 16px; margin-left: auto; color: var(--ui-fg); visibility: hidden; }
  .popover-item[aria-checked="true"] > .icon.popover-check { visibility: visible; }
  .popover-item.is-danger { color: #fca5a5; }
  .popover-item.is-danger > .icon { 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: 13px; 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; }

  .segmented { display: flex; flex-wrap: wrap; gap: 4px; }
  .segment {
    height: 30px;
    padding: 0 12px;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-4);
    color: #bdbdbd;
    font-size: 12px;
    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; }

  /* ================= Модалки ================= */
  /*
   * Анимация как у модалок 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: 420px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 22px;
    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);
    /*
     * Окно стоит по центру, и его верх часто попадает на полпикселя. Пока идёт анимация масштаба, браузер рисует
     * содержимое по целым пикселям, а после неё — по дробным: текст и кнопки сдвигались на пиксель.
     * С will-change окно всегда рисуется по целым пикселям, и сдвига в конце нет.
     */
    will-change: transform;
  }
  .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: 380px; }
  .modal-lg { max-width: 540px; }
  .modal-wide { max-width: 780px; }
  /* z-index: содержимое во время анимации смены иначе ложится поверх крестика и перехватывает нажатие */
  .modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
  .modal-grabber { display: none; }
  .modal-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 14px; border-radius: 14px; background: var(--ui-surface-4); color: var(--ui-fg-strong); }
  .modal-icon .icon { width: 20px; height: 20px; }
  .modal-title { font-size: 17px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; color: var(--ui-fg-strong); }
  .modal-text { margin-top: 6px; color: var(--ui-muted); font-size: 13px; line-height: 1.55; }
  .modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
  .modal-actions .btn { flex: 1 1 auto; }

  /*
   * Шторка на телефоне, как в iOS: во всю ширину, скруглена только сверху, выезжает снизу по «пружинной» кривой,
   * уезжает вниз за 300 мс (SHEET_LEAVE_MS в core/modal.js). Тянется пальцем: .is-dragging выключает переходы.
   */
  @media (max-width: 639px) {
    .modal-root { place-items: end stretch; padding: 0; }
    .modal-root .modal-panel {
      max-width: none;
      max-height: calc(100dvh - 44px);
      padding: 8px 16px max(20px, env(safe-area-inset-bottom));
      border-radius: 28px 28px 0 0;
      opacity: 1;
      transform: translateY(100%);
      transition: transform .3s var(--ui-ease-in);
      overscroll-behavior: contain;
    }
    .modal-root.is-open .modal-panel { transform: none; transition: transform .5s cubic-bezier(.32, .72, 0, 1); }
    /*
     * Нижняя панель Safari красится по закреплённому элементу у нижнего края экрана. Сама шторка не position: fixed,
     * поэтому у края стоит отдельная полоска её цвета: панель браузера получает цвет шторки, а не страницы под ней.
     * Нижнее меню кабинета на это время скрыто, иначе Safari берёт его чёрный цвет.
     */
    .modal-root::after { content: ""; position: fixed; inset: auto 0 0; height: max(6px, env(safe-area-inset-bottom)); background: var(--ui-surface-2); opacity: 0; pointer-events: none; }
    .modal-root.is-open::after { opacity: 1; transition: opacity 0s .3s; }
    body.has-modal .tabbar { visibility: hidden; }
    .modal-root.is-dragging .modal-panel, .modal-root.is-dragging .modal-backdrop { transition: none; }
    .modal-backdrop { transition: opacity .3s var(--ui-ease-in); }
    .modal-grabber { display: block; width: 36px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: rgb(255 255 255 / .24); }
    /* В шторке крестика нет: она закрывается свайпом вниз или нажатием на фон. Для экранных дикторов кнопка остаётся */
    .modal-close { width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
  }

  .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: 42px;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--ui-surface-3);
    color: var(--ui-fg);
    font-size: 14px;
    text-align: left;
    transition: background-color .15s, color .15s;
  }
  .choice:hover, .choice:focus-visible { background: var(--ui-surface-4); }
  .choice .icon { width: 16px; height: 16px; visibility: hidden; }
  .choice[aria-pressed="true"] { background: #fff; color: #000; }
  .choice[aria-pressed="true"] .icon { visibility: visible; }
  /* Мягкое появление блока со сдвигом. Смена шагов и вкладок делается в core/dom.js → swapContent */
  .step-in { animation: step-in .5s cubic-bezier(.32, .72, 0, 1) 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: 10px 14px;
    border-radius: 18px;
    background: var(--ui-surface-4);
    color: var(--ui-fg);
    font-size: 13px;
    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 .icon { width: 17px; height: 17px; color: var(--ui-muted); }

  /* ================= Лендинг ================= */
  /* Анимированный стикер (core/sticker.js): место занято заранее, чтобы вёрстка не прыгала при загрузке. */
  .sticker { display: block; width: var(--sticker, 132px); aspect-ratio: 1; flex-shrink: 0; opacity: 0; transition: opacity .4s var(--ui-ease); }
  .sticker.is-lg { --sticker: 156px; }
  .sticker.is-xl { --sticker: 188px; }
  /* Стикер выступает над верхним краем блока. */
  .sticker.is-pop { margin-top: -64px; }
  @media (max-width: 640px) {
    .sticker { --sticker: 116px; }
    .sticker.is-lg { --sticker: 132px; }
    .sticker.is-xl { --sticker: 148px; }
  }
  .sticker.is-ready { opacity: 1; }
  .sticker svg { display: block; }
  .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(34px, 6vw, 64px); font-weight: 600; letter-spacing: -.045em; line-height: 1.02; color: var(--ui-fg-strong); }
  .section-title { font-size: clamp(26px, 3.5vw, 40px); font-weight: 600; letter-spacing: -.04em; line-height: 1.08; color: var(--ui-fg-strong); }
  .section-text { margin-top: 12px; font-size: 15px; line-height: 1.6; color: var(--ui-muted); }
  .eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; 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: 9px; height: 44px; padding: 0 16px 0 9px; border-radius: 20px; background: var(--ui-surface-1); color: var(--ui-fg); font-size: 13px; font-weight: 500; white-space: nowrap; }

  .feature-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 22px; border-radius: var(--ui-radius-panel); background: var(--ui-surface-1); overflow: hidden; }
  /*
   * Блок «Одна карта — много сценариев»: три ленты платформ идут наискосок по правой части (на телефоне — по нижней),
   * к заголовку они гаснут. Ленты длиннее блока в несколько раз, поэтому при движении края не видны.
   */
  .lanes-card { justify-content: center; min-height: 270px; }
  .lanes { position: absolute; inset: 0 0 0 40%; overflow: hidden; pointer-events: none; -webkit-mask-image: linear-gradient(to right, transparent, #000 34%); mask-image: linear-gradient(to right, transparent, #000 34%); }
  .lanes-tilt { position: absolute; left: -160px; top: 50%; display: flex; flex-direction: column; gap: 16px; transform: translateY(-50%) rotate(-28deg); transform-origin: 460px 50%; }
  .lanes .marquee-track { gap: 14px; padding-right: 14px; animation-duration: 150s; }
  .lanes .marquee-item { height: 56px; gap: 12px; padding: 0 22px 0 11px; border-radius: 26px; font-size: 15.5px; }
  .lanes .svc-icon { width: 36px; height: 36px; }
  .lanes .marquee-track:nth-child(2) { animation-duration: 180s; }
  .lanes .marquee-track:nth-child(3) { animation-duration: 165s; }
  @media (max-width: 767px) {
    .lanes-card { justify-content: flex-start; min-height: 360px; }
    .lanes { inset: 38% 0 0 0; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 34%); mask-image: linear-gradient(to bottom, transparent, #000 34%); }
    .lanes-tilt { left: -240px; transform-origin: 420px 50%; }
  }
  /* Плашки Apple Pay и Google Pay в карточке возможностей: логотип целиком, без подписи. */
  .pay-chip { display: inline-grid; place-items: center; height: 44px; padding: 0 16px; border-radius: 14px; background: var(--ui-surface-4); color: var(--ui-fg-strong); }
  .pay-chip .icon { width: 50px; height: 22px; stroke: none; }
  .feature-card h3 { font-size: 17px; font-weight: 600; letter-spacing: -.02em; color: var(--ui-fg-strong); }
  .feature-card p { font-size: 14px; line-height: 1.6; color: var(--ui-muted); }

  .price-card { display: flex; flex-direction: column; gap: 18px; padding: 22px; 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 .icon { width: 17px; height: 17px; color: var(--ui-fg-strong); }

  /* Документы (/documents и окно документов): вкладки и текст */
  .legal-tab { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: var(--ui-radius-sm); color: var(--ui-muted); font-size: 13px; 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 .icon { display: none; } }
  .legal-doc { margin-top: 28px; }
  .legal-doc h2 { margin-top: 30px; font-size: 16px; font-weight: 600; letter-spacing: -.02em; color: var(--ui-fg-strong); }
  .legal-doc p, .legal-doc li { font-size: 14px; line-height: 1.7; color: #bdbdbd; }
  .legal-doc p { margin-top: 12px; }
  .legal-doc .legal-intro { margin-top: 0; font-size: 15px; 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); }

  .callout { display: flex; gap: 12px; margin-top: 16px; padding: 12px 14px; border-radius: 20px; background: var(--ui-surface-2); color: #cfcfcf; font-size: 13px; line-height: 1.6; }
  .callout .icon { width: 16px; height: 16px; margin-top: 2px; 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); } }
  @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-split { grid-template-columns: minmax(0, 2fr) 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; } }

  .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); }
}

/* ================= Анимации ================= */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes step-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes marquee { to { transform: translateX(-50%); } }
@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; }
}
