:root {
  --space-top: #07070a;
  --space-bottom: #0b0b14;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-strong: rgba(255, 255, 255, 0.08);
  --glass-line: rgba(0, 240, 255, 0.15);
  --glass-line-strong: rgba(0, 240, 255, 0.45);
  --text: #ffffff;
  --muted: #94a3b8;
  --cyan: #00f0ff;
  --blue: #3b82f6;
  --violet: #a855f7;
  /* Заливка кнопок чуть глубже акцентов, чтобы белый текст читался */
  --button-fill: linear-gradient(120deg, #2563eb 0%, #7c3aed 100%);
  --energy: linear-gradient(120deg, var(--cyan) 0%, var(--blue) 50%, var(--violet) 100%);
  --glow-blue: 0 0 20px rgba(59, 130, 246, 0.3);
  --glow-cyan: 0 0 18px rgba(0, 240, 255, 0.25);
  --radius: 16px;
  --tabbar-height: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--space-top); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background: linear-gradient(180deg, var(--space-top) 0%, var(--space-bottom) 100%) fixed;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Звёзды за всем интерфейсом */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 72% 9%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1.5px 1.5px at 38% 42%, rgba(0, 240, 255, 0.7), transparent),
    radial-gradient(1px 1px at 88% 36%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 22% 71%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 64% 63%, rgba(168, 85, 247, 0.7), transparent),
    radial-gradient(1px 1px at 93% 82%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 47% 88%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 5% 50%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 56% 24%, rgba(255, 255, 255, 0.4), transparent);
  background-size: 360px 520px;
  animation: twinkle 6s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

[hidden] { display: none !important; }

p { margin: 0; }

button { font: inherit; color: inherit; cursor: pointer; }

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.app {
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-height) + 40px + env(safe-area-inset-bottom));
}

/* ---------- Хедер: космос и молнии ---------- */

.hero {
  position: relative;
  overflow: hidden;
  min-height: 188px;
  margin: 0 -16px;
  padding: 16px 16px 52px;
  border-bottom: 1px solid var(--glass-line);
  border-radius: 0 0 28px 28px;
  background:
    radial-gradient(260px 180px at 78% 38%, rgba(0, 240, 255, 0.16), transparent 70%),
    radial-gradient(320px 220px at 18% 10%, rgba(59, 130, 246, 0.22), transparent 70%),
    radial-gradient(360px 240px at 100% 100%, rgba(168, 85, 247, 0.28), transparent 70%),
    linear-gradient(180deg, #0a0a1f 0%, #0d0b22 55%, #0b0b14 100%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

/* Вспышка неба в момент главного разряда */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(240px 200px at 75% 35%, rgba(0, 240, 255, 0.35), transparent 70%);
  opacity: 0;
  pointer-events: none;
  animation: sky-flash 7s linear infinite;
}

.bolts {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.bolt path {
  fill: none;
  stroke: #e0fdff;
  stroke-width: 1.6;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
}

.bolt {
  opacity: 0;
  filter: drop-shadow(0 0 3px var(--cyan)) drop-shadow(0 0 10px rgba(0, 240, 255, 0.8)) drop-shadow(0 0 22px rgba(59, 130, 246, 0.7));
}

.bolt-a { animation: strike 7s linear infinite; }
.bolt-b { animation: strike 9s linear 2.6s infinite; }
.bolt-c { animation: strike 11s linear 5.1s infinite; }

.bolt-c { filter: drop-shadow(0 0 3px var(--violet)) drop-shadow(0 0 12px rgba(168, 85, 247, 0.8)); }

/* Короткий двойной разряд, остальное время небо спокойно */
@keyframes strike {
  0%, 84% { opacity: 0; }
  85% { opacity: 1; }
  86.5% { opacity: 0.15; }
  88% { opacity: 1; }
  92% { opacity: 0.35; }
  96%, 100% { opacity: 0; }
}

@keyframes sky-flash {
  0%, 84% { opacity: 0; }
  85% { opacity: 1; }
  86.5% { opacity: 0.2; }
  88% { opacity: 0.8; }
  96%, 100% { opacity: 0; }
}

.hero-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.brand-bolt {
  width: 17px;
  height: 17px;
  margin: 0 1px;
  fill: var(--cyan);
  filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.9));
}

.brand-accent {
  background: var(--energy);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-title {
  position: relative;
  z-index: 1;
  margin: 44px 0 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-shadow: 0 0 24px rgba(0, 240, 255, 0.25);
}

/* Контент наплывает на нижний край хедера */
.content {
  position: relative;
  z-index: 1;
  margin-top: -32px;
}

h2 { margin: 28px 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lead { margin: 4px 0 18px; color: var(--muted); }

/* ---------- Стекло ---------- */

.card,
.quick-btn,
.plan {
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Первые карточки лежат на хедере: под ними тёмная подложка, чтобы текст не терялся */
.panel > :first-child {
  background-color: rgba(12, 12, 24, 0.55);
}

/* ---------- Подписка ---------- */

.sub-card {
  position: relative;
  overflow: hidden;
  padding: 18px 20px 20px;
}

.sub-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 20px;
  left: 20px;
  height: 1px;
  background: var(--energy);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
}

.sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sub-label { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }
.sub-plan { margin-top: 10px; font-size: 20px; font-weight: 700; }
.sub-text { margin-top: 6px; color: var(--muted); font-size: 15px; }

.sub-days { margin-top: 6px; }

.sub-days-value {
  font-size: 40px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--energy);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub-days-label { color: var(--muted); font-size: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.pill-off {
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
}

/* Активное подключение: пульсирующая энергия */
.pill-ok {
  border: 1px solid rgba(0, 240, 255, 0.4);
  background: rgba(0, 240, 255, 0.08);
  color: var(--cyan);
  animation: pill-glow 2.4s ease-in-out infinite;
}

.pill-ok::before { animation: energy-pulse 1.6s ease-out infinite; }

@keyframes energy-pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.7); }
  100% { box-shadow: 0 0 0 8px rgba(0, 240, 255, 0); }
}

@keyframes pill-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(0, 240, 255, 0.15); }
  50% { box-shadow: 0 0 16px rgba(0, 240, 255, 0.45); }
}

/* Карточки с данными подписки */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.info { padding: 14px; min-width: 0; }

.info-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-top svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.6));
}

.info-label { color: var(--muted); font-size: 12px; letter-spacing: 0.02em; }

.info-value {
  margin-top: 8px;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.info-hint { color: var(--muted); font-size: 12px; }

.info-empty .info-value { color: rgba(148, 163, 184, 0.6); }
.info-empty .info-top svg { stroke: var(--muted); filter: none; opacity: 0.7; }

/* ---------- Быстрые действия ---------- */

.quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 96px;
  padding: 14px 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.quick-btn:active {
  border-color: var(--glass-line-strong);
  background: var(--glass-strong);
  box-shadow: var(--glow-cyan);
}

.quick-btn svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.55));
}

/* ---------- 🧪 Тест и ключ ---------- */

.test-card { margin-top: 10px; padding: 14px; }
.test-status { margin-top: 10px; color: var(--muted); font-size: 14px; text-align: center; }
.test-status.is-error { color: #fca5a5; }

.key-card { margin-top: 10px; padding: 18px; }
.key-title { font-size: 17px; font-weight: 700; }
.key-meta { margin-top: 4px; color: var(--muted); font-size: 14px; }

.qr {
  display: flex;
  justify-content: center;
  margin: 16px auto 0;
  padding: 10px;
  width: max-content;
  max-width: 100%;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: var(--glow-cyan);
}

.qr img { display: block; width: 216px; max-width: 100%; height: auto; image-rendering: pixelated; }

.key-label { margin-top: 16px; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }

.key-link {
  display: block;
  margin-top: 6px;
  padding: 12px;
  max-height: 96px;
  overflow-y: auto;
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--cyan);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}

.key-card .button { margin-top: 12px; }

/* Быстрый импорт в Happ / INCY / v2RayTun */
.import-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.import-row .button { margin-top: 0; min-height: 48px; padding: 10px 6px; font-size: 14px; }

.key-steps {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
}

.key-steps li + li { margin-top: 4px; }

/* ---------- Сообщения ---------- */

.notice { margin-top: 12px; padding: 18px; }
.panel > .notice:first-child { margin-top: 0; }
.notice-title { font-weight: 600; }
.notice-text { color: var(--muted); font-size: 14px; }
.notice-title + .notice-text { margin-top: 4px; }
.notice .button { margin-top: 14px; }

/* ---------- Тарифы ---------- */

.plans { display: grid; gap: 10px; margin-bottom: 16px; }

.plan {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  padding: 16px;
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.plan[aria-checked="true"] {
  border-color: var(--glass-line-strong);
  background: linear-gradient(120deg, rgba(0, 240, 255, 0.08), rgba(168, 85, 247, 0.08));
  box-shadow: var(--glow-cyan), inset 0 0 20px rgba(0, 240, 255, 0.06);
}

.plan-name { font-size: 17px; font-weight: 600; }
.plan-price { font-size: 17px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.plan-monthly { color: var(--muted); font-size: 14px; }
.plan-savings { color: var(--cyan); font-size: 14px; text-align: right; }

.plan-badge {
  grid-column: 1 / -1;
  justify-self: start;
  margin-bottom: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--button-fill);
  box-shadow: var(--glow-blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

/* «Выберите срок» лежит на хедере на вкладке тарифов */
#panel-plans > .lead:first-child {
  margin-top: 0;
  padding: 14px 16px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* ---------- Кнопки ---------- */

.button {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: box-shadow 0.2s ease;
}

.button-primary {
  background: var(--button-fill);
  color: #ffffff;
  box-shadow: var(--glow-blue);
}

.button-primary:active:not(:disabled) {
  box-shadow: 0 0 28px rgba(59, 130, 246, 0.55), 0 0 12px rgba(168, 85, 247, 0.4);
}

.button-primary:disabled {
  border: 1px solid var(--glass-line);
  background: var(--glass);
  color: var(--muted);
  box-shadow: none;
  cursor: default;
}

.button-secondary {
  border: 1px solid var(--glass-line-strong);
  background: rgba(0, 240, 255, 0.06);
  box-shadow: var(--glow-cyan);
}

.status { min-height: 22px; margin-top: 12px; color: var(--muted); font-size: 14px; text-align: center; }

/* ---------- Пустые состояния ---------- */

.empty { padding: 26px 20px; text-align: center; }
.empty-title { font-weight: 600; }
.empty-text { margin-top: 4px; color: var(--muted); font-size: 14px; }
.empty .button { margin-top: 16px; }

/* ---------- Профиль ---------- */

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}

.avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: 1px solid var(--glass-line-strong);
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(168, 85, 247, 0.25));
  box-shadow: var(--glow-cyan);
  color: var(--cyan);
  font-size: 22px;
  font-weight: 700;
}

.profile-name { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.profile-sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.rows { margin: 12px 0 0; padding: 4px 18px; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
}

.row + .row { border-top: 1px solid rgba(0, 240, 255, 0.08); }
.row dt { color: var(--muted); }
.row dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Нижняя панель ---------- */

.tabbar {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 10;
  display: flex;
  justify-content: center;
  max-width: 496px;
  margin: 0 auto;
  padding: 0 6px;
  border: 1px solid var(--glass-line);
  border-radius: 22px;
  background: rgba(11, 11, 20, 0.45);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 24px rgba(59, 130, 246, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tab {
  position: relative;
  flex: 1;
  height: var(--tabbar-height);
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

.tab svg {
  display: block;
  width: 24px;
  height: 24px;
  margin: 0 auto 4px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: filter 0.2s ease;
}

.tab::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 50%;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--energy);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.9), 0 0 20px rgba(168, 85, 247, 0.5);
  transform: translateX(-50%);
  transition: width 0.25s ease;
}

.tab[aria-selected="true"] { color: var(--cyan); }
.tab[aria-selected="true"]::before { width: 36px; }
.tab[aria-selected="true"] svg { filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.8)); }

/* Без анимаций: молнии видны неподвижно и неярко, чтобы хедер не был пустым */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .bolt-a { opacity: 0.55; }
  .bolt-b { opacity: 0.3; }
}
