.gallery-masonry {
    column-count: 2;
    column-gap: 16px;
    margin-top: 20px;
}

@media (min-width: 768px) {
    .gallery-masonry {
        column-count: 3;
    }
}

@media (min-width: 992px) {
    .gallery-masonry {
        column-count: 4;
    }
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 16px;
}

.gallery-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    background: #fff;
    cursor: pointer;
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 118, 255, 0.15);
}

.gallery-card-media {
    background: #f4f6f8;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

@media (min-width: 768px) {
    .gallery-card-media {
        min-height: 300px;
    }
}

.gallery-card-media img {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    display: block;
}

@media (min-width: 768px) {
    .gallery-card-media img {
        max-height: 360px;
    }
}

.gallery-card-body {
    padding: 12px 14px 16px;
    text-align: center;
}

.gallery-card-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
    color: #334747;
    line-height: 1.4;
}

.gallery-card-category a {
    color: #0076ff;
    text-decoration: none;
    font-size: 12px;
}

.gallery-sort-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
}

.gallery-sort-pill {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: #f0f6ff;
    color: #0076ff;
    text-decoration: none;
    font-size: 14px;
}

.gallery-sort-pill:hover,
.gallery-sort-pill.is-active {
    background: #0076ff;
    color: #fff;
}

.gallery-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.gallery-pagination {
    margin-top: 30px;
    justify-content: center;
}

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.88);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px 56px;
}

.gallery-lightbox.is-open {
    display: flex;
}

.gallery-lightbox-inner {
    position: relative;
    max-width: min(95vw, 900px);
    max-height: 90vh;
    text-align: center;
    flex: 1;
}

.gallery-lightbox-img-wrap {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 16px;
    min-width: 200px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

.gallery-lightbox-img-wrap img {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
}

.gallery-lightbox-title {
    color: #fff;
    margin-top: 12px;
    font-size: 16px;
}

.gallery-lightbox-counter {
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    margin-top: 4px;
}

.gallery-lightbox-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.gallery-lightbox-actions a,
.gallery-lightbox-actions button {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background: #0076ff;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.gallery-lightbox-actions button.gallery-lightbox-close {
    background: #555;
}

.gallery-lightbox-spinner {
    color: #fff;
    font-size: 14px;
    margin-top: 8px;
}

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

.gallery-lightbox-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

.gallery-lightbox-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.gallery-lightbox-prev {
    left: 12px;
}

.gallery-lightbox-next {
    right: 12px;
}

@media (max-width: 767px) {
    .gallery-lightbox {
        padding: 8px 44px;
    }

    .gallery-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .gallery-lightbox-prev {
        left: 4px;
    }

    .gallery-lightbox-next {
        right: 4px;
    }
}

.image-page-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0;
    direction: rtl;
}

.image-page-nav a {
    flex: 1;
    max-width: 48%;
    padding: 12px 16px;
    border-radius: 8px;
    background: #f0f6ff;
    color: #0076ff;
    text-decoration: none;
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-page-nav a:hover {
    background: #dceaff;
}

.image-page-nav .nav-placeholder {
    flex: 1;
    max-width: 48%;
}
