:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #1a1d24);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #8a93a3);
  --link: var(--tg-theme-link-color, #4ea1ff);
  --button: var(--tg-theme-button-color, #3b82f6);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --accent: #3b82f6;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: 76px;
}

.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { font-size: 20px; font-weight: 700; }
.brand span { letter-spacing: 1px; }
.badge { font-size: 12px; padding: 5px 10px; border-radius: 20px; font-weight: 600; }
.badge-off { background: #3a2230; color: #ff7a90; }
.badge-on { background: #163a2b; color: #46e0a0; }

main { padding: 0 18px; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

h1 { font-size: 26px; margin: 14px 0 6px; }
h2 { font-size: 20px; margin: 6px 0 16px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }

.hero { text-align: center; padding-top: 18px; }
.hero-icon { font-size: 56px; margin-bottom: 6px; }

.btn {
  display: block; width: 100%; padding: 15px; border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; margin-top: 12px; cursor: pointer;
  transition: transform .1s ease, opacity .2s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--button); color: var(--button-text); }
.btn-ghost { background: var(--secondary-bg); color: var(--text); }
.btn-link { background: none; color: var(--link); }

.switch {
  display: flex; background: var(--secondary-bg); border-radius: var(--radius);
  padding: 4px; margin-bottom: 10px;
}
.switch-btn {
  flex: 1; padding: 10px; border: none; background: none; color: var(--hint);
  font-weight: 600; border-radius: 12px; cursor: pointer; font-size: 15px;
}
.switch-btn.active { background: var(--accent); color: #fff; }

.plans { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.plan {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--secondary-bg); padding: 16px; border-radius: var(--radius);
  border: 1.5px solid transparent; cursor: pointer;
}
.plan:active { border-color: var(--accent); }
.plan .pname { font-weight: 600; font-size: 16px; }
.plan .pdesc { color: var(--hint); font-size: 13px; margin-top: 2px; }
.plan .pprice { font-size: 18px; font-weight: 700; white-space: nowrap; }
.plan .badge-best { font-size: 11px; color: #46e0a0; margin-left: 6px; }

.status-card {
  background: var(--secondary-bg); padding: 16px; border-radius: var(--radius);
  margin: 12px 0; line-height: 1.5;
}
.sub-link {
  display: block; background: var(--bg); border: 1px solid #2a2f3a;
  border-radius: 12px; padding: 12px; font-size: 12px; word-break: break-all;
  margin: 10px 0; color: var(--text);
}
#qr { display: flex; justify-content: center; margin: 14px 0; }
#qr img, #qr canvas { border-radius: 12px; background: #fff; padding: 10px; }

.input {
  width: 100%; padding: 14px; border-radius: var(--radius); border: 1px solid #2a2f3a;
  background: var(--secondary-bg); color: var(--text); font-size: 16px; margin-bottom: 12px;
}
.msg { margin-top: 12px; font-weight: 600; text-align: center; }
.msg.ok { color: #46e0a0; }
.msg.err { color: #ff7a90; }

.steps { line-height: 1.9; padding-left: 20px; }
.hidden { display: none; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--secondary-bg); border-top: 1px solid #232833;
  padding: 6px 4px env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--hint); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; cursor: pointer;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--accent); }
