.rich-gallery:after {
    content: '';
    display: table;
    clear: both;
}

.rich-gallery img {
    cursor: pointer;
    margin: 10px;
    transition: opacity 0.3s;
}

.rich-gallery img:hover {
    opacity: 0.8;
}

.rich-gallery .item {
    padding: 5px;
    width: 23%;
    margin-bottom: 0;
    padding-bottom: 0;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
}

.modal .modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.modal .close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white; /* Изменено на белый */
    font-size: 40px;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.3s;
}

.modal .close:hover {
    color: #ccc;
}

.modal .nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 30px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: all 0.3s ease;
    user-select: none;
}

.modal .nav-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
}

.modal .nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.modal .prev {
    left: 30px;
}

.modal .next {
    right: 30px;
}

/* Счетчик изображений */
.modal .image-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-family: Arial, sans-serif;
}

/* Скрытие элементов для одного изображения */
.modal.single-image .nav-btn,
.modal.single-image .image-counter {
    display: none;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .modal img {
        max-width: 95%;
        max-height: 85%;
    }

    .modal .close {
        top: 10px;
        right: 15px;
        font-size: 35px;
    }

    .modal .nav-btn {
        width: 50px;
        height: 50px;
        font-size: 25px;
    }

    .modal .prev {
        left: 15px;
    }

    .modal .next {
        right: 15px;
    }
}
