/* ==========================================================================
   Gramtrix — Telegram-native Mini App storefront
   Dark navy palette · Inter typography · 24/19/16px radius hierarchy
   ========================================================================== */

:root {
  /* palette */
  --bg: #05080e;
  --surface: #0a1019;
  --surface-light: #101827;
  --text: #ffffff;
  --text-secondary: #71809a;
  --text-muted: #536178;
  --blue: #2864ff;
  --blue-light: #3d7aff;
  --star-gold: #c3a338;
  --purple: #8a6cff;
  --teal: #2394d8;
  --navy: #5f6b82;
  --good: #4fd688;
  --border: rgba(76, 113, 168, 0.25);
  --border-active: rgba(72, 125, 255, 0.55);
  --nav-bg: #04070b;

  /* radii */
  --radius-xl: 24px;
  --radius-lg: 19px;
  --radius-md: 16px;
  --radius-pill: 999px;

  /* spacing */
  --spacing-xs: 4px;
  --spacing-sm: 7px;
  --spacing-md: 10px;
  --spacing-lg: 14px;
  --spacing-xl: 18px;
}

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

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- app shell ------------------------------------------------------------ */
.app {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: auto;
  background: var(--bg);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  position: relative;
}

/* --- top bar ---------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  gap: 10px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.profile-meta { display: flex; flex-direction: column; min-width: 0; }

.username {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.handle {
  font-size: 10px;
  font-weight: 500;
  color: #60708a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.balance-pill {
  height: 36px;
  padding: 0 14px;
  border-radius: 20px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(35, 91, 255, 0.25);
  flex-shrink: 0;
}

.balance-icon { font-size: 13px; opacity: 0.9; }

/* --- content spacing ------------------------------------------------------- */
.content {
  padding: 0 7px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* --- featured premium card -------------------------------------------------- */
.premium-card {
  position: relative;
  border-radius: var(--radius-xl);
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(circle at 90% 50%, rgba(45, 92, 190, 0.35), transparent 45%),
    linear-gradient(135deg, #101a2d, #111d38);
  border: 1px solid rgba(70, 128, 255, 0.55);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.18);
  animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.premium-copy {
  position: relative;
  z-index: 2;
  max-width: 62%;
}

.premium-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.3px;
  color: #ffffff;
  margin: 0 0 4px;
}

.premium-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.3;
}

.btn-premium {
  height: 34px;
  padding: 0 13px;
  border-radius: 18px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(36, 94, 255, 0.22);
  transition: transform 0.15s ease, filter 0.15s ease;
  font-family: inherit;
}
.btn-premium:active { transform: scale(0.97); filter: brightness(1.15); }

.premium-art {
  position: absolute;
  right: 12px;
  top: 25px;
  width: 78px;
  height: 78px;
  object-fit: contain;
  opacity: 0.7;
  pointer-events: none;
  filter: drop-shadow(0 6px 15px rgba(40, 100, 255, 0.25));
}

/* --- product grid ----------------------------------------------------------- */
.products-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.product-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 113px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.product-card:active { transform: scale(0.98); }
.product-card:hover { border-color: var(--border-active); transform: translateY(-1px); }

.stars-card {
  background: linear-gradient(145deg, #11151b, #090e16);
  border-color: rgba(195, 163, 56, 0.3);
}
.boosts-card {
  background: linear-gradient(145deg, #151326, #090e18);
  border-color: rgba(138, 108, 255, 0.3);
}
.gram-card {
  background: linear-gradient(145deg, #0b1622, #081018);
  border-color: rgba(35, 148, 216, 0.3);
}
.giveaways-card {
  background: linear-gradient(145deg, #0c1120, #090e16);
  border-color: rgba(95, 107, 130, 0.3);
}

.product-title {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
  position: relative;
  z-index: 2;
}

.product-subtitle {
  font-size: 10px;
  font-weight: 500;
  color: #71809a;
  margin-top: 3px;
  position: relative;
  z-index: 2;
}

.product-action {
  position: absolute;
  left: 12px;
  bottom: 12px;
  font-size: 10px;
  font-weight: 800;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  padding: 6px 11px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s ease, transform 0.12s ease;
  font-family: inherit;
}
.product-action:active { transform: scale(0.95); background: rgba(255,255,255,0.16); }

.product-art {
  position: absolute;
  right: -4px;
  bottom: -8px;
  width: 65px;
  height: 65px;
  object-fit: contain;
  opacity: 0.55;
  pointer-events: none;
  filter: drop-shadow(0 6px 15px rgba(40, 100, 255, 0.15));
  z-index: 1;
}

/* --- partner banner --------------------------------------------------------- */
.partner-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 63px;
  padding: 0 12px;
  border-radius: 17px;
  background: linear-gradient(135deg, #2194e5, #167cd1);
  cursor: pointer;
  overflow: hidden;
  animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.partner-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.partner-copy { flex: 1; min-width: 0; }

.partner-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
}

.partner-name {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.partner-sub {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
}

.partner-join {
  height: 32px;
  padding: 0 13px;
  border-radius: 17px;
  background: #fff;
  color: #167bd1;
  font-weight: 800;
  font-size: 12px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease;
  font-family: inherit;
}
.partner-join:active { transform: scale(0.95); }

/* --- connect section --------------------------------------------------------- */
.connect-section {
  border-radius: var(--radius-lg);
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#connector { display: none; }

.btn-connect {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(36, 94, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-connect:active { transform: scale(0.97); filter: brightness(1.15); }

.wallet-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(79, 214, 136, 0.1);
  border: 1px solid rgba(79, 214, 136, 0.3);
  border-radius: 14px;
  animation: card-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.wallet-addr { color: var(--good); font-weight: 600; font-size: 14px; }

.dot {
  width: 8px;
  height: 8px;
  background: var(--good);
  border-radius: 50%;
  animation: glow 2s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 214, 136, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(79, 214, 136, 0); }
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  font-family: inherit;
}
.icon-btn:active { background: rgba(255,255,255,0.08); }

/* --- flow / amount panel ------------------------------------------------------ */
.flow-section, .amount-panel {
  border-radius: var(--radius-lg);
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.step-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-weight: 800;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, border-color 0.18s ease, color 0.18s;
  min-height: 38px;
  font-family: inherit;
}
.chip:active { transform: scale(0.94); }
.chip.selected {
  background: linear-gradient(135deg, #ffd54a, #ffb830);
  border-color: transparent;
  color: #201400;
  font-weight: 700;
  box-shadow: 0 3px 14px rgba(255, 213, 74, 0.35);
}

.quote-box {
  background: rgba(40, 100, 255, 0.08);
  border: 1px solid rgba(40, 100, 255, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0 12px;
}
.quote { margin: 0; font-size: 14px; }
.quote b { color: var(--blue-light); }

.btn-cta {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  transition: transform 0.15s ease, filter 0.15s ease;
  box-shadow: 0 5px 16px rgba(36, 94, 255, 0.22);
}
.btn-cta:disabled {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  box-shadow: none;
  border: 1px solid var(--border);
  cursor: not-allowed;
}
.btn-cta:not(:disabled):active { transform: scale(0.97); filter: brightness(1.15); }

.status {
  text-align: center;
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.status.ok { color: var(--good); }
.status.err { color: #ff6b6b; }
.status.busy { color: var(--blue-light); }

/* --- shared hidden utility (scoped, not clashing with tonconnect) ------------ */
.is-hidden { display: none !important; }
.hidden { display: none !important; }

/* --- animations ---------------------------------------------------------------- */
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-in { animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* --- bottom nav ------------------------------------------------------------------ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65px;
  background: var(--nav-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  color: #52627b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 8px 4px;
  font-family: inherit;
  transition: color 0.15s ease;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

.nav-item span {
  font-size: 10px;
  font-weight: 600;
}

.nav-item.active { color: var(--blue-light); }
.nav-item:not(.active):active { color: #7a8ba5; }

/* --- toast ------------------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%) translateY(80px);
  background: rgba(30, 34, 42, 0.95);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 88%;
  text-align: center;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- responsive guards ------------------------------------------------------------ */
@media (min-width: 431px) {
  .app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
