.references-section .comanbau-project-gallery {
    margin-top: 4px;
}

.comanbau-3d-row {
    display: flex !important;
    align-items: stretch;
    gap: 6px;
    height: min(58vh, 540px);
    min-height: 360px;
    overflow: visible;
    perspective: 1400px;
}

.comanbau-3d-row > .comanbau-3d-item {
    display: block;
    flex: 1 1 0%;
    width: auto;
    height: 100%;
    min-width: 0;
    border-radius: 7px;
    transform-origin: center center;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: flex-grow, transform;
}

.comanbau-3d-row > .comanbau-3d-item:nth-child(n + 13) {
    display: none;
}

.comanbau-3d-row.is-ready > .comanbau-3d-item:nth-child(n + 13) {
    display: block;
}

.comanbau-3d-row > .comanbau-3d-item[hidden] {
    display: none !important;
}

.comanbau-3d-row > .comanbau-3d-item img {
    height: 100%;
    aspect-ratio: auto;
    object-fit: cover;
}

.comanbau-3d-row > .comanbau-3d-item.is-active {
    z-index: 2;
    box-shadow: 0 18px 38px rgba(0, 0, 0, .22);
}

.comanbau-3d-row .reference-caption {
    padding: 72px 18px 20px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity .25s ease, transform .35s ease, visibility .25s ease;
}

.comanbau-3d-row > .comanbau-3d-item.is-active .reference-caption,
.comanbau-3d-row > .comanbau-3d-item:focus-visible .reference-caption {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.comanbau-3d-row:not(.is-gsap-ready) > .comanbau-3d-item {
    transition: flex-grow .4s cubic-bezier(.2, .7, .2, 1), box-shadow .35s ease;
}

.comanbau-3d-row:not(.is-gsap-ready) > .comanbau-3d-item.is-active {
    flex-grow: 8;
}

.reference-gallery-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 16px 2px 0;
}

.reference-gallery-controls[hidden] {
    display: none !important;
}

.reference-gallery-hint {
    color: var(--muted);
    font-size: 12px;
}

.reference-gallery-pager {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.reference-gallery-pager button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink);
    background: var(--cream);
    font-size: 18px;
    cursor: pointer;
    transition: transform .2s ease, background .2s ease, opacity .2s ease;
}

.reference-gallery-pager button:hover:not(:disabled) {
    transform: translateY(-2px);
    background: var(--sand);
}

.reference-gallery-pager button:disabled {
    opacity: .4;
    cursor: default;
}

.reference-gallery-pager button:focus-visible {
    outline: 2px solid var(--sand-dark);
    outline-offset: 3px;
}

.photo-lightbox.coman-stack-lightbox {
    width: min(960px, calc(100% - 32px));
    max-height: 94vh;
    padding: 0;
    border-radius: 18px;
}

.photo-lightbox.coman-stack-lightbox .coman-lightbox-source {
    display: none !important;
}

.coman-lightbox-figure {
    margin: 0;
    padding: clamp(14px, 2vw, 24px);
}

.coman-lightbox-stack {
    position: relative;
    width: min(100%, 860px);
    height: min(60vh, 600px);
    min-height: 300px;
    margin: 0 auto 16px;
    isolation: isolate;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.coman-lightbox-card {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding: 0;
    border: 1px solid rgba(200, 182, 155, .4);
    border-radius: 12px;
    background-color: #111;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain !important;
    box-shadow: 0 24px 50px rgba(0, 0, 0, .32);
    cursor: default;
    transition: translate .32s cubic-bezier(.2, .7, .2, 1), scale .32s cubic-bezier(.2, .7, .2, 1), rotate .32s cubic-bezier(.2, .7, .2, 1);
}

.coman-lightbox-card[data-stack-depth="0"] {
    z-index: 1;
    translate: 18px 13px;
    scale: .92;
    rotate: -4deg;
    pointer-events: none;
}

.coman-lightbox-card[data-stack-depth="1"] {
    z-index: 2;
    translate: 9px 7px;
    scale: .96;
    rotate: 2deg;
    pointer-events: none;
}

.coman-lightbox-card[data-stack-depth="2"] {
    z-index: 3;
    translate: 0 0;
    scale: 1;
    rotate: 0deg;
    cursor: pointer;
}

.coman-lightbox-card:focus-visible {
    outline: 3px solid var(--sand);
    outline-offset: 5px;
}

.coman-lightbox-caption {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 0 2px;
}

.coman-lightbox-caption-text {
    min-width: 0;
    line-height: 1.5;
}

.coman-lightbox-controls {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 9px;
}

.coman-lightbox-step {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid currentColor;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
}

.coman-lightbox-step:hover {
    transform: translateY(-2px);
    background: rgba(200, 182, 155, .18);
}

.coman-lightbox-count {
    min-width: 64px;
    color: inherit;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.coman-lightbox-close {
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.coman-lightbox-step:focus-visible,
.coman-lightbox-close:focus-visible {
    outline: 2px solid var(--sand);
    outline-offset: 3px;
}

@media (max-width: 700px) {
    .comanbau-3d-row {
        height: clamp(320px, 48svh, 470px);
        min-height: 320px;
        overflow-x: auto;
        overflow-y: hidden;
        perspective: none;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
    }

    .comanbau-3d-row > .comanbau-3d-item {
        flex: 0 0 min(78vw, 380px);
        scroll-snap-align: center;
        transform: none !important;
    }

    .reference-gallery-controls {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .reference-gallery-pager {
        justify-content: space-between;
    }

    .photo-lightbox.coman-stack-lightbox {
        width: calc(100% - 18px);
        max-height: 96vh;
        border-radius: 12px;
    }

    .coman-lightbox-figure {
        padding: 12px;
    }

    .coman-lightbox-stack {
        height: min(56vh, 480px);
        min-height: 250px;
        margin-bottom: 14px;
    }

    .coman-lightbox-caption {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
        gap: 10px;
        font-size: 11px;
    }

    .coman-lightbox-controls {
        justify-content: space-between;
    }
}

@media (prefers-reduced-motion: reduce) {
    .comanbau-3d-row > .comanbau-3d-item,
    .comanbau-3d-row .reference-caption,
    .reference-gallery-pager button {
        transition: none !important;
    }

    .coman-lightbox-card,
    .coman-lightbox-step {
        transition: none !important;
    }
}
