div.sidebar-wrapper{
    pointer-events: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    right: MIN(1%, 20px);
    z-index: 1;
}
div.sidebar-wrapper.modal-open{
    z-index: 9998;
}
aside.sidebar.fixed {
    pointer-events: auto;
    position: sticky;
    top: 50%;
    transform: translateY(-50%);
    z-index: 400;
    background: none;
    border: none;
    transition: opacity .3s ease;
    @media ((max-width: 640px) and (max-height: 700px)) {
        bottom: 10%;
        transform: none;
    }
    .stickyElement{
        bottom: 0;
        position: absolute;
        right: 100%;
        transform: translateY(50%);
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 5px 5px 15px 5px;
        background-color: white;
        border-color: #fffc;
        border-width: 1px;
        border-style: solid;
        border-radius: 50px;
        transition-property: all;
        transition-timing-function: cubic-bezier(.4,0,.2,1);
        transition-duration: .3s;
        --ssn-shadow: -4px 4px 12px rgba(0, 0, 0, .1);
        --ssn-shadow-colored: -4px 4px 12px var(--ssn-shadow-color);
        box-shadow: var(--ssn-ring-offset-shadow, 0 0 #0000), var(--ssn-ring-shadow, 0 0 #0000), var(--ssn-shadow);
        @media ((max-width: 640px) and (max-height: 700px)) {
            padding: 0;
        }
        .head{
            display: flex;
            gap: 10px;
            .image{
                border-radius: 50%;
                overflow: hidden;
                width: 44px;
                height: 44px;
                img{
                    width: 100%;
                    height: 100%;
                    object-fit: cover;
                }
            }
            .title{
                font-weight: 700;
                color: #000;
                &.hidden{
                    display: none;
                }
            }
        }
        .options{
            display: flex;
            &:not(.no-hs){
                @media ((max-width: 640px) and (max-height: 700px)) {
                    display: none;
                }
            }
            flex-direction: column;
            gap: 8px;
            .option{
                align-items: center;
                display: flex;
                gap: 12px;
                &.wysiwyg{
                    min-width: 300px;
                    display: block;
                    padding: 15px;
                }
                &:last-child{
                    margin-bottom: 5px;
                }
                > a{
                    transition: color .3s ease-in-out;
                    font-size: .875rem;
                    line-height: 1.25rem;
                    text-decoration: none;
                    white-space: nowrap;
                    display: flex;
                    gap: 5px;
                    &:hover{
                        color: black;
                        .icon img{
                            filter: drop-shadow(0px 0px 3px var(--mainColor, #000));
                        }
                    }
                }
                .icon{
                    padding: 0 7px;
                    display: flex;
                    img{
                        width: 28px;
                        max-height: 28px;
                        object-fit: contain;
                    }
                }
                .link{
                    &.hidden{
                        display: none;
                    }
                }
                &.divider{
                    hr{
                        margin: 5px 0;
                        background: rgb(206, 206, 206);
                        width: 100%;
                    }
                }
                &.hidden{
                    display: none;
                }
            }
        }
    }
    &:hover,
    &:focus,
    &:focus-within{
        .stickyElement{
            border-radius: 20px;
            padding: 16px;
            @media ((max-width: 640px) and (max-height: 700px)) {
                position: absolute;
                bottom: 0;
                right: 0;
            }
            .title.hidden,
            .options .option.hidden,
            .options .link.hidden{
                display: flex;
                align-items: center;
                &.wysiwyg{
                    display: block;
                }
            }
            .options{
                @media ((max-width: 640px) and (max-height: 700px)) {
                    display: flex;
                }
            }
        }
    }
}
div.sidebar-wrapper.scroll-hide:not(.modal-open) aside.sidebar.fixed:not(:hover):not(:focus):not(:focus-within) .stickyElement{
    transform: translateY(50%) translateX(calc(98% + 10px));
}

/* ==========================================================================
   Header-Modus: Icon im Header + Modal-Darstellung
   ========================================================================== */

/* Header-Trigger (Icon im Header) - bis zur Einhängung versteckt (gegen FOUC) */
.ssn-header-trigger{
    width: 40px;
    height: 40px;
    padding: 6px;
    border: 1px solid #fffc;
    background-color: white;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: -4px 4px 12px rgba(0, 0, 0, .1);
    transition: box-shadow .2s ease, outline-offset .15s ease;
}
.ssn-header-trigger:focus{
    outline: none;
}
.ssn-header-trigger:focus-visible{
    outline: 3px solid var(--mainColor, #2271b1);
    outline-offset: 3px;
}
.ssn-header-trigger img{
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.ssn-header-trigger:hover{
    box-shadow: -4px 4px 16px rgba(0, 0, 0, .18);
}

/* Header-Modus greift nur auf mobilen Geräten (Theme-Breakpoint: 1200px) */
@media (max-width: 1200px){
    /* Variante 1: Icon ist im Header eingehängt (vor #site-navigation) */
    .ssn-header-trigger.in-header{
        display: flex;
        position: relative;
        margin-left: auto;
        align-self: center;
        flex-shrink: 0;
        pointer-events: auto;
    }

    /* Variante 2: Fallback - kein #site-navigation gefunden, fixiert oben rechts */
    .ssn-header-trigger.floating{
        display: flex;
        position: fixed;
        top: 15px;
        right: 15px;
        width: 48px;
        height: 48px;
        padding: 8px;
        z-index: 9997;
        pointer-events: auto;
    }

    /* Im Header-Modus: seitliche Sticky Nav komplett ausblenden (außer im Modal) */
    div.sidebar-wrapper.has-header-mode:not(.modal-open) aside.sidebar.fixed{
        display: none;
    }
}

/* Modal-Backdrop */
.ssn-modal-backdrop{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, .45);
    z-index: 9996;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
div.sidebar-wrapper.modal-open .ssn-modal-backdrop{
    opacity: 1;
    pointer-events: auto;
}

/* Schließen-Button (X) */
.ssn-modal-close{
    pointer-events: auto;
    position: fixed;
    top: 15px;
    right: 15px;
    width: 48px;
    height: 48px;
    border: 1px solid #fffc;
    background-color: white;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: #333;
    box-shadow: -4px 4px 12px rgba(0, 0, 0, .1);
    transition: box-shadow .2s ease;
}
.ssn-modal-close span{
    display: block;
    margin-top: -3px;
}
.ssn-modal-close:hover{
    box-shadow: -4px 4px 16px rgba(0, 0, 0, .18);
}
.ssn-modal-close:focus{
    outline: none;
}
.ssn-modal-close:focus-visible{
    outline: 3px solid var(--mainColor, #2271b1);
    outline-offset: 3px;
}

/* Fokus-Stil für Links im Modal/Sticky Element */
div.sidebar-wrapper aside.sidebar.fixed .stickyElement a:focus{
    outline: none;
}
div.sidebar-wrapper aside.sidebar.fixed .stickyElement a:focus-visible{
    outline: 2px solid var(--mainColor, #2271b1);
    outline-offset: 3px;
    border-radius: 4px;
}
div.sidebar-wrapper.modal-open .ssn-modal-close{
    display: flex;
}

/* Modal-Darstellung der stickyElement */
div.sidebar-wrapper.modal-open aside.sidebar.fixed{
    pointer-events: auto;
    opacity: 1;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: none;
    z-index: 9998;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 80px 15px 15px 15px;
}
div.sidebar-wrapper.modal-open aside.sidebar.fixed .stickyElement{
    position: relative;
    right: auto;
    bottom: auto;
    transform: none;
    border-radius: 20px;
    padding: 24px;
    max-width: 360px;
    width: auto;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    animation: ssnModalIn .3s cubic-bezier(.4,0,.2,1);
}
/* Versteckte Elemente im Modal vollständig anzeigen */
div.sidebar-wrapper.modal-open .stickyElement .head .title.hidden,
div.sidebar-wrapper.modal-open .stickyElement .options .option.hidden,
div.sidebar-wrapper.modal-open .stickyElement .options .option .link.hidden{
    display: flex;
    align-items: center;
}
div.sidebar-wrapper.modal-open .stickyElement .options .option.wysiwyg.hidden{
    display: block;
}
div.sidebar-wrapper.modal-open .stickyElement .options{
    display: flex;
}

@keyframes ssnModalIn{
    from{
        opacity: 0;
        transform: translateY(-12px);
    }
    to{
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile: Modal als Slide-Down von oben, volle Breite */
@media (max-width: 640px){
    div.sidebar-wrapper.modal-open aside.sidebar.fixed{
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
    }
    div.sidebar-wrapper.modal-open aside.sidebar.fixed .stickyElement{
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        border-radius: 0 0 24px 24px;
        padding: 70px 20px 24px 20px;
        animation: ssnModalSlideDown .35s cubic-bezier(.4,0,.2,1);
    }
    @keyframes ssnModalSlideDown{
        from{
            opacity: 0;
            transform: translateY(-100%);
        }
        to{
            opacity: 1;
            transform: translateY(0);
        }
    }
}
