.cxf-form-wrapper {
  /* Default before JS applies the per-form width class. */
  max-width: 640px;
  margin: 0 auto;
  font-family: inherit;
  font-size: inherit;
  color: var(--cxf-text, #202223);
}

/* Form width presets — the two-class selector outranks the base rule above,
 * so these override the theme block's --cxf-max-width slider. */
.cxf-form-wrapper.cxf-width-narrow {
  max-width: 480px;
}

.cxf-form-wrapper.cxf-width-medium {
  max-width: 840px;
}

.cxf-form-wrapper.cxf-width-theme {
  max-width: none;
}

/* Full-bleed: break out of the theme's page-width container to the
 * viewport edges. */
.cxf-form-wrapper.cxf-width-full {
  max-width: none;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

.cxf-form {
  background: var(--cxf-bg, #ffffff);
  border-radius: var(--cxf-radius, 8px);
  box-sizing: border-box;
}

.cxf-form-image-above {
  display: block;
}

.cxf-form-content {
  padding: var(--cxf-padding, 32px);
}

.cxf-form-image-left,
.cxf-form-image-right {
  display: flex;
  align-items: stretch;
}

.cxf-form-image-left {
  flex-direction: row;
}

.cxf-form-image-right {
  flex-direction: row-reverse;
}

.cxf-form-image-left .cxf-form-image-wrap,
.cxf-form-image-right .cxf-form-image-wrap,
.cxf-form-image-left .cxf-form-content,
.cxf-form-image-right .cxf-form-content {
  flex: 1 1 0;
  min-width: 0;
}

.cxf-form-image-above .cxf-form-image-wrap {
  margin-bottom: 1.25rem;
}

.cxf-form-image-wrap {
  display: flex;
}

.cxf-form-image {
  width: 100%;
  height: auto;
  border-radius: var(--cxf-radius, 8px);
  display: block;
}

.cxf-form-image-left .cxf-form-image,
.cxf-form-image-right .cxf-form-image {
  height: 100%;
  object-fit: cover;
}

@media (max-width: 600px) {

  .cxf-form-image-left,
  .cxf-form-image-right {
    flex-direction: column;
  }

  .cxf-form-image-left .cxf-form-image-wrap,
  .cxf-form-image-right .cxf-form-image-wrap {
    margin-bottom: 1.25rem;
  }

  .cxf-form-image-left .cxf-form-image,
  .cxf-form-image-right .cxf-form-image {
    height: auto;
  }
}

.cxf-form-title {
  font: inherit;
  font-size: 1.5em;
  font-weight: 700;
  margin: 0 0 0.5rem;
  line-height: 1.1;
  color: var(--cxf-text, inherit);
}

.cxf-form-description {
  margin: 0 0 1.5rem;
  color: var(--cxf-text, inherit);
  opacity: 0.8;
}

.cxf-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cxf-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  /* Positioning context for the floating label. */
  position: relative;
}

.cxf-field[hidden] {
  display: none !important;
}

/* Floating label — absolutely positioned over its input. This rule is the
 * resting state (label sits inside the field); the floated state is driven by
 * the input :focus / :placeholder-shown rules further down. */
.cxf-label {
  font: inherit;
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1em;
  color: var(--cxf-text, inherit);
  opacity: 0.6;
  pointer-events: none;
  max-width: calc(100% - 1.6rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: top 0.12s ease, font-size 0.12s ease, transform 0.12s ease;
}

.cxf-label-required::after {
  content: " *";
  color: #e53e3e;
}

.cxf-help {
  font: inherit;
  font-size: 0.8em;
  color: var(--cxf-text, inherit);
  opacity: 0.65;
  margin: 0;
}

.cxf-input,
.cxf-select,
.cxf-textarea {
  font: inherit;
  font-size: 1em;
  color: var(--cxf-text, inherit);
  background: transparent;
  border: 1px solid var(--cxf-border, #d1d5db);
  border-radius: calc(var(--cxf-radius, 8px) / 2);
  /* Extra top padding leaves room for the floated label. */
  padding: 1.15rem 0.75rem 0.35rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

/* Selects need an explicit background so the opened option list matches the
 * form background instead of the browser's default white.
 *
 * `appearance: none` forces Safari out of its native "popup button" rendering
 * (which centers the popup on the selected option, making options appear above
 * the trigger and looking squashed once background-color is set) into the
 * standard dropdown that opens below — matching Chrome/Firefox. */
.cxf-select,
.cxf-phone-country {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23202223' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 8px;
  padding-right: 2rem;
}

.cxf-select {
  background-color: var(--cxf-dropdown-bg, var(--cxf-bg, #ffffff));
}

.cxf-select option {
  background-color: var(--cxf-dropdown-bg, var(--cxf-bg, #ffffff));
  color: var(--cxf-text, #202223);
}

/* Chrome on Windows (and other browsers) renders the <select> popup as a
 * native OS widget that ignores CSS — including `background-color` and CSS
 * custom properties — leaving the dropdown white regardless of the form's bg.
 * `appearance: base-select` (Chrome 130+, Firefox/Safari rolling out) opts
 * into an HTML-rendered popup we can style via `::picker(select)`. Browsers
 * that don't recognize the value ignore this whole block and keep the
 * `appearance: none` fallback from above. */
@supports (appearance: base-select) {
  .cxf-select,
  .cxf-phone-country {
    appearance: base-select;
  }

  /* `appearance: base-select` adds a native chevron via ::picker-icon on top
   * of our custom SVG arrow (set as background-image above). Hide the native
   * one so only our arrow shows. */
  .cxf-select::picker-icon,
  .cxf-phone-country::picker-icon {
    display: none;
  }

  .cxf-select::picker(select),
  .cxf-phone-country::picker(select) {
    appearance: base-select;
    background-color: var(--cxf-dropdown-bg, var(--cxf-bg, #ffffff));
    color: var(--cxf-text, #202223);
    border: 1px solid var(--cxf-border, #d1d5db);
    border-radius: calc(var(--cxf-radius, 8px) / 2);
    padding: 0.25rem 0;
  }

  .cxf-select::picker(select) option,
  .cxf-phone-country::picker(select) option {
    background-color: var(--cxf-dropdown-bg, var(--cxf-bg, #ffffff));
    color: var(--cxf-text, #202223);
    padding: 0.4rem 0.75rem;
  }

  .cxf-select::picker(select) option:hover,
  .cxf-phone-country::picker(select) option:hover,
  .cxf-select::picker(select) option:checked,
  .cxf-phone-country::picker(select) option:checked {
    background-color: var(--cxf-accent, #008060);
    color: var(--cxf-dropdown-bg, var(--cxf-bg, #ffffff));
  }
}

.cxf-input:focus,
.cxf-select:focus,
.cxf-textarea:focus {
  outline: none;
  border-color: var(--cxf-accent, #008060);
}

/* Floated label — when the input is focused or already holds a value. Selects
 * have no :placeholder-shown state, so their label stays permanently floated;
 * empty date inputs never match :placeholder-shown either, so they float too. */
.cxf-input:focus + .cxf-label,
.cxf-input:not(:placeholder-shown) + .cxf-label,
.cxf-textarea:focus + .cxf-label,
.cxf-textarea:not(:placeholder-shown) + .cxf-label,
.cxf-select + .cxf-label {
  top: 0.32rem;
  transform: none;
  font-size: 0.7em;
  opacity: 0.7;
}

/* Textareas are tall — rest the label near the top rather than centered. */
.cxf-textarea + .cxf-label {
  top: 1.15rem;
  transform: none;
}

/* Keep the placeholder invisible while the label rests over the same space;
 * reveal it on focus as a secondary hint once the label has floated up. */
.cxf-input::placeholder,
.cxf-textarea::placeholder {
  color: transparent;
}

.cxf-input:focus::placeholder,
.cxf-textarea:focus::placeholder {
  color: var(--cxf-text, #202223);
  opacity: 0.4;
}

.cxf-input[aria-invalid="true"],
.cxf-select[aria-invalid="true"],
.cxf-textarea[aria-invalid="true"] {
  border-color: #e53e3e;
}

.cxf-textarea {
  min-height: 100px;
  resize: vertical;
}

.cxf-phone-group {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.cxf-phone-country {
  font: inherit;
  font-size: 1em;
  color: var(--cxf-text, inherit);
  background-color: var(--cxf-dropdown-bg, var(--cxf-bg, #ffffff));
  border: 1px solid var(--cxf-border, #d1d5db);
  border-radius: calc(var(--cxf-radius, 8px) / 2);
  /* Right padding leaves room for the custom dropdown arrow. */
  padding: 0.5rem 2rem 0.5rem 0.5rem;
  /* Width tuned for "🇬🇧 +44" plus arrow gutter — option labels are flag +
   * dial code only, with full country name available via tooltip / aria-label. */
  flex: 0 0 auto;
  max-width: 9rem;
  box-sizing: border-box;
}

.cxf-phone-country:focus {
  outline: none;
  border-color: var(--cxf-accent, #008060);
}

.cxf-phone-country option {
  background-color: var(--cxf-dropdown-bg, var(--cxf-bg, #ffffff));
  color: var(--cxf-text, #202223);
}

/* Wraps the national-number input so the floating label is positioned over
 * just the input, not the whole country + number row. */
.cxf-phone-national-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.cxf-checkbox-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.cxf-checkbox {
  width: 1rem;
  height: 1rem;
  margin-top: 0.125rem;
  flex-shrink: 0;
  accent-color: var(--cxf-accent, #008060);
}

.cxf-consent-label {
  font: inherit;
  font-size: 0.875em;
  color: var(--cxf-text, inherit);
  cursor: pointer;
}

.cxf-field-error {
  font: inherit;
  font-size: 0.8em;
  color: #e53e3e;
  margin: 0;
}

.cxf-disclaimer {
  font: inherit;
  font-size: 0.8em;
  color: var(--cxf-text, inherit);
  opacity: 0.75;
  white-space: pre-wrap;
  margin-top: 1rem;
}

.cxf-disclaimer a {
  color: var(--cxf-accent, #008060);
  text-decoration: underline;
}

.cxf-submit-btn {
  font: inherit;
  font-size: 1em;
  font-weight: 600;
  background: var(--cxf-accent, #008060);
  color: #ffffff;
  border: none;
  border-radius: calc(var(--cxf-radius, 8px) / 2);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  width: 100%;
  margin-top: 0.5rem;
  transition: opacity 0.15s;
}

.cxf-submit-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.cxf-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cxf-error-banner {
  background: #fff5f5;
  border: 1px solid #fc8181;
  border-radius: calc(var(--cxf-radius, 8px) / 2);
  padding: 0.75rem 1rem;
  color: #c53030;
  font: inherit;
  font-size: 0.875em;
  margin-bottom: 1rem;
}

.cxf-success {
  text-align: center;
  padding: var(--cxf-padding, 32px);
  background: var(--cxf-bg, #ffffff);
  border-radius: var(--cxf-radius, 8px);
}

.cxf-success-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.cxf-success-msg {
  font: inherit;
  font-size: 1.1em;
  color: var(--cxf-text, inherit);
}

.cxf-noscript {
  font: inherit;
  padding: 1rem;
  background: #fff3cd;
  border-radius: 4px;
  color: #856404;
}

/* ---- Success title ---- */
.cxf-success-title {
  font: inherit;
  font-size: 1.4em;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--cxf-text, inherit);
}

/* ---- Popup modal ---- */
.cxf-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  z-index: 2147483000;
}

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

.cxf-modal {
  position: relative;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-sizing: border-box;
}

.cxf-modal-body {
  margin: 0;
}

.cxf-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: var(--cxf-text, #202223);
  cursor: pointer;
  z-index: 1;
}

.cxf-modal-close:hover {
  background: rgba(0, 0, 0, 0.16);
}

/* ---- Teaser tab ---- */
.cxf-teaser {
  position: fixed;
  bottom: 0;
  z-index: 2147482000;
  font: inherit;
  font-size: 0.95em;
  font-weight: 600;
  background: var(--cxf-accent, #008060);
  color: #ffffff;
  border: none;
  border-radius: var(--cxf-radius, 8px) var(--cxf-radius, 8px) 0 0;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.18);
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cxf-teaser[hidden] {
  display: none;
}

.cxf-teaser:hover {
  opacity: 0.92;
}

.cxf-teaser-bottomLeft {
  left: 1rem;
}

.cxf-teaser-bottomCenter {
  left: 50%;
  transform: translateX(-50%);
}

.cxf-teaser-bottomRight {
  right: 1rem;
}

@media (max-width: 600px) {
  .cxf-modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .cxf-modal {
    max-height: 95vh;
    width: 100%;
  }
}