.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 12px;
}

/* shared look of all lightbox buttons */
.lb-close,
.lb-fullscreen,
a.lb-download.download-btn,
button.lb-upload.upload-btn,
.lb-prev,
.lb-next,
.lb-fs-close,
.lb-zoom-bar button {
  padding: 0;
  box-sizing: border-box;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.6);
  color: white;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  transition: transform 0.08s, background 0.15s;
}
.lb-close:hover,
.lb-fullscreen:hover,
a.lb-download.download-btn:hover,
button.lb-upload.upload-btn:hover,
.lb-prev:hover,
.lb-next:hover,
.lb-fs-close:hover,
.lb-zoom-bar button:hover {
  background: rgba(0, 0, 0, 0.85);
}
.lb-close:active,
.lb-fullscreen:active,
a.lb-download.download-btn:active,
button.lb-upload.upload-btn:active,
.lb-prev:active,
.lb-next:active,
.lb-fs-close:active,
.lb-zoom-bar button:active {
  background: rgba(0, 0, 0, 0.95);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* corner buttons: geometry */
.lb-close,
.lb-fullscreen,
a.lb-download.download-btn,
button.lb-upload.upload-btn {
  position: absolute;
  top: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.lb-close:active,
.lb-fullscreen:active,
a.lb-download.download-btn:active,
button.lb-upload.upload-btn:active {
  transform: translateY(1px) scale(0.94);
}

/* position and specifics of each button */
.lb-close { right: 10px; font-size: 1.2rem; }
.lb-fullscreen { right: 54px; }   /* 10 + 36 + 8 */
a.lb-download.download-btn { left: 10px; font-size: 1.2rem; }
button.lb-upload.upload-btn { left: 54px; }   /* 10 + 36 + 8 */
.lb-fullscreen svg,
a.lb-download.download-btn svg,
button.lb-upload.upload-btn svg { display: block; }

.lb-media {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-media img,
.lb-media video {
  max-width: 85vw;
  max-height: 70vh;
  border-radius: 4px;
}
.lb-media:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: black;
}
.lb-media:fullscreen img,
.lb-media:fullscreen video {
  max-width: 100%;
  max-height: 100%;
}
.lb-media--zoom {
  position: relative;
  width: 85vw;
  height: 70vh;
}
/* prev/next and close button inside .lb-media: Only shown in fullscreen */
.lb-media > .lb-fs-nav {
  display: none;
}
.lb-media:fullscreen > .lb-fs-nav {
  display: block;
  z-index: 3;
}

.lb-fs-close {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  z-index: 3;
}
.lb-fs-close:active {
  transform: translateY(1px) scale(0.94);
}

.lb-fullscreen svg,
a.lb-download.download-btn svg,
button.lb-upload.upload-btn svg {
  width: 18px;
  height: 18px;
}

.lb-zoom-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}
.lb-zoom-bar button {
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
}
.lb-zoom-bar button:active {
  transform: translateY(1px) scale(0.94);
}

.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
}
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-prev:active, .lb-next:active {
  transform: translateY(calc(-50% + 1px)) scale(0.94);
}

.lb-filename {
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  text-align: center;
}
.lb-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 90vw;
  padding: 4px;
}
.lb-thumb {
  width: 70px;
  height: 52px;
  object-fit: cover;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.5;
  border: 2px solid transparent;
  flex-shrink: 0;
}
.lb-thumb.active {
  opacity: 1;
  border-color: #0f70d0;
}

/* Responsive smartphone */
/* ===================== */
@media (max-width: 768px) {
  .lightbox { --lb-btn: 32px; }
  
  .lb-close,
  .lb-fullscreen,
  a.lb-download.download-btn,
  button.lb-upload.upload-btn,
  .lb-zoom-bar button,
  .lb-fs-close {
    width: 32px;
    height: 32px;
  }
  /* .lb-fullscreen { right: 50px; }   /* 10 + 32 + 8 */
  /* button.lb-upload.upload-btn { left: 50px; }   10 + 32 + 8 */
  
  .lb-prev, .lb-next {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }
  .lb-prev { left: 2px; }
  .lb-next { right: 2px; }
  
  .lb-thumbs {
    max-width: 100vw;
  }
  
  .lb-media img,
  .lb-media video {
    max-width: 95vw;
    max-height: 60vh;
  }
}
