.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3.5rem 2rem 5rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-auto-rows: 10px;
    gap: 18px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
    background: var(--bg-secondary);
    border: none;
    padding: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-item:hover,
.gallery-item:focus-visible {
    transform: translateY(-6px) scale(1.015);
    box-shadow: var(--shadow-lg);
    outline: none;
    z-index: 2;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s var(--ease-out), opacity 0.4s ease;
    opacity: 0;
}

.gallery-item.loaded img {
    opacity: 1;
}

.gallery-item:hover img {
    transform: scale(1.08);
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0%, transparent 55%);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0.85rem;
    opacity: 0;
    transition: opacity var(--dur-fast);
}

.gallery-item:hover .gallery-overlay,
.gallery-item:focus-visible .gallery-overlay {
    opacity: 1;
}

.gallery-overlay-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, 0.96);
    z-index: 2000;
    animation: fadeIn 0.25s ease;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    position: relative;
    max-width: 92%;
    max-height: 88%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 88vh;
}

.lightbox-image {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
    animation: none;
}

.lightbox-image.loaded {
    opacity: 1;
    transform: scale(1);
}

.lightbox-spinner {
    position: absolute;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--accent-color);
    animation: spin 0.8s linear infinite;
    opacity: 0;
    transition: opacity var(--dur-fast);
}

.lightbox-spinner.active {
    opacity: 1;
}

.lightbox-close {
    position: fixed;
    top: 1.25rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.8rem;
    line-height: 1;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
    z-index: 2002;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.08);
}

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 1.8rem;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
    z-index: 2002;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-50%) scale(1.08);
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-counter {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-pill);
    z-index: 2002;
}

@media (max-width: 768px) {
    .gallery-container {
        padding: 2.5rem 1.25rem 3.5rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .lightbox-nav {
        font-size: 1.4rem;
        width: 44px;
        height: 44px;
    }

    .lightbox-prev {
        left: 0.4rem;
    }

    .lightbox-next {
        right: 0.4rem;
    }

    .lightbox-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
}
