.modal {
  width: min(880px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 48px);
  padding: 0;
  color: var(--color-text);
  background: none;
  border: 0;
  overflow: visible;
}

.modal::backdrop {
  background-color: rgba(20, 28, 35, 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.modal--open::backdrop {
  opacity: 1;
}

.modal--closing::backdrop {
  opacity: 0;
}

.modal__box:focus {
  outline: none;
}

.modal__box {
  position: relative;
  display: grid;
  grid-template-columns: 46% 1fr;
  overflow: hidden;
  max-height: calc(100vh - 48px);
  background-color: var(--color-surface);
  border-radius: 28px;
  box-shadow: 0 40px 90px rgba(20, 28, 35, 0.3);
  opacity: 0;
  transform: translate3d(0, 24px, 0) scale(0.96);
  transition:
    opacity 0.4s ease,
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal--open .modal__box {
  opacity: 1;
  transform: none;
}

.modal--closing .modal__box {
  opacity: 0;
  transform: translate3d(0, 16px, 0) scale(0.97);
  transition-duration: 0.25s;
}

.modal__aside {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 44px 40px 0;
  background: linear-gradient(160deg, #e4edf5 0%, #eef3f7 45%, #e8eef4 100%);
}

.modal__pill {
  align-self: flex-start;
  margin-bottom: 24px;
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  background-color: rgba(255, 255, 255, 0.75);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 14px rgba(30, 50, 70, 0.06);
}

.modal__title {
  margin-bottom: 18px;
  font-size: 40px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.modal__text {
  margin-bottom: 26px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-muted);
}

.modal__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 30px;
}

.modal__list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: var(--color-text-secondary);
}

.modal__list-item svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--color-dark);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal__spiral {
  flex-shrink: 0;
  width: 116%;
  margin-top: auto;
  margin-left: -16%;
  margin-bottom: -9%;
  filter:
    drop-shadow(0 26px 30px rgba(40, 62, 84, 0.18))
    drop-shadow(0 8px 12px rgba(40, 62, 84, 0.1));
}

.modal__form,
.modal__success {
  grid-column: 2;
  grid-row: 1;
}

.modal__form[hidden] {
  display: none;
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 44px 40px;
}

.modal__form > * {
  flex-shrink: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.field__label span {
  color: #b23b3b;
}

.field__input {
  width: 100%;
  padding: 14px 18px;
  font: inherit;
  font-size: 16px;
  color: var(--color-text);
  background-color: #f7f9fb;
  border: 1px solid #e3e9ee;
  border-radius: 14px;
  transition: border-color var(--transition), background-color var(--transition), box-shadow var(--transition);
}

.field__input::placeholder {
  color: #9aa6b2;
}

.field__input:hover {
  border-color: #d3dce4;
}

.field__input:focus {
  outline: none;
  background-color: var(--color-surface);
  border-color: var(--color-dark);
  box-shadow: 0 0 0 4px rgba(20, 28, 35, 0.07);
}

.modal__form--checked .field__input:invalid {
  border-color: #d98a8a;
  background-color: #fdf7f7;
}

textarea.field__input {
  min-height: 104px;
  resize: vertical;
}

.field__select {
  appearance: none;
  padding-right: 46px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237d8694' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 12px;
  cursor: pointer;
}

.field__select:invalid {
  color: #9aa6b2;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-muted);
  cursor: pointer;
}

.checkbox__link {
  color: var(--color-dark);
  text-decoration: underline;
  text-decoration-color: #c3ced7;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition);
}

.checkbox__link:hover {
  text-decoration-color: currentColor;
}

.checkbox__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.checkbox__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background-color: #f7f9fb;
  border: 1px solid #dfe6ec;
  border-radius: 7px;
  transition: background-color var(--transition), border-color var(--transition);
}

.checkbox__mark svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--transition), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.checkbox__input:checked + .checkbox__mark {
  background-color: var(--color-dark);
  border-color: var(--color-dark);
}

.checkbox__input:checked + .checkbox__mark svg {
  opacity: 1;
  transform: none;
}

.checkbox__input:focus-visible + .checkbox__mark {
  outline: 2px solid var(--color-dark);
  outline-offset: 3px;
}

.modal__form--checked .checkbox__input:invalid + .checkbox__mark {
  border-color: #d98a8a;
  background-color: #fdf7f7;
}

.modal__submit {
  width: 100%;
  height: 56px;
  margin-top: 6px;
}

.modal__close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--color-text-secondary);
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(30, 50, 70, 0.1);
  transition: color var(--transition), background-color var(--transition), transform var(--transition);
}

.modal__close svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.modal__close:hover {
  color: #fff;
  background-color: var(--color-dark);
  transform: rotate(90deg);
}

.modal__success[hidden] {
  display: none;
}

.modal__success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 44px 40px;
  text-align: center;
}

.modal__success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  color: #fff;
  background: linear-gradient(160deg, #283742, #141e26);
  border-radius: 50%;
  animation: modal-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal__success-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal__success-title {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.modal__success-text {
  max-width: 320px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-muted);
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal__aside > *,
.modal__form > * {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
}

.modal--open .modal__aside > *,
.modal--open .modal__form > * {
  animation: modal-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(0.12s + var(--i, 0) * 0.05s);
}

.modal__aside > *:nth-child(2) { --i: 1; }
.modal__aside > *:nth-child(3) { --i: 2; }
.modal__aside > *:nth-child(4) { --i: 3; }
.modal__aside > *:nth-child(5) { --i: 4; }

.modal__form > *:nth-child(2) { --i: 1; }
.modal__form > *:nth-child(3) { --i: 2; }
.modal__form > *:nth-child(4) { --i: 3; }
.modal__form > *:nth-child(5) { --i: 4; }
.modal__form > *:nth-child(6) { --i: 5; }

@keyframes modal-rise {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal__box,
  .modal::backdrop {
    transition: none;
  }

  .modal__aside > *,
  .modal__form > * {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .modal__success-icon {
    animation: none;
  }

  .modal__close:hover {
    transform: none;
  }
}

@media (max-width: 900px) {
  .modal {
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .modal__box {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .modal__aside {
    flex-shrink: 0;
  }

  .modal__form,
  .modal__success {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .modal__aside {
    padding: 32px 28px 76px;
  }

  .modal__title {
    font-size: 30px;
  }

  .modal__text {
    margin-bottom: 0;
    font-size: 15px;
  }

  .modal__list {
    display: none;
  }

  .modal__aside > *:not(.modal__spiral) {
    position: relative;
    z-index: 1;
    max-width: 68%;
  }

  .modal__spiral {
    position: absolute;
    right: -18px;
    bottom: -62px;
    width: 216px;
    margin: 0;
  }

  .modal__form {
    padding: 28px;
  }
}

@media (max-width: 576px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal {
    width: 100vw;
    max-height: 92vh;
    max-height: 92dvh;
    margin: 0;
    margin-top: auto;
    margin-bottom: 0;
  }

  .modal__box {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
    transform: translate3d(0, 40px, 0);
  }

  .modal--closing .modal__box {
    transform: translate3d(0, 24px, 0);
  }

  .modal__aside {
    padding: 26px 20px 22px;
  }

  .modal__spiral {
    display: none;
  }

  .modal__aside > *:not(.modal__spiral) {
    max-width: 100%;
  }

  .modal__pill {
    margin-bottom: 16px;
  }

  .modal__title {
    font-size: 26px;
  }

  .modal__form {
    gap: 14px;
    padding: 22px 20px 26px;
  }

  .field__input {
    padding: 12px 16px;
  }

  textarea.field__input {
    min-height: 88px;
  }

  .modal__close {
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
  }

  .modal__submit {
    height: 52px;
  }
}

@media (max-width: 576px) and (max-height: 820px) {
  .modal__aside {
    padding: 20px 20px 16px;
  }

  .modal__pill {
    margin-bottom: 12px;
  }

  .modal__title {
    margin-bottom: 8px;
    padding-right: 44px;
    font-size: 23px;
  }

  .modal__text {
    font-size: 14px;
    line-height: 1.45;
  }

  .modal__form {
    gap: 12px;
    padding: 18px 20px 22px;
  }

  .field {
    gap: 6px;
  }

  textarea.field__input {
    min-height: 72px;
  }

  .modal__submit {
    height: 50px;
  }
}

@media (max-height: 700px) and (min-width: 901px) {
  .modal__aside {
    padding-top: 32px;
  }

  .modal__title {
    font-size: 32px;
  }

  .modal__form {
    padding-block: 32px;
  }
}
