.wizard {
    padding: 28px;
    border: 1px solid var(--theme-line);
    border-radius: 20px;
    background-color: var(--theme-surface);
    box-shadow: var(--shadow-lg);
}

.wizard__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.site .wizard__title {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 700;
}

.wizard__subtitle {
    margin: 0;
    color: var(--theme-muted);
    font-size: .875rem;
}

.wizard__counter {
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 999px;
    background-color: var(--brand-primary-tint);
    color: var(--brand-primary);
    font-size: .8rem;
    font-weight: 500;
}

.wizard__progress {
    height: 4px;
    margin-bottom: 24px;
    border-radius: 999px;
    background-color: var(--theme-line);
    overflow: hidden;
}

.wizard__progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background-color: var(--brand-primary);
    transition: width .6s cubic-bezier(.22, 1, .36, 1);
}

.wizard__step {
    min-width: 0;
    margin: 0 0 20px;
    padding: 0;
    border: 0;
}

.wizard.is-enhanced .wizard__step,
.has-js .wizard:not(.is-enhanced) .wizard__step ~ .wizard__step,
.has-js .wizard:not(.is-enhanced) [data-wizard-back],
.has-js .wizard:not(.is-enhanced) [data-wizard-submit] {
    display: none;
}

.wizard.is-enhanced .wizard__step.is-active {
    display: block;
    animation: wizard-step .5s cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes wizard-step {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
}

[dir="ltr"] .wizard.is-enhanced .wizard__step.is-active {
    animation-name: wizard-step-ltr;
}

@keyframes wizard-step-ltr {
    from {
        opacity: 0;
        transform: translateX(12px);
    }
}

.wizard__question {
    float: none;
    width: auto;
    margin: 0 0 14px;
    padding: 0;
    color: var(--theme-text);
    font-size: 1rem;
    font-weight: 600;
}

.wizard__options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.wizard-option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border: 1.5px solid var(--theme-line);
    border-radius: 14px;
    background-color: var(--theme-surface);
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, transform .35s cubic-bezier(.22, 1, .36, 1), box-shadow .35s ease;
}

.wizard-option:hover {
    border-color: var(--input-border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.wizard-option:active {
    transform: scale(.98);
}

.wizard-option:has(input:checked) {
    border-color: var(--brand-primary);
    background-color: var(--brand-primary-tint);
}

.wizard-option:has(input:focus-visible) {
    outline: 3px solid var(--brand-focus);
    outline-offset: 2px;
}

.wizard-option__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    border-radius: 11px;
    background-color: var(--theme-page);
    color: var(--brand-primary);
    transition: background-color .2s ease, color .2s ease;
}

.wizard-option:has(input:checked) .wizard-option__icon {
    background-color: var(--brand-primary);
    color: #FFFFFF;
    animation: wizard-pop .45s cubic-bezier(.22, 1, .36, 1);
}

@keyframes wizard-pop {
    40% {
        transform: scale(1.15) rotate(-6deg);
    }
}

.wizard-option__title {
    color: var(--theme-text);
    font-weight: 600;
    font-size: .95rem;
}

.wizard-option__text {
    color: var(--theme-muted);
    font-size: .8rem;
    line-height: 1.5;
}

.wizard-option__check {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    color: var(--brand-primary);
    opacity: 0;
    transform: scale(.6);
    transition: opacity .15s ease, transform .15s ease;
}

.wizard-option:has(input:checked) .wizard-option__check {
    opacity: 1;
    transform: none;
}

.wizard__field + .wizard__field {
    margin-top: 14px;
}

.wizard__label {
    display: block;
    margin-bottom: 6px;
    color: var(--theme-text);
    font-size: .875rem;
    font-weight: 500;
}

.wizard__label span {
    color: var(--brand-danger);
}

.wizard__control {
    display: block;
    width: 100%;
    height: var(--input-height);
    padding: 0 14px;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background-color: var(--input-bg);
    color: var(--input-text);
    font-family: inherit;
    font-size: .95rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.wizard__control:hover {
    border-color: var(--input-border-hover);
}

.wizard__control:focus {
    border-color: var(--input-border-focus);
    box-shadow: var(--input-shadow-focus);
    outline: none;
}

[dir="rtl"] .wizard__control[dir="ltr"] {
    text-align: right;
}

select.wizard__control {
    appearance: none;
    padding-inline-end: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
}

[dir="ltr"] select.wizard__control {
    background-position: right 14px center;
}

.wizard__textarea {
    height: auto;
    min-height: 140px;
    padding: 12px 14px;
    resize: vertical;
}

.wizard__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.wizard__back,
.wizard__next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 48px;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, transform .15s ease;
}

.wizard__back:active,
.wizard__next:active {
    transform: scale(.97);
}

.wizard__back {
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: var(--theme-muted);
}

.wizard__back:hover {
    color: var(--theme-text);
}

.wizard__next {
    flex: 1;
    max-width: 220px;
    margin-inline-start: auto;
    padding: 0 24px;
    border: 0;
    background-color: var(--brand-primary);
    color: #FFFFFF;
}

.wizard__next:hover {
    background-color: var(--brand-primary-deep);
}

.wizard.is-enhanced [data-wizard-back][hidden],
.wizard.is-enhanced [data-wizard-next][hidden],
.wizard.is-enhanced [data-wizard-submit][hidden] {
    display: none;
}

@media (max-width: 575.98px) {
    .wizard {
        padding: 20px 16px;
        border-radius: 16px;
    }

    .wizard__header {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .wizard__options {
        gap: 10px;
    }

    .wizard-option {
        padding: 14px 12px;
    }

    .wizard__next {
        max-width: none;
    }
}

.wizard:not(.is-enhanced) [data-wizard-back],
.wizard:not(.is-enhanced) [data-wizard-next] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .wizard.is-enhanced .wizard__step.is-active,
    .wizard-option:has(input:checked) .wizard-option__icon {
        animation: none;
    }
}

.wizard__error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0 0;
    color: var(--brand-danger);
    font-size: .85rem;
}

.wizard__error[hidden] {
    display: none;
}

.wizard__field.has-error .wizard__control,
.wizard__field.has-error .wizard__control:hover {
    border-color: var(--brand-danger);
}

.wizard__field.has-error .wizard__control:focus {
    box-shadow: 0 0 0 3.5px rgba(239, 68, 68, .18);
}

.wizard__options.has-error .wizard-option {
    border-color: rgba(239, 68, 68, .45);
}

.wizard__submit {
    position: relative;
}

.wizard__submit-loading {
    display: none;
    align-items: center;
    gap: 10px;
}

.wizard.is-sending .wizard__submit-label {
    display: none;
}

.wizard.is-sending .wizard__submit-loading {
    display: inline-flex;
}

.wizard__submit:disabled {
    cursor: progress;
    opacity: .85;
}

.wizard__spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: wizard-spin .7s linear infinite;
}

@keyframes wizard-spin {
    to {
        transform: rotate(360deg);
    }
}

.wizard__content[hidden],
.wizard-status[hidden] {
    display: none;
}

.wizard-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 8px 8px;
    text-align: center;
    outline: none;
    animation: wizard-step .5s cubic-bezier(.22, 1, .36, 1) both;
}

.wizard-status__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    border-radius: 50%;
    font-size: 1.5rem;
}

.wizard-status--success .wizard-status__icon {
    background-color: rgba(16, 185, 129, .12);
    color: var(--brand-success);
    animation: wizard-pop .6s cubic-bezier(.22, 1, .36, 1) .1s both;
}

.wizard-status--error .wizard-status__icon {
    background-color: rgba(239, 68, 68, .1);
    color: var(--brand-danger);
}

.site .wizard-status__title {
    margin: 0 0 10px;
    font-size: 1.3rem;
    font-weight: 600;
}

.wizard-status__text {
    max-width: 380px;
    margin: 0 0 28px;
    color: var(--theme-muted);
    line-height: 1.85;
}

.wizard-status__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.wizard-status__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 20px;
    border: 1px solid var(--theme-line);
    border-radius: 12px;
    background-color: var(--theme-surface);
    color: var(--theme-text) !important;
    font-family: inherit;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease;
}

.wizard-status__button:hover {
    border-color: var(--theme-text);
}

.wizard-status__button--primary {
    border-color: var(--brand-primary);
    background-color: var(--brand-primary);
    color: #FFFFFF !important;
}

.wizard-status__button--primary:hover {
    border-color: var(--brand-primary-deep);
    background-color: var(--brand-primary-deep);
}

@media (prefers-reduced-motion: reduce) {
    .wizard-status,
    .wizard-status--success .wizard-status__icon,
    .wizard__spinner {
        animation: none;
    }
}

/* an odd card left alone on the last row takes the full width */
.wizard-option:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}
