/* Чёрно-жёлтая тема в современном стиле: стеклянная плавающая панель вкладок, мягкое свечение фона,
   крупная типографика, кнопки-пилюли, анимации появления и нажатия. Одна тема для сайта и Mini App
   (тема Telegram не используется). Цвет шапки Telegram — BRAND_BG в app.js, страницы /open и /terms —
   routes/pages.py. */
:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f5f5;
  --hint: rgba(255, 255, 255, 0.56);
  --accent: #ffd60a;
  --accent-soft: rgba(255, 214, 10, 0.12);
  --accent-text: #0a0a0a;
  --accent-fill: linear-gradient(180deg, #ffe14d 0%, #ffcc00 100%);
  --link: #ffd60a;
  --ok: #ffd60a;
  --bad: #ff5a4f;
  --radius: 22px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* иначе .row { display: flex } и подобные перебивают атрибут hidden */
::selection { background: rgba(255, 214, 10, 0.35); color: #fff; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
/* мягкое жёлтое свечение за содержимым */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(90% 42% at 50% -6%, rgba(255, 214, 10, 0.16), transparent 70%),
    radial-gradient(70% 40% at 100% 105%, rgba(255, 214, 10, 0.06), transparent 70%);
}

.container { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(108px + env(safe-area-inset-bottom)); }

/* шапка: логотип «Как раньше» (static/brand/logo.png — прозрачный фон, свечение в самой картинке),
   справа — имя пользователя; заголовок страницы остаётся для экранных чтецов */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 16px; }
.brand { display: flex; align-items: center; min-width: 0; }
.brand-logo { display: block; flex: none; width: auto; height: 56px; margin-left: -6px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
h1 { font-size: 24px; line-height: 1.1; font-weight: 800; letter-spacing: -0.025em; margin: 0; }
#who:not(:empty) {
  flex: none;
  max-width: 45%;
  margin: 0;
  padding: 6px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

/* заголовок карточки — подпись-«надстрочник» */
h2 { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hint); margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 20px 0 8px; }
p { margin: 6px 0; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.035));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 24px 48px -28px rgba(0, 0, 0, 0.9);
}
.center { text-align: center; }
.hint { color: var(--hint); font-size: 13px; margin: 6px 0; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.status { font-size: 21px; font-weight: 800; letter-spacing: -0.015em; margin: 0; }
.status.active { color: var(--ok); }
.status.expired, .status.disabled { color: var(--bad); }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; }
.actions { margin-top: 16px; }
.actions .btn { flex: 1 1 auto; }
/* есть пробный период — он главная кнопка, «Выбрать тариф» становится второстепенной */
#trial-btn:not([hidden]) ~ #renew-link { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255, 214, 10, 0.35); }

input {
  font: inherit;
  font-size: 16px;   /* меньше 16px — iOS увеличивает страницу при фокусе на поле, и она так и остаётся */
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
input::placeholder { color: rgba(255, 255, 255, 0.35); }
input:focus { outline: none; border-color: rgba(255, 214, 10, 0.7); box-shadow: 0 0 0 4px rgba(255, 214, 10, 0.14); background: rgba(255, 255, 255, 0.07); }

/* кнопки-пилюли */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-fill);
  color: var(--accent-text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 10px 26px -12px rgba(255, 204, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.15s var(--ease), filter 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.97); filter: brightness(0.95); }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 13px; font-weight: 600; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255, 214, 10, 0.35); }
.btn.danger { background: rgba(255, 90, 79, 0.1); color: var(--bad); box-shadow: inset 0 0 0 1px rgba(255, 90, 79, 0.45); }
.btn:disabled, .btn.disabled { opacity: 0.45; cursor: default; pointer-events: none; box-shadow: none; }
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }

.link { background: none; border: 0; padding: 0; color: var(--hint); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* главная: крупное число дней и полоса срока */
.days { display: flex; align-items: baseline; gap: 10px; }
.days-num {
  font-size: 58px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 32px rgba(255, 214, 10, 0.35);
}
.days-label { color: var(--hint); font-size: 15px; }
.progress { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; overflow: hidden; margin: 16px 0 8px; }
.progress .bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffc300, #ffe45c);
  box-shadow: 0 0 14px rgba(255, 214, 10, 0.55);
  transition: width 0.6s var(--ease);
}

/* пробный период: расход трафика */
.traffic { margin-top: 14px; }
.traffic-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--hint); }
.traffic-num { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.progress.thin { height: 6px; margin: 8px 0 0; }
.progress.low .bar { background: linear-gradient(90deg, #ff5a4f, #ff8a65); box-shadow: 0 0 14px rgba(255, 90, 79, 0.5); }

.device { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.device:first-child { border-top: 0; padding-top: 0; }
.device-info { display: flex; flex-direction: column; min-width: 0; }
.device-info .hint { margin: 2px 0 0; font-size: 12px; }

/* сворачиваемая карточка: <details class="card fold"> с заголовком в <summary> */
.fold > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; text-transform: none; color: var(--text); }
.fold > summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin: -4px 4px 0 0;
  border-right: 2px solid var(--hint);
  border-bottom: 2px solid var(--hint);
  transform: rotate(45deg);
  transition: transform 0.25s var(--ease), margin 0.25s var(--ease);
}
.fold[open] > summary { margin-bottom: 10px; }
.fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.steps { margin: 8px 0 14px; padding-left: 22px; }
.steps li { margin: 6px 0; }
.steps li::marker { color: var(--accent); font-weight: 800; }
.steps .link { color: var(--link); }

/* промокод — отдельная карточка-строка в самом верху страницы тарифов */
.card.promo { padding: 8px; border-radius: 22px; }
.card.promo #promo-state { padding: 6px 10px; }
.promo input { text-transform: uppercase; letter-spacing: 0.04em; border-color: transparent; background: transparent; }
.promo input:focus { background: rgba(255, 255, 255, 0.05); }
.promo input::placeholder { text-transform: none; letter-spacing: 0; }
#promo-state { margin: 0; }

/* пока открыта клавиатура, панель вкладок не должна закрывать поле ввода */
body.typing .tabbar { display: none; }

/* тарифы: выбор числа устройств + карточки сроков */
.tiers { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tiers-label { color: var(--hint); font-size: 13px; }
.tiers .seg { flex: 1; margin: 0; }

.periods { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.period {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s var(--ease);
}
.period:active { transform: scale(0.98); }
.period.selected {
  border-color: var(--accent);
  background: rgba(255, 214, 10, 0.1);
  box-shadow: inset 0 0 0 1px var(--accent), 0 14px 30px -18px rgba(255, 214, 10, 0.8);
}
.period-title { font-size: 12px; font-weight: 600; color: var(--hint); }
.period-price { display: flex; flex-direction: column; }
.period-price strong { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.period-price strong + strong { font-size: 13px; font-weight: 700; }
.period-price s { color: var(--hint); font-size: 12px; }
.period-note { font-size: 11px; color: var(--hint); white-space: nowrap; }

.checkout { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
#checkout-summary { margin: 0 0 10px; font-weight: 700; font-size: 15px; }
#checkout-buttons .btn { flex: 1 1 auto; }

.pay-item { padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); font-size: 14px; }
.pay-item:first-child { border-top: 0; padding-top: 0; }
.pay-line { display: flex; justify-content: space-between; gap: 10px; }
.pay-amount { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-meta { color: var(--hint); font-size: 12px; margin-top: 2px; }
#payments > .link { margin-top: 8px; font-size: 13px; }
.pstatus.paid { color: var(--ok); }
.pstatus.pending { color: var(--hint); }
.pstatus.refunded, .pstatus.expired { color: var(--bad); }

/* подключение */
#sub-box label { display: block; margin-bottom: 10px; }
.qr-box { margin-top: 12px; }
.qr-box summary { color: var(--link); font-size: 14px; font-weight: 600; cursor: pointer; }
.qr { display: flex; justify-content: center; margin: 14px 0 4px; }
.qr svg {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  padding: 6px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 40px -20px rgba(255, 214, 10, 0.45);
}
.seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 4px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); border-radius: 16px; }
.card > .seg { margin-bottom: 16px; }
.seg-btn {
  flex: 1;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--hint);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.seg-btn.active { background: var(--accent-fill); color: var(--accent-text); box-shadow: 0 6px 16px -8px rgba(255, 204, 0, 0.8); }
.guide p { margin: 6px 0; }
.guide h3:first-child { margin-top: 0; }
.dl { display: flex; flex-wrap: wrap; gap: 6px; }

#support-line { margin-top: 18px; }

/* плавающая «стеклянная» панель вкладок */
.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  gap: 4px;
  max-width: 440px;
  margin: 0 auto;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background: rgba(24, 24, 24, 0.68);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 7px;
  border-radius: 20px;
  color: var(--hint);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s, background 0.25s var(--ease);
}
.tabbar .ico { display: grid; place-items: center; height: 22px; }
.tabbar .ico svg { width: 22px; height: 22px; }
.tabbar a.active { color: var(--accent); background: var(--accent-soft); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border: 1px solid rgba(255, 214, 10, 0.4);
  border-radius: 16px;
  background: rgba(30, 30, 30, 0.85);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: #fff;
  font-size: 14px;
  z-index: 20;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.3s var(--ease);
}

/* появление: карточки страницы мягко поднимаются при открытии вкладки */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pulse { 50% { opacity: 0.45; } }
.page > *, #view-login, #view-closed { animation: rise 0.4s var(--ease) both; }
.page > :nth-child(2) { animation-delay: 0.05s; }
.page > :nth-child(3) { animation-delay: 0.1s; }
.page > :nth-child(4) { animation-delay: 0.15s; }
#view-loading p { animation: pulse 1.4s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
