:root {
  --telegram-bar: 54px;
}

body {
  padding-top: calc(var(--telegram-bar) + env(safe-area-inset-top));
}

/* ========================= */
/* ?? GLOBAL FIXES + WEBVIEW */
/* ========================= */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding-top: 60px; /* Telegram header offset */
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: background .25s, color .25s;
}

/* Blocking Telegram forced theme overrides */
:root {
  --tg-theme-bg-color: inherit !important;
  --tg-theme-accent-text-color: inherit !important;
  --tg-theme-button-color: inherit !important;
  --tg-theme-button-text-color: inherit !important;
}

/* ========================= */
/* ?? THEMES */
/* ========================= */

body.dark {
  background: radial-gradient(circle at top, #101c31 0, #05070d 60%);
  color: #ffffff;
}

body.light {
  background: #f4f7fb;
  color: #101522;
}

body.light .card,
body.light .plan {
  background: #ffffff;
  color: #0d1724;
  box-shadow: 0 6px 20px rgba(0,0,0,.06);
}

body.dark .card,
body.dark .plan {
  background: #111c2a;
  color: #ffffff;
  box-shadow: 0 14px 32px rgba(0,0,0,.35);
}

/* ========================= */
/* ?? LOADING ANIMATION */
/* ========================= */

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, #00b4ff, #7c5cff, #00e0ff);
  z-index: 999;
  pointer-events: none;
}

body.loading::before {
  animation: load .35s ease-out forwards;
}

@keyframes load {
  from { width: 0; }
  to { width: 100%; }
}

/* ========================= */
/* ?? HEADER */
/* ========================= */

header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10,15,26,.75);
  backdrop-filter: blur(14px);
  z-index: 100;
}

.logo {
  height: 32px;
  cursor: pointer;
}

/* Controls group */
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ========================= */
/* ?? THEME SWITCHER */
/* ========================= */

.theme-toggle {
  width: 56px;
  height: 28px;
  background: #192133;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  position: relative;
  cursor: pointer;
  font-size: 16px;
}

.sun,
.moon {
  user-select: none;
  pointer-events: none;
}

.toggle-ball {
  position: absolute;
  width: 21px;
  height: 21px;
  left: 4px;
  border-radius: 50%;
  background: #0094ff;
  transition: left .25s;
  box-shadow: 0 0 10px rgba(0,180,255,.6);
}

body.light .toggle-ball {
  left: 31px;
}

/* ========================= */
/* ?? LANGUAGE PICKER */
/* ========================= */

.lang-picker {
  position: relative;
}

#lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #192133;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.flag {
  width: 20px;
  height: 20px;
  border-radius: 3px;
}

.lang-list {
  position: absolute;
  top: 42px;
  right: 0;
  background: #192133;
  border-radius: 10px;
  overflow: hidden;
  min-width: 100px;
  box-shadow: 0 14px 32px rgba(0,0,0,.4);
  z-index: 5;
}

.lang-list div {
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  cursor: pointer;
}

.lang-list div:hover {
  background: rgba(0,180,255,.22);
}

.hidden {
  display: none !important;
}

/* ========================= */
/* ?? MAIN */
/* ========================= */

h2 {
  margin: 10px 16px 16px;
  font-size: 20px;
  font-weight: 600;
}

.services {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 14px 20px;
}

.card {
  border-radius: 16px;
  padding: 18px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: .18s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.arrow {
  font-size: 20px;
  color: #00b4ff;
}

/* ========================= */
/* ?? PAGES */
/* ========================= */

.page {
  padding: 0 10px 20px;
}

.page.hidden,
#main-page.hidden {
  display: none;
}

.back {
  margin: 4px 4px 10px;
  padding: 6px 8px;
  background: none;
  border: none;
  color: #00b4ff;
  font-size: 16px;
  cursor: pointer;
}

/* ========================= */
/* ??? SLIDER / CAROUSEL */
/* ========================= */

.carousel {
  display: flex;
  overflow-x: auto;
  gap: 16px;
  scroll-snap-type: x mandatory;
  padding: 4px 4px 14px;
}

.carousel::-webkit-scrollbar {
  height: 4px;
}

.carousel::-webkit-scrollbar-thumb {
  background: rgba(0,180,255,.5);
  border-radius: 999px;
}

/* ========================= */
/* ?? PLAN CARD */
/* ========================= */

.plan {
  flex: 0 0 86%;
  padding: 18px 18px 16px;
  scroll-snap-align: center;
  border-radius: 18px;
  animation: fadeUp .3s ease;
  backdrop-filter: blur(18px);

  /* AirCloud Server Pattern */
  background-image:
    radial-gradient(circle at top left, rgba(0,180,255,.12), transparent 55%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='90'><rect x='8' y='12' width='60' height='18' rx='3' fill='none' stroke='%235b6fff'/><rect x='78' y='12' width='60' height='18' rx='3' fill='none' stroke='%235b6fff'/><circle cx='22' cy='21' r='3' fill='%2300b4ff'/></svg>");
  background-repeat: no-repeat;
  background-position: bottom right;
  background-size: 240px auto;
}

.server-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  margin-bottom: 10px;
}

.plan-title {
  margin: 2px 0 8px;
  font-size: 18px;
  font-weight: 600;
}

.plan ul {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  font-size: 14px;
}

.plan ul li + li {
  margin-top: 4px;
}

/* ========================= */
/* ?? ORDER BUTTON */
/* ========================= */

.order-btn {
  width: 100%;
  padding: 11px 0;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg,#00b4ff,#7c5cff);
  color: white;
  font-size: 15px;
  cursor: pointer;
}

.order-btn:active {
  opacity: .85;
}

/* ========================= */
/* ?? ORDER POPUP */
/* ========================= */

.order-popup {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(7,18,35,.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
}

.order-popup.show {
  animation: popupIn .25s ease forwards;
}

.order-popup.hide {
  animation: popupOut .25s ease forwards;
}

/* ========================= */
/* ?? ANIMATIONS */
/* ========================= */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes popupIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes popupOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, 8px); }
}
/* Fix emoji visibility */
.emoji {
  font-size: 16px;
  display: flex;
  align-items: center;
}

/* Fix arrow icon position */
.arrow-icon {
  margin-left: 3px;
  opacity: .7;
  transition: .2s;
}
#lang-btn:hover .arrow-icon {
  opacity: 1;
}

/* Fix flag size in button */
#lang-btn .flag {
  width: 18px;
  height: 18px;
}

/* ========================= */
/* ?? FIX FOR iOS SAFE AREAS */
/* ========================= */

html, body {
  height: -webkit-fill-available;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  padding-top: calc(env(safe-area-inset-top) + 60px); /* header + iOS notch */
}

/* Fix white bottom bounce */
main, .page {
  min-height: calc(100vh - env(safe-area-inset-bottom) - 60px);
}

/* Prevent content shifting while keyboard opens */
* {
  -webkit-text-size-adjust: 100%;
}

@supports (padding: max(0px)) {
  body {
    padding-bottom: max(env(safe-area-inset-bottom), 16px);
  }
}
.icon,
.arrow-icon {
  width: 16px;
  height: 16px;
  user-select: none;
  pointer-events: none;
}

.arrow-icon {
  margin-left: 3px;
  opacity: .7;
  transition: .2s;
}

#lang-btn:hover .arrow-icon {
  opacity: 1;
}
