.contact-dialog[open] {
  width: min(46rem, calc(100% - 2rem));
  max-width: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 1.05rem;
  background: var(--surface);
  color: var(--ink);
}

.contact-dialog[open]:not(:modal) {
  position: relative;
  inset: auto;
  margin: 0 auto var(--section-space);
}

.contact-dialog:modal {
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  margin: auto;
  box-shadow: 0 24px 85px #10180d55;
}

.contact-dialog::backdrop {
  background: #152016ad;
  backdrop-filter: blur(3px);
}

body:has(.contact-dialog:modal) {
  overflow: hidden;
}

.contact-dialog-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.6rem 4.4rem 1.65rem 2rem;
}

.contact-dialog-head h2 {
  color: #fff;
  font-size: clamp(1.85rem, 5.65vw, 2.7rem);
  line-height: 1.05;
}

.contact-dialog-head h2:focus,
.contact-form-success h3:focus {
  outline: none;
}

.contact-dialog-head p {
  margin-top: .4rem;
  color: #e3e9d9;
}

.contact-dialog-mark {
  width: 3.8rem;
  height: 3.8rem;
  object-fit: contain;
  margin-inline-end: 1.1rem;
}

.contact-dialog-close {
  position: absolute;
  top: .8rem;
  right: .8rem;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #7a8870;
  border-radius: .5rem;
  background: #34422c;
  color: #fff;
  cursor: pointer;
}

.contact-dialog-close:hover {
  background: #49563e;
}

.contact-dialog [hidden] {
  display: none;
}

.contact-form,
.contact-form-success {
  padding: 1.45rem 2rem 1.65rem;
}

.contact-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .95rem 1.1rem;
}

.contact-field-message {
  grid-column: 1 / -1;
}

.contact-field label {
  display: block;
  margin-bottom: .35rem;
  font-size: .92rem;
  font-weight: 800;
  line-height: 1.25;
}

.contact-field label span {
  color: #536647;
  font-weight: 650;
}

.contact-field :is(input, select, textarea) {
  display: block;
  width: 100%;
  min-height: 2.8rem;
  padding: .55rem .7rem;
  border: 1px solid #bdc5b2;
  border-radius: .5rem;
  background: #fafbf6;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.4;
}

.contact-field textarea {
  min-height: 6rem;
  resize: vertical;
}

.contact-field textarea::placeholder {
  color: #666f60;
}

.contact-field :is(input, select, textarea)[aria-invalid="true"] {
  border-color: #8e3c31;
}

.contact-trap {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.contact-form-end {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .95rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.contact-form-end p {
  max-width: 43ch;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}

.contact-form-end a {
  font-weight: 800;
}

.contact-dialog .button {
  cursor: pointer;
  white-space: nowrap;
}

.contact-dialog .button:disabled {
  opacity: .68;
  cursor: wait;
}

.contact-form-status {
  margin-top: 1rem;
  padding: .75rem .9rem;
  border: 1px solid #daaea7;
  border-radius: .5rem;
  background: #fcf1ec;
  color: #692e25;
  font-size: .94rem;
  line-height: 1.45;
}

.contact-form-status ul {
  margin: .35rem 0 0;
  padding-left: 1.2rem;
}

.contact-form-status a {
  display: inline-block;
  margin-top: .4rem;
  font-weight: 800;
}

.contact-form-success {
  display: grid;
  justify-items: center;
  gap: .85rem;
  padding-block: 2.2rem;
  text-align: center;
}

.contact-success-icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: var(--pale);
  color: #496333;
}

.contact-form-success h3 {
  font-size: 1.65rem;
}

.contact-form-success p {
  max-width: 38ch;
  color: var(--muted);
}

.contact-form-success .button {
  margin-top: .25rem;
}

@media (max-width: 560px) {
  .contact-dialog[open] {
    width: calc(100% - 1rem);
  }

  .contact-dialog:modal {
    max-height: calc(100dvh - 1rem);
  }

  .contact-dialog-head {
    padding: 1.15rem 3.65rem 1.15rem 1rem;
  }

  .contact-dialog-head p {
    font-size: .91rem;
    line-height: 1.35;
  }

  .contact-dialog-mark {
    display: none;
  }

  .contact-dialog-close {
    top: .55rem;
    right: .55rem;
  }

  .contact-form,
  .contact-form-success {
    padding: 1rem;
  }

  .contact-fields {
    grid-template-columns: 1fr;
    gap: .65rem;
  }

  .contact-form-end {
    flex-direction: column;
    align-items: stretch;
    gap: .8rem;
  }
}
