:root {
  --space: #000000;
  --panel: rgba(255, 255, 255, .035);
  --panel-hi: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .09);
  --starlight: #f2f2f7;
  --dust: #8b8ca0;
  --streak: #ff1f78;
  --streak-glow: rgba(255, 31, 120, .35);
  --r-lg: 22px;
  --r-md: 14px;
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-t: var(--tg-content-safe-area-inset-top, 0px);
  --tabbar-h: 68px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--space); color: var(--starlight); }
body {
  font-family: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--streak); outline-offset: 3px; }
p { margin: 0; }
.muted { color: var(--dust); font-size: 15px; }

/* Звёздное небо, как на логотипе */
.sky {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 78% 12%, #fff, transparent),
    radial-gradient(1.4px 1.4px at 88% 44%, #fff, transparent),
    radial-gradient(1px 1px at 30% 62%, rgba(255,255,255,.8), transparent),
    radial-gradient(1px 1px at 64% 78%, rgba(255,255,255,.7), transparent),
    radial-gradient(1.3px 1.3px at 8% 88%, #fff, transparent),
    radial-gradient(.8px .8px at 50% 34%, rgba(255,255,255,.6), transparent),
    radial-gradient(.8px .8px at 94% 90%, rgba(255,255,255,.6), transparent);
  opacity: .8;
}

main {
  position: relative; z-index: 1;
  max-width: 520px; margin: 0 auto;
  padding: calc(16px + var(--safe-t)) 20px calc(var(--tabbar-h) + 32px + var(--safe-b));
}

.view { display: none; }
.view.is-active { display: block; animation: appear .28s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Главная ---------- */
.hero { position: relative; margin: -16px -20px 0; height: 290px; overflow: hidden; }
.hero-art {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%;
  transform: scale(1.6); transform-origin: 50% 44%;
  -webkit-mask-image: linear-gradient(#000 45%, transparent 82%);
          mask-image: linear-gradient(#000 45%, transparent 82%);
}
.streak { position: absolute; left: 0; right: 0; bottom: 18px; width: 100%; height: 60px; }
.streak path {
  fill: none; stroke: var(--streak); stroke-width: 2; stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--streak-glow));
  stroke-dasharray: 460; stroke-dashoffset: 460;
  animation: draw 1.4s .2s cubic-bezier(.3,.7,.2,1) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.wordmark {
  text-align: center; font-weight: 300; font-size: 15px;
  letter-spacing: .62em; margin: 4px 0 14px; padding-left: .62em;
}
.wordmark span { color: var(--dust); }
.headline {
  font-weight: 400; font-size: 27px; line-height: 1.18; letter-spacing: -.01em;
  text-align: center; margin: 0 auto 26px; max-width: 16em;
}

.status {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px;
}
.status-title { font-size: 19px; font-weight: 500; }
.status-sub { color: var(--dust); margin-top: 4px; }
.status .big { font-size: 56px; font-weight: 300; line-height: 1; letter-spacing: -.02em; }
.status .big small { font-size: 17px; font-weight: 400; color: var(--dust); margin-left: 6px; letter-spacing: 0; }
.status .btn { margin-top: 18px; width: 100%; }
.status .btn + .btn { margin-top: 10px; }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.status.is-live { border-color: rgba(255, 31, 120, .45); box-shadow: 0 0 40px -12px var(--streak-glow); }

.btn-wide { display: block; width: 100%; margin: 0 0 14px; }

.perks { margin-top: 34px; }
.perks h2 { font-size: 22px; font-weight: 500; margin: 0 0 6px; }
.perks ul { list-style: none; padding: 0; margin: 0; }
.perks li { display: flex; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.perks li:last-child { border-bottom: 0; }
.perks svg {
  flex: none; width: 40px; height: 40px; padding: 9px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel);
  fill: none; stroke: var(--starlight); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.perks b { display: block; font-weight: 500; }
.perks span { color: var(--dust); font-size: 15px; }
.perk-link {
  display: inline-block; margin-top: 8px; padding: 0; background: none; border: 0;
  color: var(--streak); font-size: 15px; font-weight: 500;
}

/* ---------- Кнопки ---------- */
.btn {
  border: 0; border-radius: 999px; padding: 15px 22px; font-weight: 500; font-size: 16px;
  transition: transform .12s, opacity .2s, background .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-light { background: var(--starlight); color: #000; box-shadow: 0 0 26px rgba(255,255,255,.18); }
.btn-ghost { background: var(--panel-hi); border: 1px solid var(--line); }

/* ---------- Заголовки разделов ---------- */
.view-head { margin: 8px 0 20px; }
.view-head h2 { font-size: 30px; font-weight: 500; margin: 0 0 6px; letter-spacing: -.01em; }
.view-head p { color: var(--dust); font-size: 15px; }

/* ---------- Тарифы ---------- */
.plans { display: grid; gap: 10px; }
.plan {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px 18px 16px 20px; overflow: hidden;
}
.plan::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px;
  background: var(--streak); box-shadow: 0 0 12px var(--streak-glow);
  transform: scaleY(0); transition: transform .2s;
}
.plan[aria-checked="true"] { background: var(--panel-hi); border-color: rgba(255,255,255,.22); }
.plan[aria-checked="true"]::before { transform: scaleY(1); }
.plan-main { flex: 1; min-width: 0; }
.plan-title { font-size: 18px; font-weight: 500; }
.plan-meta { color: var(--dust); font-size: 14px; }
.plan-price { text-align: right; white-space: nowrap; }
.plan-price b { font-size: 20px; font-weight: 500; display: block; }
.plan-price span { color: var(--dust); font-size: 13px; }
.plan-tag { color: var(--streak); font-size: 13px; font-weight: 500; margin-left: 6px; }

.paybar {
  position: fixed; left: 0; right: 0; z-index: 5;
  bottom: calc(var(--tabbar-h) + 20px + var(--safe-b));
  padding: 0 20px; max-width: 520px; margin: 0 auto;
}
.paybar .btn { width: 100%; }
[data-view="tariffs"] { padding-bottom: 80px; }

/* ---------- Подключение ---------- */
.keybox {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px;
  color: #d9d9e3; word-break: break-all; margin: 14px 0 12px; max-height: 120px; overflow: auto;
}
.steps { counter-reset: step; list-style: none; padding: 0; margin: 26px 0 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 18px 42px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -1px;
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 14px; color: var(--dust);
}
.steps b { font-weight: 500; display: block; }
.steps span { color: var(--dust); font-size: 15px; }
.note { margin-top: 8px; font-size: 14px; color: var(--dust); border-left: 2px solid var(--streak); padding-left: 12px; }

/* ---------- Профиль ---------- */
.me { display: flex; align-items: center; gap: 16px; margin: 12px 0 24px; }
.avatar {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  font-size: 24px; font-weight: 300; border: 1px solid rgba(255,255,255,.3);
  box-shadow: 0 0 22px rgba(255,255,255,.12), inset 0 0 18px rgba(255,255,255,.06);
}
.me-name { font-size: 22px; font-weight: 500; }
.me-id { color: var(--dust); font-size: 14px; }

.block { padding: 20px 0; border-top: 1px solid var(--line); }
.block h3 { margin: 0 0 10px; font-size: 18px; font-weight: 500; }
.promo { display: flex; gap: 8px; }
.promo input {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 13px 18px; outline: none;
}
.promo input:focus { border-color: rgba(255,255,255,.35); }
.promo .btn { padding: 13px 18px; }
.ref-stats { display: flex; gap: 28px; margin: 16px 0; }
.ref-stats strong { display: block; font-size: 32px; font-weight: 300; line-height: 1.1; }
.ref-stats span { color: var(--dust); font-size: 14px; }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; padding: 13px 10px; font-size: 15px; }

.links { display: grid; border-top: 1px solid var(--line); }
.links a, .links button {
  text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 16px 2px; color: var(--starlight); text-decoration: none; font-size: 16px;
  display: flex; justify-content: space-between;
}
.links a::after, .links button::after { content: "›"; color: var(--dust); font-size: 20px; line-height: 1; }
.version { text-align: center; color: #55566a; font-size: 13px; margin-top: 22px; }

/* ---------- Настройки и аккаунты ---------- */
.setting { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.setting h3 { margin-bottom: 4px; }
.switch {
  flex: none; width: 52px; height: 30px; border-radius: 999px; margin-top: 2px; padding: 0;
  background: var(--panel-hi); border: 1px solid var(--line); position: relative; transition: background .2s, border-color .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--dust); transition: transform .2s, background .2s;
}
.switch[aria-checked="true"] { background: rgba(255,31,120,.22); border-color: rgba(255,31,120,.6); }
.switch[aria-checked="true"]::after { transform: translateX(22px); background: var(--streak); box-shadow: 0 0 10px var(--streak-glow); }

.acc { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.acc svg {
  flex: none; width: 38px; height: 38px; padding: 8px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  fill: none; stroke: var(--starlight); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round;
}
.acc-main { flex: 1; min-width: 0; }
.acc-main b { display: block; font-weight: 500; }
.acc-main span { color: var(--dust); font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-state { color: var(--dust); font-size: 14px; }
.acc-action { background: none; border: 0; color: var(--streak); font-weight: 500; font-size: 15px; padding: 6px 0; }
.email-flow { margin-top: 6px; display: grid; gap: 10px; }
.email-flow > * { min-width: 0; }
.promo .btn { white-space: nowrap; }

.logout {
  display: block; margin: 22px auto 0; background: none; border: 0; color: var(--dust); font-size: 15px; padding: 8px 12px;
}
.logout:hover { color: var(--starlight); }
body.in-telegram .web-only, body:not(.in-telegram) .tg-only { display: none !important; }

/* ---------- Вход ---------- */
body.is-guest .tabbar { display: none; }
body.is-guest main { padding-bottom: 40px; }
.login { max-width: 380px; margin: 0 auto; text-align: center; padding-top: 12px; }
.login-art { width: 180px; height: 180px; object-fit: cover; border-radius: 50%; margin-bottom: 8px; }
.login h2 { font-size: 26px; font-weight: 500; margin: 0 0 6px; }
.login > .muted { margin-bottom: 24px; }
.login-wait { margin-top: 12px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dust); font-size: 14px; margin: 26px 0 16px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field {
  display: block; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 14px 18px; outline: none; margin-bottom: 10px; text-align: center;
}
.field:focus { border-color: rgba(255,255,255,.35); }

/* ---------- Нижняя навигация ---------- */
.tabbar {
  position: fixed; z-index: 10; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b));
  width: min(calc(100% - 24px), 496px); height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(14, 14, 20, .78); border: 1px solid var(--line); border-radius: 24px;
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.tab {
  background: none; border: 0; color: var(--dust); position: relative;
  display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 12px;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--starlight); }
.tab.is-active::after {
  content: ""; position: absolute; bottom: 7px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--streak); box-shadow: 0 0 8px var(--streak);
}

/* ---------- Уведомление ---------- */
.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(16px + var(--safe-t));
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  background: var(--starlight); color: #000; padding: 11px 18px; border-radius: 999px;
  font-size: 15px; max-width: calc(100% - 40px); text-align: center; transition: .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--streak); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .streak path { stroke-dashoffset: 0; }
}
