.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.gallery-item {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.gallery-caption {
  padding: 12px;
  font-size: 0.9em;
  color: var(--text);
  text-align: center;
  background: #f8f9fa;
}

/* Сообщения */
.loading, .no-photos {
  text-align: center;
  padding: 40px;
  font-size: 1.2em;
  color: var(--text);
  grid-column: 1 / -1;
}

.loading {
  color: var(--orange);
}

/* Модальное окно*/
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.9);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  display: block;
  margin: auto;
  max-width: 90%;
  max-height: 80%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
  transition: color 0.3s ease;
}

.modal-close:hover {
  color: var(--orange);
}

.modal-caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  text-align: center;
  font-size: 1.1em;
  background: rgba(0,0,0,0.7);
  padding: 10px 20px;
  border-radius: 20px;
  max-width: 80%;
}

/* Кнопки навигации */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  font-size: 24px;
  padding: 15px 20px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.modal-prev {
  left: 20px;
}

.modal-next {
  right: 20px;
}

.modal-nav:hover {
  background: rgba(255,255,255,0.4);
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
  }
  
  .gallery-item img {
    height: 200px;
  }
  
  .modal-content {
    max-width: 95%;
    max-height: 70%;
  }
  
  .modal-close {
    top: 10px;
    right: 15px;
    font-size: 30px;
  }
  
  .modal-nav {
    padding: 10px 15px;
    font-size: 20px;
  }
  
  .modal-prev {
    left: 10px;
  }
  
  .modal-next {
    right: 10px;
  }
  
  .modal-caption {
    font-size: 1em;
    bottom: 10px;
    padding: 8px 15px;
  }
}

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