.encrypted-gallery-page {
  padding-top: 2.6rem;
}

.gallery-shell {
  min-height: 58vh;
}

.gallery-privacy-note {
  width: 100%;
  margin: 0 0 1.4rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(230, 39, 39, 0.32);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.gallery-status,
.gallery-error,
.gallery-count,
.gallery-photo-status {
  color: var(--muted);
}

.gallery-error {
  margin-top: 0.85rem;
  color: #ffb8b8;
}

.gallery-unlock {
  width: min(100%, 34rem);
  margin: 1.4rem auto 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 4, 4, 0.82);
}

.gallery-unlock label {
  display: block;
  margin-bottom: 0.65rem;
  color: var(--white);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gallery-otp {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.gallery-otp input {
  width: 100%;
  min-width: 0;
  height: 3.2rem;
  border: 1px solid rgba(230, 39, 39, 0.5);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.74);
  color: var(--white);
  font: 700 1.25rem/1 "Poppins", sans-serif;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

.gallery-otp input:focus {
  outline: 2px solid rgba(230, 39, 39, 0.62);
  outline-offset: 2px;
}

.gallery-otp span {
  color: var(--red-strong);
  font-weight: 700;
}

.gallery-unlock .btn {
  width: 100%;
  margin-top: 0.9rem;
  cursor: pointer;
}

.gallery-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.gallery-toolbar h1 {
  margin-bottom: 0;
}

.gallery-count {
  margin: 0;
  white-space: nowrap;
}

.secure-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.72rem;
}

.secure-gallery-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(230, 39, 39, 0.32);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(230, 39, 39, 0.12), rgba(0, 0, 0, 0.82));
  color: var(--white);
  cursor: pointer;
}

.secure-gallery-tile:hover,
.secure-gallery-tile:focus-visible {
  border-color: rgba(230, 39, 39, 0.82);
}

.secure-gallery-tile:focus-visible {
  outline: 2px solid rgba(230, 39, 39, 0.75);
  outline-offset: 2px;
}

.secure-gallery-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.secure-gallery-tile.is-loading::before,
.secure-gallery-tile:not(.is-loaded)::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent),
    rgba(255, 255, 255, 0.025);
  animation: galleryPulse 1.2s ease-in-out infinite;
}

.secure-gallery-tile.is-error::before {
  animation: none;
  background: rgba(80, 0, 0, 0.36);
}

.gallery-photo-status {
  position: absolute;
  inset: auto 0.45rem 0.45rem;
  z-index: 1;
  font-size: 0.78rem;
  text-align: left;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  height: 100dvh;
  padding: clamp(0.7rem, 2vw, 1.2rem);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.94);
}

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

.gallery-lightbox-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.gallery-lightbox-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: visible;
}

.gallery-lightbox-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.gallery-icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.65rem;
  height: 2.65rem;
  border: 1px solid rgba(230, 39, 39, 0.48);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
  color: var(--white);
  font: inherit;
  cursor: pointer;
}

.gallery-icon-button:hover,
.gallery-icon-button:focus-visible {
  border-color: var(--red-strong);
}

.gallery-lightbox-stage {
  position: relative;
  min-height: 0;
  max-height: calc(100dvh - 12rem);
  overflow: hidden;
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 3rem;
  align-items: center;
  gap: 0.7rem;
}

.gallery-lightbox-stage > .gallery-icon-button {
  position: relative;
  z-index: 2;
  justify-self: center;
}

.gallery-lightbox-image-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: calc(100dvh - 12rem);
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

.gallery-lightbox-image-slide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  will-change: transform;
}

.gallery-lightbox-stage.is-dragging .gallery-lightbox-image-wrap {
  cursor: grabbing;
}

.gallery-lightbox-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 12rem);
  object-fit: contain;
  border-radius: 8px;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.gallery-lightbox-nav {
  --gallery-thumb-size: clamp(3rem, 7vw, 4.6rem);
  display: flex;
  justify-content: flex-start;
  gap: 0.38rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-padding-inline: calc(50% - (var(--gallery-thumb-size) / 2));
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 0.38rem calc(50% - (var(--gallery-thumb-size) / 2)) 0.48rem;
  cursor: grab;
  user-select: none;
}

.gallery-lightbox-nav::-webkit-scrollbar {
  display: none;
}

.gallery-lightbox-thumb {
  flex: 0 0 auto;
  width: var(--gallery-thumb-size);
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(230, 39, 39, 0.35);
  border-radius: 8px;
  background: #050505;
  cursor: pointer;
  opacity: 0.58;
  scroll-snap-align: center;
  transform-origin: center;
  user-select: none;
  transition: border-color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.gallery-lightbox-thumb[aria-current="true"] {
  border-color: var(--red-strong);
  opacity: 1;
  transform: scale(1.08);
}

.gallery-lightbox-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

@keyframes galleryPulse {
  0% {
    opacity: 0.45;
    transform: translateX(-18%);
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.45;
    transform: translateX(18%);
  }
}

@media (max-width: 760px) {
  .gallery-toolbar {
    display: block;
  }

  .gallery-count {
    margin-top: 0.25rem;
  }

  .secure-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .gallery-otp {
    gap: 0.35rem;
  }

  .gallery-otp input {
    height: 3rem;
    font-size: 1.05rem;
    letter-spacing: 0.12em;
  }

  .gallery-lightbox {
    gap: 0.28rem;
  }

  .gallery-lightbox-stage {
    grid-template-columns: 1fr;
    max-height: calc(100dvh - 8.8rem);
  }

  .gallery-lightbox-stage > .gallery-icon-button {
    display: none;
  }

  .gallery-lightbox-image-wrap,
  .gallery-lightbox-image {
    max-height: calc(100dvh - 8.8rem);
  }

  .gallery-lightbox-nav {
    padding-top: 0.34rem;
    padding-bottom: 0.42rem;
  }
}
