/* AVPN cabinet: OLED black and ember orange, the same inside Telegram and in a browser.
   The home screen is a tunnel with orange light at its far end showing the days left;
   motion follows one idea - light flowing through that tunnel.
   No color-mix() and no :has(): iOS 15 WKWebView still runs Telegram on older iPhones. */

:root {
  color-scheme: dark;
  --bg: #000000;
  --card: #0f0f11;
  --card-2: #17171b;
  --text: #f6f1eb;
  --hint: #8c857e;
  --line: rgba(255, 255, 255, .07);
  --accent: #ff7a1a;
  --accent-hi: #ffb04a;
  --accent-rgb: 255, 122, 26;
  --accent-ink: #1a0900;
  --ember: #ff4d3d;
  --danger: #ff5a4f;
  --link: var(--accent);
  --button: var(--accent);
  --button-text: var(--accent-ink);
  --destructive: var(--danger);

  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --tabbar-h: 66px;

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: none;
}

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 16px calc(var(--tabbar-h) + 30px + var(--safe-bottom));
}

h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.25rem; font-weight: 750; letter-spacing: -.01em; margin: 30px 2px 12px; }
h3 { font-size: 1.0625rem; font-weight: 650; }
a { color: var(--link); text-decoration: none; }
.hint { color: var(--hint); font-size: .875rem; }
::selection { background: rgba(var(--accent-rgb), .35); }

/* ---------------------------------------------------------------- boot */

.boot { display: flex; gap: 8px; justify-content: center; padding-top: 38vh; }
.boot span { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); opacity: .25; }

/* ---------------------------------------------------------------- header */

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.wordmark { font-size: 1.375rem; font-weight: 850; letter-spacing: -.045em; }
.wordmark i { font-style: normal; color: var(--accent); }
.avatar {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--card-2); color: var(--accent-hi);
  font-weight: 750; font-size: .9375rem;
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .25);
}

/* ---------------------------------------------------------------- the tunnel */

.tunnel {
  --glow: var(--accent-rgb);
  --glow-hi: 255, 176, 74;
  --glow-ink: var(--accent-ink);
  position: relative;
  isolation: isolate;
  aspect-ratio: 1.12;
  max-height: 460px;
  width: 100%;
  border-radius: 30px;
  overflow: hidden;
  background:
    radial-gradient(55% 50% at 50% 48%, rgba(var(--glow), .42), rgba(var(--glow), 0) 72%),
    radial-gradient(120% 90% at 50% 120%, rgba(var(--glow), .12), rgba(var(--glow), 0) 60%),
    #050302;
  box-shadow: inset 0 0 0 1px rgba(var(--glow), .14);
  color: var(--text);
}
.tunnel[data-state="grace"] { --glow: 255, 77, 61; --glow-hi: 255, 140, 110; --glow-ink: #1d0503; }
.tunnel[data-state="expired"], .tunnel[data-state="none"] { --glow: 120, 112, 104; --glow-hi: 170, 162, 154; --glow-ink: #0c0b0a; }

/* The same rounded frame, smaller and brighter the deeper it sits. */
.ring {
  position: absolute;
  inset: calc(var(--i) * 6.6%) calc(var(--i) * 6%);
  border-radius: calc(30px - var(--i) * 3px);
  border: 1.5px solid rgba(var(--glow), calc(.08 + var(--i) * .1));
  z-index: -1;
}
.ring:nth-child(1) { --i: 0; }
.ring:nth-child(2) { --i: 1; }
.ring:nth-child(3) { --i: 2; }
.ring:nth-child(4) { --i: 3; }
.ring:nth-child(5) { --i: 4; }
.ring:nth-child(6) {
  --i: 5;
  background: linear-gradient(160deg, rgb(var(--glow-hi)), rgb(var(--glow)));
  border-color: rgba(var(--glow-hi), 1);
  box-shadow: 0 0 70px 14px rgba(var(--glow), .5), 0 0 22px 2px rgba(var(--glow-hi), .6);
}

.tunnel-core {
  position: absolute;
  inset: 33% 30%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--glow-ink);
  text-align: center;
}
.tunnel-core strong { font-size: clamp(2.6rem, 13vw, 3.7rem); font-weight: 850; line-height: .9; letter-spacing: -.05em; }
.tunnel-core span { font-size: .8125rem; font-weight: 700; margin-top: 2px; }

.tunnel-head, .tunnel-foot {
  position: absolute; left: 20px; right: 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.tunnel-head { top: 18px; }
.tunnel-foot { bottom: 18px; }
.tunnel-state { font-weight: 750; font-size: .9375rem; }
.tunnel-plan { font-size: .875rem; color: var(--hint); }
.tunnel-until { font-size: .9375rem; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  font-size: .8125rem; font-weight: 650; white-space: nowrap;
}
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--glow)); box-shadow: 0 0 8px rgb(var(--glow)); }

.notice { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--card); font-size: .9375rem; }
.notice.warn { color: var(--accent-hi); box-shadow: inset 3px 0 0 var(--accent); }

/* ---------------------------------------------------------------- cards, lists */

.card { background: var(--card); border-radius: var(--r-lg); padding: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.card + .card { margin-top: 10px; }
.card p + p { margin-top: 8px; }

.rows { margin: 0; padding: 0; list-style: none; background: var(--card); border-radius: var(--r-lg); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.rows > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 16px;
  border: 0; background: none; color: inherit; font: inherit; text-align: left;
  transition: background .18s var(--ease);
}
button.row { cursor: pointer; }
button.row:active { background: var(--card-2); }
.row-icon {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 13px;
  background: rgba(var(--accent-rgb), .1); color: var(--accent);
}
.row-icon svg { width: 22px; height: 22px; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row-sub { display: block; color: var(--hint); font-size: .875rem; }
.row-end { color: var(--hint); font-size: .875rem; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--hint); vertical-align: 1px; }
.dot[data-state="active"] { background: var(--accent); box-shadow: 0 0 7px rgba(var(--accent-rgb), .8); }
.dot[data-state="restricted"], .dot[data-state="missing"], .dot[data-state="grace"] { background: var(--accent-hi); }
.dot[data-state="blocked"] { background: var(--ember); box-shadow: 0 0 7px rgba(255, 77, 61, .8); }
.empty { padding: 26px 16px; text-align: center; color: var(--hint); background: var(--card); border-radius: var(--r-lg); }

/* ---------------------------------------------------------------- buying */

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 14px 12px 12px;
  border: 0; border-radius: var(--r-md);
  background: var(--card); color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font: inherit; text-align: left; cursor: pointer;
  transition: box-shadow .25s var(--ease), background .25s var(--ease), transform .2s var(--ease);
}
.plan[aria-checked="true"] {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .16), rgba(var(--accent-rgb), .04));
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 8px 26px -12px rgba(var(--accent-rgb), .8);
}
.plan:active { transform: scale(.97); }
.plan-n { font-size: 2rem; font-weight: 850; letter-spacing: -.04em; line-height: 1; }
.plan[aria-checked="true"] .plan-n { color: var(--accent-hi); }
.plan-label { font-size: .8125rem; color: var(--hint); margin-top: 2px; }
.plan-price { font-size: .875rem; font-weight: 650; margin-top: 12px; }

/* The pair offer, set apart like the flyer: an orange card with the crossed-out price. */
.bundle {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; margin-top: 14px; padding: 18px 18px 16px;
  border: 0; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--accent-hi), var(--accent) 60%, #ff6a00);
  color: var(--accent-ink); font: inherit; text-align: left; cursor: pointer;
  box-shadow: 0 16px 40px -18px rgba(var(--accent-rgb), .9);
  transition: transform .2s var(--ease), box-shadow .25s var(--ease);
}
.bundle:active { transform: scale(.985); }
.bundle.is-picked { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-hi), 0 18px 44px -16px rgba(var(--accent-rgb), 1); }
.bundle-badge {
  position: absolute; top: -10px; right: 14px;
  padding: 4px 10px; border-radius: 999px;
  background: #0b0704; color: var(--accent-hi);
  font-size: .75rem; font-weight: 800; letter-spacing: .02em;
}
.bundle-price { font-size: 2.6rem; font-weight: 900; letter-spacing: -.05em; line-height: 1; }
.bundle-price small { font-size: 1.4rem; margin-left: 2px; }
.bundle-title { margin-top: 8px; font-size: 1.0625rem; font-weight: 750; }
.bundle-sub { margin-top: 2px; font-size: .875rem; opacity: .8; }
.bundle-sub s { opacity: .75; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-top: 10px; background: var(--card); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); }
.segmented button {
  position: relative;
  padding: 10px 6px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--hint);
  font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.segmented button[aria-checked="true"] { background: var(--card-2); color: var(--text); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .35); }
.save { display: block; font-size: .75rem; font-weight: 750; color: var(--accent); }

.summary { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 18px 4px 12px; }
.summary-total { font-size: 1.85rem; font-weight: 850; letter-spacing: -.03em; line-height: 1; }
.summary-note { color: var(--hint); font-size: .875rem; text-align: right; }

.actions { display: grid; gap: 8px; }

/* ---------------------------------------------------------------- buttons, fields */

.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 18px;
  border: 0; border-radius: var(--r-md);
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform .15s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease);
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-hi), var(--accent) 55%);
  color: var(--button-text);
  box-shadow: 0 10px 28px -12px rgba(var(--accent-rgb), .9);
}
.btn-soft { background: var(--card-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn-plain { min-height: 44px; background: transparent; color: var(--link); font-weight: 650; }
.btn-danger { background: var(--card-2); color: var(--destructive); box-shadow: inset 0 0 0 1px var(--line); }
.btn-block { width: 100%; }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: default; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.field { display: grid; gap: 6px; font-size: .9375rem; color: var(--hint); }
.field + .field { margin-top: 12px; }
.input, select.input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: #08080a; color: var(--text);
  font: inherit; color-scheme: dark;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .15); outline: none; }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline > .input { flex: 1; min-width: 0; }

.code {
  display: block; padding: 12px 14px; border-radius: var(--r-md);
  background: #08080a; box-shadow: inset 0 0 0 1px var(--line);
  font: .8125rem/1.5 ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  overflow-wrap: anywhere; user-select: all;
}

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding-left: 40px; min-height: 28px; counter-increment: step; }
.steps li + li { margin-top: 14px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -1px;
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(var(--accent-rgb), .12); color: var(--accent); font-weight: 750; font-size: .875rem;
}

/* ---------------------------------------------------------------- tab bar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(0, 0, 0, .82);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tabbar-inner { display: flex; width: 100%; max-width: 540px; }
.tab {
  position: relative;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px; border: 0; background: none;
  color: var(--hint); font: inherit; font-size: .6875rem; font-weight: 650; cursor: pointer;
  transition: color .25s var(--ease);
}
.tab svg { width: 24px; height: 24px; transition: transform .35s var(--spring); }
.tab::before {
  content: ""; position: absolute; top: -7px; left: 50%;
  width: 26px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--accent); box-shadow: 0 0 12px 1px rgba(var(--accent-rgb), .9);
  transform: translateX(-50%) scaleX(0);
  transition: transform .35s var(--spring);
}
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"]::before { transform: translateX(-50%) scaleX(1); }
.tab[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); }

/* ---------------------------------------------------------------- sheet */

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 540px; max-height: 88vh; margin: 0 auto;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 16px calc(22px + var(--safe-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--card);
  box-shadow: 0 -1px 0 rgba(var(--accent-rgb), .35), 0 -20px 60px -20px rgba(var(--accent-rgb), .35);
}
.sheet-grip { width: 38px; height: 5px; margin: 0 auto 14px; border-radius: 3px; background: var(--hint); opacity: .4; }
.sheet-title { font-size: 1.25rem; font-weight: 750; margin-bottom: 4px; }
.sheet-sub { color: var(--hint); font-size: .9375rem; margin-bottom: 16px; }
.sheet-panel .card { background: var(--card-2); }

/* ---------------------------------------------------------------- admin */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--card); border-radius: var(--r-md); padding: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.stat b { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.stat:first-child b { color: var(--accent-hi); }
.stat span { color: var(--hint); font-size: .8125rem; }
.check { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* ---------------------------------------------------------------- toast */

#toast {
  position: fixed; left: 50%; z-index: 30;
  bottom: calc(var(--tabbar-h) + 18px + var(--safe-bottom));
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 14px;
  background: var(--card-2); color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .35), 0 12px 36px rgba(0, 0, 0, .6);
  font-size: .9375rem; font-weight: 600;
}
#toast.error { box-shadow: inset 0 0 0 1px rgba(255, 90, 79, .6), 0 12px 36px rgba(0, 0, 0, .6); color: #ffd9d5; }

/* ---------------------------------------------------------------- motion
   One idea throughout: light flowing through the tunnel. All of it goes away with
   prefers-reduced-motion. */

@media (prefers-reduced-motion: no-preference) {
  .boot span { animation: boot 1s infinite var(--ease); }
  .boot span:nth-child(2) { animation-delay: .15s; }
  .boot span:nth-child(3) { animation-delay: .3s; }
  @keyframes boot { 50% { opacity: 1; transform: translateY(-5px); } }

  /* The tunnel opens ring by ring... */
  .tunnel.enter .ring { animation: ring-in .8s var(--ease) both; animation-delay: calc(var(--i) * 80ms); }
  .tunnel.enter .tunnel-core { animation: core-in .7s .5s var(--spring) both; }
  .tunnel.enter .tunnel-head, .tunnel.enter .tunnel-foot { animation: fade-up .6s .7s var(--ease) both; }
  @keyframes ring-in { from { opacity: 0; transform: scale(.78); } }
  @keyframes core-in { from { opacity: 0; transform: scale(.6); } }

  /* ...then light keeps running outward along the rings while the core breathes. */
  .tunnel[data-state="active"] .ring:not(:nth-child(6))::after,
  .tunnel[data-state="grace"] .ring:not(:nth-child(6))::after {
    content: ""; position: absolute; inset: -1.5px; border-radius: inherit;
    border: 1.5px solid rgba(var(--glow-hi), .75);
    opacity: 0;
    animation: flow 3.2s infinite ease-in-out;
    animation-delay: calc((5 - var(--i)) * 260ms + 1.2s);
  }
  @keyframes flow { 0%, 100% { opacity: 0; } 18% { opacity: .9; } 45% { opacity: 0; } }
  .tunnel[data-state="active"] .ring:nth-child(6),
  .tunnel[data-state="grace"] .ring:nth-child(6) { animation: breathe 3.2s 1.2s infinite ease-in-out; }
  .tunnel.enter[data-state="active"] .ring:nth-child(6),
  .tunnel.enter[data-state="grace"] .ring:nth-child(6) { animation: ring-in .8s .4s var(--ease) both, breathe 3.2s 1.2s infinite ease-in-out; }
  @keyframes breathe {
    50% { box-shadow: 0 0 95px 22px rgba(var(--glow), .62), 0 0 30px 4px rgba(var(--glow-hi), .8); }
  }

  /* Views slide in when a tab is switched, list rows follow in a stagger. */
  .view-enter > * { animation: fade-up .45s var(--ease) both; }
  .view-enter > *:nth-child(2) { animation-delay: .04s; }
  .view-enter > *:nth-child(3) { animation-delay: .08s; }
  .view-enter > *:nth-child(4) { animation-delay: .12s; }
  .view-enter > *:nth-child(n+5) { animation-delay: .16s; }
  .view-enter .rows > li { animation: fade-up .45s var(--ease) both; }
  .view-enter .rows > li:nth-child(2) { animation-delay: .06s; }
  .view-enter .rows > li:nth-child(3) { animation-delay: .12s; }
  .view-enter .rows > li:nth-child(4) { animation-delay: .18s; }
  .view-enter .rows > li:nth-child(n+5) { animation-delay: .24s; }
  @keyframes fade-up { from { opacity: 0; transform: translateY(12px); } }

  /* A picked plan's number bumps; the pay button catches a glint of light. */
  .plan.just-picked .plan-n { animation: bump .45s var(--spring); }
  @keyframes bump { 40% { transform: scale(1.18); } }
  .btn-primary::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: skewX(-18deg);
    animation: glint 4.5s 1.5s infinite;
  }
  @keyframes glint { 0% { left: -60%; } 18%, 100% { left: 130%; } }

  .sheet:not([hidden]) .sheet-panel { animation: sheet-up .42s var(--spring); }
  .sheet:not([hidden]) .sheet-backdrop { animation: fade .25s ease-out; }
  .sheet:not([hidden]) .sheet-panel > * { animation: fade-up .4s var(--ease) both; animation-delay: .06s; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  @keyframes fade { from { opacity: 0; } }

  #toast:not([hidden]) { animation: toast-in .45s var(--spring); }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } }
}
