.clg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(var(--clg-columns, 3), 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .clg-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .clg-gallery-grid {
        grid-template-columns: 1fr;
    }
}

.clg-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 4 / 3;
    background: #eee;
}

/*
 * Fix for images being awkwardly half-cropped: a lot of source photos
 * aren't 4:3, so object-fit:cover on the <img> itself was chopping off
 * the top/bottom (or sides) of tall or wide shots. Instead we show the
 * full, uncropped photo via object-fit:contain, and fill the empty
 * letterbox space behind it with a blurred, zoomed copy of the same
 * image so there's no dead gray bars.
 */
.clg-thumb {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(18px) brightness(0.75);
    transform: scale(1.15);
}

.clg-item img,
.clg-slide-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    display: block;
    transition: transform 0.3s ease;
    filter: none;
}

.clg-item:hover img,
.clg-slide-item:hover img {
    transform: scale(1.03);
}

.clg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    text-align: center;
    padding: 12px;
}

.clg-item:hover .clg-overlay,
.clg-item:focus-within .clg-overlay,
.clg-slide-item:hover .clg-overlay,
.clg-slide-item:focus-within .clg-overlay {
    opacity: 1;
    background: rgba(0, 0, 0, 0.4);
}

.clg-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

.clg-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.clg-like-btn,
.clg-share-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    padding: 4px 6px;
    line-height: 1;
}

.clg-like-btn i,
.clg-share-btn i {
    font-size: 18px;
}

.clg-like-btn.is-liked {
    color: #ff5a5f;
}

.clg-like-btn:hover,
.clg-share-btn:hover {
    opacity: 0.8;
}

/* Share modal */
.clg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.clg-modal-overlay[hidden] {
    display: none;
}

.clg-modal {
    position: relative;
    background: #fff;
    border-radius: 6px;
    padding: 48px 40px 32px;
    width: 100%;
    max-width: 420px;
}

.clg-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #222;
    font-size: 20px;
    line-height: 1;
    padding: 4px;
}

.clg-share-icons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 28px;
}

.clg-share-link {
    color: #222;
    font-size: 22px;
    display: inline-flex;
}

.clg-share-link[data-network="facebook"] {
    color: #1877f2;
}

.clg-share-link:hover {
    opacity: 0.7;
}

.clg-share-url-row {
    display: flex;
    align-items: stretch;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}

.clg-share-url-input {
    flex: 1;
    border: none;
    padding: 10px 12px;
    font-size: 13px;
    color: #444;
    background: #fff;
    min-width: 0;
}

.clg-share-url-input:focus {
    outline: none;
}

.clg-copy-btn {
    background: #1a1a1a;
    color: #fff;
    border: none;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
}

.clg-copy-btn:hover {
    background: #333;
}

/* Lightbox */
.clg-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 40px;
}

.clg-lightbox-overlay[hidden] {
    display: none;
}

.clg-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.clg-lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    padding: 8px;
}

.clg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 28px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.clg-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.clg-lightbox-nav[hidden] {
    display: none;
}

.clg-lightbox-prev {
    left: 20px;
}

.clg-lightbox-next {
    right: 20px;
}

@media (max-width: 600px) {
    .clg-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
    .clg-lightbox-prev { left: 8px; }
    .clg-lightbox-next { right: 8px; }
}

.clg-item img {
    cursor: pointer;
}

/* Slider (filmstrip) mode */
.clg-slider-wrap {
    position: relative;
}

.clg-slider-track {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.clg-slider-track::-webkit-scrollbar {
    display: none;
}

.clg-slide-item {
    position: relative;
    flex: 0 0 auto;
    width: 22%;
    min-width: 140px;
    aspect-ratio: 3 / 4;
    scroll-snap-align: start;
    overflow: hidden;
    background: #eee;
    cursor: pointer;
}

@media (max-width: 768px) {
    .clg-slide-item {
        width: 45%;
    }
}

.clg-slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.85);
    border: none;
    color: #333;
    font-size: 22px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.clg-slider-nav:hover {
    background: #fff;
}

.clg-slider-prev {
    left: 8px;
}

.clg-slider-next {
    right: 8px;
}

/* Detail overlay (opened from slider mode) */
.clg-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 40px;
}

.clg-detail-overlay[hidden] {
    display: none;
}

.clg-detail-inner {
    background: #fff;
    max-width: 1100px;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 48px;
    align-items: center;
    padding: 32px;
    border-radius: 6px;
}

@media (max-width: 768px) {
    .clg-detail-inner {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }
}

.clg-detail-media {
    position: relative;
}

.clg-detail-img {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

.clg-detail-like-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: transparent;
    border: none;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    padding: 4px;
}

.clg-detail-like-btn.is-liked {
    color: #ff5a5f;
}

.clg-detail-share-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 18px;
    padding: 4px;
    transition: opacity 0.2s ease;
}

.clg-detail-share-btn:hover {
    opacity: 0.7;
}

.clg-detail-title {
    font-size: 34px;
    font-weight: 600;
    margin: 0 0 16px;
    color: #222;
}

.clg-detail-description {
    font-size: 15px;
    line-height: 1.6;
    color: #444;
    margin: 0;
}

.clg-detail-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    padding: 8px;
    z-index: 1;
}

.clg-detail-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #fff;
    font-size: 30px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.clg-detail-nav[hidden] {
    display: none;
}

.clg-detail-prev {
    left: 12px;
}

.clg-detail-next {
    right: 12px;
}
