:host {
    display: block;
    all: initial;
    font-family: var(--embed-font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
    line-height: 1.5;
    box-sizing: border-box;
}

:host * {
    box-sizing: border-box;
}

.embed-container {
    background: var(--embed-bg-container, #ffffff);
    border: var(--embed-border-container, 1px solid #e5e5e5);
    border-radius: var(--embed-border-radius-container, 12px);
    padding: var(--embed-padding-container, 20px);
    box-shadow: var(--embed-shadow-container, 0 5px 15px rgba(0, 0, 0, 0.08));
    max-width: 400px;
    min-width: 360px;
    margin: 0 auto;
    color: #333;
}

/* Typography */
.embed-title {
    margin: 0 0 var(--embed-spacing-content, 15px) 0;
    color: var(--embed-color-title, #333333);
    font-family: var(--embed-font-title, inherit);
    font-size: var(--embed-font-size-title, 24px);
    font-weight: var(--embed-font-weight-title, 600);
    line-height: 1.2;
}

.embed-subtitle {
    margin: 0 0 var(--embed-spacing-content, 15px) 0;
    color: var(--embed-color-subtitle, #666666);
    font-size: var(--embed-font-size-subtitle, 16px);
}

/* Row Title & Description */
.embed-row-title {
    margin: 0 0 0.5rem 0;
    color: var(--embed-color-title, #333333);
    font-family: var(--embed-font-title, inherit);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.embed-row-description {
    margin: 0 0 0.75rem 0;
    color: var(--embed-color-subtitle, #666666);
    font-size: 0.9rem;
    line-height: 1.5;
}

.embed-link {
    color: var(--embed-color-link, #667eea);
    text-decoration: none;
    cursor: pointer;
}

.embed-link:hover {
    text-decoration: underline;
}

.embed-privacy-text {
    font-size: 0.875rem;
    color: var(--embed-color-subtitle, #666666);
    margin-bottom: 10px;
}

.embed-privacy-text a {
    color: var(--embed-color-link, #667eea);
    text-decoration: underline;
}

/* Form Elements */
.embed-form-group {
    margin-bottom: var(--embed-spacing-input, 16px);
    position: relative;
}

/* Ensure form group with helper icon on hover has higher z-index than siblings */
.embed-form-group:has(.helper-icon:hover),
.embed-form-group:has(.helper-icon:focus) {
    z-index: 100;
}

.embed-grid {
    display: flex;
    gap: 10px;
    margin-bottom: var(--embed-spacing-input, 15px);
}

.embed-grid>* {
    min-width: 0;
    /* Prevent grid blowout */
}

.embed-input,
.embed-select,
.embed-textarea {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background-color: var(--embed-bg-input, #ffffff);
    color: var(--embed-color-input, #333333);
    border: var(--embed-border-input, 1px solid #e5e5e5);
    border-radius: var(--embed-border-radius-input, 4px);
    font-size: var(--embed-font-size-input, 16px);
    font-family: inherit;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

.embed-input:focus,
.embed-select:focus,
.embed-textarea:focus {
    outline: none;
    border: var(--embed-border-focus-input, 1px solid #667eea);
}

.embed-input::placeholder,
.embed-textarea::placeholder {
    color: var(--embed-color-placeholder, #999999);
    opacity: 1;
}

.embed-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--embed-font-size-label, 14px);
    color: var(--embed-color-label, #666666);
    cursor: pointer;
}

.input-helper-wrapper {
    position: relative;
}

.input-helper-wrapper .embed-input,
.input-helper-wrapper .embed-select,
.input-helper-wrapper .embed-textarea {
    padding-right: 38px;
}

.helper-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--embed-color-placeholder, #999999);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.helper-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.helper-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(51, 51, 51, 0.95);
    color: #fff;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    white-space: normal;
    min-width: 180px;
    max-width: 260px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
    z-index: 10000;
}

.helper-icon::before {
    content: '';
    position: absolute;
    top: 120%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(51, 51, 51, 0.95);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out;
}

.helper-icon:hover::after,
.helper-icon:hover::before,
.helper-icon:focus::after,
.helper-icon:focus::before {
    opacity: 1;
    visibility: visible;
}

.helper-icon:focus::after {
    transform: translateX(-50%) translateY(2px);
}

.helper-icon-inline {
    position: relative;
    right: auto;
    top: auto;
    transform: none;
    margin-left: 8px;
}

/* Helper text below field (alternative to tooltip) */
.helper-text-below {
    font-size: 12px;
    color: var(--embed-color-placeholder, #999);
    margin: 4px 0 0 0;
    line-height: 1.4;
}

/* Helper icon positioning for textareas - align to top */
.input-helper-wrapper:has(.embed-textarea) .helper-icon {
    top: 12px;
    transform: none;
}

/* Mobile responsive tooltip positioning - constrain to viewport to prevent clipping */
@media (max-width: 500px) {
    .helper-icon::after {
        /* Keep centered but use smaller width to fit within field boundaries */
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        min-width: 140px;
        max-width: 200px;
        white-space: normal;
        word-wrap: break-word;
    }

    .helper-icon::before {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .helper-icon:focus::after {
        transform: translateX(-50%) translateY(2px);
    }
}

.embed-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    min-width: 16px;
    flex-shrink: 0;
    border: 1px solid #ccc;
    border-radius: 3px;
    background-color: #fff;
    cursor: pointer;
    position: relative;
    margin: 0;
}

.embed-checkbox:checked {
    background-color: var(--embed-primary-color, var(--embed-color-link, #667eea));
    border-color: var(--embed-primary-color, var(--embed-color-link, #667eea));
}

.embed-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Radio Button */
.embed-radio {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid #ccc;
    border-radius: 50%;
    background-color: #fff;
    cursor: pointer;
    position: relative;
    margin: 0;
}

.embed-radio:checked {
    background-color: var(--embed-primary-color, var(--embed-color-link, #667eea));
    border-color: var(--embed-primary-color, var(--embed-color-link, #667eea));
}

.embed-radio:checked::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: white;
}

/* Picture cards — the same radio or checkbox group, drawn as images.

   The native control is hidden by opacity, not display: a display:none input
   cannot be focused, and this is still a radio group to the keyboard and to
   every reader that finds its answers by input type.

   The visible card is .embed-choice-card-body, a SIBLING of the input, so every
   selected-state rule is a `~` away. Styling the <label> itself would need
   :has(:checked), which is newer than anything else this embed leans on — and
   the embed is loaded on whatever browser a supporter happens to have. */
.embed-choice-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 10px;
}

.embed-choice-card {
    position: relative;
    display: block;
    cursor: pointer;
}

.embed-choice-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.embed-choice-card-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.embed-choice-card-image,
.embed-choice-card-blank {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    background-color: #f5f5f5;
}

.embed-choice-card-label {
    font-size: 0.9em;
    line-height: 1.25;
    text-align: center;
}

/* A literal, not a var(): the per-form primary colour arrives as a real
   declaration from FormEmbedStyleGenerator, and a var() here only decides what
   an UNBRANDED form looks like. Not worth the failure mode either — a custom
   property that is defined but empty makes the whole declaration invalid at
   computed-value time, and the fallback never fires. */
.embed-choice-card-input:checked ~ .embed-choice-card-body {
    border-color: #667eea;
    box-shadow: 0 0 0 1px #667eea;
}

.embed-choice-card-input:checked ~ .embed-choice-card-body .embed-choice-card-label {
    font-weight: 600;
}

.embed-choice-card-input:focus-visible ~ .embed-choice-card-body {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* How many places an answer has left.
   Quiet by default: it is information beside the answer, not a claim about it.
   A full one is dimmed rather than hidden — an answer that vanishes reads as a
   form that changed its mind, and somebody who came back for that exact shift
   deserves to see that it went rather than that it never existed. */
.embed-option-quota {
    margin-left: 8px;
    font-size: 0.85em;
    opacity: 0.7;
}

.embed-option-quota-full {
    font-weight: 600;
    opacity: 1;
}

.embed-choice-full {
    opacity: 0.55;
    cursor: not-allowed;
}

/* The card variant puts the count under the caption rather than beside it,
   where a card is already a column. */
.embed-choice-card .embed-option-quota {
    display: block;
    margin-left: 0;
    margin-top: 2px;
}

/* The searchable dropdown.

   Tom Select copies the original control's classes onto its own wrapper, so
   the wrapper arrives wearing .embed-select or .embed-input — a border, a
   radius and 8px 12px of padding around a control that draws all three itself.
   The result is a box inside a box. So the wrapper gives up the look and
   .ts-control takes it, which is the element people now see and click.

   Written against the same custom properties the native inputs read, so a form
   with its own branding gets a search box that matches rather than one wearing
   the library's defaults. */
.ts-wrapper.embed-select,
.ts-wrapper.embed-input {
    padding: 0;
    border: 0;
    background: transparent;
    border-radius: 0;
}

.ts-wrapper.embed-select .ts-control,
.ts-wrapper.embed-input .ts-control {
    padding: 8px 12px;
    background-color: var(--embed-bg-input, #ffffff);
    color: var(--embed-color-input, #333333);
    border: var(--embed-border-input, 1px solid #e5e5e5);
    border-radius: var(--embed-border-radius-input, 4px);
    font-size: var(--embed-font-size-input, 16px);
    font-family: inherit;
}

.ts-wrapper.embed-select.focus .ts-control,
.ts-wrapper.embed-input.focus .ts-control {
    border: var(--embed-border-focus-input, 1px solid #667eea);
    box-shadow: none;
}

/* The address's country box is one cell of a flex row. Tom Select copies the
   CLASS attribute to its wrapper but only `width` from the inline style — the
   select has none — so the wrapper inherited `width: 100%` from .embed-input
   with `flex: 0 1 auto`, and claimed a whole line to itself. The inline
   `flex: 1 1 10rem` has to be said again here. */
.ts-wrapper.embed-address-part {
    flex: 1 1 10rem;
    min-width: 0;
    width: auto;
}

/* A full option inside the searchable dropdown. Tom Select draws its own list,
   so the dimming that .embed-choice-full does for a radio has to be said again
   for the one control that does not use a native <option>. */
.ts-dropdown .ts-option-full {
    opacity: 0.55;
}

/* Calculated total — a figure, not a box. Drawn heavier than an answer the
   visitor typed, because it is the line they will check. */
.embed-calculation {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 1.15em;
    font-weight: 600;
    color: var(--embed-color-input, #333333);
}

.embed-calculation-affix {
    font-size: 0.85em;
    font-weight: normal;
    color: #777;
}

/* Amount — a number field that knows it is money.

   The symbol is drawn INSIDE the box's border rather than beside it, so the
   control still reads as one input among the others; the wrapper carries the
   border and the input inside it carries none. */
.embed-amount-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.embed-amount-preset {
    padding: 6px 14px;
    border: var(--embed-border-input, 1px solid #e5e5e5);
    border-radius: var(--embed-border-radius-input, 4px);
    background-color: var(--embed-bg-input, #ffffff);
    color: var(--embed-color-input, #333333);
    font-family: inherit;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.embed-amount-preset:hover {
    background-color: #f5f5f5;
}

.embed-amount-preset[aria-pressed="true"] {
    border-color: var(--embed-primary-color, #667eea);
    box-shadow: inset 0 0 0 1px var(--embed-primary-color, #667eea);
}

.embed-amount-input {
    display: flex;
    align-items: center;
    border: var(--embed-border-input, 1px solid #e5e5e5);
    border-radius: var(--embed-border-radius-input, 4px);
    background-color: var(--embed-bg-input, #ffffff);
}

.embed-amount-input--after {
    flex-direction: row-reverse;
}

.embed-amount-symbol {
    padding: 0 4px 0 12px;
    color: #777;
    white-space: nowrap;
}

.embed-amount-input--after .embed-amount-symbol {
    padding: 0 12px 0 4px;
}

/* The box inside the box: no border of its own, or the control shows two. */
.embed-amount .embed-amount-value {
    border: 0;
    border-radius: 0;
    background-color: transparent;
    flex: 1;
    min-width: 0;
}

.embed-amount .embed-amount-value:focus {
    box-shadow: none;
}

/* A value the form is showing rather than asking for.
   Dimmed and given the cursor that says so, but still selectable and still
   copyable — the usual reason a field is read-only is that somebody needs to
   quote the reference number in it. */
.embed-input[readonly],
.embed-textarea[readonly] {
    background-color: #f5f5f5;
    color: #555;
    cursor: default;
}

.embed-input[readonly]:focus,
.embed-textarea[readonly]:focus {
    border: var(--embed-border-input, 1px solid #e5e5e5);
}

/* A number with a unit beside it. Same shape as the amount control above and
   deliberately not the same rules: this one can carry text on BOTH sides
   ("€ 1.250 /month"), so the affixes are ordinary flex children rather than a
   symbol with a side. */
.embed-number {
    display: flex;
    align-items: center;
    border: var(--embed-border-input, 1px solid #e5e5e5);
    border-radius: var(--embed-border-radius-input, 4px);
    background-color: var(--embed-bg-input, #ffffff);
}

.embed-number-affix {
    padding: 0 8px;
    color: #777;
    white-space: nowrap;
}

/* The box inside the box: no border of its own, or the control shows two. */
.embed-number .embed-number-value {
    border: 0;
    border-radius: 0;
    background-color: transparent;
    flex: 1;
    min-width: 0;
}

.embed-number .embed-number-value:focus {
    box-shadow: none;
}

/* Input grid — rows x columns of boxes.

   The wrapper scrolls, not the page: a grid wide enough to overflow would
   otherwise push the whole embed sideways, and an iframe cannot scroll its
   parent back. */
.embed-grid {
    border-collapse: collapse;
    width: 100%;
}

.embed-grid th,
.embed-grid td {
    padding: 4px 6px;
    text-align: left;
    font-weight: normal;
    vertical-align: middle;
}

.embed-grid thead th {
    font-size: 0.85em;
    color: #666;
    white-space: nowrap;
}

.embed-grid tbody th {
    white-space: nowrap;
    padding-right: 12px;
}

.embed-grid .embed-grid-cell {
    min-width: 5rem;
    width: 100%;
    box-sizing: border-box;
}

/* Yes / No — a segmented pair, backed by two radios.

   The inputs are transparent rather than display:none: a hidden input cannot be
   focused, and this control has to be reachable and operable from the keyboard
   like the radio group it actually is. */
.embed-yesno {
    display: inline-flex;
    /* Sized by its answers, never by the field. Growing to the row put a 400px
       pill around two short words. `max-width` is the other half of that: two
       long answers on a narrow phone shrink rather than pushing the form
       sideways. */
    flex: 0 0 auto;
    max-width: 100%;
    /* The form's OWN border and radius, not a pill. Every other control on an
       embed is a soft-cornered box in the admin's chosen colours, and a 999px
       lozenge among them reads as something pasted in from another form. Both
       follow the same custom properties the inputs do, so a form that restyles
       its fields restyles this too. */
    border: var(--embed-border-input, 1px solid #e5e5e5);
    border-radius: var(--embed-border-radius-input, 4px);
    overflow: hidden;
    background-color: var(--embed-bg-input, #ffffff);
}

.embed-yesno-option {
    position: relative;
    margin: 0;
    display: block;
}

.embed-yesno-option input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.embed-yesno-option span {
    display: block;
    /* The vertical padding an .embed-input has, so the control lines up with
       the boxes above and below it rather than sitting a few pixels short. */
    padding: 8px 22px;
    /* Equal halves whatever the words are: "Present"/"Absent" and "Yes"/"No"
       both come out symmetrical instead of one side twice the other. The
       border box, or the minimum lands on the content and the padding adds
       44px on top of it — which is how "Yes" ended up 132px wide. */
    box-sizing: border-box;
    min-width: 5.5rem;
    text-align: center;
    color: var(--embed-color-input, #333333);
    font-size: var(--embed-font-size-input, 16px);
    cursor: pointer;
    user-select: none;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Feedback on the side that is not chosen — without it the control looks inert
   until the moment it is clicked. */
.embed-yesno-option input:not(:checked):hover + span {
    background-color: #f5f5f5;
}

.embed-yesno-option + .embed-yesno-option span {
    border-left: var(--embed-border-input, 1px solid #e5e5e5);
}

.embed-yesno-option input:checked + span {
    background-color: var(--embed-primary-color, var(--embed-color-link, #667eea));
    color: #fff;
}

/* :focus-visible, not :focus — a mouse click must not leave a ring behind on a
   control whose input is invisible and therefore never looks focused. */
.embed-yesno-option input:focus-visible + span {
    outline: 2px solid var(--embed-primary-color, var(--embed-color-link, #667eea));
    outline-offset: -2px;
}

/* Button */
.embed-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 10px 20px;
    background: var(--embed-bg-button, #667eea);
    color: var(--embed-color-button, #ffffff);
    border: var(--embed-border-button, 1px solid transparent);
    border-radius: var(--embed-border-radius-button, 4px);
    font-size: var(--embed-font-size-button, 16px);
    font-weight: var(--embed-font-weight-button, 700);
    font-family: var(--embed-font-button, inherit);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s;
    margin-top: var(--embed-spacing-content, 15px);
    text-decoration: none;
}

.embed-button:hover {
    background: var(--embed-bg-button-hover, #5a67d8);
    color: var(--embed-color-button-hover, #ffffff);
}

.embed-button:active {
    background: var(--embed-bg-button-active, #4c51bf);
    color: var(--embed-color-button-active, #ffffff);
}

.embed-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Progress Bar & Stats */
.embed-stats {
    margin-bottom: var(--embed-spacing-content, 15px);
}

.embed-goal-text {
    font-size: 0.875rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--embed-primary-color, var(--embed-color-counter, #667eea));
}

.embed-progress-bar {
    width: 100%;
    height: 10px;
    background-color: #f0f2f5;
    border-radius: 5px;
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
}

.embed-progress-bar::-webkit-progress-bar {
    background-color: #f0f2f5;
}

.embed-progress-bar::-webkit-progress-value {
    background-color: var(--embed-primary-color, var(--embed-color-counter, #667eea));
    transition: width 1s ease;
}

.embed-progress-bar::-moz-progress-bar {
    background-color: var(--embed-primary-color, var(--embed-color-counter, #667eea));
}

.embed-signature-badge {
    background: #f0f2f5;
    color: var(--embed-primary-color, var(--embed-color-counter, #667eea));
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-block;
}

/* Alerts */
.embed-alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.embed-alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.embed-alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.embed-alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    display: flex;
}

.modal-container {
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    position: relative;
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.modal-overlay.open .modal-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #999;
    padding: 0;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
}

.text-center {
    text-align: center;
}

.margin-top-small {
    margin-top: 10px;
}

/* Mobile Responsive Styles */
@media (max-width: 500px) {
    .embed-container {
        min-width: 100%;
        max-width: 100%;
        padding: 16px;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    /* Stack grids with 3+ fields vertically on mobile */
    .embed-grid[data-field-count]:not([data-field-count="1"]):not([data-field-count="2"]) {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }

    .embed-grid[data-field-count]:not([data-field-count="1"]):not([data-field-count="2"])>* {
        width: 100%;
        flex: none;
    }

    /* Keep 2-field rows side-by-side but allow wrapping */
    .embed-grid[data-field-count="2"] {
        display: flex !important;
        flex-wrap: wrap;
        gap: 10px;
    }

    .embed-grid[data-field-count="2"]>* {
        flex: 1 1 45%;
        min-width: 140px;
    }

    /* Ensure inputs take full width */
    .embed-input,
    .embed-select,
    .embed-textarea {
        font-size: 16px;
        /* Prevent iOS zoom */
    }
}

/* =====================
   Multistep Form Styles
   ===================== */

/* Progress Indicator Container */
.embed-progress {
    margin-bottom: 1.5rem;
}

/* Progress Bar Style */
.embed-progress[data-style="progress_bar"] .embed-progress-bar {
    height: 6px;
    background: #e5e5e5;
    border-radius: 3px;
    overflow: hidden;
}

.embed-progress .embed-progress-fill {
    height: 100%;
    background: var(--embed-primary-color, var(--embed-bg-button, #667eea));
    transition: width 0.3s ease;
    border-radius: 3px;
}

.embed-progress .embed-progress-text {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #666;
}

/* Step Numbers Style */
.embed-progress-numbers {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.embed-step-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e5e5e5;
    color: #666;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.embed-step-number.active {
    background: var(--embed-primary-color, var(--embed-bg-button, #667eea));
    color: #fff;
}

.embed-step-number.completed {
    background: var(--embed-primary-color, var(--embed-bg-button, #667eea));
    opacity: 0.6;
    color: #fff;
}

/* Note: .embed-page and .embed-page-single have no special base styles;
   they are used for JavaScript targeting */

/* Page Validation Message */
.embed-page-validation-message {
    background: linear-gradient(135deg, #fff5f5 0%, #fff0f0 100%);
    border: 1px solid #f5c2c7;
    border-left: 4px solid #dc3545;
    border-radius: 6px;
    padding: 12px 16px;
    margin-top: 1rem;
    color: #842029;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: embed-shake 0.5s ease-in-out;
}

.embed-page-validation-message .embed-validation-icon {
    font-style: normal;
    font-size: 1.1em;
}

@keyframes embed-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

/* Page Navigation */
.embed-page-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e5e5;
}

/* Secondary Button (Previous) */
.embed-button-secondary {
    background: transparent;
    color: var(--embed-bg-button, #667eea);
    border: 1px solid var(--embed-bg-button, #667eea);
}

.embed-button-secondary:hover {
    background: var(--embed-bg-button, #667eea);
    color: #fff;
}

/* Navigation Buttons - auto width */
.embed-page-nav .embed-button {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
}

/* Next button - align right */
.embed-page-nav .embed-next-btn {
    margin-left: auto;
}

/* Auto-advance: a fill sweeps across the Next button while the jump is pending,
   so the user sees why the page is about to move. Duration mirrors
   AUTO_ADVANCE_DELAY_MS in embed-core.js. Both properties below are scoped to
   .embed-auto-advancing (not the base .embed-next-btn) so the feature is fully
   inert — no stray `overflow: hidden` — on every multistep Next/Review button
   when auto-advance is off. */
.embed-next-btn.embed-auto-advancing {
    position: relative;
    overflow: hidden;
}

.embed-next-btn.embed-auto-advancing::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 4px;
    /* Button color is admin-configurable (default_color_button), so a fixed
       white bar would vanish on a white/pale brand button. currentColor is the
       button's own label color, which the admin already had to make legible
       against that background — so this stays visible whatever they picked,
       without the inverted-hue flash a blend mode produces. */
    background: currentColor;
    transform-origin: left center;
    transform: scaleX(0);
    animation: embed-auto-advance-fill 0.8s linear forwards;
    pointer-events: none;
}

@keyframes embed-auto-advance-fill {
    to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
    .embed-next-btn.embed-auto-advancing::after {
        animation: none;
        transform: scaleX(1);
    }
}

/* Visually hidden, still announced by screen readers. */
.embed-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    overflow: hidden;
    white-space: nowrap;
}

/* Note: .embed-preview-page has no special base styles; styled via children */

.embed-preview-title {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: #333;
    font-weight: 600;
}

.embed-preview-list {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 1rem;
}

.embed-preview-item {
    display: flex;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e5e5e5;
}

.embed-preview-item:last-child {
    border-bottom: none;
}

.embed-preview-label {
    flex: 0 0 40%;
    font-weight: 500;
    color: #666;
}

.embed-preview-value {
    flex: 1;
    color: #333;
}

/* Range/Slider Input */
.embed-range-container {
    padding: 4px 0;
}

.embed-range {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #e5e5e5;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.embed-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--embed-primary-color, var(--embed-bg-button, #667eea));
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

.embed-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.embed-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--embed-primary-color, var(--embed-bg-button, #667eea));
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.embed-range::-moz-range-track {
    background: #e5e5e5;
    height: 8px;
    border-radius: 4px;
}

.embed-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: #666;
    margin-top: 4px;
}

.embed-range-value {
    font-weight: 600;
    color: var(--embed-primary-color, var(--embed-bg-button, #667eea));
}

/* A required slider starts unset: the thumb marks a starting position, not an
   answer, so it must not look like a committed choice. embed-core.js drops this
   class on the first interaction. */
.embed-range-unset::-webkit-slider-thumb {
    background: #fff;
    border: 2px solid #b0b0b0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.embed-range-unset::-moz-range-thumb {
    background: #fff;
    border: 2px solid #b0b0b0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.embed-range-unset ~ .embed-range-labels .embed-range-value {
    color: #999;
}

/* The slider has no border, so .embed-input-error's border-color alone would be
   invisible on it — colour the track itself. */
.embed-range.embed-input-error {
    background: #fdecee;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.embed-range.embed-input-error::-moz-range-track {
    background: #fdecee;
}

/* Input Validation Error State */
.embed-input-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* Email Typo Suggestion */
.embed-email-suggestion {
    margin-top: 6px;
    padding: 8px 12px;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #856404;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.embed-email-suggestion .suggestion-text {
    flex: 1;
    min-width: 0;
}

.embed-email-suggestion .suggestion-fix-link {
    color: #856404;
    text-decoration: underline;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s;
}

.embed-email-suggestion .suggestion-fix-link:hover {
    color: #533f03;
    text-decoration: underline;
}

.embed-email-suggestion .suggestion-fix-link:active {
    color: #856404;
}

/* Mobile Responsive for Multistep */
@media (max-width: 500px) {
    .embed-progress-numbers {
        gap: 0.5rem;
    }

    .embed-step-number {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .embed-page-nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .embed-page-nav .embed-button {
        width: 100%;
        margin-left: 0;
    }

    .embed-preview-item {
        flex-direction: column;
        gap: 0.25rem;
    }

    .embed-preview-label {
        flex: none;
    }
}

/* Rating Stars */
.embed-rating-stars {
    display: flex;
    gap: 4px;
    cursor: pointer;
}

.embed-star {
    font-size: 1.5em;
    color: #ddd;
    transition: color 0.15s ease, transform 0.1s ease;
    user-select: none;
}

.embed-star:hover {
    transform: scale(1.1);
}

/* Color Picker */
.embed-color {
    width: 50px;
    height: 38px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
    background: transparent;
}

.embed-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.embed-color::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.embed-color::-moz-color-swatch {
    border: none;
    border-radius: 4px;
}

/* File Upload */
.embed-file-container {
    font-family: inherit;
}

.embed-file-dropzone {
    display: block;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
    transition: border-color 0.2s ease, background 0.2s ease;
    font-family: inherit;
}

.embed-file-dropzone:hover,
.embed-file-dropzone.drag-over {
    border-color: var(--embed-primary-color, var(--embed-bg-button, #667eea));
    background: #f0f4ff;
}

.embed-file-list {
    font-family: inherit;
}

.embed-file-item {
    font-family: inherit;
}

.embed-file-name,
.embed-file-error {
    font-family: inherit;
}

/* File Upload Error State */
.embed-file-dropzone.embed-input-error {
    border-color: #dc3545 !important;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.embed-file-container.embed-input-error .embed-file-dropzone {
    border-color: #dc3545 !important;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}
/* =====================================================
   Save and Continue Later
   ===================================================== */

/* Sits outside the <form>, so it inherits none of the form's own spacing
   rules and sets its own separation from the submit button above it. */
.embed-save-resume {
    margin-top: 1rem;
    font-family: inherit;
}

.embed-save-resume-trigger {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    color: var(--embed-bg-button, #667eea);
    text-decoration: underline;
}

.embed-save-resume-trigger:hover {
    text-decoration: none;
}

.embed-save-resume-panel {
    margin-top: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--embed-color-input-border, #ddd);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.02);
}

.embed-save-resume-intro {
    margin: 0 0 0.5rem;
    font-size: 0.9em;
}

.embed-save-resume-note {
    margin: 0.25rem 0 0.75rem;
    font-size: 0.8em;
    opacity: 0.75;
}

.embed-save-resume-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.85em;
    font-weight: 600;
}

/* The panel's buttons sit side by side and size to their text; the embed's
   default button is full width, which would stack them into a column. */
.embed-save-resume-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.embed-save-resume-actions .embed-button {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
}

.embed-save-resume-feedback {
    margin-top: 0.75rem;
    font-size: 0.85em;
}

.embed-save-resume-feedback.is-error {
    color: #dc3545;
}

.embed-save-resume-feedback.is-success {
    color: #198754;
}

.embed-save-resume-result {
    margin-top: 0.75rem;
}

.embed-save-resume-linkrow {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

/* min-width: 0 or the input refuses to shrink below its content width and
   pushes the copy button out of a narrow embed. */
.embed-save-resume-linkrow .embed-input {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.85em;
}

.embed-save-resume-linkrow .embed-button {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
}
