/* Форма генерации на главной (этап S06; S31 — цвета, тени и стекло списка только из tokens.css).
   Разметка — main.tpl (.stx-form), поведение селекта и тумблеров — js/form.js.
   Логику отправки (generate.js) не трогаем: поля те же, добавлено no_sources=1. */
.stx-form {
  /* S31-r: цвета формы — алиасы единых токенов tokens.css (один акцент #2F6BFF на весь проект) */
  --f-accent: var(--stx-accent, #2F6BFF);
  --f-accent-2: var(--stx-accent-hover, #2258EE);
  --f-accent-soft: var(--stx-accent-soft, rgba(47, 107, 255, .10));
  --f-ink: var(--stx-text, #1B2430);
  --f-muted: var(--stx-text-2, #566274);
  --f-line: var(--stx-line, rgba(27, 36, 48, .14));
  --f-line-strong: var(--stx-accent-line, rgba(47, 107, 255, .28));
  --f-chip: var(--stx-surface-2, #F8FAFF);
  --f-radius: var(--stx-r-card, 14px);
  --f-ease: var(--stx-ease, cubic-bezier(.32, .72, 0, 1));
  --f-paid-from: var(--stx-accent, #2F6BFF);
  --f-paid-to: var(--stx-accent, #2F6BFF);
  --f-font: var(--stx-font, "Inter", system-ui, -apple-system, "Segoe UI", sans-serif);

  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 580px;
  margin: 0 auto 28px;
  padding: 28px 28px 22px;
  box-sizing: border-box;
  border-radius: 24px;
  background: var(--stx-surface, #fff);
  box-shadow: var(--stx-shadow-paper, 0 1px 2px rgba(20, 40, 80, .06), 0 12px 40px rgba(20, 40, 80, .08)), 0 18px 50px rgba(47, 107, 255, .08);
  text-align: left;
  font-family: var(--f-font);
  color: var(--f-ink);
  opacity: 0;
  animation: contentFadeUp 1s cubic-bezier(.19, 1, .22, 1) .8s forwards;
}
/* Анимация появления — у карточки целиком, у вложенных блоков старые анимации снимаем */
.stx-form .hero__create,
.stx-form .hero__work-types,
.stx-form .hero__generate,
.stx-form .policy {
  opacity: 1;
  animation: none;
  transform: none;
}

.stx-form__label {
  display: block;
  margin: 0 0 10px;
  font: 500 15px/1.3 var(--f-font);
  color: var(--f-ink);
  letter-spacing: -.01em;
}

/* Тема */
.stx-form .hero__create {
  display: block;
  padding: 0;
  margin: 0 0 22px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  z-index: auto;
}
.stx-form .hero__create .theme-presentation {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  border: 1px solid var(--f-line);
  border-radius: var(--f-radius);
  background: var(--stx-surface, #fff);
  font: 400 16px/1.4 var(--f-font);
  color: var(--f-ink);
  outline: none;
  transition: border-color .2s var(--f-ease), box-shadow .2s var(--f-ease);
}
.stx-form .hero__create .theme-presentation::placeholder { color: var(--stx-text-3, #8A94A6); }
.stx-form .hero__create .theme-presentation:hover { border-color: var(--f-line-strong); }
.stx-form .hero__create .theme-presentation:focus {
  border-color: var(--f-accent-2);
  box-shadow: 0 0 0 4px var(--f-accent-soft);
}
.stx-form .hero__create .theme-presentation.is-invalid {
  outline: none;
  border-color: var(--stx-danger, #E0405A);
  box-shadow: 0 0 0 4px var(--stx-danger-soft, rgba(224, 64, 90, .12));
}

/* Тип работы — «таблетки» в 2 ряда */
.stx-form .hero__work-types {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 24px;
}
.stx-form .hero__work-type {
  flex: 0 0 auto;
  position: relative;
}
.stx-form .hero__work-type span {
  min-height: 46px;
  padding: 11px 18px;
  box-sizing: border-box;
  border: 1px solid var(--f-line);
  border-radius: 12px;
  background: var(--f-chip);
  color: var(--f-ink);
  font: 500 16px/1.2 var(--f-font);
  box-shadow: none;
  transition: background .2s var(--f-ease), border-color .2s var(--f-ease),
    color .2s var(--f-ease), box-shadow .25s var(--f-ease), transform .2s var(--f-ease);
}
.stx-form .hero__work-type .hero__work-type__icon { opacity: .7; }
.stx-form .hero__work-type:hover span {
  background: var(--stx-surface, #fff);
  border-color: var(--f-line-strong);
  box-shadow: var(--stx-shadow-sm, 0 1px 2px rgba(20, 40, 80, .04), 0 4px 12px rgba(20, 40, 80, .06));
}
.stx-form .hero__work-type:active span { transform: scale(.97); }
.stx-form .hero__work-type.is-active span,
.stx-form .hero__work-type:has(input:checked) span {
  background: var(--f-accent);
  border-color: transparent;
  color: var(--stx-on-accent, #fff);
  box-shadow: var(--stx-accent-shadow, 0 6px 16px rgba(47, 107, 255, .26));
}
.stx-form .hero__work-type.is-active .hero__work-type__icon,
.stx-form .hero__work-type:has(input:checked) .hero__work-type__icon { opacity: 1; }
.stx-form .hero__work-type:has(input:focus-visible) span {
  outline: 3px solid var(--f-accent-2);
  outline-offset: 2px;
}

/* Ряд селектов */
.stx-form__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 0 0 18px;
}
.stx-field { min-width: 0; }

/* Селект: нативный <select> — источник значения; кастомный список поверх (form.js) */
.stx-select { position: relative; }
.stx-select__native {
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 0 48px 0 18px;
  border: 1px solid var(--f-line);
  border-radius: var(--f-radius);
  background: var(--stx-surface, #fff);
  font: 500 17px/1.2 var(--f-font);
  color: var(--f-ink);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
/* Когда form.js поднял кастомный список, нативный скрыт визуально, но остаётся в форме */
.stx-select.is-enhanced .stx-select__native {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
/* Сенсорный экран: системный список, нативный select прозрачный поверх кнопки */
.stx-select.is-native-pick .stx-select__native {
  z-index: 2;
  pointer-events: auto;
}
.stx-select.is-native-pick .stx-select__native:focus-visible ~ .stx-select__btn {
  border-color: var(--f-accent-2);
  box-shadow: 0 0 0 4px var(--f-accent-soft);
}
.stx-select__value {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.stx-select__btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 0 48px 0 18px;
  box-sizing: border-box;
  border: 1px solid var(--f-line);
  border-radius: var(--f-radius);
  background: var(--stx-surface, #fff);
  color: var(--f-ink);
  font: 500 17px/1.2 var(--f-font);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s var(--f-ease), box-shadow .2s var(--f-ease);
}
.stx-select__btn:hover { border-color: var(--f-line-strong); box-shadow: var(--stx-shadow-sm, 0 1px 2px rgba(20, 40, 80, .04), 0 4px 12px rgba(20, 40, 80, .06)); }
.stx-select__btn:focus { outline: none; }
.stx-select__btn:focus-visible,
.stx-select.is-open .stx-select__btn {
  border-color: var(--f-accent-2);
  box-shadow: 0 0 0 4px var(--f-accent-soft);
}
.stx-select__chevron,
.stx-select::after {
  position: absolute;
  top: 50%;
  right: 18px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  color: var(--f-accent);
  pointer-events: none;
  transition: transform .25s var(--f-ease);
}
/* Шеврон у нативного селекта без JS */
.stx-select:not(.is-enhanced)::after {
  content: "";
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.stx-select.is-enhanced::after { content: none; }
.stx-select.is-open .stx-select__chevron { transform: rotate(180deg); }

.stx-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--f-paid-from), var(--f-paid-to));
  color: var(--stx-on-accent, #fff);
  font: 600 12px/1 var(--f-font);
  letter-spacing: .01em;
  white-space: nowrap;
}

.stx-select__list {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(380px, 60vh); /* S31: 8 пунктов объёма целиком */
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  box-sizing: border-box;
  border: 1px solid var(--f-line);
  border-radius: var(--f-radius);
  background: var(--stx-glass-bg-strong, rgba(255, 255, 255, .96));
  -webkit-backdrop-filter: var(--stx-glass-blur, blur(20px) saturate(140%));
  backdrop-filter: var(--stx-glass-blur, blur(20px) saturate(140%));
  box-shadow: var(--stx-shadow-md, 0 8px 24px rgba(20, 40, 80, .10));
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(.98);
  transform-origin: top center;
  transition: opacity .18s var(--f-ease), transform .22s var(--f-ease), visibility 0s linear .22s;
}
.stx-select.is-up .stx-select__list {
  top: auto;
  bottom: calc(100% + 8px);
  transform-origin: bottom center;
}
.stx-select.is-open .stx-select__list {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}
.stx-select__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--f-ink);
  font: 400 16px/1.2 var(--f-font);
  cursor: pointer;
  transition: background .15s var(--f-ease), color .15s var(--f-ease);
}
.stx-select__option.is-active { background: var(--stx-fill, #f1f5fb); }
.stx-select__option[aria-selected="true"] { color: var(--f-accent); font-weight: 600; }
.stx-select__check {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--f-accent);
  visibility: hidden;
}
.stx-select__option[aria-selected="true"] .stx-select__check { visibility: visible; }
.stx-select__option .stx-badge { margin-left: auto; }
.stx-select__option .stx-badge + .stx-select__check { margin-left: 0; }

/* Тумблеры */
.stx-switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.stx-switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--stx-fill-2, rgba(27, 36, 48, .09));
  box-shadow: inset 0 0 0 1px var(--stx-line, rgba(27, 36, 48, .14));
  transition: background .25s var(--f-ease), box-shadow .25s var(--f-ease);
}
.stx-switch__input:checked + .stx-switch { box-shadow: none; }
.stx-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--stx-surface, #fff);
  box-shadow: 0 1px 3px rgba(20, 40, 80, .25);
  transition: transform .3s cubic-bezier(.34, 1.4, .64, 1);
}
.stx-switch__input:checked + .stx-switch { background: var(--f-accent); }
.stx-switch__input:checked + .stx-switch::after { transform: translateX(18px); }
.stx-switch__input:focus-visible + .stx-switch {
  outline: 3px solid var(--f-accent-2);
  outline-offset: 2px;
}
.stx-switch--sm { width: 36px; height: 22px; border-radius: 11px; }
.stx-switch--sm::after { width: 16px; height: 16px; }
.stx-switch__input:checked + .stx-switch--sm::after { transform: translateX(14px); }

.stx-switch-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  margin: 0 0 26px;
  padding: 14px 18px;
  box-sizing: border-box;
  border: 1px solid var(--f-line);
  border-radius: var(--f-radius);
  background: var(--stx-surface, #fff);
  cursor: pointer;
  user-select: none;
  transition: border-color .2s var(--f-ease), background .2s var(--f-ease), box-shadow .2s var(--f-ease);
}
.stx-switch-card:hover { border-color: var(--f-line-strong); box-shadow: var(--stx-shadow-sm, 0 1px 2px rgba(20, 40, 80, .04), 0 4px 12px rgba(20, 40, 80, .06)); }
.stx-switch-card:has(input:checked) { border-color: var(--stx-accent-line, rgba(47, 107, 255, .28)); background: var(--stx-surface-2, #F8FAFF); }
.stx-switch-card__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stx-switch-card__title { font: 500 16px/1.3 var(--f-font); color: var(--f-ink); }
.stx-switch-card__hint { font: 400 13px/1.35 var(--f-font); color: var(--f-muted); }

/* Кнопка */
.stx-form .hero__generate.stx-form__submit {
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
}
.stx-form .stx-form__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--f-radius);
  background: var(--f-accent);
  color: var(--stx-on-accent, #fff);
  font: 600 18px/1.2 var(--f-font);
  letter-spacing: -.01em;
  box-shadow: 0 12px 28px rgba(47, 107, 255, .28);
  cursor: pointer;
  overflow: hidden;
  transition: transform .2s var(--f-ease), box-shadow .25s var(--f-ease), filter .2s var(--f-ease);
}
.stx-form .stx-form__btn::before,
.stx-form .stx-form__btn::after { content: none; }
.stx-form .stx-form__btn:hover {
  transform: translateY(-1px);
  background: var(--f-accent-2);
  box-shadow: 0 16px 34px rgba(47, 107, 255, .34);
}
.stx-form .stx-form__btn:active { transform: translateY(0) scale(.985); background: var(--stx-accent-active, #1B4DD6); box-shadow: 0 8px 18px rgba(47, 107, 255, .28); }
.stx-form .stx-form__btn:focus-visible { outline: 3px solid var(--f-accent-2); outline-offset: 3px; }

/* Согласие — маленький тумблер */
.stx-form .policy.stx-form__policy { width: 100%; margin: 0; }
.stx-switch-line {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.stx-switch-line .stx-switch { margin-top: 1px; }
.stx-switch-line__text { font: 400 12px/1.45 var(--f-font); color: var(--f-muted); }
.stx-switch-line__text a { display: inline; color: var(--f-accent); text-decoration: underline; text-underline-offset: 2px; }
.stx-switch-line__text a:hover { text-decoration: none; }

@media (max-width: 600px) {
  .stx-form { padding: 20px 16px 18px; border-radius: 20px; }
  .stx-form .hero__work-types { gap: 8px; }
  .stx-form .hero__work-type { flex: 1 1 calc(33.333% - 8px); }
  .stx-form .hero__work-type span { min-height: 46px; padding: 10px 8px; font-size: 15px; }
  .stx-form__row { grid-template-columns: 1fr; }
  .stx-switch-card { padding: 14px; gap: 12px; }
  .stx-form .stx-form__btn { min-height: 58px; font-size: 17px; }
  .stx-switch-line { min-height: 44px; align-items: center; }
}
@media (max-width: 420px) {
  .stx-form .hero__work-type .hero__work-type__icon { display: none; }
}
@media (max-width: 360px) {
  .stx-form .hero__work-type { flex: 1 1 calc(50% - 8px); }
}

@media (prefers-reduced-motion: reduce) {
  .stx-form { opacity: 1; animation: none; }
  .stx-form *,
  .stx-form *::before,
  .stx-form *::after {
    transition-duration: .01ms !important;
    animation: none !important;
  }
  .stx-form .stx-form__btn:hover,
  .stx-form .hero__work-type:active span { transform: none; }
}
