/* WayGate Mini App — тёмно-бирюзовая тема */
:root {
  --bg: #061517;
  --bg-elev: #0a2023;
  --card: rgba(18, 52, 55, .42);
  --card-solid: #0c2427;
  --line: rgba(125, 230, 214, .09);
  --line-strong: rgba(125, 230, 214, .16);
  --text: #e4f3f0;
  --muted: #8aaba6;
  --faint: #5f7f7b;
  --accent: #2dd4bf;
  --accent-2: #5eead4;
  --accent-deep: #0f766e;
  --accent-soft: rgba(45, 212, 191, .12);
  --accent-line: rgba(45, 212, 191, .5);
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 22px;
  --radius-sm: 14px;
  --nav-h: 68px;
  /* --safe-t / --safe-b-tg выставляет app.js из Telegram (полноэкранный режим) */
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--safe-b-tg, 0px));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 var(--font);
  min-height: 100vh;
  padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 20px);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Мягкое свечение сверху */
.glow {
  position: fixed; inset: -20vh -20vw auto; height: 60vh; pointer-events: none; z-index: -1;
  background:
    radial-gradient(60% 55% at 50% 30%, rgba(20, 184, 166, .16), transparent 70%),
    radial-gradient(40% 40% at 85% 10%, rgba(94, 234, 212, .07), transparent 70%);
}

/* ---------- Шапка ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(max(var(--safe-t, 0px), env(safe-area-inset-top, 0px)) + 14px) 0 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(160deg, rgba(45, 212, 191, .2), rgba(45, 212, 191, .05));
  border: 1px solid var(--line-strong);
}
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.brand-name b { color: var(--accent); font-weight: 700; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .02);
  color: var(--text); font-size: 14px; font-weight: 500; transition: background .15s;
}
.pill .i { width: 17px; height: 17px; color: var(--muted); }
.pill:active { background: var(--accent-soft); }

/* ---------- Общие блоки ---------- */
.view { outline: none; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stack > * + * { margin-top: 14px; }
.card {
  background: linear-gradient(180deg, rgba(22, 62, 65, .5), rgba(12, 36, 39, .5));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin: 0; }
.h2 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; margin: 2px 0 0; }
.h3 { font-size: 17px; font-weight: 650; margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 20px; border-radius: 16px; font-weight: 650; font-size: 16px;
  transition: transform .12s, filter .15s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  flex: 1; min-width: 0; padding: 0 14px; white-space: nowrap; font-size: 15.5px; color: #032a27;
  background: linear-gradient(180deg, #4fe3cf, #22c3ae);
  box-shadow: 0 8px 24px -10px rgba(45, 212, 191, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn-ghost { border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .02); }
.btn-icon { width: 52px; padding: 0; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .02); color: var(--accent-2); }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- Профиль-карточка ---------- */
.user { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; font-size: 20px; color: #032a27;
  background: linear-gradient(150deg, #5eead4, #0d9488);
  border: 2px solid rgba(94, 234, 212, .25);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.user-meta .mono { letter-spacing: .02em; }
.copy { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: var(--muted); }
.copy .i { width: 15px; height: 15px; }
.copy:active { background: var(--accent-soft); color: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .15); }

/* ---------- Главная: подключение ---------- */
.hero { position: relative; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 212, 191, .16), transparent 65%); pointer-events: none;
}
.hero-top { display: flex; align-items: center; gap: 14px; }
.hero-icon {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(45, 212, 191, .22);
}
.hero-icon .i { width: 26px; height: 26px; }
.hero-text { color: var(--muted); margin: 14px 0 16px; }
.row { display: flex; gap: 10px; }

/* ---------- Установка ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 14px; }
.section-title { display: flex; align-items: center; gap: 12px; }
.section-title .h1 { font-size: 28px; }
.round-ico {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line-strong); color: var(--accent-2);
}
.select { position: relative; }
.select select { position: absolute; inset: 0; opacity: 0; width: 100%; font-size: 16px; }
.select .pill { pointer-events: none; height: 42px; padding: 0 12px 0 16px; font-size: 15px; }
.select .i { color: var(--muted); }

.step { display: flex; gap: 14px; }
.step-num {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 14px; font-weight: 650; color: var(--accent-2); background: var(--accent-soft);
  border: 1px solid rgba(45, 212, 191, .2);
}
.step-body { min-width: 0; flex: 1; }
.step-body p { margin: 6px 0 0; color: var(--muted); }

.apps { margin-top: 14px; display: grid; gap: 10px; }
.app {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px;
  border: 1px solid var(--line); background: rgba(6, 21, 23, .35);
}
.app.rec { border-color: var(--accent-line); background: linear-gradient(180deg, rgba(45, 212, 191, .1), rgba(45, 212, 191, .03)); }
.app img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.app-info { min-width: 0; flex: 1; }
.app-name { font-weight: 650; font-size: 16px; }
.app-note { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.app-tag { display: block; margin: 1px 0 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); vertical-align: 2px; }
.store {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 13px; font-weight: 550; white-space: nowrap; flex: none;
}
.store .i { width: 16px; height: 16px; color: var(--accent-2); }
.store:active { background: var(--accent-soft); }

.footer { margin-top: 26px; }
.footer .links a { display: block; width: max-content; color: var(--muted); font-size: 15px; padding: 4px 0; text-decoration: underline; text-decoration-color: rgba(138, 171, 166, .4); text-underline-offset: 4px; }
.footer hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.contact { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 5px 0; font-size: 15px; }
.contact .i { width: 18px; height: 18px; }
.contact a { text-decoration: none; color: var(--text); }
.fine { font-size: 13px; color: var(--faint); margin-top: 8px; }
.bot-handle { text-align: center; color: var(--faint); font-size: 14px; margin-top: 22px; }

/* ---------- Устройства ---------- */
.dev-head { display: flex; align-items: baseline; justify-content: space-between; }
.dev-count { font-family: var(--mono); color: var(--muted); font-size: 16px; }
.dev-count b { color: var(--text); font-weight: 600; }
.segs { display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); gap: 6px; margin: 16px 0 14px; }
.seg { height: 5px; border-radius: 4px; background: rgba(125, 230, 214, .1); }
.seg.on { background: linear-gradient(90deg, #2dd4bf, #5eead4); }
.empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 28px 22px; text-align: center; color: var(--muted);
}
.empty .btn { margin-top: 16px; height: 44px; font-size: 15px; }

/* ---------- Подписка ---------- */
.kv { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-top: 10px; }
.kv .i { width: 18px; height: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 84px;
  border-radius: 18px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(22, 62, 65, .45), rgba(12, 36, 39, .45));
  font-size: 14px; font-weight: 550; color: var(--muted); transition: background .15s, border-color .15s;
}
.tile .i { width: 22px; height: 22px; }
.tile.primary { color: var(--text); border-color: var(--accent-line); background: linear-gradient(180deg, rgba(45, 212, 191, .16), rgba(45, 212, 191, .05)); }
.tile.primary .i { color: var(--accent-2); }
.tile:active { border-color: var(--accent-line); }
.plan {
  position: relative; text-align: left; padding: 14px; border-radius: 18px; border: 1px solid var(--line);
  background: rgba(6, 21, 23, .35); transition: border-color .15s, background .15s;
}
.plan.sel { border-color: var(--accent-line); background: linear-gradient(180deg, rgba(45, 212, 191, .14), rgba(45, 212, 191, .04)); }
.plan-term { font-size: 13px; color: var(--muted); }
.plan-price { font-size: 21px; font-weight: 750; letter-spacing: -.3px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.plan-per { font-size: 12px; color: var(--faint); margin-top: 2px; }
.badge {
  position: absolute; top: 10px; right: 10px; font-size: 10.5px; font-weight: 700; padding: 3px 7px; border-radius: 999px;
  color: #032a27; background: var(--accent-2);
}
.pay-methods { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { font-size: 12.5px; color: var(--muted); padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); }

/* ---------- Профиль ---------- */
.profile-hero { text-align: center; padding: 26px 18px 20px; }
.profile-hero .avatar { width: 84px; height: 84px; font-size: 30px; margin: 0 auto 12px; }
.profile-hero .user-meta { justify-content: center; }
.list { padding: 6px 0; }
.list-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 18px; text-align: left; }
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-item .i:first-child { color: var(--accent-2); }
.list-item span { flex: 1; }
.list-item small { color: var(--muted); font-size: 14px; }
.list-item .chev { width: 16px; height: 16px; color: var(--faint); }
.list-item:active { background: rgba(45, 212, 191, .05); }
.version { text-align: center; color: var(--faint); font-size: 12.5px; margin-top: 18px; }

/* ---------- Нижнее меню ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(6, 21, 23, .86); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--faint); font-size: 12px; font-weight: 550; }
.tab .i { width: 23px; height: 23px; }
.tab.active { color: var(--accent); }

/* ---------- Тост и шторка ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 40;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 14px; font-size: 14px;
  background: #11383a; border: 1px solid var(--line-strong); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .6);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(2, 10, 11, .6); animation: fadeIn .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(20px + var(--safe-b));
  background: var(--card-solid); border-top: 1px solid var(--line-strong); border-radius: 24px 24px 0 0;
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 0 auto 14px; }
.sheet-title { margin: 0 0 12px; font-size: 18px; }
.sheet-body .app { cursor: pointer; }
.sheet .tick { width: 22px; height: 22px; color: var(--accent); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 560px) { body { max-width: 520px; margin: 0 auto; } }
