.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 9, 13, 0.93);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  touch-action: pan-y;
  user-select: none;
}
.lightbox.active {
  opacity: 1;
  visibility: visible;
}
.lightbox-header {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1020;
}
.lightbox-counter {
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
}
.lightbox-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: scale(1.05);
}
.lightbox-close:active {
  transform: scale(0.92);
}
.lightbox-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: lbSpin 0.7s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1015;
}
.lightbox.loading .lightbox-loader {
  opacity: 1;
}
@keyframes lbSpin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
.lightbox-content {
  position: relative;
  max-width: 92vw;
  max-height: 82vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1010;
}
.lightbox img {
  max-width: 92vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  opacity: 0;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.lightbox.active img.loaded {
  opacity: 1;
  transform: scale(1);
}
.lightbox.loading img {
  opacity: 0;
}
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  z-index: 1030;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  transform: translateY(-50%) scale(1.06);
}
.lightbox-nav:active {
  transform: translateY(-50%) scale(0.94);
}
.lightbox-nav.prev {
  left: 20px;
}
.lightbox-nav.next {
  right: 20px;
}
.lightbox-footer {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 1020;
}
.lightbox-caption {
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  letter-spacing: 0.01em;
  text-align: center;
  max-width: min(90vw, 540px);
  line-height: 1.4;
  word-break: break-word;
  box-sizing: border-box;
  pointer-events: auto;
}
.lightbox-caption .lb-counter {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11.5px;
  margin-left: 6px;
  white-space: nowrap;
}
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}
@media(max-width:768px) {
  .lightbox-nav {
    display: none;
  }
  .lightbox-content {
    max-width: 96vw;
    max-height: calc(100vh - 120px);
  }
  .lightbox img {
    max-width: 94vw;
    max-height: calc(100vh - 130px);
    border-radius: 6px;
  }
  .lightbox-caption {
    font-size: 11.5px;
    padding: 5px 12px;
    line-height: 1.35;
    max-width: 92vw;
  }
}
