:root, :root[data-theme="dark"] {
  --bg: #000000;
  --bg-2: #0e0e10;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --line: rgba(255,255,255,.08);
  --hairline: rgba(255,255,255,.12);
  --text: #ffffff;
  --text-2: #8e8e93;
  --muted: #636366;
  --accent: #3390ec;
  --accent-soft: rgba(51,144,236,.18);
  --accent-2: #2a7fd6;
  --gold: #ffd24a;
  --violet: #8a6cff;
  --indigo: #5e6bff;
  --green: #34c759;
  --red: #ff453a;
  --tabbar-bg: rgba(28,28,30,.86);
  --shadow-card: 0 12px 40px rgba(0,0,0,.55);
  --group-radius: 12px;
  /* Telegram WebApp вернёт настоящие значения через JS (см. applySafeInsets). */
  --tg-safe-top: 0px;
  --tg-safe-bottom: 0px;
  --tg-content-top: 0px;
  --tg-content-bottom: 0px;
  /* Финальные отступы: системный inset (notch) + зона Telegram-контролов сверху.
     env() оставлен как фоллбек для запуска вне Telegram. */
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-top) + var(--tg-content-top)));
  --safe-bot: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-bottom) + var(--tg-content-bottom)));
}

:root[data-theme="light"] {
  --bg: #efeff4;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #e5e5ea;
  --line: rgba(60,60,67,.10);
  --hairline: rgba(60,60,67,.18);
  --text: #000000;
  --text-2: #6c6c70;
  --muted: #aeaeb2;
  --accent: #007aff;
  --accent-soft: rgba(0,122,255,.14);
  --accent-2: #0064d2;
  --tabbar-bg: rgba(255,255,255,.86);
  --shadow-card: 0 8px 28px rgba(20,30,60,.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ===== Стартовый лоадер: корона + три iOS-точки ===== */
.loader {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .35s ease;
}
.loader--hide { opacity: 0; pointer-events: none; }
.loader__center {
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  animation: loaderFadeIn .45s ease both;
}
.loader__logo {
  width: 115px; height: 115px;
  /* PNG-короны белые. На светлой теме инвертируем в чёрный, чтобы силуэт
     читался на сером фоне сайта. */
  animation: loaderPulse 1.6s ease-in-out infinite;
}
:root[data-theme="light"] .loader__logo { filter: brightness(0); }
@keyframes loaderFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes loaderPulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: .75; transform: scale(.96); }
}

/* ===== Гейт «Только в Telegram» ===== */
.tg-gate {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.tg-gate__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--group-radius);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
  max-width: 360px; width: 100%;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.tg-gate__logo { width: 110px; height: 110px; }
/* PNG-короны белые. На светлой карточке гейта они сливаются с фоном —
   красим их в чёрный фильтром (brightness 0 + альфа PNG сохраняет силуэт). */
:root[data-theme="light"] .tg-gate__logo { filter: brightness(0); }
.tg-gate__title { font-size: 22px; font-weight: 700; margin: 0; color: var(--text); }
.tg-gate__text { font-size: 14px; color: var(--text-2); margin: 0; line-height: 1.5; }
#tgGateBtn { margin-top: 8px; text-decoration: none; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.4; overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;           /* учёт системных полос (Android/iOS) */
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / legacy Edge */
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar { width: 0 !important; height: 0 !important; display: none; }
.screen-host, .textarea, .keylist, .logs-list { scrollbar-width: none; -ms-overflow-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
/* iOS WebView (и Telegram in-app) кладёт свой -webkit-text-fill-color на
   плейсхолдер поверх обычного color, иногда даже окрашивая его в
   tg-theme-link-color (синий). Дублируем все вендорные селекторы и
   ставим !important — это единственный способ перекрыть инжекшен клиента. */
::placeholder,
::-webkit-input-placeholder,
::-moz-placeholder,
:-ms-input-placeholder,
:-moz-placeholder {
  color: var(--text-2) !important;
  -webkit-text-fill-color: var(--text-2) !important;
  opacity: 1 !important;
}
a { color: var(--accent); text-decoration: none; }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(10,10,12,.95), rgba(10,10,12,.75) 80%, rgba(10,10,12,0));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar__back { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-size: 16px; padding: 6px 4px; }
.topbar__title { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.topbar__name { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 17px; }
.topbar__verified { flex-shrink: 0; }
.topbar__sub { color: var(--text-2); font-size: 12px; margin-top: -2px; }
.topbar__menu { justify-self: end; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text); }

/* ===== Screens ===== */
.screen-host { padding: calc(16px + var(--safe-top)) 14px 120px; max-width: 720px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; gap: 10px; }
.screen[hidden] { display: none; }
/* Анимация появления экрана убрана полностью. Раньше .screen имел
   animation: fade .22s ease — это давало видимое «дёрганье» текста, короны
   и иконок Stars/TON на подписке: пока экран был display:none, браузер не
   декодировал вложенные SVG/img, а при показе декод и repaint совпадали с
   opacity-фейдом и читались как сдвиг. Переключение вкладок теперь мгновенное. */

.h2 { font-size: 22px; font-weight: 700; margin: 6px 4px 0; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 4px 0; }
.screen-head .h2 { margin: 0; }
.btn--admin {
  background: var(--surface-2); color: var(--text); border: 0;
  height: 28px; padding: 0 12px; font-size: 13px; font-weight: 600;
}
.admin-user {
  background: var(--surface); border-radius: var(--group-radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--line);
  width: 100%; text-align: left; color: inherit; cursor: pointer;
  transition: background .15s, transform .12s;
}
.admin-user:active { transform: scale(.99); background: var(--surface-2); }
.admin-user--open { background: var(--surface-2); }
.admin-user__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-user__name { font-weight: 600; }
.admin-user__at { color: var(--text-2); font-weight: 500; }
.admin-user__plan { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-transform: uppercase; flex-shrink: 0; }
.admin-user__plan.king { background: rgba(255,210,74,.18); color: var(--gold); }
.admin-user__plan.pro  { background: var(--accent-soft); color: var(--accent); }
.admin-user__plan.free { background: var(--surface-2); color: var(--text-2); }
.admin-user--open .admin-user__plan.free { background: var(--surface); }
.admin-user__meta { color: var(--text-2); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.admin-user__meta b { color: var(--text); font-weight: 600; }
.admin-user__details {
  margin-top: 8px; padding-top: 10px;
  border-top: 1px solid var(--hairline);
  display: flex; flex-direction: column; gap: 6px;
}
.admin-user__detail-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13px; }
.admin-user__detail-key { color: var(--text-2); flex-shrink: 0; }
.admin-user__detail-val { color: var(--text); font-weight: 600; text-align: right; word-break: break-word; }
.admin-user__actions { display: flex; gap: 8px; margin-top: 10px; }
.admin-user__actions .btn { flex: 1; height: 36px; font-size: 13px; }

.admin-tabs { margin: 8px 0 8px; }
.admin-pane { display: flex; flex-direction: column; gap: 8px; }
/* .logs-filter снаружи (на экране журналов) идёт после заголовков и имеет
   свой margin-top: 8px. Внутри .admin-pane заголовков нет, а gap у пейна
   уже даёт нужный отступ от табов — лишний margin удваивает зазор. */
.admin-pane > .logs-filter { margin-top: 0; }

.admin-log-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--group-radius);
  padding: 12px 14px;
}

/* Лента ошибок в админ-панели. Цветной слева бордер кодирует категорию
   (оплата — красный, ИИ — оранжевый, отправка — жёлтый и т.д.) — глаз
   быстро сканирует, где «горит». */
.admin-errors { display: flex; flex-direction: column; gap: 6px; }
.admin-error {
  background: var(--surface); border-radius: var(--group-radius);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
  border-left: 3px solid var(--text-2);
}
.admin-error[data-cat="payment"]  { border-left-color: #ff5c5c; }
.admin-error[data-cat="ai"]       { border-left-color: #ff9d3d; }
.admin-error[data-cat="ai_key"]   { border-left-color: #ff9d3d; }
.admin-error[data-cat="send"]     { border-left-color: #ffd23d; }
.admin-error[data-cat="support"]  { border-left-color: #4dabff; }
.admin-error[data-cat="ton"]      { border-left-color: #a777ff; }
.admin-error[data-cat="other"]    { border-left-color: var(--text-2); }
.admin-error__head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.admin-error__cat {
  font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.02em; color: var(--text);
}
.admin-error__when { color: var(--text-2); font-size: 12px; }
.admin-error__uid {
  margin-left: auto; color: var(--text-2); font-size: 12px;
  background: var(--surface-2); padding: 2px 8px; border-radius: 10px;
}
.admin-error__msg { color: var(--text); font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.admin-error__meta { color: var(--text-2); font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace; }
.admin-log-row__who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-log-row__name { font-weight: 600; color: var(--text); }
.admin-log-row__when { color: var(--text-2); font-size: 12px; }
.admin-log-row .btn { height: 32px; font-size: 13px; padding: 0 12px; flex-shrink: 0; }
.admin-user__at { color: var(--accent); text-decoration: none; }
.admin-user__at:active { opacity: .7; }
.h3 { font-size: 15px; font-weight: 600; color: var(--text); margin: 14px 4px 4px; }
.sub { color: var(--text-2); font-size: 14px; margin: 0 4px 4px; }
.hint { color: var(--text-2); font-size: 13px; margin: -4px 4px 0; }
.hint--block { background: var(--surface); border-radius: var(--group-radius); padding: 14px 16px; margin: 10px 0 0; width: 100%; color: var(--text-2); }
.spacer-bottom { height: 12px; }

/* ===== Карточка подключения (Home) =====
   Визуально совпадает с .plan (Free/Pro/King): белая поверхность, скруглённые
   углы того же радиуса что и у .group-блоков на сайте (--group-radius),
   та же геометрия. Внутри — свайпабельный тур из трёх шагов. */
.connect-card { width: 100%; border-radius: var(--group-radius); padding: 16px 18px; }
.connect-card--pending {
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
/* Заголовок карточки — компактный, как пункт меню «Автоматизация чатов»,
   а не как большой plan-title. Размер совпадает с подписями шагов внутри. */
.connect-card__title { font-weight: 600; font-size: 15px; color: var(--text); }
.connect-card__hint { margin: 4px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.4; }

/* ===== Свайп-тур внутри карточки =====
   Каждый шаг = отдельная страница на всю ширину карточки. Snap по горизонтали,
   скроллбар скрыт. Под слайдами — точки пагинации (активная вытягивается в pill). */
.connect-tour { display: flex; flex-direction: column; gap: 10px; align-items: center; width: 100%; }
.connect-tour__slides {
  width: 100%;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.connect-tour__slides::-webkit-scrollbar { display: none; }
.connect-tour__slide {
  min-width: 100%;
  scroll-snap-align: start; flex-shrink: 0;
  /* Геометрия как у .row из секции «Сервисы»: бейдж слева, текст справа,
     центр по вертикали. align-items:center чтобы и одностроковые, и двух-
     строковые подписи выглядели одинаково ровно. */
  display: flex; align-items: center; gap: 12px;
  padding: 8px 2px;
  color: var(--text);
  /* Высота фиксирована, чтобы при свайпе между шагами карточка не прыгала. */
  min-height: 64px;
}
/* Бейдж номера повторяет .row__icon: 30×30, скруглённый квадрат, синий фон,
   белая цифра по центру. line-height:1 + flex-центрирование убирают вертикальный
   сдвиг внутри кружка (раньше «1» казалась выше «2/3» из-за baseline). */
.connect-tour__num {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; line-height: 1;
  flex-shrink: 0;
}
.connect-tour__cap { margin: 0; font-size: 15px; line-height: 1.4; color: var(--text); font-weight: 500; }
.connect-tour__cap code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px; padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--text);
}
/* Тапаемый @username — копируется в буфер по клику. Визуально показываем
   что это интерактивный элемент: подсвечиваем accent-цветом, курсор pointer,
   лёгкая обратная связь на :active. */
.connect-tour__copy {
  cursor: pointer; color: var(--accent) !important;
  transition: background .15s, transform .1s;
}
.connect-tour__copy:active { transform: scale(.96); background: var(--accent-soft); }
.connect-tour__copy.is-copied {
  background: var(--green); color: #fff !important;
}
/* Второй ряд того же шага — единый размер/цвет/вес со строкой выше, просто
   с новой линии. Юзер хочет видеть оба ряда как равноправные пункты пути
   (со стрелками ↓ между ними), а не основной + приглушённое уточнение. */
.connect-tour__sub {
  display: block; margin-top: 2px;
  font-size: 15px; line-height: 1.4; color: var(--text); font-weight: 500;
}
.connect-tour__dots { display: flex; gap: 6px; }
.connect-tour__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-2); opacity: .4;
  transition: opacity .2s ease, width .2s ease, background .2s ease;
}
.connect-tour__dot--active { opacity: 1; width: 18px; border-radius: 4px; background: var(--accent); }
.connect-card--ok {
  background: color-mix(in srgb, var(--green) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 35%, transparent);
  color: var(--text); font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
}
.connect-card__check {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
}

/* ===== Profile ===== */
.profile { position: relative; display: flex; flex-direction: column; align-items: center; padding: 12px 0 8px; gap: 2px; }
.profile__avatar { position: relative; width: 96px; height: 96px; border-radius: 50%; overflow: hidden; box-shadow: var(--shadow-card); background: #1a1a20; }
.profile__avatar svg { width: 100%; height: 100%; display: block; }
.profile__avatar-img:not([hidden]) { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.profile__name { font-size: 20px; font-weight: 700; margin: 6px 0 0; display: inline-flex; align-items: center; gap: 6px; }
.profile__name .crown svg { width: 18px; height: 18px; }
/* Когда корона видна, добавляем «призрак» слева той же ширины, чтобы имя оставалось по центру. */
.profile__name:has(.crown:not([hidden]))::before { content: ""; display: inline-block; width: 18px; height: 18px; }
.profile__handle { color: var(--text-2); font-size: 14px; margin: 0 0 4px; display: inline-flex; align-items: center; gap: 6px; }
.crown { display: inline-flex; align-items: center; }
/* Тень без y-сдвига (как у .plan__crown): иначе она торчит ниже самой короны
   и визуальный «низ» уплывает под текст имени в профиле. */
.crown svg { width: 16px; height: 16px; display: block; filter: drop-shadow(0 0 1px rgba(0,0,0,.25)); }
.crown--pro { color: var(--accent); }
.crown--king { color: var(--gold); }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--group-radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.card__icon { width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card__icon--gold { background: var(--accent-soft); }
.card__icon--ton  { background: rgba(0, 152, 234, 0.15); }
.wallet-card__body { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
/* Не подключён: подпись «TON-кошелёк» по центру карточки, без баланса. */
.wallet-card__label { font-size: 17px; font-weight: 600; color: var(--text); }
/* Подключён: показываем только баланс, без подписи и адреса. */
.wallet-card--on .wallet-card__label { display: none; }
.wallet-card__balance { display: flex; align-items: baseline; gap: 4px; font-size: 20px; font-weight: 700; color: var(--text); }
.wallet-unit { color: var(--text-2); font-size: 13px; font-weight: 600; }
.card__value { display: inline-flex; align-items: baseline; gap: 6px; }
.card__value .star { width: 18px; height: 18px; }
.card__body { flex: 1; min-width: 0; }
.card__label { color: var(--text-2); font-size: 13px; }
.card__value { font-size: 17px; font-weight: 600; margin-top: 2px; }
.card__value-sub { color: var(--text-2); font-size: 13px; font-weight: 600; }
.card__title { font-weight: 600; color: var(--text); }
.card__desc { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.card__head { margin-bottom: 8px; }
.card__row { display: flex; align-items: center; gap: 12px; width: 100%; }
.card__row > div:first-child { flex: 1; }
.card--king { flex-direction: column; align-items: flex-start; padding: 14px; }
.card--switch { justify-content: space-between; }
.card--switch > div:first-child { flex: 1; padding-right: 12px; }
.card--col { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; }

/* ===== Admin: состояние ИИ ===== */
.ai-providers { display: flex; flex-direction: column; gap: 12px; }
.ai-provider[data-role="inactive"] { opacity: 0.55; }
.ai-provider__role { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; vertical-align: middle; }
.ai-provider__role--primary  { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ai-provider__role--fallback { color: var(--text-2); background: var(--surface-2); }
.ai-provider__role--inactive { color: var(--text-2); background: var(--surface-2); }
.ai-state { display: flex; flex-direction: column; gap: 6px; }
.ai-state__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ai-state__label { color: var(--text-2); font-size: 13px; }
.ai-state__value { font-weight: 600; color: var(--text); font-size: 14px; text-align: right; }
.ai-keys { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ai-key { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.ai-key__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-2); }
.ai-key__dot--ok { background: #34c759; }
.ai-key__dot--warn { background: #ff9f0a; }
.ai-key__dot--err { background: #ff453a; }
.ai-key__main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ai-key__tail { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; color: var(--text); }
.ai-key__status { font-size: 13px; color: var(--text-2); }
.ai-key__used { font-size: 13px; color: var(--text-2); white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--accent); }
.badge--king svg { flex-shrink: 0; }

/* ===== Group (iOS-style table) ===== */
.group {
  background: var(--surface);
  border-radius: var(--group-radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
/* Доп. зазор поверх базового gap:10px у .screen — отделяет навигационные
   группы от карточек статуса (визуально кластер «настройки приложения»). */
.screen > .card + .group,
.screen > .group + .group { margin-top: 8px; }
.group > .row { border-radius: 0; }
.group > .row + .row { position: relative; }
.group > .row + .row::before {
  content: ""; position: absolute; left: 56px; right: 0; top: 0;
  height: 1px; background: var(--hairline);
}

.group-title {
  font-size: 14px; color: var(--text-2);
  margin: 18px 16px 6px;
}

/* ===== Rows ===== */
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: var(--group-radius);
  padding: 11px 14px; width: 100%;
  transition: background .15s;
  min-height: 48px;
}
.row:active { background: var(--surface-2); }
.row__icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.row__icon--blue { background: #2a5fb3; }
.row__icon--violet { background: #6d4ed6; }
.row__icon--indigo { background: #4a55c2; }
.row__icon--yellow { background: var(--gold); color: #0a0a0c; }
.row__icon--green { background: #2e8b57; }
.row__title { flex: 1; text-align: left; font-weight: 500; }
.row__value { color: var(--text-2); font-size: 14px; }
.row__chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); margin-left: 4px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 16px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  transition: transform .12s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn--pill { background: var(--accent-soft); color: var(--accent); }
.btn--primary { background: var(--accent); color: #fff; height: 50px; font-size: 16px; }
.btn--primary:active { background: var(--accent-2); }
.btn--gold { background: var(--gold); color: #1a1300; height: 50px; font-size: 16px; }
.btn--ghost { background: transparent; border: 1px dashed var(--line); color: var(--text); height: 50px; }
.btn--ton   { background: #0098EA; color: #fff; height: 50px; font-size: 16px; }
.btn--ton:active { background: #0079bf; }
.btn--gold  { background: var(--gold); color: #1a1305; height: 50px; font-size: 16px; }
.btn--gold:active { background: #e6b938; }

/* Зелёная подсветка кнопки «Сохранить» после успешного сохранения. */
.btn--saved { background: var(--green) !important; color: #fff !important; transition: background .2s; }

/* === Гейты доступа ===
   .gate-pro — фича Pro+: на Free визуально приглушена, заблокирована для
   клика, в правом верхнем углу (или инлайн рядом с заголовком/сегментом)
   маленький бейдж «PRO». Pro и King обе видят и могут использовать.
   Разница тарифов — только в числовых лимитах (chats/replies), которые
   считает сервер. */
html[data-plan="free"] .gate-pro {
  position: relative;
  opacity: .55;
  pointer-events: none;
}
html[data-plan="free"] .gate-pro::after {
  content: "PRO";
  position: absolute;
  top: 8px; right: 12px;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px;
}
/* Сегмент в группе и заголовки используют инлайн-бейдж — иначе абсолютный
   PRO налезает на текст. */
html[data-plan="free"] .seg.gate-pro::after,
html[data-plan="free"] h3.gate-pro::after {
  position: static;
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
}
/* На самих полях ввода бейдж не нужен — он уже стоит у заголовка над полем,
   иначе бы два PRO висели на одну фичу. */
html[data-plan="free"] .textarea.gate-pro::after,
html[data-plan="free"] .input.gate-pro::after { content: none; }

/* Контейнерная секция воспроизводит вертикальный gap родителя .screen,
   иначе обёрнутые элементы слипаются — у обычной div нет flex-gap. */
.gate-pro--section { display: flex; flex-direction: column; gap: 10px; }

/* Свитч-карточки и контейнерные секции: угловой PRO налезает на переключатель,
   поэтому переносим его инлайн к заголовку карточки. */
html[data-plan="free"] .card.gate-pro::after,
html[data-plan="free"] .gate-pro--section::after { content: none; }
html[data-plan="free"] .card.gate-pro .card__title::after,
html[data-plan="free"] .gate-pro--section .card__title::after {
  content: "PRO";
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px;
}
.btn__icon { width: 1.1em; height: 1.1em; flex-shrink: 0; object-fit: contain; }
/* В tg-star.svg сам силуэт смещён вниз внутри viewBox (path translate y=14),
   поэтому при «контейнерном» центрировании визуально звезда проваливается.
   Сдвигаем картинку вверх через object-position, чтобы её центр совпал с центром цифр. */
.btn__icon[src*="tg-star"] { object-position: 50% 35%; }
/* Логотип TON залит #0098EA — на синей кнопке этого же цвета он сольётся,
   поэтому в .btn--ton инвертируем в белый. */
.btn--ton .btn__icon { filter: brightness(0) invert(1); }
.btn--full { width: 100%; margin-top: 10px; }

/* ===== Segmented ===== */
.segmented { display: flex; gap: 6px; background: var(--surface); padding: 4px; border-radius: 12px; flex-wrap: wrap; }
.segmented--vert { flex-direction: column; gap: 4px; }
.seg {
  flex: 1; min-height: 36px; padding: 0 12px; border-radius: 9px;
  color: var(--text-2); font-size: 14px; font-weight: 500;
  white-space: nowrap;
}
.segmented--vert .seg { text-align: left; padding: 10px 12px; }
.seg--active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.custom-time { display: flex; align-items: center; gap: 8px; padding: 4px 4px 0; color: var(--text-2); }
.custom-time input { width: 90px; }

/* ===== Inputs ===== */
/* Каретка акцентного цвета на всех полях ввода: чёрная по дефолту сливалась
   с текстом на светлой теме и прилипала к букве. Синяя видна и в светлой,
   и в тёмной. Глобально — чтобы покрыть и .input, и .textarea, и type=search
   у логов, и type=number/time в диапазонах. */
input, textarea { caret-color: var(--accent); }

.input, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; color: var(--text);
  font-size: 15px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 110px; font-family: inherit; }

input[type="number"], input[type="time"] {
  width: 90px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; color: var(--text); outline: none;
}
input[type="number"]:focus, input[type="time"]:focus { border-color: var(--accent); }
.range-pair {
  display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap;
  background: var(--surface);
  padding: 12px 14px;
  border-radius: var(--group-radius);
  width: 100%;
}
.range-pair label {
  flex: 1; min-width: 0;
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text-2); font-size: 14px;
}
.range-pair label + label { border-left: 1px solid var(--hairline); padding-left: 12px; }
.range-pair input[type="time"],
.range-pair input[type="number"] { flex: 1; min-width: 0; width: auto; }

/* ===== Switch ===== */
.switch { position: relative; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { display: none; }
.switch span {
  position: absolute; inset: 0; background: var(--surface-2); border-radius: 999px;
  transition: background .2s;
  box-shadow: inset 0 0 0 1px var(--line);
}
.switch span::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ===== Keys ===== */
.keylist { display: flex; flex-direction: column; gap: 8px; }
.keyitem {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 12px; padding: 10px 12px;
}
.keyitem__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.keyitem__dot--bad { background: var(--red); }
.keyitem__name { flex: 1; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; color: var(--text-2); }
.keyitem__del { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border-radius: 12px; padding: 12px; text-align: center; }
.stat__v { font-size: 20px; font-weight: 700; }
.stat__l { color: var(--text-2); font-size: 12px; margin-top: 2px; }

/* ===== Weekdays ===== */
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays button {
  height: 42px; border-radius: 10px; background: var(--surface);
  color: var(--text-2); font-weight: 600; font-size: 13px;
}
.weekdays button.on { background: var(--accent); color: #fff; }

/* ===== Plans ===== */
.plan {
  background: var(--surface); border-radius: var(--group-radius);
  padding: 18px; display: flex; flex-direction: column; gap: 8px;
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
}
.plan__name { font-size: 18px; font-weight: 700; }
.plan__price { font-size: 26px; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plan__price-sep { font-size: 13px; color: var(--text-2); font-weight: 500; margin: 0 2px; }
.plan__buy { display: flex; gap: 8px; margin-top: 10px; }
/* flex: 1 1 0 + одинаковый min-width: 0 заставляет обе кнопки занимать ровно
   половину строки независимо от длины внутреннего лейбла. Без этого замена
   текста на «Подтвердите…» во время оплаты раздвигает одну кнопку и сжимает
   соседнюю — звёзды и TON-иконки внутри визуально дёргаются. */
.plan__buy .btn { flex: 1 1 0; min-width: 0; }
/* На кнопках покупки выключаем общий .btn:active scale(.97) — он на телефоне
   читается как «дёрганье» всей плашки, особенно когда нажимаешь одну кнопку,
   а вторая остаётся на 100%. Background-смена ниже даёт достаточную обратную
   связь. */
.plan__buy .btn:active { transform: none; }
/* Кнопки покупки — одинаковые цвета на обеих темах:
   Stars/основная — Telegram-blue, TON — фирменный синий TON. */
.plan__buy .btn--primary { background: #3390ec; color: #fff; }
.plan__buy .btn--primary:active { background: #2a7fd6; }
.plan__buy .btn--ton { background: #0098EA; color: #fff; }
.plan__buy .btn--ton:active { background: #0079bf; }
.star { width: 1em; height: 1em; vertical-align: -0.15em; flex-shrink: 0; object-fit: contain; display: inline-block; }
/* В строке цены и кнопках используем flex-центрирование,
   тогда не важно, как иконка смещена внутри своего viewBox. */
.plan__price-chunk { display: inline-flex; align-items: center; gap: 4px; line-height: 1; }
.plan__price-chunk .star { width: .85em; height: .85em; vertical-align: baseline; }
.stat .star { width: 18px; height: 18px; }
.plan__price span { font-size: 13px; color: var(--text-2); font-weight: 500; }
.plan__list { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 14px; }
.plan__list li { padding-left: 22px; position: relative; }
.plan__list li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 10px; height: 6px; border-left: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: rotate(-45deg); }
.plan--pro { border: 1px solid var(--accent); }
.plan--king {
  border: 1px solid var(--gold);
  background: linear-gradient(160deg, rgba(255,210,74,.12) 0%, var(--surface) 60%);
}
.plan--king .plan__list li::before { border-color: var(--gold); }
.plan__name { display: inline-flex; align-items: center; gap: 8px; line-height: 1; }
.plan__crown { color: var(--gold); display: inline-flex; align-items: center; line-height: 1; }
.plan__crown svg { display: block; }
.plan__crown--pro { color: var(--accent); }
/* align-items:center выравнивает корону по середине line-box, которая
   находится ниже середины капитала (line-box больше cap-height из-за
   ascender/descender метрик шрифта). Сдвиг на 1px ставит корону ровно
   в визуальный центр «P» / «K».
   filter: drop-shadow без y-сдвига — раньше было «0 1px 0», и тень торчала
   ниже короны, утягивая визуальный низ за текст. Сейчас blur 1px вокруг даёт
   ту же мягкую тень, не смещая центр. */
.plan__crown { transform: translateY(-1px); filter: drop-shadow(0 0 1px rgba(0,0,0,.22)); }
/* Pro: низ короны прижат к низу текста — как у King в макете. */
.plan__crown--pro { align-self: flex-end; transform: none; }
.plan__badge {
  position: absolute; top: 14px; right: 14px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 5px 11px; border-radius: 999px;
}

/* ===== Tab bar ===== */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  /* --kbd-h — реальная высота клавиатуры из visualViewport / Telegram
     WebApp viewportChanged. --kbd-fallback — заведомо большой оффсет
     (500px), который ставится из app.js по focusin на любой текстовый
     инпут: viewportChanged на iOS Telegram WebApp фаерится с задержкой,
     и без фоллбэка док успевает мелькнуть над клавиатурой. Берём
     максимум — пока хоть один источник сигналит «клавиатура поднята»,
     док уезжает вниз. */
  bottom: calc(10px + var(--safe-bot) - max(var(--kbd-h, 0px), var(--kbd-fallback, 0px)));
  display: flex; align-items: center; gap: 10px;
  z-index: 30;
}
.tabbar {
  display: flex; align-items: center; gap: 4px;
  background: var(--tabbar-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  padding: 3px; border-radius: 999px;
  box-shadow: var(--shadow-card);
}
.tab {
  display: inline-flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 999px;
  color: var(--text-2);
  transition: color .15s, background .15s;
}
.tab__ico { display: inline-flex; align-items: center; justify-content: center; }
.tab__ico svg {
  width: 32px; height: 32px;
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.tab__ico--avatar svg { width: 40px; height: 40px; }
/* Корона визуально чуть мельче за счёт того, что её путь не дотягивает
   до краёв viewBox (тонкие наклонные линии). Бампаем рендер-размер
   именно у короны, не трогая сам SVG, чтобы она по массе совпадала
   с соседними иконками. */
.tab[data-tab="subscription"] .tab__ico svg { width: 34px; height: 34px; }
.tab__lb { display: none; }
.tab--active { color: var(--text); background: var(--surface-2); }
.tab--active .tab__ico svg { animation: tab-pop .35s cubic-bezier(.34, 1.56, .64, 1); }
.tab:active .tab__ico svg { transform: scale(.85); transition-duration: .08s; }
.tab--active .tab__ico--avatar svg { transform: scale(1.08); }

@keyframes tab-pop {
  0%   { transform: scale(.9); }
  60%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.dock-avatar.tab {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--tabbar-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  padding: 4px;
  overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.dock-avatar.tab svg { width: 100%; height: 100%; border-radius: 50%; display: block; }
.dock-avatar__img:not([hidden]) { width: 100%; height: 100%; border-radius: 50%; display: block; object-fit: cover; }
.dock-avatar.tab:active,
.dock-avatar.tab--active {
  background: var(--surface-2);
}

/* ===== Reply logs ===== */
.logs-filter { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 0; }
/* Подпись «Пока пусто...» в журнале — поджимаем margin сверху, иначе она
   уезжает ниже из-за двойного отступа (margin .hint--block + flex gap .screen). */
#logsEmpty { margin-top: 2px; }
.logs-filter__search {
  width: 100%; box-sizing: border-box;
  height: 40px; padding: 0 14px;
  background: var(--surface); color: var(--text);
  border-radius: 12px; border: 1px solid var(--line);
  font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
.logs-filter__search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.logs-filter__search::placeholder { color: var(--text-2); text-overflow: ellipsis; }
/* Light-theme: страница уже почти белая, поэтому делаем поле iOS-серым «pill»,
   а на фокусе подсвечиваем мягким accent-кольцом — без тонкой синей линии,
   которая на белом фоне выглядит хлипко. */
:root[data-theme="light"] .logs-filter__search { background: var(--surface-2); border-color: transparent; }
:root[data-theme="light"] .logs-filter__search:focus { background: var(--surface); border-color: var(--accent); }
/* iOS/WebKit рисует встроенный «крестик очистки» у type=search — он залезает на текст. */
.logs-filter__search::-webkit-search-cancel-button,
.logs-filter__search::-webkit-search-decoration,
.logs-filter__search::-webkit-search-results-button,
.logs-filter__search::-webkit-search-results-decoration { display: none; -webkit-appearance: none; }
.logs-filter__chips { padding: 4px; }

.logs-list { display: flex; flex-direction: column; gap: 8px; }
.log-item {
  background: var(--surface); border-radius: var(--group-radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--line);
}
.log-item__head { display: flex; align-items: center; justify-content: space-between; }
.log-item__from { font-weight: 600; font-size: 14px; }
.log-item__at { color: var(--text-2); font-size: 12px; }
.log-item__msg { color: var(--text); font-size: 14px; opacity: .85; }
.log-item__reply { color: var(--accent); font-size: 14px; padding-left: 14px; border-left: 2px solid var(--accent-soft); }
.admin-user__logs-empty { color: var(--text-2); font-size: 13px; padding: 8px 0; }

/* ===== Language list ===== */
.row--lang .row__check {
  width: 14px; height: 9px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg) translateY(-2px);
  opacity: 0;
  transition: opacity .15s;
}
.row--lang.on .row__check { opacity: 1; }
.row--lang.on .row__title { color: var(--text); }

/* ===== Referral ===== */
.card--ref { flex-direction: row; align-items: center; gap: 12px; }
.ref-link {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px; color: var(--text); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row--static { pointer-events: none; }
.row__icon b { font-size: 14px; font-weight: 700; color: #fff; }
.row__icon--yellow b { color: #0a0a0c; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--text);
  padding: 10px 16px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50; border: 1px solid var(--line);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Theme toggle ===== */
.row--toggle { cursor: pointer; }
.row--toggle .switch { flex-shrink: 0; }

/* ===== Phone breakpoint tweaks ===== */
@media (max-width: 360px) {
  .seg { font-size: 13px; padding: 0 8px; }
  .h2 { font-size: 20px; }
  .profile__name { font-size: 19px; }
}
