/* Sentra VPN Mini App — собственный дизайн (тёмный, неоновый градиент).
   Без сборки: один файл, системные шрифты, Telegram-переменные как акценты. */

:root {
  --bg: #0b0e14;
  --bg-2: #10141d;
  --card: rgba(255, 255, 255, .045);
  --card-solid: #151a24;
  --line: rgba(255, 255, 255, .08);
  --text: #eef1f6;
  --muted: #8b93a3;
  --accent-1: #4f7cff;   /* индиго */
  --accent-2: #38d9f5;   /* циан  */
  --grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --ok: #2fd575;
  --warn: #ffb454;
  --danger: #ff5c5c;
  --r: 18px;
  --r-sm: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
  overflow-x: hidden;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.boot { padding: 48px; text-align: center; color: var(--muted); }

/* Фоновое свечение */
.bg-fx {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(420px 300px at 85% -60px, rgba(79, 124, 255, .22), transparent 70%),
    radial-gradient(380px 260px at -10% 30%, rgba(56, 217, 245, .10), transparent 70%),
    radial-gradient(500px 400px at 50% 110%, rgba(79, 124, 255, .12), transparent 70%);
}

/* ── Шапка ─────────────────────────────────────────── */
header.appbar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  /* Верхний inset — на случай полноэкранного режима Telegram под вырезом. */
  padding: max(14px, env(safe-area-inset-top, 0px)) 16px 14px;
  background: rgba(11, 14, 20, .75);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; display: flex; align-items: center; gap: 7px; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { flex: none; }
/* Эмодзи-логотип: без градиентного clip'а, иначе эмодзи станет силуэтом. */
.brand-mark { font-size: 19px; display: inline-flex; align-items: center; }
.brand-logo { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; display: block; }
.brand-sub { color: var(--muted); font-weight: 500; font-size: 13px; margin-top: 2px; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.chip b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

main.view { flex: 1; padding: 16px; padding-bottom: 96px; position: relative; z-index: 1; }
.fade-in { animation: fadeUp .25s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Живой фон (canvas из fx.js) — за контентом, поверх свечения. */
#fxCanvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .55; }

/* Каскадное появление карточек и кнопок при смене вкладки. */
.fade-in > .card, .fade-in > .btn, .fade-in > .list-item {
  animation: fadeUp .34s ease both;
}
.fade-in > *:nth-child(2) { animation-delay: .04s; }
.fade-in > *:nth-child(3) { animation-delay: .08s; }
.fade-in > *:nth-child(4) { animation-delay: .12s; }
.fade-in > *:nth-child(5) { animation-delay: .16s; }
.fade-in > *:nth-child(6) { animation-delay: .20s; }
.fade-in > *:nth-child(n+7) { animation-delay: .24s; }

/* ── Карточки ──────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; margin-bottom: 12px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.card h2 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 13px; }
.card.hero {
  background:
    linear-gradient(160deg, rgba(79, 124, 255, .16), rgba(56, 217, 245, .05) 55%, transparent),
    var(--card);
  border-color: rgba(79, 124, 255, .25);
}
.card.glow { position: relative; overflow: hidden; }
.card.glow::after {
  content: ''; position: absolute; top: -40%; right: -20%; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(56, 217, 245, .18), transparent 70%); pointer-events: none;
}

/* Строка «подпись — значение». Содержимое приходит от пользователя и бэкенда
   (почта, имя устройства, название страны, подпись кнопки), поэтому ширина
   заранее неизвестна. Правила:
   - строка переносится, если содержимое не помещается: лучше вторая строка,
     чем выезд за карточку;
   - значение справа сжимается и рвётся где угодно — там бывают длинные строки
     без пробелов (почта, имя устройства);
   - подпись слева и кнопка сжимаются, но не уже самого длинного слова
     (min-width:auto) и не рвутся по буквам — иначе «Email» превращался
     в вертикальный столбик из букв;
   - бейджи, тумблер и полоса прогресса не сжимаются вовсе. */
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; flex-wrap: wrap; }
.row + .row { border-top: 1px solid var(--line); }
.row > * { min-width: 0; overflow-wrap: anywhere; }
.row > .muted, .row > .btn { min-width: auto; flex: 0 1 auto; overflow-wrap: normal; }
.row > .badge, .row > .switch, .row > .progress { flex: none; overflow-wrap: normal; }
.muted { color: var(--muted); }
.big { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── Кнопки ────────────────────────────────────────── */
button.btn {
  width: 100%; border: none; border-radius: 14px; padding: 15px;
  background: var(--grad); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 22px rgba(79, 124, 255, .35);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s;
}
button.btn:active { transform: scale(.985); }
button.btn.secondary { background: var(--card-solid); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
button.btn.ghost { background: transparent; color: var(--accent-2); border: 1px solid var(--line); box-shadow: none; }
button.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 92, 92, .35); box-shadow: none; }
button.btn:disabled { opacity: .45; box-shadow: none; }
button.btn.sm { width: auto; padding: 9px 15px; font-size: 13px; border-radius: 11px; }

/* ── Бейджи, статусы ───────────────────────────────── */
.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(47, 213, 117, .4); background: rgba(47, 213, 117, .08); }
.badge.off { color: var(--muted); }
.badge.warn { color: var(--warn); border-color: rgba(255, 180, 84, .4); }
.badge.grad { border: none; background: var(--grad); color: #fff; font-weight: 600; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(47, 213, 117, .8); animation: pulseDot 2s ease-in-out infinite; }
.status-dot.off { background: var(--muted); }
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 6px rgba(47, 213, 117, .5); }
  50% { box-shadow: 0 0 14px rgba(47, 213, 117, .95); }
}

/* ── Сегменты (уровни тарифа) ──────────────────────── */
.tiers { display: flex; gap: 8px; }
.tiers button {
  flex: 1; min-width: 0; padding: 13px 6px 11px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card-solid); color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: border-color .15s, background .15s;
}
.tiers button .t-ic { font-size: 20px; }
/* Названия тарифов приходят из админки и могут быть длинными — подпись
   ужимается и обрезается, а не ломает ширину соседних сегментов. */
.tiers button .t-name,
.tiers button .t-price { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiers button .t-name { font-weight: 700; font-size: clamp(12px, 3.4vw, 13px); }
.tiers button .t-price { font-size: 11px; color: var(--muted); }
.tiers button.active {
  border-color: transparent;
  background:
    linear-gradient(var(--card-solid), var(--card-solid)) padding-box,
    var(--grad) border-box;
  border: 1px solid transparent;
  box-shadow: 0 4px 18px rgba(79, 124, 255, .25);
}
.tiers button.active .t-price { color: var(--accent-2); }

/* ── Переключатель платформ (инструкции) ───────────── */
/* Своя сетка, а не .tiers: там подпись с эмодзи не помещается в одну строку
   на узких экранах и кнопки получаются разной высоты. Здесь иконка и подпись
   на отдельных строках, колонки равные. */
.os-tabs {
  display: grid;
  /* Строго одна строка равных колонок (--os-count проставляет guide.js): при
     auto-fit последняя платформа срывалась на второй ряд, и высота блока
     менялась — ровно то «скакание», от которого уходим. Узость добирается
     ужиманием подписи, а не переносом. */
  grid-template-columns: repeat(var(--os-count, 4), minmax(0, 1fr));
  gap: 8px;
}
.os-tabs button {
  min-width: 0; padding: 10px 4px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card-solid); color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: border-color .15s, background .15s;
}
.os-tabs .os-ic { font-size: 20px; line-height: 1; }
.os-tabs .os-name {
  font-weight: 700; font-size: clamp(11px, 3.1vw, 13px); line-height: 1.2;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.os-tabs button.active {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--card-solid), var(--card-solid)) padding-box,
    var(--grad) border-box;
  box-shadow: 0 4px 18px rgba(79, 124, 255, .25);
}

/* ── Слайдеры ──────────────────────────────────────── */
.slider-block { margin-top: 14px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.slider-head .sl-title { font-size: 13px; color: var(--muted); }
.slider-head .sl-value { font-weight: 700; font-size: 14px; }
input[type="range"] {
  width: 100%; margin: 10px 0 2px; appearance: none; -webkit-appearance: none; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-1) var(--fill, 0%), rgba(255,255,255,.12) var(--fill, 0%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; margin-top: -9px;
  background: #fff; border: 3px solid var(--accent-1);
  box-shadow: 0 2px 10px rgba(79, 124, 255, .5);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(255,255,255,.12); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent-1); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent-1);
}
.slider-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 0 2px; }

/* ── Тумблер (автопродление) ───────────────────────── */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, .14); transition: background .2s;
}
.switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.switch input:checked + i { background: var(--grad); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ── Итог покупки ──────────────────────────────────── */
.price-panel {
  margin-top: 16px; border-radius: var(--r); padding: 16px;
  background: linear-gradient(160deg, rgba(47, 213, 117, .10), transparent 60%), var(--card);
  border: 1px solid rgba(47, 213, 117, .25);
}
.price-panel .row { padding: 6px 0; }
.price-panel .total { font-size: 26px; font-weight: 800; color: var(--ok); display: inline-block; }
.price-panel .total.pulse { animation: pricePop .28s ease; }
@keyframes pricePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.09); }
  100% { transform: scale(1); }
}
.strike { text-decoration: line-through; color: var(--muted); font-size: 14px; margin-right: 8px; }

/* ── Списки/строки ─────────────────────────────────── */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  margin-bottom: 8px; cursor: pointer; color: var(--text); width: 100%; text-align: left; font-size: 14px;
}
.list-item .li-ic { font-size: 18px; width: 24px; text-align: center; flex: none; }
.list-item .li-arrow { margin-left: auto; color: var(--muted); flex: none; padding-left: 4px; }

.tx { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.tx + .tx { border-top: 1px solid var(--line); }
.tx-ic {
  width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--card-solid); border: 1px solid var(--line); flex: none;
}
.tx-body { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.tx-date { font-size: 12px; color: var(--muted); }
.tx-amount { font-weight: 700; white-space: nowrap; }
.tx-amount.plus { color: var(--ok); }
.tx-amount.minus { color: var(--text); }

/* ── Аватар ────────────────────────────────────────── */
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.profile-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
/* Имя и @username рядом с аватаром — длинное имя распирало карточку на узких
   экранах (аватар фиксирован, ужиматься может только текстовая колонка). */
.profile-head > div { min-width: 0; overflow-wrap: anywhere; }

/* ── Поля ──────────────────────────────────────────── */
input.field, select.field, textarea.field {
  width: 100%; padding: 13px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); font-size: 15px; outline: none;
  font-family: inherit; resize: vertical;
}
input.field:focus, textarea.field:focus { border-color: var(--accent-1); }

/* ── Прогресс срока подписки ───────────────────────── */
.progress {
  height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .10); overflow: hidden;
}
.progress i {
  display: block; height: 100%; border-radius: 999px; background: var(--grad);
  transition: width .6s ease;
}
/* Квота трафика на исходе / исчерпана */
.progress.warn i { background: var(--warn); }
.progress.danger i { background: var(--danger); }

/* Крупные шаги в инструкциях */
ol.big-steps { font-size: 14px; color: var(--text); }
ol.big-steps li { margin: 8px 0; }

/* ── Страны/локации ────────────────────────────────── */
.country { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* Название страны и подпись под ним — единственное, что можно сжать в строке. */
.country > div { min-width: 0; overflow-wrap: anywhere; }
img.flag { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--line); }
.flag-ph { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--card-solid); border: 1px solid var(--line); flex: none; font-size: 20px; line-height: 1; }
.proto-badges { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; flex: none; max-width: 45%; }
.proto-badges .badge { color: var(--accent-2); border-color: rgba(56, 217, 245, .3); }
/* На узком экране бейджи протоколов съедали половину строки, и название страны
   вытягивалось в столбик по одному слову. Уводим бейджи под название. */
@media (max-width: 430px) {
  .srv-row { flex-wrap: wrap; }
  .srv-row .country { flex: 1 1 100%; }
  .srv-row .proto-badges { max-width: 100%; justify-content: flex-start; margin-top: 8px; }
}
.copy { display: flex; gap: 8px; align-items: center; }
.copy input { flex: 1; min-width: 0; }
.copy .btn { flex: none; }

/* ── QR/импорт ─────────────────────────────────────── */
.qr { display: flex; justify-content: center; padding: 14px; background: #fff; border-radius: var(--r-sm); }
/* Фиксированные 190px не помещались в узкий webview (≈280px с отступами) —
   QR должен ужиматься, оставаясь квадратным. */
.qr img { width: min(190px, 100%); height: auto; aspect-ratio: 1; }
.links a { display: flex; align-items: center; gap: 8px; padding: 11px 0; color: var(--accent-2); text-decoration: none; border-top: 1px solid var(--line); font-size: 14px; }
.links a:first-of-type { border-top: none; }
ol.steps { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
ol.steps li { margin: 4px 0; }

/* ── Нижняя навигация ──────────────────────────────── */
nav.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 560px; margin: 0 auto; z-index: 6;
  display: flex; gap: 2px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 14, 20, .82);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
nav.tabbar button {
  flex: 1; background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; align-items: center;
  padding: 7px 0 5px; border-radius: 13px; font-size: 11px; font-weight: 600;
  transition: color .15s, background .15s;
}
nav.tabbar button .ic svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
nav.tabbar button.active { color: #fff; background: rgba(79, 124, 255, .16); }
nav.tabbar button.active .ic svg { stroke: var(--accent-2); }
nav.tabbar button.active .ic { animation: tabBounce .3s ease; }
@keyframes tabBounce {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ── Конфетти (fx.js) ──────────────────────────────── */
.confetti { position: fixed; left: 50%; top: 45%; z-index: 60; pointer-events: none; }
.confetti i {
  position: absolute; width: 8px; height: 12px; border-radius: 2px; opacity: 0;
  animation: confettiFly 1.1s cubic-bezier(.2, .6, .3, 1) both;
}
@keyframes confettiFly {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* Уважение к prefers-reduced-motion: гасим декоративные анимации. */
@media (prefers-reduced-motion: reduce) {
  .fade-in, .fade-in > .card, .fade-in > .btn, .fade-in > .list-item { animation: none; }
  .status-dot.on, nav.tabbar button.active .ic, .price-panel .total.pulse { animation: none; }
  .skel-line { animation: none; }
}

/* ── Шторка (bottom sheet) ─────────────────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  background: var(--card-solid); border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: none;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease;
  /* dvh, а не vh: на мобильных с исчезающей адресной строкой vh считается по
     максимальной высоте, и низ шторки уезжал под край экрана. */
  max-height: 86vh; max-height: 86dvh; overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--card); color: var(--muted); cursor: pointer; font-size: 13px;
}
.sheet-body h2 { margin: 4px 0 12px; font-size: 17px; }
.doc-html { font-size: 14px; color: var(--text); overflow-wrap: break-word; }
.doc-html h1 { font-size: 18px; }

/* ── Пресеты сумм ──────────────────────────────────── */
/* auto-fit вместо жёстких трёх колонок: на очень узком экране пресеты
   переносятся на вторую строку, а не сплющиваются в нечитаемые полоски. */
.amounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; margin: 10px 0; }
.amounts button {
  padding: 12px 4px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); font-weight: 700; cursor: pointer; font-size: 14px;
}
.amounts button.active { border-color: var(--accent-1); background: rgba(79, 124, 255, .12); color: #fff; }

/* ── Тост/лоадеры ──────────────────────────────────── */
.toast {
  /* Над плавающим таббаром с учётом нижнего inset, иначе на iPhone тост
     наезжал на кнопки навигации. */
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(6px);
  background: rgba(21, 26, 36, .96); border: 1px solid var(--line); color: #fff;
  padding: 11px 18px; border-radius: 13px; font-size: 14px; z-index: 50; max-width: 90%;
  opacity: 0; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.notice { padding: 48px 24px; text-align: center; color: var(--muted); }
.spin { padding: 34px; text-align: center; }
.loader {
  width: 26px; height: 26px; border-radius: 50%; display: inline-block;
  border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent-1);
  animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
.err { color: var(--danger); }

/* Недоступные серверы в списке локаций (health-check на бэкенде). */
.srv-offline { color: var(--danger); }

/* ── Бенефиты уровня тарифа (#3) ───────────────────── */
/* Пункты «что даёт уровень» появляются каскадом при каждой смене тарифа
   (delay проставляет subscribe.js через style). */
.benefits { margin-top: 12px; display: grid; gap: 6px; }
.benefit {
  display: flex; align-items: center; gap: 10px; font-size: 13.5px;
  padding: 8px 12px; border-radius: 12px;
  background: rgba(79, 124, 255, .08); border: 1px solid rgba(79, 124, 255, .14);
  animation: benefitIn .38s var(--spring) both;
}
.benefit .b-ic { font-size: 16px; flex: none; }
@keyframes benefitIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }

.skel { pointer-events: none; }
.skel-line {
  height: 13px; border-radius: 7px; margin: 9px 0;
  background: linear-gradient(90deg, rgba(255,255,255,.06) 25%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.06) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
.skel-line.w60 { width: 60%; } .skel-line.w90 { width: 90%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Онбординг первого входа ───────────────────────── */
/* Адаптивность: .onboarding — фон-градиент на весь экран (100dvh, учитывает
   динамическую высоту мобильных браузеров и любой размер окна десктопа), а весь
   контент — в колонке .ob-inner с общим max-width, центрированной по горизонтали.
   Так экран корректно выглядит и на узком телефоне, и на широком/низком десктопе. */
.onboarding {
  position: fixed; inset: 0; z-index: 60;
  height: 100vh; height: 100dvh;
  display: flex;
  user-select: none; -webkit-user-select: none;
  background:
    radial-gradient(60vw 40vh at 85% -6vh, rgba(79, 124, 255, .28), transparent 70%),
    radial-gradient(55vw 36vh at -10% 35%, rgba(56, 217, 245, .14), transparent 70%),
    var(--bg);
  animation: obIn .3s ease both;
}
@keyframes obIn { from { opacity: 0; } to { opacity: 1; } }
.onboarding.ob-out { animation: obOut .26s ease both; }
@keyframes obOut { from { opacity: 1; } to { opacity: 0; transform: scale(1.02); } }

.ob-inner {
  /* width задаёт горизонталь (центрируется margin:0 auto), высоту даёт
     cross-axis stretch родителя (.onboarding — flex). flex:1 не используем:
     с margin:auto он обнулил бы grow и колонка схлопнулась бы по контенту. */
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  min-height: 0; display: flex; flex-direction: column;
}

.ob-skip {
  position: absolute; top: max(16px, env(safe-area-inset-top, 0px)); right: 16px; z-index: 2;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}

.ob-viewport { flex: 1; min-height: 0; overflow: hidden; display: flex; cursor: grab; }
.ob-viewport.dragging { cursor: grabbing; }
.ob-track {
  /* min-width:0 обязателен: по умолчанию flex-элемент не сжимается ниже своего
     контента (min-width:auto), трек раздувается до суммы слайдов, а их ширина
     в процентах считается уже от раздутого трека. Ширина слайда переставала
     совпадать с .ob-viewport.clientWidth, по которому JS считает сдвиг, — и
     контент уезжал за край тем сильнее, чем больше слайдов. */
  flex: 1; min-width: 0; display: flex; align-items: stretch; will-change: transform;
  /* iOS-пружина: быстрый разгон, мягкое затухание. Во время drag транзишен
     снимается инлайном (style.transition='none') — палец ведёт напрямую. */
  transition: transform .42s cubic-bezier(.32, .72, .28, 1);
}
.ob-slide {
  /* Ровно одна ширина вьюпорта: не растём, не сжимаемся. */
  flex: 0 0 100%; width: 100%; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  /* Флюидные отступы + прокрутка на низких экранах: контент не обрежется. */
  padding: clamp(20px, 6vh, 48px) clamp(20px, 6vw, 36px) clamp(16px, 3vh, 24px);
  overflow-y: auto; gap: 0;
}
/* Каскадное появление контента активного слайда (класс ob-live вешает JS). */
.ob-slide .ob-icon, .ob-slide h2, .ob-slide p, .ob-slide .ob-steps { opacity: 0; }
.ob-slide.ob-live .ob-icon { animation: fadeUp .4s cubic-bezier(.32, .72, .28, 1) both; }
.ob-slide.ob-live h2 { animation: fadeUp .4s cubic-bezier(.32, .72, .28, 1) .06s both; }
.ob-slide.ob-live p { animation: fadeUp .4s cubic-bezier(.32, .72, .28, 1) .12s both; }
.ob-slide.ob-live .ob-steps { animation: fadeUp .4s cubic-bezier(.32, .72, .28, 1) .18s both; }
.ob-icon {
  width: clamp(72px, 20vh, 96px); height: clamp(72px, 20vh, 96px); border-radius: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(34px, 9vh, 44px); margin-bottom: clamp(16px, 3.4vh, 26px); flex: none;
  background: linear-gradient(160deg, rgba(79, 124, 255, .25), rgba(56, 217, 245, .12));
  border: 1px solid rgba(79, 124, 255, .35);
  box-shadow: 0 14px 44px rgba(79, 124, 255, .28);
  animation: obFloat 3.2s ease-in-out infinite;
}
@keyframes obFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.ob-slide h2 { margin: 0 0 12px; font-size: clamp(19px, 5.4vw, 24px); line-height: 1.25; letter-spacing: -.3px; }
.ob-slide p { margin: 0; color: var(--muted); font-size: clamp(14px, 3.8vw, 16px); line-height: 1.6; max-width: 360px; }
.ob-slide img.ob-logo {
  width: clamp(80px, 22vh, 108px); height: clamp(80px, 22vh, 108px); border-radius: 26px;
  object-fit: cover; margin-bottom: clamp(16px, 3.4vh, 26px); flex: none;
  box-shadow: 0 14px 44px rgba(79, 124, 255, .28);
  animation: obFloat 3.2s ease-in-out infinite;
}

.ob-footer { padding: clamp(12px, 2.4vh, 16px) clamp(20px, 6vw, 24px) calc(clamp(16px, 3vh, 24px) + env(safe-area-inset-bottom, 0px)); }
.ob-dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 16px; }
.ob-dots i {
  width: 7px; height: 7px; border-radius: 999px; background: rgba(255, 255, 255, .18);
  transition: width .25s ease, background .25s ease;
}
.ob-dots i.active { width: 22px; background: var(--grad); }
.ob-dots i { cursor: pointer; }

/* Онбординг после покупки: чек-анимация + шаги. */
.ob-check { margin-bottom: 22px; }
.ob-check svg { width: 96px; height: 96px; }
.ob-check circle {
  fill: none; stroke: var(--ok); stroke-width: 2.5; opacity: .9;
  stroke-dasharray: 151; stroke-dashoffset: 151;
  animation: obDraw .5s cubic-bezier(.32, .72, .28, 1) .1s forwards;
}
.ob-check path {
  fill: none; stroke: var(--ok); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: obDraw .35s cubic-bezier(.32, .72, .28, 1) .5s forwards;
}
@keyframes obDraw { to { stroke-dashoffset: 0; } }
.ob-purchase .ob-check { opacity: 0; }
.ob-purchase .ob-live .ob-check { animation: fadeUp .4s cubic-bezier(.32, .72, .28, 1) both; opacity: 1; }
.ob-plan {
  display: inline-block; margin: 0 0 4px; padding: 5px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--text);
}
.ob-steps { margin-top: 18px; text-align: left; max-width: 360px; width: 100%; }
.ob-step {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 0; font-size: 14px; color: var(--text); line-height: 1.45;
}
.ob-step + .ob-step { border-top: 1px solid var(--line); }
.ob-step span {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; margin-top: 1px;
}
.ob-footer .btn + .btn { margin-top: 10px; }

/* ── iOS-полировка ─────────────────────────────────── */
:root { --spring: cubic-bezier(.32, .72, .28, 1); }

/* Переходы экранов и каскад — на пружинной кривой вместо линейного ease. */
.fade-in { animation: fadeUp .32s var(--spring) both; }
.fade-in > .card, .fade-in > .btn, .fade-in > .list-item {
  animation: fadeUp .38s var(--spring) both;
}

/* Нажатие как в iOS: интерактивные элементы мягко сжимаются под пальцем. */
.list-item, .card { transition: transform .18s var(--spring), background .18s ease; }
.list-item:active { transform: scale(.98); }
button.btn { transition: transform .18s var(--spring), box-shadow .18s ease, opacity .18s; }
button.btn:active { transform: scale(.97); opacity: .85; }
.chip { transition: transform .18s var(--spring), background .18s; }
.chip:active { transform: scale(.94); }

/* Таббар: плавающая «капсула» с блюром и тенью, как нативный tab bar. */
nav.tabbar {
  left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
  max-width: 536px;
  padding: 6px; gap: 4px;
  border: 1px solid var(--line); border-radius: 24px;
  background: rgba(16, 20, 29, .78);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
}
nav.tabbar button { padding: 8px 0 6px; border-radius: 18px; transition: color .2s, background .2s, transform .18s var(--spring); }
nav.tabbar button:active { transform: scale(.94); }
main.view { padding-bottom: 118px; }

/* Шторка: пружинное появление, скругление и грип как у native sheet. */
.sheet { transition: transform .38s var(--spring); border-radius: 26px 26px 0 0; }
.sheet-grip { width: 36px; height: 5px; background: rgba(255, 255, 255, .22); }

/* Тост — капсула с блюром, появляется пружиной снизу. */
.toast {
  border-radius: 999px; padding: 12px 20px;
  background: rgba(21, 26, 36, .88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transform: translateX(-50%) translateY(14px) scale(.96);
  transition: opacity .28s ease, transform .32s var(--spring);
}
.toast.show { transform: translateX(-50%) translateY(0) scale(1); }

/* ── Появление приложения при запуске (#3) ─────────── */
/* Шапка съезжает сверху, таббар всплывает снизу — один раз при старте
   (элементы создаются в shell() однократно). */
header.appbar { animation: barDown .5s var(--spring) both; }
nav.tabbar { animation: barUp .55s var(--spring) both; animation-delay: .06s; }
@keyframes barDown { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes barUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .ob-track, .sheet, .toast { transition: none; }
  .ob-slide .ob-icon, .ob-slide h2, .ob-slide p, .ob-slide .ob-steps,
  .ob-purchase .ob-check { opacity: 1; animation: none; }
  .ob-check circle, .ob-check path { animation: none; stroke-dashoffset: 0; }
  header.appbar, nav.tabbar, .benefit { animation: none; }
  /* Повтор блока выше по файлу: секция «iOS-полировка» переобъявляет анимацию
     карточек уже ПОСЛЕ первого reduced-motion, и та снова включалась. Правила
     каскада должны стоять последними, иначе отключение не работает. */
  .fade-in, .fade-in > .card, .fade-in > .btn, .fade-in > .list-item { animation: none; }
  .status-dot.on, nav.tabbar button.active .ic, .price-panel .total.pulse { animation: none; }
  .skel-line { animation: none; }
  .ob-icon, .ob-slide img.ob-logo { animation: none; }
}

/* ── Фокус, указатель, мелочи ──────────────────────── */
/* Клавиатурная навигация (Telegram Desktop) раньше не подсвечивалась вообще.
   :focus-visible — только для клавиатуры, палец и мышь кольцо не получают. */
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 12px;
}
nav.tabbar button:focus-visible { outline-offset: -2px; }

/* Ховер — только там, где есть настоящий курсор: на тач-экранах он «залипает»
   после тапа и элемент остаётся подсвеченным. */
@media (hover: hover) and (pointer: fine) {
  .list-item:hover, .card.hoverable:hover { background: rgba(255, 255, 255, .07); }
  .tiers button:hover, .os-tabs button:hover, .amounts button:hover { border-color: rgba(79, 124, 255, .45); }
  button.btn:hover { box-shadow: 0 8px 26px rgba(79, 124, 255, .45); }
  button.btn.secondary:hover, button.btn.ghost:hover { border-color: rgba(79, 124, 255, .45); }
  .chip:hover { background: rgba(255, 255, 255, .09); }
}

::selection { background: rgba(79, 124, 255, .35); color: #fff; }

/* Скроллбар в десктопном Telegram — тонкий, в тон интерфейсу. */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .26); }
::-webkit-scrollbar-track { background: transparent; }

/* Полоса квоты подсвечивается в тон состоянию — «осталось мало» видно боковым
   зрением, без чтения цифр. */
.progress i { box-shadow: 0 0 12px rgba(79, 124, 255, .45); }
.progress.warn i { box-shadow: 0 0 12px rgba(255, 180, 84, .45); }
.progress.danger i { box-shadow: 0 0 12px rgba(255, 92, 92, .45); }

/* ── Адаптивность: узкие и низкие экраны ───────────────
   Дизайн mobile-first в колонке max-width 560px (центрируется на десктопе).
   Ниже — донастройка крайних случаев, чтобы «кривизны» не было ни на одном
   размере: тесные телефоны, низкие/ландшафтные окна, крупные экраны. */

/* Узкие телефоны (≤360px): ужимаем отступы и крупный текст, чтобы ничего
   не выпирало за край и не появлялся горизонтальный скролл. */
@media (max-width: 360px) {
  main.view { padding: 12px; padding-bottom: 118px; }
  .card { padding: 14px; }
  .big { font-size: 25px; }
  .price-panel .total { font-size: 23px; }
  .tiers { gap: 6px; }
  .tiers button { padding: 11px 4px 9px; }
  .tiers button .t-ic { font-size: 18px; }
  .amounts { gap: 6px; }
}

/* Низкие экраны (ландшафт телефона, компактное окно Telegram Desktop):
   гасим «плавание» иконки и поджимаем вертикаль онбординга — контент
   помещается целиком, а если нет — прокручивается внутри слайда. */
@media (max-height: 560px) {
  .ob-icon, .ob-slide img.ob-logo { animation: none; }
  .ob-slide { justify-content: flex-start; padding-top: clamp(16px, 4vh, 28px); }
  .ob-check svg { width: 72px; height: 72px; }
  .ob-dots { margin-bottom: 10px; }
}

/* Крупные экраны: держим приложение читаемой центрированной колонкой,
   не растягивая контент во всю ширину (иначе строки становятся слишком
   длинными). Колонка уже ограничена max-width 560px у #app/таббара/шторки. */
@media (min-width: 620px) {
  body { background: radial-gradient(90vw 90vh at 50% -10%, rgba(79,124,255,.06), transparent 60%), var(--bg); }
}
