/* Цвета берутся из темы Telegram (--tg-theme-*), ниже — запасные значения для браузера. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-2: var(--tg-theme-secondary-bg-color, #f0f2f5);
  --text: var(--tg-theme-text-color, #14171a);
  --hint: var(--tg-theme-hint-color, #868c94);
  --accent: var(--tg-theme-button-color, #2a83d0);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2a83d0);
  --danger: var(--tg-theme-destructive-text-color, #d9473d);
  --gold: #f2a900;
  --gold-soft: color-mix(in srgb, #f2a900 16%, transparent);
  --radius-l: 18px;
  --radius-s: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) {
    --bg: #17191d; --bg-2: #22252b; --text: #eef0f3; --hint: #8b919a; --accent: #4c9be3;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.screen { max-width: 520px; margin: 0 auto; padding: 12px 16px calc(28px + env(safe-area-inset-bottom)); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- вкладки --- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); border-radius: 12px; padding: 3px; }
.tab { border: 0; background: none; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--hint); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 12%, transparent); }

/* --- главный элемент: счётчик звёзд --- */
.dial { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 30px 0 2px; }
.dial-star {
  width: 44px; height: 44px; fill: var(--gold); flex: none;
  filter: drop-shadow(0 4px 14px color-mix(in srgb, var(--gold) 45%, transparent));
  transform: scale(var(--star-scale, 1)); transition: transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.dial-value {
  width: 3.4ch; max-width: 7.4ch; border: 0; background: none; color: var(--text); text-align: center;
  font-size: 56px; font-weight: 800; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; padding: 0;
}
.dial-value:focus-visible { outline: none; border-bottom: 2px solid var(--gold); }
.dial-price { text-align: center; margin: 0 0 18px; color: var(--hint); font-variant-numeric: tabular-nums; min-height: 1.4em; }
.dial-price b { color: var(--text); font-weight: 600; }

.slider { width: 100%; height: 28px; appearance: none; background: none; margin: 0 0 14px; }
.slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--gold) var(--fill, 50%), var(--bg-2) var(--fill, 50%));
}
.slider::-webkit-slider-thumb {
  appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
}
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--bg-2); }
.slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--gold); }
.slider::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0,0,0,.25); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 0; background: var(--bg-2); padding: 7px 13px; border-radius: 999px; cursor: pointer;
  font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px;
}
.chip[aria-pressed="true"] { background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 70%, var(--text)); }

/* --- Premium --- */
.plans { display: grid; gap: 10px; margin-top: 24px; }
.plan {
  display: flex; justify-content: space-between; align-items: center; text-align: left;
  border: 2px solid transparent; background: var(--bg-2); border-radius: var(--radius-l); padding: 16px 18px; cursor: pointer;
}
.plan[aria-pressed="true"] { border-color: var(--accent); }
.plan-months { font-size: 20px; font-weight: 700; }
.plan-sub { color: var(--hint); font-size: 14px; }
.plan-price { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }

/* --- блоки формы --- */
.block { margin-top: 26px; }
.block h2 { font-size: 15px; font-weight: 600; color: var(--hint); margin: 0 0 8px 4px; }
.field { display: flex; align-items: center; background: var(--bg-2); border-radius: var(--radius-s); padding: 0 6px 0 14px; }
.field .at { color: var(--hint); }
.field input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; padding: 13px 4px; }
.field input:focus { outline: none; }
.link-btn { border: 0; background: none; color: var(--link); font-weight: 500; padding: 8px 10px; cursor: pointer; text-decoration: none; }

.recipient-card { display: flex; gap: 12px; align-items: center; padding: 12px 4px 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--accent) center/cover;
  color: var(--accent-text); display: grid; place-items: center; font-weight: 700;
}
.rc-name { font-weight: 600; }
.rc-hint { color: var(--hint); font-size: 14px; }
.error { color: var(--danger); font-size: 14px; margin: 8px 4px 0; }

.methods { display: grid; gap: 1px; background: var(--bg-2); border-radius: var(--radius-s); overflow: hidden; }
.method {
  display: flex; align-items: center; gap: 12px; border: 0; background: var(--bg-2); padding: 13px 14px;
  cursor: pointer; text-align: left; border-bottom: 1px solid color-mix(in srgb, var(--hint) 18%, transparent);
}
.method:last-child { border-bottom: 0; }
.method .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--hint); flex: none; }
.method[aria-pressed="true"] .radio { border: 6px solid var(--accent); }
.method small { display: block; color: var(--hint); font-size: 13px; }

.fallback-main {
  width: 100%; margin-top: 24px; border: 0; border-radius: var(--radius-s); padding: 15px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer;
}
.fallback-main:disabled { opacity: .5; }
.secondary-btn {
  width: 100%; margin-top: 16px; border: 0; border-radius: var(--radius-s); padding: 14px;
  background: var(--bg-2); color: var(--link); font-weight: 600; cursor: pointer;
}
.footer-links { display: flex; justify-content: center; gap: 8px; margin-top: 22px; }

.consent { color: var(--hint); font-size: 13px; line-height: 1.45; margin: 22px 4px 0; }
.consent a, .legal-links a { color: var(--link); text-decoration: none; }
.legal-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: 13px; }

/* --- подписка на канал --- */
.sub-box { text-align: center; padding: 48px 8px 0; }
.sub-icon { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; }
.sub-icon svg { width: 36px; height: 36px; fill: var(--accent-text); margin-left: -3px; }
.sub-title { font-size: 24px; margin: 0 0 8px; }
.sub-text { color: var(--hint); margin: 0 auto 8px; max-width: 32ch; }
.sub-text b { color: var(--text); font-weight: 600; }
.sub-hint { color: var(--danger); font-size: 14px; min-height: 1.4em; }

/* --- экран заказа --- */
.order-head { text-align: center; margin: 28px 0 26px; }
.order-qty { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.order-to { color: var(--hint); margin-top: 2px; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li {
  counter-increment: s; position: relative; padding: 0 0 22px 42px; color: var(--hint); min-height: 28px; line-height: 28px;
}
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-2); display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 13px; top: 31px; bottom: 3px; width: 2px; background: var(--bg-2);
}
.steps li.done { color: var(--text); }
.steps li.done::before { content: "✓"; background: var(--accent); color: var(--accent-text); }
.steps li.done::after { background: var(--accent); }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active::before { background: var(--gold-soft); color: var(--text); animation: pulse 1.4s ease-in-out infinite; }
.steps li.final.done::before { content: "★"; background: var(--gold); color: #fff; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--gold-soft); } }
.order-note { background: var(--bg-2); border-radius: var(--radius-s); padding: 12px 14px; margin: 4px 0 18px; }
.order-note:empty { display: none; }
.order-meta { margin: 0; display: grid; gap: 8px; }
.order-meta div { display: flex; justify-content: space-between; }
.order-meta dt { color: var(--hint); }
.order-meta dd { margin: 0; font-variant-numeric: tabular-nums; }

/* --- история --- */
.screen-title { font-size: 24px; margin: 8px 4px 14px; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; cursor: pointer; border-bottom: 1px solid var(--bg-2); }
.h-what { font-weight: 600; }
.h-sub { color: var(--hint); font-size: 14px; }
.h-right { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.badge { font-size: 13px; color: var(--hint); }
.badge.ok { color: #2e9e5b; }
.badge.warn { color: var(--danger); }
.empty { color: var(--hint); text-align: center; margin-top: 40px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  max-width: calc(100% - 32px); font-size: 15px; z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  .dial-star { transition: none; }
  .steps li.active::before { animation: none; }
}
