.gallery{
  position:fixed;
  inset:0;
  background:rgba(53, 18, 30, .85);
  z-index:1000;
  display:none;
  align-items:flex-start;
  justify-content:center;
  padding:20px;
  overflow-y:auto;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition: opacity 0.08s linear;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.gallery[hidden],
.lightbox[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.gallery.open {
  display:flex;
  touch-action: pan-y;
  pointer-events: auto;
  opacity:1;
  visibility:visible;
}

.gallery-card{
  position:relative;
  width:min(900px, 100%);
  margin:auto 0;
  background:#fff;
  border-radius:26px;
  padding:20px;
  box-shadow:var(--shadow);
}

.gallery::-webkit-scrollbar {
  width: 12px;
}

.gallery::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
}

.gallery::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #ff6b9d, #c44569);
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.gallery::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #ff8fab, #ff6b9d);
}

.close{
  position:absolute;
  top:14px;
  right:14px;
  width:42px;
  height:42px;
  border-radius:50%;
  background:#fff0f5;
  font-size:22px;
  line-height:1;
  padding:0;
}

.gallery-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:16px;
  margin-top:24px;
}

.photo{
  background:#fff6fa;
  border-radius:20px;
  overflow:hidden;
  box-shadow:0 8px 24px rgba(0,0,0,.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.photo:hover{
  transform: translateY(-8px) scale(1.02);
  box-shadow:0 16px 32px rgba(0,0,0,.12);
}

.photo img{
  width:100%;
  height:280px;
  object-fit:cover;
  display:block;
  transition: transform 0.3s ease;
  -webkit-user-drag: none;
  user-select: none;
  touch-action: pan-y;
}

.photo:hover img{
  transform: scale(1.05);
}

.photo p{
  margin:0;
  padding:12px;
  font-size:.95rem;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 5000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease;
  touch-action: none;
}

.lightbox.open {
  display: flex;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}

@media (max-width: 768px) {
  /* Fix scroll blocking on iPhone */
  .gallery {
    backdrop-filter: none;
    background: rgba(53, 18, 30, 0.9);
  }

  .gallery-card {
    margin: 0;
  }
}
