html.form-dialog-open,
body.form-dialog-open {
  overflow: hidden;
}
.form-dialog {
  width: min(660px, calc(100% - 32px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 40px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(18, 49, 32, 0.22);
}
.form-dialog[open] {
  display: flex;
  flex-direction: column;
}
.form-dialog::backdrop {
  background: rgba(17, 35, 26, 0.48);
}
.form-dialog-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 20px;
  flex: 0 0 auto;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}
.form-dialog-kicker {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 750;
}
.form-dialog-header h2 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.2;
}
.form-dialog-header h2:focus {
  outline: none;
}
.form-dialog-close {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 1.6rem;
  cursor: pointer;
}
.form-progress {
  grid-column: 1 / -1;
}
.form-progress p {
  margin: 0 0 10px;
  font-size: 0.83rem;
  color: var(--text-muted);
}
.form-progress progress {
  display: block;
  width: 100%;
  height: 5px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  accent-color: var(--green);
  background: var(--green-light);
}
.form-progress progress::-webkit-progress-bar {
  background: var(--green-light);
}
.form-progress progress::-webkit-progress-value {
  background: var(--green);
}
.form-progress progress::-moz-progress-bar {
  background: var(--green);
}
.form-dialog-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 28px 0;
}
.form-dialog .wizard-form {
  margin: 0;
  max-width: none;
}
.wizard-step h3 {
  margin: 0 0 18px;
  font-size: 1.1rem;
}
.form-dialog .field-row {
  margin-bottom: 18px;
}
.form-dialog .field-row label {
  display: block;
  margin-bottom: 7px;
}
.form-dialog .field-row input,
.form-dialog .field-row select,
.form-dialog .field-row textarea {
  width: 100%;
  font-size: 1rem;
}
.form-dialog .field-row textarea {
  min-height: 100px;
}
.wizard-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 22px;
  margin-top: 18px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.wizard-actions .primary-button {
  margin-left: auto;
}
.wizard-actions button {
  min-height: 46px;
}
.wizard-status {
  margin: 14px 0 0;
  font-size: 0.9rem;
}
.wizard-status:empty {
  display: none;
}
.wizard-text-button {
  border: 0;
  padding: 8px;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.wizard-summary-group {
  padding: 0 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.wizard-summary-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wizard-summary-heading h3 {
  margin: 0;
}
.wizard-summary-group dl {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1.3fr);
  gap: 10px 20px;
  margin: 12px 0 0;
  font-size: 0.88rem;
}
.wizard-summary-group dt {
  color: var(--text-muted);
}
.wizard-summary-group dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.form-dialog label.wizard-confirm {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  margin: 20px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background-soft);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.55;
  cursor: pointer;
}
.form-dialog .wizard-confirm input[type="checkbox"] {
  appearance: auto;
  display: block;
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 1px 0 0;
  padding: 0;
  accent-color: var(--green);
  cursor: pointer;
}
.form-dialog .wizard-confirm:has(input:checked) {
  border-color: #8bb99a;
  background: var(--green-light);
}
.form-dialog .wizard-confirm:focus-within {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.form-dialog .wizard-confirm input:focus {
  outline: none;
  box-shadow: none;
}
.wizard-captcha {
  min-width: 0;
}
.wizard-captcha-status {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.form-launcher {
  margin: 22px 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background-soft);
}
.form-launcher p {
  margin: 0 0 16px;
}
.form-launch-status {
  padding: 12px;
  color: #8d331e;
}
.support-invitation {
  position: fixed;
  z-index: 1500;
  right: 24px;
  bottom: 24px;
  width: min(380px, calc(100% - 32px));
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 42px rgba(18, 49, 32, 0.18);
  color: var(--text);
}
.support-invitation h2 {
  font-size: 1.25rem;
  line-height: 1.25;
  margin: 0 34px 10px 0;
}
.support-invitation > p {
  font-size: 0.87rem;
  margin: 0 0 18px;
  color: var(--text-muted);
}
.support-invitation-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}
.support-invitation-options {
  display: grid;
  gap: 10px;
}
.support-invitation-options a {
  display: block;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--green);
  background: var(--green-light);
}
.support-invitation-options strong {
  display: block;
  font-size: 0.9rem;
}
.support-invitation-options span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.support-invitation-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  gap: 8px;
}
.support-invitation-actions button {
  min-height: 40px;
}
@media (max-width: 560px) {
  .form-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 14px;
  }
  .form-dialog-header {
    padding: 18px 16px 16px;
    gap: 14px;
  }
  .form-dialog-header h2 {
    font-size: 1.35rem;
  }
  .form-dialog-scroll {
    padding: 18px 16px 0;
  }
  .form-dialog .two-column {
    grid-template-columns: 1fr;
  }
  .wizard-actions {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .wizard-actions button {
    padding-inline: 14px;
    font-size: 0.88rem;
  }
  .wizard-summary-group dl {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .wizard-summary-group dd {
    margin-bottom: 8px;
  }
  .support-invitation {
    right: 16px;
    bottom: 16px;
    padding: 18px;
  }
}

/* Leave room for fields on landscape phones and when a keyboard is open. */
@media (max-height: 520px) {
  .form-dialog {
    max-height: calc(100dvh - 16px);
  }
  .form-dialog-header {
    padding: 10px 16px;
    gap: 8px;
    align-items: center;
  }
  .form-dialog-kicker {
    display: none;
  }
  .form-dialog-header h2 {
    font-size: 1.15rem;
  }
  .form-dialog-close {
    width: 36px;
    height: 36px;
  }
  .form-progress p {
    margin-bottom: 5px;
  }
  .form-dialog-scroll {
    padding: 14px 16px 0;
  }
  .wizard-actions {
    padding-block: 8px;
  }
  .wizard-actions button {
    min-height: 44px;
  }
}
