@layer components {
    .cookie-consent {
        position: fixed;
        z-index: var(--z-cookie-consent);
        pointer-events: none;
        --_s: var(--cookie-consent-spacing, 0px);
        left: var(--_s);
        right: var(--_s);
    }

    .cookie-consent.is-visible .cookie-consent__inner {
        pointer-events: auto;
    }

    /* ── Position ── */
    .cookie-consent--bottom {
        bottom: var(--_s);
    }

    .cookie-consent--top {
        top: var(--_s);
    }

    /* ── Align ── */
    .cookie-consent--align-left   { text-align: left; }
    .cookie-consent--align-center { text-align: center; }
    .cookie-consent--align-right  { text-align: right; }

    /* ── Width ── */
    .cookie-consent--auto .cookie-consent__inner {
        display: inline-flex;
        text-align: left;
        max-width: var(--cookie-consent-max-width, none);
    }

    /* ── Styles ── */
    .cookie-consent--filled .cookie-consent__inner {
        background: var(--color-surface);
        color: var(--color-text);
    }

    .cookie-consent--outline .cookie-consent__inner {
        background: var(--color-background);
        border: 1px solid var(--color-border);
        color: var(--color-text);
    }

    .cookie-consent--glass .cookie-consent__inner {
        background: color-mix(in srgb, var(--color-surface) 80%, transparent);
        backdrop-filter: blur(var(--cookie-consent-blur, 10px));
        -webkit-backdrop-filter: blur(var(--cookie-consent-blur, 10px));
        color: var(--color-text);
    }

    /* Full-width top border (no outline border) */
    .cookie-consent--full:not(.cookie-consent--outline) .cookie-consent__inner {
        border-top: 1px solid var(--color-border);
    }

    .cookie-consent--top.cookie-consent--full:not(.cookie-consent--outline) .cookie-consent__inner {
        border-top: none;
        border-bottom: 1px solid var(--color-border);
    }

    .cookie-consent--spaced .cookie-consent__inner {
        border-color: var(--color-border);
    }

    /* ── Content alignment (centers wrapped items) ── */
    .cookie-consent--content-left .cookie-consent__inner {
        justify-content: flex-start;
        text-align: left;
    }

    .cookie-consent--content-center .cookie-consent__inner {
        justify-content: center;
        text-align: center;
    }

    .cookie-consent--content-right .cookie-consent__inner {
        justify-content: flex-end;
        text-align: right;
    }

    /* ── Inner ── */
    .cookie-consent__inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--spacing-md);
        padding: var(--cookie-consent-padding-block, var(--spacing-md)) var(--cookie-consent-padding-inline, var(--spacing-lg));
        border-radius: var(--cookie-consent-radius, 0);
        box-shadow: var(--cookie-consent-shadow, var(--shadow));
    }

    /* ── Groups (stacked items from nested arrays) ── */
    .cookie-consent__group {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-md);
        flex: 1;
        min-width: 0;
    }

    .cookie-consent__group--left {
        align-items: flex-start;
    }

    .cookie-consent__group--center {
        align-items: center;
        text-align: center;
    }

    .cookie-consent__group--right {
        align-items: flex-end;
        text-align: right;
    }

    /* ── Icon ── */
    .cookie-consent__icon {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        color: var(--color-muted);
    }

    /* ── Content ── */
    .cookie-consent__heading {
        font-family: var(--font-heading);
        font-weight: var(--font-weight-heading);
        font-size: var(--font-size-md);
        margin: 0;
    }

    .cookie-consent__message {
        font-size: var(--font-size-body);
        color: var(--color-text);
        margin: 0;
        line-height: var(--line-height-base);
    }

    /* ── Actions ── */
    .cookie-consent__actions {
        display: flex;
        gap: var(--spacing-sm);
        flex-shrink: 0;
        flex-wrap: wrap;
    }

    .cookie-consent__actions[class*="cookie-consent__actions--"] {
        flex-grow: 1;
    }

    .cookie-consent__actions--left   { justify-content: flex-start; }
    .cookie-consent__actions--center { justify-content: center; }
    .cookie-consent__actions--right  { justify-content: flex-end; }

    /* ── Privacy link ── */
    .cookie-consent__privacy-link {
        font-size: var(--font-size-xs);
        color: var(--color-muted);
        text-decoration: underline;
        text-underline-offset: 2px;
        transition: color var(--transition-speed);
        width: 100%;
    }

    .cookie-consent__privacy-link:hover {
        color: var(--color-text);
    }

    /* ── Divider ── */
    .cookie-consent__divider {
        width: 100%;
        border: none;
        border-top: 1px solid var(--color-border);
        margin: 0;
    }

    .cookie-consent--flush-dividers .cookie-consent__divider {
        width: calc(100% + 2 * var(--cookie-consent-padding-inline, var(--spacing-lg)));
        margin-inline: calc(-1 * var(--cookie-consent-padding-inline, var(--spacing-lg)));
    }

    /* ── Details wrapper (accordion + categories) ── */
    .cookie-consent__details {
        width: 100%;
    }

    /* ── Accordion (detailed mode) ── */
    .cookie-consent__accordion {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0;
        background: none;
        border: none;
        color: var(--color-muted);
        font-family: var(--font-body);
        font-size: var(--font-size-body-sm);
        cursor: pointer;
        transition: color var(--transition-speed);
    }

    .cookie-consent__accordion:hover {
        color: var(--color-text);
    }

    .cookie-consent__chevron {
        transition: transform var(--transition-speed);
        transform: rotate(90deg);
    }

    .cookie-consent__accordion.is-open .cookie-consent__chevron {
        transform: rotate(270deg);
    }

    /* ── Categories ── */
    .cookie-consent__categories {
        interpolate-size: allow-keywords;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: var(--spacing-sm);
        height: 0;
        opacity: 0;
        overflow: hidden;
        padding-block: 0;
        transition:
            height var(--transition-speed) ease,
            opacity var(--transition-speed) ease,
            padding var(--transition-speed) ease;
    }

    .cookie-consent__categories.is-open {
        height: auto;
        opacity: 1;
        padding-block: var(--spacing-sm);
    }

    .cookie-consent__categories[data-inline] {
        transition: none;
    }

    .cookie-consent__category {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--spacing-md);
        padding: var(--spacing-sm) 0;
        cursor: pointer;
    }

    .cookie-consent__category-info {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-xs);
        text-align: left;
    }

    .cookie-consent__category-name {
        font-size: var(--font-size-body-sm);
        font-weight: var(--font-weight-heading);
    }

    .cookie-consent__category-desc {
        font-size: var(--font-size-xs);
        color: var(--color-muted);
    }

    /* ── Toggle switch ── */
    .cookie-consent__toggle {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

    .cookie-consent__switch {
        position: relative;
        flex-shrink: 0;
        width: 44px;
        height: 24px;
        background: color-mix(in oklch, var(--color-text) 30%, var(--color-background));
        border-radius: var(--radius-full);
        transition: background var(--transition-speed), opacity var(--transition-speed);
    }

    .cookie-consent__switch::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 20px;
        height: 20px;
        background: var(--color-background);
        border-radius: var(--radius-full);
        transition: transform var(--transition-speed);
    }

    .cookie-consent__toggle:checked + .cookie-consent__switch {
        background: var(--color-text);
    }

    .cookie-consent__toggle:checked + .cookie-consent__switch::after {
        transform: translateX(20px);
    }

    .cookie-consent__toggle:disabled + .cookie-consent__switch {
        background: color-mix(in oklch, var(--color-text) 30%, var(--color-background));
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* Toggle variant: checkbox */
    .cookie-consent--toggle-checkbox .cookie-consent__switch {
        width: 22px;
        height: 22px;
        border: 2px solid var(--color-border);
        border-radius: var(--radius-sm);
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background var(--transition-speed), border-color var(--transition-speed);
    }

    .cookie-consent--toggle-checkbox .cookie-consent__switch::after {
        display: none;
    }

    .cookie-consent--toggle-checkbox .cookie-consent__check {
        color: transparent;
        transition: color var(--transition-speed);
    }

    .cookie-consent--toggle-checkbox .cookie-consent__toggle:checked + .cookie-consent__switch {
        background: var(--color-primary);
        border-color: var(--color-primary);
    }

    .cookie-consent--toggle-checkbox .cookie-consent__toggle:checked + .cookie-consent__switch .cookie-consent__check {
        color: var(--color-on-primary);
    }

    @media print {
        .cookie-consent {
            display: none;
        }
    }
}
