:root {
      --overlay: rgba(0,0,0,0.75);
      --bg: #fff;
      --thumb: #ddd;
    }

    body {
      margin: 0;
      font-family: Arial, sans-serif;
      background: #f5f5f5;
      color: #333;
    }

    /* Галерея миниатюр */
    .gallery {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
      gap: 12px;
      padding: 20px;
      max-width: 1200px;
      margin: 0 auto;
    }

    .thumb {
      width: 100%;
      padding-bottom: 75%; /* соотношение 4:3 */
      position: relative;
      background: var(--thumb);
      border-radius: 6px;
      overflow: hidden;
      cursor: pointer;
      box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    }

    .thumb img {
      position: absolute;
      top: 0; left: 0;
      width: 100%; height: 100%;
      object-fit: cover;
      transform: scale(1.05);
      transition: transform 0.5s ease;
    }

    .thumb:hover img { transform: scale(1.08); }

    /* Затемняющий фон и модальное окно */
    .overlay {
      position: fixed;
      inset: 0;
      background: var(--overlay);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 1000;
    }

    .modal {
      background: var(--bg);
      border-radius: 8px;
      max-width: 90vw;
      max-height: 80vh;
      box-shadow: 0 20px 40px rgba(0,0,0,0.4);
      display: grid;
      grid-template-columns: 1fr;
      overflow: hidden;
    }

    /* Контент модального окна: фото + навигация снизу */
    .modal-media {
      width: 100%;
      height: auto;
      display: block;
      max-height: 75vh;
    }

    .modal-actions {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 12px;
      border-top: 1px solid #eaeaea;
      background: #fff;
    }

    .nav-btn, .close-btn {
      background: #eee;
      border: none;
      padding: 8px 12px;
      border-radius: 6px;
      cursor: pointer;
    }

    .close-btn {
      background: #f44336;
      color: #fff;
    }

    @media (min-width: 700px) {
      .modal {
        grid-template-columns: 1fr;
      }
      .modal-media {
        max-height: 72vh;
      }
    }

    /* Стилизация для большого изображения внутри модалки на больших экранах */
    .modal-image-wrap {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 6px;
      background: #000;
    }

    .modal-image-wrap img {
      max-width: 100%;
      max-height: 70vh;
      display: block;
    }