html, body {
    margin: 0; padding: 0;
    background: #000;
    font-family: 'Inter', sans-serif;
    color: #fff;
    overflow-x: hidden;
}

.gallery-container {
    position: relative;
    z-index: 10;
    max-width: 1400px;
    margin: 100px auto;
    padding: 0 40px;
}

.gallery-header {
    text-align: center;
    margin-bottom: 60px;
}

.page-title {
    font-size: 3rem;
    font-weight: 200;
    text-transform: uppercase;
    letter-spacing: 15px;
    margin: 0;
}

.subtitle {
    color: #d4af37;
    letter-spacing: 5px;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-top: 10px;
    opacity: 0.8;
}

/* Сетка с фиксированным шагом и выравниванием по верху */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-auto-rows: 10px; /* Маленький шаг для точной подгонки высоты */
    gap: 20px;            /* Межстрочный интервал */
    align-items: start;   /* Заставляет элементы не растягиваться принудительно */
}

.gallery-item {
    grid-row-end: span 20; /* Начальное значение по умолчанию до загрузки */
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateY(30px);
    padding: 0;
    width: 100%;
    background: transparent;
    color: inherit;
    text-align: left;
    transition: opacity 0.6s ease, transform 0.6s ease, border-color 0.4s ease;
}

.gallery-item img {
    width: 100%;
    height: auto;         /* Высота рассчитывается строго пропорционально ширине */
    display: block;
    object-fit: contain; 
    filter: brightness(1) contrast(1.05); 
    transition: transform 0.8s ease;
}

.gallery-item:hover {
    border-color: #d4af37;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.2);
}

.gallery-item:hover img { transform: none; }
.gallery-item:focus-visible { outline: 3px solid #d4af37; outline-offset: 2px; }
.gallery-load-trigger { height: 2px; }

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    z-index: 50000;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 5px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.close-lightbox {
    border: 0;
    background: transparent;
    position: absolute;
    top: 30px; right: 40px;
    font-size: 50px;
    color: #fff;
    cursor: pointer;
    line-height: 1;
}

/* Фон */
.photo-bg { position: fixed; inset: 0; z-index: 1; overflow: hidden; }
.photo-bg img { width: 100%; height: 100%; object-fit: cover; filter: brightness(0.5); }

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    
    /* Фиксируем размеры для идеального круга */
    width: 60px;
    height: 60px;
    
    /* Центрируем иконку стрелки внутри круга */
    display: flex;
    justify-content: center;
    align-items: center;
    
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    font-size: 24px;
    border-radius: 50%; /* Это делает форму круглой */
    z-index: 50001;
    transition: 0.3s;
    
    /* Убираем лишние отступы, так как размер фиксирован */
    padding: 0; 
}

.nav-arrow:hover {
    background: rgba(212, 175, 55, 0.4);
    border-color: #d4af37;
}

.prev { left: 40px; }
.next { right: 40px; }

@media (max-width: 768px) {
    .gallery-container {
        margin: 100px auto 48px;
        padding: 0 16px;
    }

    .page-title {
        font-size: clamp(1.5rem, 6vw, 3rem);
        letter-spacing: 4px;
    }

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

    .close-lightbox {
        top: 16px;
        right: 16px;
        font-size: 36px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-arrow {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .prev { left: 12px; }
    .next { right: 12px; }
}