:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-secondary-bg-color, #f6f2ff);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --surface-soft: var(--tg-theme-section-bg-color, #faf8ff);
  --text: var(--tg-theme-text-color, #171229);
  --muted: var(--tg-theme-hint-color, #716b7f);
  --border: var(--tg-theme-section-separator-color, rgba(79, 70, 100, .14));
  --primary: #7c3aed;
  --primary-strong: #6424d6;
  --accent: #ec4899;
  --shadow: 0 14px 40px rgba(69, 39, 111, .10);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% -5%, rgba(236, 72, 153, .13), transparent 30%),
    radial-gradient(circle at -5% 8%, rgba(124, 58, 237, .16), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; touch-action: manipulation; }
.hidden { display: none !important; }
.shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}
.topbar { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; color: white; background: linear-gradient(145deg, var(--primary), var(--accent)); box-shadow: 0 10px 24px rgba(124, 58, 237, .25); }
.brand-mark svg { width: 31px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.25; }
h2 { font-size: 22px; line-height: 1.22; }
h3 { font-size: 20px; line-height: 1.25; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.badge { padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; }
.state-card, .welcome-card, .usage-card, .plan-card {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.state-card { min-height: 116px; display: flex; align-items: center; gap: 14px; padding: 20px; border-radius: 22px; }
.state-card p, .muted { margin-top: 5px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.error-card { align-items: flex-start; flex-wrap: wrap; }
.spinner { width: 28px; height: 28px; flex: 0 0 auto; border: 3px solid rgba(124, 58, 237, .18); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.welcome-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px; border-radius: 24px; margin-bottom: 26px; }
.avatar { width: 52px; height: 52px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 17px; color: white; background: linear-gradient(145deg, var(--primary), var(--accent)); font-size: 20px; font-weight: 800; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 12px; }
.section-heading h2 { font-size: 19px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.usage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 28px; }
.usage-card { min-width: 0; padding: 14px 12px; border-radius: 18px; }
.usage-card strong { display: block; margin-top: 10px; font-size: 18px; white-space: nowrap; }
.usage-card p { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.usage-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: rgba(124, 58, 237, .11); }
.usage-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.plan-stack { display: grid; gap: 12px; }
.plan-card { padding: 20px; border-radius: 24px; }
.plan-card.featured { position: relative; overflow: hidden; border-color: rgba(124, 58, 237, .42); }
.plan-card.featured::before { content: ""; position: absolute; width: 130px; height: 130px; right: -55px; top: -60px; border-radius: 50%; background: linear-gradient(145deg, rgba(124, 58, 237, .23), rgba(236, 72, 153, .13)); }
.plan-row { position: relative; display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.price { color: var(--primary); font-size: 26px; line-height: 1; text-align: right; }
.price small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
ul { margin: 18px 0; padding: 0; list-style: none; }
li { position: relative; margin: 10px 0; padding-left: 24px; color: var(--muted); font-size: 14px; line-height: 1.4; }
li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 900; }
.button { min-height: 48px; border: 0; border-radius: 15px; padding: 12px 18px; font-weight: 800; cursor: pointer; transition: transform .16s ease, opacity .16s ease; }
.button:active { transform: scale(.98); }
.button:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, white); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: .58; }
.primary { width: 100%; color: white; background: linear-gradient(135deg, var(--primary), var(--primary-strong)); box-shadow: 0 10px 24px rgba(124, 58, 237, .25); }
.secondary { color: var(--primary); background: rgba(124, 58, 237, .10); }
.current-label { display: block; width: 100%; padding: 13px 16px; border-radius: 15px; color: var(--primary); background: rgba(124, 58, 237, .10); text-align: center; font-size: 14px; font-weight: 800; }
.fine-print, .legal { color: var(--muted); font-size: 11px; line-height: 1.45; }
.fine-print { margin-top: 12px; }
.legal { margin: 18px 12px 0; text-align: center; }

@media (max-width: 360px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .usage-grid { grid-template-columns: 1fr; }
  .usage-card { display: grid; grid-template-columns: 34px auto 1fr; align-items: center; gap: 8px; }
  .usage-card strong, .usage-card p { margin: 0; }
  .usage-card p { text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
