/* Delad bildförhandsvisning (lightbox) */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px));
}

.image-lightbox[hidden] {
  display: none !important;
}

.image-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.image-lightbox__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: min(92dvh, calc(100dvh - 1.5rem));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}

.image-lightbox__toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}

.image-lightbox__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.image-lightbox__counter {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
}

.image-lightbox__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.image-lightbox__close:hover {
  background: #cbd5e1;
}

.image-lightbox__stage {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 2.75rem 1rem;
}

.image-lightbox__img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(68dvh, calc(100dvh - 11rem));
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.image-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #1d4ed8;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.15);
  z-index: 2;
}

.image-lightbox__nav:hover:not(:disabled) {
  background: #eff6ff;
}

.image-lightbox__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.image-lightbox__nav-prev { left: 0.5rem; }
.image-lightbox__nav-next { right: 0.5rem; }

html.image-lightbox-open,
body.image-lightbox-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .image-lightbox {
    padding: max(0.65rem, env(safe-area-inset-top, 0px))
      max(0.65rem, env(safe-area-inset-right, 0px))
      max(0.65rem, env(safe-area-inset-bottom, 0px))
      max(0.65rem, env(safe-area-inset-left, 0px));
    place-items: center;
  }

  .image-lightbox__dialog {
    width: min(100%, 26rem);
    max-height: min(90dvh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 1.25rem));
    border-radius: 16px;
  }

  .image-lightbox__toolbar {
    padding: 0.75rem 0.85rem;
  }

  .image-lightbox__title {
    font-size: 0.9rem;
  }

  .image-lightbox__stage {
    padding: 0.65rem 2.5rem 0.85rem;
  }

  .image-lightbox__img {
    max-height: min(58dvh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 9.5rem));
  }

  .image-lightbox__nav {
    width: 34px;
    height: 34px;
    font-size: 1.35rem;
  }
}
