.snippet-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.snippet-gallery-masonry {
    column-count: 4;
    column-gap: 12px;
}

.snippet-gallery-masonry .snippet-gallery-item {
    break-inside: avoid;
    margin-bottom: 12px;
}

.snippet-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background: #f3f4f6;
}

.snippet-gallery-grid .snippet-gallery-item {
    aspect-ratio: 1;
}

.snippet-gallery-link {
    position: relative;
    display: block;
    text-decoration: none;
}

.snippet-gallery-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.snippet-gallery-link::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.25s ease;
}

a[data-lightbox].snippet-gallery-link::before {
    content: "⌕";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.snippet-gallery-link:hover::after {
    opacity: 1;
}

a[data-lightbox].snippet-gallery-link:hover::before {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
}

.snippet-gallery-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    color: #fff;
    font-size: 12px;
    padding: 18px 12px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.snippet-gallery-link:hover .snippet-gallery-caption {
    transform: translateY(0);
}

#cbp-lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#cbp-lb-overlay.cbp-lb-open {
    opacity: 1;
}

.cbp-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
}

.cbp-lb-box {
    position: relative;
    z-index: 2;
    width: fit-content;
    max-width: 92vw;
    margin: 4vh auto 0;
}

.cbp-lb-img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    background: #111827;
}

.cbp-lb-caption {
    color: #fff;
    text-align: center;
    margin-top: 10px;
    font-size: 13px;
}

.cbp-lb-close {
    position: absolute;
    top: -40px;
    right: 0;
    border: 0;
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.snippet-loading,
.snippet-empty {
    padding: 40px;
    text-align: center;
    color: #9ca3af;
}

.snippet-builder-placeholder {
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    min-height: 220px;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.cbp-settings-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cbp-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.cbp-input,
.cbp-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
}

.cbp-radio-group {
    display: flex;
    gap: 10px;
}

.cbp-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.cbp-apply-btn {
    border: 0;
    border-radius: 6px;
    padding: 9px 14px;
    color: #fff;
    background: var(--bd-primary, #07A169);
    cursor: pointer;
    font-weight: 600;
}

@media (max-width: 1024px) {
    .snippet-gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .snippet-gallery-masonry {
        column-count: 3;
    }
}

@media (max-width: 640px) {
    .snippet-gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .snippet-gallery-masonry {
        column-count: 2;
    }
}
