/* Цвета берём из темы Telegram (SDK выставляет --tg-theme-*), чтобы
   приложение выглядело частью клиента и в светлой, и в тёмной теме.
   Значения после запятой — для открытия в обычном браузере на стенде. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #16181d);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --surface: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --danger: var(--tg-theme-destructive-text-color, #d93025);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) {
    --bg: #17191d;
    --text: #eceef2;
    --hint: #8d939e;
    --surface: #23262c;
  }
}

* { box-sizing: border-box; }

/* display: block у кнопок-ссылок перебивает атрибут hidden — возвращаем ему силу. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 8px;
  min-height: 70vh;
}

footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  text-align: center;
}

.screen { animation: appear .18s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.hero {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.text { white-space: pre-line; overflow-wrap: anywhere; }
.text b { font-weight: 650; }
.text + .text { margin-top: 16px; }

.actions { display: grid; gap: 10px; margin-top: 20px; }

.button {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--btn);
  color: var(--btn-text);
  transition: opacity .15s;
}
.button.secondary { background: var(--surface); color: var(--text); }
.button:disabled { opacity: .45; cursor: default; }
.button.busy { opacity: .7; pointer-events: none; }
.button:focus-visible, .option:focus-visible, .link-button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.progress {
  height: 4px;
  border-radius: 2px;
  background: var(--surface);
  margin-bottom: 16px;
  overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--btn); transition: width .25s; }

.options { display: grid; gap: 8px; margin-top: 16px; }

.option {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.option .letter {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 14px;
  background: var(--bg);
  color: var(--hint);
}
.option.chosen { border-color: var(--btn); }
.option.chosen .letter { background: var(--btn); color: var(--btn-text); }
.options.locked .option:not(.chosen) { opacity: .5; }

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 14px;
  cursor: pointer;
}
.check input {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--btn);
}

.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  white-space: pre-line;
}

.mailing { margin-top: 24px; }
.mailing .link-button { display: block; margin: 8px auto 0; }

.divider { height: 1px; background: var(--surface); margin: 24px 0; border: 0; }

.link-button {
  appearance: none;
  border: 0;
  background: none;
  padding: 8px;
  font: inherit;
  font-size: 14px;
  color: var(--hint);
  text-decoration: underline;
  cursor: pointer;
}
footer .link-button { display: block; margin: 0 auto; }

.link-button.inline { padding: 0; color: var(--link); font-size: inherit; }

.plain { padding: 16px; text-align: center; color: var(--hint); }

.loading { display: grid; place-items: center; min-height: 50vh; }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  border-top-color: var(--btn);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
