.form-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: none;
}

.form-modal[hidden] { display: none; }

@media (max-height: 860px) {
  .form-modal {
    align-items: flex-start;
    padding-block: 20px;
  }
}

.form-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.form-modal__window {
  position: relative;
  overflow: hidden;
  width: min(1405px, 73vw);
  max-width: 100%;
  margin: auto;
  padding: 60px 30px;
  background: var(--gradient-accent);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.form-modal__window::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 55% at 88% 8%, rgba(255, 255, 255, 0.28), transparent 70%),
    radial-gradient(75% 60% at 78% 96%, rgba(255, 255, 255, 0.16), transparent 70%);
}

.form-modal__window > * {
  position: relative;
  z-index: 1;
}

.form-modal__close {
  position: absolute;
  top: 30px;
  right: 30px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: var(--radius-pill);
  color: var(--color-white);
  transition: background-color 0.25s ease;
}

.form-modal__close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.form-modal__title {
  width: 67%;
  min-width: min(100%, 320px);
  margin: 0 auto 40px;
  font-size: var(--fs-h3);
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--color-white);
}

.form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

.form__fields {
  display: flex;
  flex-direction: column;
  gap: 30px;
  width: 55%;
  min-width: min(100%, 280px);
}

.form__field {
  width: 100%;
}

.form__input {
  width: 100%;
  padding: 0 0 12px;
  font: inherit;
  font-size: var(--fs-text);
  color: var(--color-white);
  background: none;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0;
  transition: border-color 0.25s ease, color 0.25s ease;
}

.form__input::placeholder {
  color: var(--color-light-blue);
}

.form__input:focus {
  outline: none;
  border-bottom-color: var(--color-white);
}

.form__input:disabled {
  color: rgba(255, 255, 255, 0.4);
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

.form__input:disabled::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.form__field--error .form__input,
.form__field--error .form__input:focus {
  color: var(--color-error);
  border-bottom-color: var(--color-error);
}

.form__field--error .form__input::placeholder {
  color: var(--color-error);
}

.form__error {
  margin-top: 8px;
  font-size: var(--fs-small);
  color: var(--color-error);
}

.form__schools--error .form__radio-mark {
  border-color: var(--color-error);
}

.form__schools .form__error {
  margin-top: 0;
}

.form__error:empty {
  display: none;
}

.form__bottom {
  width: 55%;
  min-width: min(100%, 280px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form__schools {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form__legend {
  padding: 0;
  margin-bottom: 10px;
  color: var(--color-light-blue);
}

.form__radio,
.form__consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--color-white);
  cursor: pointer;
}

.form__radio input,
.form__consent input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.form__radio-mark,
.form__consent-mark {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.form__radio-mark {
  border-radius: var(--radius-pill);
}

.form__consent-mark {
  position: relative;
  border-radius: 6px;
}

.form__radio input:checked + .form__radio-mark {
  border-color: var(--color-white);
  background:
    radial-gradient(circle at center, var(--color-white) 0 5px, transparent 5px);
}

.form__consent input:checked + .form__consent-mark::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--color-white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form__radio input:focus-visible + .form__radio-mark,
.form__consent input:focus-visible + .form__consent-mark {
  outline: 2px solid var(--color-white);
  outline-offset: 2px;
}

.form__consent-text {
  font-size: var(--fs-small);
}

.form__consent-text a {
  text-decoration: underline;
}

.form__submit[disabled] {
  opacity: 0.6;
  cursor: default;
}

.form-modal__success {
  text-align: center;
  color: var(--color-white);
}

.form-modal__success[hidden] { display: none; }

.form-modal__success-title {
  font-size: var(--fs-h3);
  font-family: var(--font-heading);
  font-weight: 700;
  margin-bottom: 16px;
}

.form-modal__success-text {
  max-width: 640px;
  margin: 0 auto 32px;
}

@media (max-width: 767px) {
  .form-modal {
    align-items: flex-start;
    padding: 0;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--gradient-accent);
  }

  .form-modal__backdrop { display: none; }

  .form-modal__window {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding:
      calc(89px + env(safe-area-inset-top)) 30px
      calc(40px + env(safe-area-inset-bottom));
    border-radius: 0;
    box-shadow: none;
  }

  .form-modal__close {
    position: absolute;
    top: calc(5px + env(safe-area-inset-top));
    right: 6px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.18);
  }

  .form__radio {
    gap: 10px;
    align-items: center;
  }

  .form__radio-mark {
    width: 20px;
    height: 20px;
    margin-top: 0;
  }

  .form__consent { gap: 13px; }

  .form__consent-mark {
    width: 25px;
    height: 25px;
  }

  .form__consent input:checked + .form__consent-mark::after {
    left: 8px;
    top: 4px;
  }

  .form-modal__title {
    width: 260px;
    max-width: 100%;
    margin-inline: auto;
    margin-bottom: 51px;
    font-size: 32px;
    line-height: 0.9;
  }

  .form__input,
  .form__input::placeholder {
    font-size: 16px;
  }

  .form {
    gap: 30px;
  }

  .form__fields {
    gap: 24px;
  }

  .form__submit {
    width: 100%;
    height: 48px;
    padding: 0;
  }
}
