:root {
  --bg: var(--tg-theme-bg-color, #0a0b0f);
  --surface: var(--tg-theme-secondary-bg-color, #14161d);
  --surface-2: #1d2029;
  --text: var(--tg-theme-text-color, #f4f5f8);
  --muted: var(--tg-theme-hint-color, #8b91a1);
  --accent: var(--tg-theme-button-color, #6d5efc);
  --accent-2: #4a8cff;
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --accent-soft: rgba(109,94,252,.16);
  --line: rgba(255,255,255,.07);
  --line-2: rgba(255,255,255,.12);
  --ok: #3ad07a;
  --danger: #ff5d6c;
  --r: 18px;
  --r-sm: 13px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: 'Manrope', -apple-system, 'Segoe UI', Roboto, system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(109,94,252,.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text); padding-bottom: 104px; letter-spacing: -.01em;
}
.hidden { display: none !important; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 0; }

/* ── Шапка ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 19px; flex: 1; letter-spacing: -.02em; }
.brand span { background: linear-gradient(92deg, #fff, #b9b3ff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.nav-back {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 12px; font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: transform .12s, background .15s;
}
.nav-back:active { transform: scale(.92); }
.cur-switch { display: flex; gap: 3px; background: var(--surface); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.cur-switch button { border: none; background: transparent; color: var(--muted);
  width: 34px; height: 30px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 14px; transition: .15s; }
.cur-switch button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* ── Кабинет ─────────────────────────────────────────── */
.cabinet { margin: 14px 16px 0; padding: 16px 18px; border-radius: var(--r);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-soft), transparent 55%),
    var(--surface);
  border: 1px solid var(--line); }
.cab-top { display: flex; justify-content: space-between; align-items: center; }
.cab-name { font-size: 15px; font-weight: 600; }
.cab-tier { font-size: 12px; font-weight: 600; color: #cfc8ff;
  background: var(--accent-soft); padding: 4px 10px; border-radius: 20px; }
.balances { display: flex; gap: 10px; margin-top: 14px; }
.bal { flex: 1; background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 14px; display: flex; flex-direction: column; gap: 3px; }
.bal-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.bal b { font-size: 19px; font-weight: 800; }

/* ── Заголовки / крошки ──────────────────────────────── */
.app { padding: 18px 16px 8px; }
.loader { color: var(--muted); text-align: center; padding: 60px 0; }
.view-title { font-size: 24px; font-weight: 800; margin: 6px 2px 18px; letter-spacing: -.025em; }
.crumb { color: var(--muted); font-size: 13px; font-weight: 600; margin: 2px 2px 14px; }
.crumb b { color: var(--text); }

/* ── Бренд-карточки разделов (главная) ───────────────── */
.brand-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.brand-card { text-align: left; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--r); overflow: hidden; padding: 0;
  display: flex; flex-direction: column; transition: transform .14s ease, border-color .15s; }
.brand-card:active { transform: scale(.975); border-color: var(--line-2); }
.brand-banner { height: 84px; display: flex; align-items: center; justify-content: flex-start;
  padding: 0 16px; position: relative; }
.brand-banner::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.12); }
.brand-ico { font-size: 38px; position: relative; z-index: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.brand-body { padding: 12px 16px 16px; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.02em; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.35; min-height: 16px; }
.brand-meta { color: var(--accent); font-size: 12px; font-weight: 700; margin-top: 10px; }
.brand-card[data-brand="playstation"] .brand-banner { background: linear-gradient(135deg, #1f7ae8, #0a2a86); }
.brand-card[data-brand="xbox"] .brand-banner { background: linear-gradient(135deg, #36b24a, #0b6b1f); }
.brand-card[data-brand="emails"] .brand-banner { background: linear-gradient(135deg, #6b7484, #2c313d); }
.brand-card[data-brand="steam"] .brand-banner { background: linear-gradient(135deg, #2a4d6e, #0e1a27); }
.brand-card[data-brand="ns"] .brand-banner { background: linear-gradient(135deg, #7c5cff, #3a2b9e); }
.brand-card[data-brand="default"] .brand-banner { background: linear-gradient(135deg, #3a3f4e, #20232c); }

/* ── Подразделы ──────────────────────────────────────── */
.subcards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.subcard { display: flex; align-items: center; gap: 14px; cursor: pointer; text-align: left;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 16px;
  transition: transform .14s, border-color .15s; }
.subcard:active { transform: scale(.985); border-color: var(--line-2); }
.subcard-ico { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center;
  justify-content: center; font-size: 24px; background: var(--accent-soft); flex-shrink: 0; }
.subcard-main { flex: 1; min-width: 0; }
.subcard-name { font-weight: 700; font-size: 15px; }
.subcard-count { color: var(--muted); font-size: 12px; margin-top: 2px; }
.subcard-arrow { color: var(--muted); font-size: 20px; }

/* ── Товары (сетка карточек) ─────────────────────────── */
.group { margin-bottom: 22px; }
.group-head { color: var(--muted); font-size: 13px; font-weight: 700; margin: 6px 2px 12px;
  text-transform: uppercase; letter-spacing: .5px; }
.section-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }

.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 12px; }
.product { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 104px; transition: border-color .15s; }
.product.in-cart { border-color: var(--accent); background:
  linear-gradient(180deg, var(--accent-soft), var(--surface)); }
.product-name { font-weight: 600; font-size: 13.5px; line-height: 1.35; flex: 1; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product-price { font-weight: 800; font-size: 15px; white-space: nowrap; }
.product-price.req { color: var(--muted); font-size: 13px; font-weight: 600; }

.add-btn { border: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  width: 34px; height: 34px; border-radius: 11px; font-size: 22px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.add-btn:active { transform: scale(.9); }
.stepper { display: flex; align-items: center; background: var(--accent-soft); border-radius: 11px; }
.stepper button { border: none; background: transparent; color: #cfc8ff; width: 30px; height: 34px;
  font-size: 19px; cursor: pointer; font-weight: 800; }
.stepper .qty { min-width: 20px; text-align: center; font-weight: 800; font-size: 14px; }

/* ── Калькулятор ─────────────────────────────────────── */
.calc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; margin-bottom: 16px; }
.calc-title { font-weight: 800; font-size: 17px; margin-bottom: 6px; letter-spacing: -.02em; }
.calc-hint { color: var(--muted); font-size: 12px; margin-bottom: 14px; line-height: 1.5; }
.calc-input-row { display: flex; gap: 10px; }
.calc-input { flex: 1; padding: 14px 16px; border-radius: 13px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text); font-size: 16px; font-family: inherit; font-weight: 600; }
.calc-input:focus { outline: none; border-color: var(--accent); }
.calc-result { margin-top: 14px; font-size: 16px; min-height: 22px; font-weight: 600; }
.calc-result b { font-weight: 800; font-size: 20px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.calc-sub { color: var(--muted); font-size: 13px; }
.calc-add { width: 100%; margin-top: 14px; padding: 14px; font-size: 15px; }

/* ── Плавающая корзина ───────────────────────────────── */
.cart-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 14px 16px;
  background: linear-gradient(transparent, var(--bg) 42%); }
.cart-bar button { width: 100%; border: none; color: #fff; padding: 16px 20px; border-radius: 16px;
  font-size: 16px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 32px rgba(109,94,252,.4); }
.cart-sum { font-weight: 800; }

/* ── Модалка корзины ─────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.66);
  display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); }
.modal-card { width: 100%; max-width: 560px; background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 18px 18px 28px; max-height: 90vh; overflow: auto; border-top: 1px solid var(--line-2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h3 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.x { border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 34px; height: 34px;
  border-radius: 11px; font-size: 16px; cursor: pointer; }
.cart-line { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.cart-line-main { flex: 1; min-width: 0; }
.cart-line-name { font-size: 14px; font-weight: 600; }
.cart-line-price { color: var(--muted); font-size: 12px; margin-top: 3px; }
.cart-line .rm { border: none; background: none; color: var(--danger); font-size: 18px; cursor: pointer; }
.cart-total { display: flex; justify-content: space-between; font-size: 17px; font-weight: 800; padding: 16px 2px 4px; }
.cart-total .muted { color: var(--muted); font-weight: 600; font-size: 13px; }
.field { display: block; margin: 14px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field textarea { width: 100%; margin-top: 7px; padding: 13px 14px; border-radius: 13px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; }
.btn-primary { border: none; color: #fff; border-radius: 14px; font-weight: 800; cursor: pointer; padding: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-primary.big { width: 100%; margin-top: 18px; font-size: 16px; padding: 16px; }
.btn-primary:disabled { opacity: .6; }
.hint { color: var(--muted); font-size: 12px; margin-top: 12px; text-align: center; }
.empty-cart { color: var(--muted); text-align: center; padding: 24px 0; }

/* ── Footer ──────────────────────────────────────────── */
.footer { padding: 30px 16px 48px; text-align: center; color: var(--muted); font-size: 13px; }
.footer a { display: inline-block; margin: 0 8px; color: #b9b3ff; text-decoration: none; font-weight: 600; }
.footer .support { margin-top: 14px; }

/* ── Toast ───────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(8px);
  background: var(--surface-2); color: var(--text); padding: 11px 18px; border-radius: 13px; font-size: 14px;
  font-weight: 600; z-index: 50; border: 1px solid var(--line-2); opacity: 0; transition: .22s;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Юр. страницы ────────────────────────────────────── */
.doc { max-width: 720px; margin: 0 auto; padding: 28px 20px 64px; line-height: 1.65; }
.doc h1 { font-size: 25px; font-weight: 800; letter-spacing: -.02em; }
.doc h2 { font-size: 18px; font-weight: 700; margin-top: 28px; }
.doc a { color: #b9b3ff; }
.doc .back { display: inline-block; margin-bottom: 18px; color: #b9b3ff; text-decoration: none; font-weight: 600; }
.doc .placeholder { background: rgba(255,200,0,.13); padding: 2px 6px; border-radius: 6px; }
