.gallery-preview {
  display: inline-block;
  cursor: pointer;
  text-align: center;
  margin-top: 10px;
}

.gallery-preview img {
  max-width: 100%;
  max-height: 100px;
  height: auto;
  width: auto;
  display: block;
  margin: 0 auto;
}

.gallery-label {
  text-align: center;
  font-size: 0.9em;
  color: #333;
  margin-top: 4px;
}

.gallery-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #222;
  color: white;
  z-index: 10001;
  border-radius: 8px;
  overflow: visible;
  padding: 0;
  max-width: 90vw;
  max-height: 90vh;
  touch-action: pan-x pan-y;
  -ms-touch-action: pan-x pan-y;
  pointer-events: auto;
}

.gallery-header {
  background: #111;
  padding: 8px 12px;
  cursor: move;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-title {
  font-size: 1.2em;
}

.gallery-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.close-button {
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
}

.gallery-content img {
  max-width: 100%;
  max-height: 150px;
  border-radius: 4px;
}

.main-image-container {
  position: relative;
  width: auto;
  max-width: 90vw;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px;
}

.main-image-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2em;
  cursor: pointer;
  user-select: none;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.3);
  z-index: 10;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.arrow.left {
  left: 0;
}

.arrow.right {
  right: 0;
}

.arrow:hover {
  background: rgba(61, 61, 61, 0.25);
}

.arrow.hidden {
  opacity: 0;
  pointer-events: none; /* ensures clicks don't trigger when invisible */
}

.thumbnail-strip {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  gap: 8px;
  padding: 10px;
  background: #111;
  max-width: 90vw;
}

.thumbnail-strip img {
  height: 60px;
  width: auto;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.2s;
}

.thumbnail-strip img.active {
  opacity: 1;
}

@media (max-width: 768px) {
  .gallery-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95vw;
    height: auto;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    overflow: visible;
    z-index: 1000000;
  }

  .main-image-container {
    height: auto;
    width: auto;
    max-width: 100vw;
    max-height: 60vh;
    margin: 0;
    padding: 0;
  }

  .main-image-container img {
    max-height: 80vh;
    width: auto;
  }

  .thumbnail-strip {
    padding: 6px;
    gap: 6px;
    max-width: 100vw;
  }

  .thumbnail-strip img {
    height: 50px;
  }

  .gallery-modal {
  overflow-y: auto;
  }

  .main-image-container {
    overflow: auto;
  }
}
