/* Открыть Курсор — Telegram Mini App. Стиль проекта SPACE VPN. */

:root {
  color-scheme: dark;
  --bg: #07060e;
  --card: #131020;
  --card-hi: #1d1a33;
  --line: #2a2440;
  --text: #efedff;
  --muted: #9c93c4;
  --accent: #7c5cff;
  --accent-2: #4b2fe0;
  --accent-ink: #f4f2ff;
  --grad: linear-gradient(135deg, #8b6cff 0%, #5c3df0 55%, #4b2fe0 100%);
  --ok: #2ee6a8;
  --ok-text: #6df4c0;
  --warn: #ffc24d;
  --warn-text: #ffd27a;
  --err: #ff4d6d;
  --err-text: #ff7a91;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --safe-t: calc(env(safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --pad-x: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --t: 0.15s;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100dvh; overscroll-behavior-y: contain; }
#app { min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.ic { width: 18px; height: 18px; flex: none; }

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

/* ---------- каркас ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(var(--safe-t) + 14px) var(--pad-x) 10px;
}
.title { font-size: 22px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
.title.sm { font-size: 18px; letter-spacing: -0.01em; font-weight: 750; }
.bar { display: flex; align-items: center; gap: 6px; margin-left: -8px; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; flex: none; box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.35), 0 8px 24px -8px rgba(124, 92, 255, 0.5); }
.brand .bt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand .bt2 { font-size: 11px; font-weight: 650; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.brand .bt1 { font-size: 15px; font-weight: 750; line-height: 1.1; overflow-wrap: anywhere; }
.brand span.title { font-size: 22px; }

.content { flex: 1; padding: 8px var(--pad-x) calc(104px + var(--safe-b)); }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 10px;
  padding: 12px var(--pad-x) calc(12px + var(--safe-b));
  background: rgba(7, 6, 14, 0.9);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.center {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  padding: 24px var(--pad-x); text-align: center;
}
.center h2 { font-size: 20px; }
.center p { max-width: 30ch; }
.center .row { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- экран-заставка с логотипом ---------- */
.splash {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  padding: 24px var(--pad-x) calc(40px + var(--safe-b)); text-align: center;
  background:
    radial-gradient(900px 480px at 50% -12%, rgba(124, 92, 255, 0.2), transparent 62%),
    radial-gradient(720px 480px at 50% 112%, rgba(46, 230, 168, 0.08), transparent 60%),
    var(--bg);
}
.splash .logo {
  width: 112px; height: 112px; border-radius: 28px; object-fit: cover; flex: none;
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.4), 0 30px 70px -16px rgba(124, 92, 255, 0.6);
  animation: splash-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.splash .name {
  font-size: 30px; font-weight: 850; letter-spacing: -0.02em; line-height: 1.05;
  background: linear-gradient(180deg, #fbfaff 0%, #cfc4ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: splash-in 0.55s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.splash .sub {
  font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.22em; text-transform: uppercase;
  animation: splash-in 0.55s 0.16s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.splash .prog { margin-top: 10px; animation: splash-in 0.55s 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.splash .prog p { margin-top: 10px; font-size: 13px; color: var(--muted); }
@keyframes splash-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ---------- спиннер ---------- */
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.spinner.xs { width: 16px; height: 16px; border-width: 2px; }
.spinner.dark { border-color: rgba(244, 242, 255, 0.35); border-top-color: var(--accent-ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- кнопки ---------- */
.btn {
  height: 48px; padding: 0 18px; border: 0; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 650; cursor: pointer;
  transition: background var(--t), opacity var(--t), transform var(--t), border-color var(--t), box-shadow var(--t);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.grow { flex: 1; }
.btn.block { width: 100%; }
.btn.primary { background: var(--grad); color: var(--accent-ink); box-shadow: 0 10px 28px -10px rgba(124, 92, 255, 0.6); }
.btn.primary:active:not(:disabled) { background: var(--grad); filter: brightness(0.94); box-shadow: 0 6px 18px -10px rgba(124, 92, 255, 0.5); }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.secondary:active:not(:disabled) { background: var(--card-hi); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:active:not(:disabled) { background: var(--card); }
.btn.danger { color: var(--err-text); border-color: rgba(255, 77, 109, 0.4); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 11px; box-shadow: none; }
.btn.mt { margin-top: 12px; }

.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background var(--t), color var(--t);
}
.icon-btn:active { background: var(--card); color: var(--text); }
.icon-btn.danger:active { color: var(--err-text); }

/* ---------- статистика и вкладки ---------- */
.stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--card); color: var(--muted); font-size: 13px;
  border: 1px solid rgba(124, 92, 255, 0.1);
}
.chip b { color: var(--text); font-weight: 700; }
.chip.ok b { color: var(--ok-text); }
.chip.bad b { color: var(--err-text); }
.chip.lock { background: rgba(255, 194, 77, 0.12); color: var(--warn-text); font-weight: 600; }
.chip .ic { width: 14px; height: 14px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--card); border-radius: 14px; border: 1px solid rgba(124, 92, 255, 0.1); }
.tab {
  height: 38px; border: 0; border-radius: 11px; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 650; cursor: pointer;
  transition: background var(--t), color var(--t);
}
.tab.on { background: rgba(124, 92, 255, 0.18); color: #cfc4ff; }

/* ---------- карточки и списки ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: 16px; padding: 14px; border: 1px solid rgba(124, 92, 255, 0.13); }
.node { cursor: pointer; transition: background var(--t), border-color var(--t); }
.node:active { background: var(--card-hi); border-color: rgba(124, 92, 255, 0.3); }
.node-row { display: flex; gap: 12px; align-items: flex-start; }
.node-main { flex: 1; min-width: 0; display: block; }
.node-name { display: block; font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.node-sub { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; margin-top: 2px; }
.node-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.step-note { color: var(--muted); font-size: 12px; }

.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 6px; flex: none; background: #4a4466; }
.dot.done { background: var(--ok); }
.dot.working { background: var(--accent); animation: pulse-w 1.4s ease-out infinite; }
.dot.error { background: var(--err); animation: pulse-e 1.4s ease-out infinite; }
@keyframes pulse-w { 0% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.55); } 100% { box-shadow: 0 0 0 9px rgba(124, 92, 255, 0); } }
@keyframes pulse-e { 0% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.55); } 100% { box-shadow: 0 0 0 9px rgba(255, 77, 109, 0); } }

.badge { font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: rgba(154, 147, 196, 0.16); color: var(--muted); white-space: nowrap; }
.badge.done { background: rgba(46, 230, 168, 0.14); color: var(--ok-text); }
.badge.working { background: rgba(124, 92, 255, 0.2); color: #cfc4ff; }
.badge.error { background: rgba(255, 77, 109, 0.16); color: var(--err-text); }

.prog { margin-top: 12px; }
.prog-text { margin-top: 8px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.err-box {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-size: 13px;
  background: rgba(255, 77, 109, 0.1); border: 1px solid rgba(255, 77, 109, 0.3);
  color: #ffc3ce; overflow-wrap: anywhere; white-space: pre-wrap;
}
.actions { display: flex; gap: 8px; margin-top: 12px; }

.srv-card { display: flex; align-items: center; gap: 12px; }
.srv-ic { width: 40px; height: 40px; border-radius: 12px; background: rgba(124, 92, 255, 0.14); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.srv-ic .ic { width: 20px; height: 20px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 12px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; color: #4a4466; }
.empty h3 { color: var(--text); font-size: 17px; }
.empty p { max-width: 32ch; }

/* ---------- рейка шагов: главный элемент ---------- */
.rail { display: grid; grid-template-columns: repeat(var(--n, 7), 1fr); gap: 4px; }
.rail i { height: 6px; border-radius: 3px; background: var(--line); display: block; }
.rail i.done { background: var(--accent); }
.rail i.fail { background: var(--err); }
.rail i.cur {
  background: linear-gradient(90deg, var(--line) 0%, var(--accent) 50%, var(--line) 100%);
  background-size: 200% 100%; animation: sweep 1.2s linear infinite;
}
.rail.ok i { background: var(--ok); }
.rail.tall i { height: 8px; border-radius: 4px; }
@keyframes sweep { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- мастер ---------- */
.wiz-meta { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 8px; font-size: 13px; color: var(--muted); }
.wiz-meta b { color: var(--text); font-size: 15px; }
.lead { color: var(--muted); margin: 4px 0 14px; }
.sect { font-size: 16px; margin: 20px 0 10px; }

.country-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.country {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px 8px; min-width: 0;
  background: var(--card); color: var(--text);
  border: 1.5px solid transparent; border-radius: 13px; cursor: pointer;
  transition: border-color var(--t), background var(--t), transform var(--t);
}
.country:active { transform: scale(0.97); }
.country .flag { font-size: 28px; line-height: 1.1; }
.country .cname { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country.sel { border-color: var(--accent); background: rgba(124, 92, 255, 0.14); }
.country.sel .cname { color: var(--text); }

.search { position: relative; margin-bottom: 12px; }
.search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 46px; padding: 0 40px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px;
  transition: border-color var(--t);
}
.search input:focus { outline: none; border-color: var(--accent); }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.pick { display: flex; align-items: center; gap: 12px; cursor: pointer; border: 1.5px solid transparent; transition: border-color var(--t), background var(--t); }
.pick.sel { border-color: var(--accent); background: rgba(124, 92, 255, 0.1); }
.pick input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }

.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt, .kv .k { color: var(--muted); flex: none; }
.kv dd, .kv .v { margin: 0; text-align: right; overflow-wrap: anywhere; min-width: 0; }
.kv-wrap { margin: 0; padding: 4px 14px; }
.kv-wrap dl { margin: 0; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }

.note { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.note.warn { background: rgba(255, 194, 77, 0.1); border: 1px solid rgba(255, 194, 77, 0.3); color: var(--warn-text); }
.note.info { background: rgba(124, 92, 255, 0.1); border: 1px solid rgba(124, 92, 255, 0.28); color: #d9d2ff; }
.note .btn { margin-top: 8px; }

/* ---------- формы ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
  width: 100%; height: 46px; padding: 0 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 11px;
  font: inherit; font-size: 16px;
  transition: border-color var(--t);
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--err); }
.field-err { color: var(--err-text); font-size: 12px; }
.form-card { padding: 16px 14px 14px; }
.pw { display: flex; align-items: center; gap: 4px; }
.pw .icon-btn { margin-right: -6px; }
.pw input { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn { flex: 1; }

/* ---------- прогресс и результат ---------- */
.hero { padding: 6px 0 16px; }
.hero h2 { font-size: 20px; overflow-wrap: anywhere; }
.hero .sub { color: var(--muted); font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }
.hero .rail { margin: 16px 0 12px; }
.prog-now { font-size: 15px; min-height: 22px; overflow-wrap: anywhere; }

.steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.st { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: var(--muted); }
.st-ic { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 650; flex: none; transition: background var(--t), border-color var(--t); }
.st-ic .ic { width: 15px; height: 15px; }
.st.done { color: var(--text); }
.st.done .st-ic { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.st.cur { color: var(--text); font-weight: 650; }
.st.cur .st-ic { border-color: var(--accent); }
.st.fail { color: var(--err-text); font-weight: 650; }
.st.fail .st-ic { background: var(--err); border-color: var(--err); color: #fff; }
.steps.ok .st.done .st-ic { background: var(--ok); border-color: var(--ok); color: #04231a; }

.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 18px 0 20px; }
.result-ic { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.result-ic .ic { width: 36px; height: 36px; stroke-width: 2.4; }
.result.ok .result-ic { background: rgba(46, 230, 168, 0.15); color: var(--ok-text); }
.result.bad .result-ic { background: rgba(255, 77, 109, 0.16); color: var(--err-text); }
.result h2 { font-size: 21px; }
.result p { color: var(--muted); max-width: 34ch; }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; z-index: 20;
  top: calc(var(--safe-t) + 10px);
  transform: translate(-50%, -16px);
  max-width: min(92vw, 420px); padding: 10px 14px; border-radius: 14px;
  font-size: 14px; font-weight: 550; text-align: center;
  background: #35131d; color: #ffc3ce; border: 1px solid rgba(255, 77, 109, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t), transform var(--t);
  overflow-wrap: anywhere;
}
.toast.ok { background: #0c2a22; color: #b3f5d6; border-color: rgba(46, 230, 168, 0.5); }
.toast.warn { background: #33290e; color: #ffe3a8; border-color: rgba(255, 194, 77, 0.5); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .rail i.cur { background: var(--accent); opacity: 0.6; }
}