.nxml-form-wrap,
.nxml-form-wrap * { box-sizing: border-box; }

.nxml-form-wrap {
    --nxml-primary: #6c4cf1;
    --nxml-button-text: #fff;
    --nxml-bg: #fff;
    --nxml-text: #18181b;
    --nxml-muted: #60646c;
    --nxml-border: #dfe1e6;
    --nxml-input-bg: #fff;
    --nxml-radius: 14px;
    --nxml-max-width: 760px;
    width: 100%;
    max-width: var(--nxml-max-width);
    margin: 0 auto;
    color: var(--nxml-text);
    font: inherit;
}

.nxml-form {
    position: relative;
    width: 100%;
    margin: 0;
    color: inherit;
}

.nxml-layout--card .nxml-form {
    padding: clamp(22px, 4vw, 42px);
    border: 1px solid var(--nxml-border);
    border-radius: var(--nxml-radius);
    background: var(--nxml-bg);
}

.nxml-layout--minimal .nxml-form {
    padding: 10px 0;
    background: transparent;
}

.nxml-layout--split .nxml-form {
    display: grid;
    grid-template-columns: minmax(0, .78fr) minmax(320px, 1.22fr);
    overflow: hidden;
    border: 1px solid var(--nxml-border);
    border-radius: var(--nxml-radius);
    background: var(--nxml-bg);
}

.nxml-layout--split .nxml-form__intro {
    padding: clamp(28px, 5vw, 52px);
    background: color-mix(in srgb, var(--nxml-primary) 11%, var(--nxml-bg));
    border-right: 1px solid var(--nxml-border);
}

.nxml-layout--split .nxml-form__body {
    padding: clamp(28px, 5vw, 52px);
}

.nxml-form__intro { margin: 0 0 22px; }
.nxml-layout--split .nxml-form__intro { margin: 0; }

.nxml-form__heading {
    margin: 0;
    color: var(--nxml-text);
    font: inherit;
    font-size: clamp(1.45rem, 3vw, 2.25rem);
    font-weight: 750;
    line-height: 1.08;
    letter-spacing: -.035em;
}

.nxml-form__description {
    margin-top: 12px;
    color: var(--nxml-muted);
    font-size: .98rem;
    line-height: 1.55;
}

.nxml-form__description p { margin: 0 0 8px; }
.nxml-form__description p:last-child { margin-bottom: 0; }

.nxml-form__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0 -7px;
}

.nxml-input-group {
    position: relative;
    flex: 0 0 calc(100% - 14px);
    width: calc(100% - 14px);
    margin: 0 7px;
}
.nxml-width--50 { flex-basis: calc(50% - 14px); width: calc(50% - 14px); }
.nxml-width--33 { flex-basis: calc(33.333% - 14px); width: calc(33.333% - 14px); }

.nxml-input-group label {
    display: block;
    margin: 0 0 7px;
    color: var(--nxml-text);
    font-size: .86rem;
    font-weight: 650;
    line-height: 1.3;
}

.nxml-input-group label i,
.nxml-consent__text i {
    color: var(--nxml-primary);
    font-style: normal;
}

.nxml-form--compact-labels .nxml-input-group label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.nxml-input-group input {
    display: block;
    width: 100%;
    min-height: 50px;
    margin: 0;
    padding: 12px 15px;
    color: var(--nxml-text);
    background: var(--nxml-input-bg);
    border: 1px solid var(--nxml-border);
    border-radius: max(4px, calc(var(--nxml-radius) * .62));
    box-shadow: none;
    outline: none;
    font: inherit;
    font-size: 16px;
    line-height: 1.3;
    transition: border-color .16s ease, outline-color .16s ease, background-color .16s ease;
    appearance: none;
}

.nxml-input-group input::placeholder { color: color-mix(in srgb, var(--nxml-muted) 70%, transparent); }
.nxml-input-group input:hover { border-color: color-mix(in srgb, var(--nxml-border) 45%, var(--nxml-text)); }
.nxml-input-group input:focus {
    border-color: var(--nxml-primary);
    outline: 3px solid color-mix(in srgb, var(--nxml-primary) 18%, transparent);
    outline-offset: 0;
}
.nxml-input-group.is-invalid input { border-color: #c62828; }
.nxml-input-group.is-invalid input:focus { outline-color: rgba(198, 40, 40, .15); }

.nxml-input-error {
    display: block;
    min-height: 0;
    margin-top: 5px;
    color: #b42318;
    font-size: .78rem;
    line-height: 1.3;
}

.nxml-form__consents {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.nxml-consent {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
    margin: 0;
    cursor: pointer;
}

.nxml-consent > input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.nxml-consent__box {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 1px solid var(--nxml-border);
    border-radius: max(3px, calc(var(--nxml-radius) * .3));
    background: var(--nxml-input-bg);
    transition: background .15s ease, border-color .15s ease, outline-color .15s ease;
}
.nxml-consent__box svg { width: 14px; height: 14px; fill: none; stroke: var(--nxml-button-text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.7); transition: .15s ease; }
.nxml-consent > input:checked + .nxml-consent__box { background: var(--nxml-primary); border-color: var(--nxml-primary); }
.nxml-consent > input:checked + .nxml-consent__box svg { opacity: 1; transform: scale(1); }
.nxml-consent > input:focus-visible + .nxml-consent__box { outline: 3px solid color-mix(in srgb, var(--nxml-primary) 18%, transparent); }
.nxml-consent.is-invalid .nxml-consent__box { border-color: #c62828; outline: 2px solid rgba(198,40,40,.12); }

.nxml-consent__text {
    color: var(--nxml-muted);
    font-size: .79rem;
    line-height: 1.45;
}
.nxml-consent__text a { color: var(--nxml-text); text-decoration: underline; text-underline-offset: 2px; }

.nxml-form__actions { margin-top: 18px; }
.nxml-submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    min-width: 150px;
    padding: 12px 21px;
    margin: 0;
    border: 1px solid var(--nxml-primary);
    background: var(--nxml-primary);
    color: var(--nxml-button-text);
    box-shadow: none;
    cursor: pointer;
    font: inherit;
    font-size: .95rem;
    line-height: 1.2;
    text-decoration: none;
    transition: filter .15s ease, transform .15s ease, opacity .15s ease;
}
.nxml-submit:hover { filter: brightness(.94); }
.nxml-submit:active { transform: translateY(1px); }
.nxml-submit:focus-visible { outline: 3px solid color-mix(in srgb, var(--nxml-primary) 22%, transparent); outline-offset: 2px; }
.nxml-submit:disabled { opacity: .7; cursor: wait; }
.nxml-submit__spinner {
    display: none;
    width: 16px;
    height: 16px;
    margin-left: 9px;
    border: 2px solid color-mix(in srgb, var(--nxml-button-text) 35%, transparent);
    border-top-color: var(--nxml-button-text);
    border-radius: 50%;
    animation: nxml-spin .7s linear infinite;
}
.nxml-form.is-loading .nxml-submit__spinner { display: inline-block; }
@keyframes nxml-spin { to { transform: rotate(360deg); } }

.nxml-form__message {
    display: none;
    margin-top: 14px;
    padding: 11px 13px;
    border-radius: max(4px, calc(var(--nxml-radius) * .5));
    font-size: .86rem;
    line-height: 1.4;
}
.nxml-form__message.is-success { display: block; color: #15603d; background: #eaf8f0; border: 1px solid #b9e6cb; }
.nxml-form__message.is-error { display: block; color: #8d211b; background: #fff0ef; border: 1px solid #f4c5c1; }

.nxml-hp { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.nxml-form-wrap.is-preview { min-width: 0; }
.nxml-form-wrap.is-preview .nxml-form { pointer-events: none; }
.nxml-form-missing { padding: 12px; border: 1px dashed #b7bcc5; }

@media (max-width: 720px) {
    .nxml-layout--split .nxml-form { grid-template-columns: 1fr; }
    .nxml-layout--split .nxml-form__intro { border-right: 0; border-bottom: 1px solid var(--nxml-border); }
    .nxml-width--33, .nxml-width--50 { flex-basis: calc(100% - 14px); width: calc(100% - 14px); }
    .nxml-submit { width: 100%; }
}

/* ==========================================================================
   Wizualny wybór grup docelowych
   ========================================================================== */

.nxml-form__groups {
    display: block;
    margin: 0 0 22px;
}

.nxml-form__body > .nxml-form__fields + .nxml-form__groups { margin: 22px 0 0; }

.nxml-groups__label {
    display: block;
    margin: 0 0 4px;
    color: var(--nxml-text);
    font-size: .74rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.nxml-groups__help {
    display: block;
    margin: 0 0 4px;
    color: var(--nxml-muted);
    font-size: .82rem;
    line-height: 1.45;
}

.nxml-groups__grid {
    display: grid;
    grid-template-columns: repeat(var(--nxml-choice-cols, 2), minmax(0, 1fr));
    gap: 14px;
    margin-top: 12px;
}

.nxml-groups--cols-1 { --nxml-choice-cols: 1; }
.nxml-groups--cols-2 { --nxml-choice-cols: 2; }
.nxml-groups--cols-3 { --nxml-choice-cols: 3; }
.nxml-groups--cols-4 { --nxml-choice-cols: 4; }

.nxml-choice {
    position: relative;
    display: block;
    margin: 0;
    cursor: pointer;
}

.nxml-choice__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.nxml-choice__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    padding: 14px;
    border: 1px solid var(--nxml-border);
    border-radius: max(4px, calc(var(--nxml-radius) * .8));
    background: var(--nxml-bg);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, background-color .16s ease;
}

.nxml-choice:hover .nxml-choice__inner {
    border-color: color-mix(in srgb, var(--nxml-primary) 45%, var(--nxml-border));
}

.nxml-choice__input:checked + .nxml-choice__inner {
    border-color: var(--nxml-primary);
    box-shadow: 0 0 0 1px var(--nxml-primary), 0 6px 22px -14px color-mix(in srgb, var(--nxml-primary) 80%, transparent);
    background: color-mix(in srgb, var(--nxml-primary) 4%, var(--nxml-bg));
}

.nxml-choice__input:focus-visible + .nxml-choice__inner {
    outline: 3px solid color-mix(in srgb, var(--nxml-primary) 22%, transparent);
    outline-offset: 2px;
}

.nxml-choice__input:disabled + .nxml-choice__inner { cursor: default; }
.nxml-choice.is-locked { opacity: .45; }
.nxml-choice.is-locked .nxml-choice__inner { cursor: not-allowed; }

.nxml-choice__media {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: max(3px, calc(var(--nxml-radius) * .55));
    background: color-mix(in srgb, var(--nxml-border) 40%, var(--nxml-bg));
}

.nxml-choice__img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: cover;
    border-radius: inherit;
}

.nxml-choice__img--empty {
    display: block;
    width: 100%;
    min-height: 90px;
    background: repeating-linear-gradient(
        45deg,
        color-mix(in srgb, var(--nxml-border) 55%, var(--nxml-bg)),
        color-mix(in srgb, var(--nxml-border) 55%, var(--nxml-bg)) 8px,
        color-mix(in srgb, var(--nxml-border) 25%, var(--nxml-bg)) 8px,
        color-mix(in srgb, var(--nxml-border) 25%, var(--nxml-bg)) 16px
    );
}

.nxml-groups--ratio-square .nxml-choice__media { aspect-ratio: 1 / 1; }
.nxml-groups--ratio-portrait .nxml-choice__media { aspect-ratio: 4 / 5; }
.nxml-groups--ratio-landscape .nxml-choice__media { aspect-ratio: 16 / 9; }
.nxml-groups--ratio-natural .nxml-choice__media { aspect-ratio: auto; }
.nxml-groups--ratio-natural .nxml-choice__img { height: auto; }

.nxml-choice__body {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
}

.nxml-choice__badge {
    display: inline-block;
    margin: 0 0 7px;
    padding: 3px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--nxml-primary) 12%, var(--nxml-bg));
    color: var(--nxml-primary);
    font-size: .67rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.nxml-choice__title {
    display: block;
    color: var(--nxml-text);
    font-size: .98rem;
    font-weight: 700;
    line-height: 1.25;
}

.nxml-choice__desc {
    display: block;
    margin-top: 5px;
    color: var(--nxml-muted);
    font-size: .84rem;
    line-height: 1.45;
}

.nxml-choice__mark {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--nxml-border);
    background: var(--nxml-input-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
    transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}

.nxml-groups--single .nxml-choice__mark { border-radius: 50%; }
.nxml-groups--multiple .nxml-choice__mark { border-radius: max(3px, calc(var(--nxml-radius) * .3)); }

.nxml-choice__mark svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: var(--nxml-button-text);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    transform: scale(.6);
    transition: .15s ease;
}

.nxml-choice__input:checked + .nxml-choice__inner .nxml-choice__mark {
    background: var(--nxml-primary);
    border-color: var(--nxml-primary);
}

.nxml-choice__input:checked + .nxml-choice__inner .nxml-choice__mark svg {
    opacity: 1;
    transform: scale(1);
}

/* Wariant: grafika z tekstem na wierzchu */
.nxml-groups--cover .nxml-choice__inner {
    padding: 0;
    overflow: hidden;
    gap: 0;
}
.nxml-groups--cover .nxml-choice__media { border-radius: 0; }
.nxml-groups--cover .nxml-choice__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, .82) 0%, rgba(0, 0, 0, .35) 45%, rgba(0, 0, 0, 0) 75%);
}
.nxml-groups--cover .nxml-choice__body {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 16px;
}
.nxml-groups--cover .nxml-choice__title,
.nxml-groups--cover .nxml-choice__desc { color: #fff; }
.nxml-groups--cover .nxml-choice__desc { opacity: .85; }
.nxml-groups--cover .nxml-choice__badge { background: rgba(255, 255, 255, .92); color: #111; }

/* Wariant: kompaktowy, miniatura z boku */
.nxml-groups--compact .nxml-choice__inner {
    flex-direction: row;
    align-items: center;
    gap: 13px;
    padding: 12px;
}
.nxml-groups--compact .nxml-choice__media {
    flex: 0 0 auto;
    width: 62px;
    aspect-ratio: 1 / 1;
}
.nxml-groups--compact .nxml-choice__mark {
    position: static;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
}

/* Wariant: bez grafiki */
.nxml-groups--plain .nxml-choice__inner {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 15px 46px 15px 16px;
}
.nxml-groups--plain .nxml-choice__mark { top: 50%; transform: translateY(-50%); }

.nxml-form__groups.is-invalid .nxml-choice__inner { border-color: #c62828; }
.nxml-form__groups.is-invalid .nxml-input-error { min-height: auto; }

@media (max-width: 720px) {
    .nxml-groups--cols-3 .nxml-groups__grid,
    .nxml-groups--cols-4 .nxml-groups__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
    .nxml-groups__grid { grid-template-columns: 1fr; }
    .nxml-groups--cols-3 .nxml-groups__grid,
    .nxml-groups--cols-4 .nxml-groups__grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .nxml-choice__inner,
    .nxml-choice__mark,
    .nxml-choice__mark svg { transition: none; }
}
