body.gallery-viewer-open { overflow: hidden; }

.gallery-viewer[hidden] { display: none; }

.gallery-viewer {
  inset: 0;
  position: fixed;
  z-index: 1000;
}

.gallery-viewer__backdrop {
  background: rgba(0, 0, 0, .74);
  inset: 0;
  position: absolute;
}

.gallery-viewer__panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
  display: grid;
  gap: var(--space-md);
  inset: clamp(.75rem, 3vw, 2rem);
  max-height: calc(100vh - clamp(1.5rem, 6vw, 4rem));
  overflow: auto;
  padding: clamp(1rem, 3vw, 1.5rem);
  position: absolute;
}

.gallery-viewer__header {
  align-items: flex-start;
  display: flex;
  gap: var(--space-md);
  justify-content: space-between;
}

.gallery-viewer__header h2 {
  margin-bottom: 0;
}

.gallery-viewer__close {
  border: 1px solid var(--line);
  min-height: 44px;
  min-width: 44px;
  padding: 0;
}

.gallery-viewer__stage {
  align-items: center;
  background: color-mix(in srgb, var(--bg), black 8%);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: min(58vh, 680px);
  overflow: hidden;
}

.gallery-viewer__image {
  display: block;
  height: auto;
  justify-self: center;
  max-height: 70vh;
  max-width: 100%;
  object-fit: contain;
}

.gallery-viewer__nav {
  align-self: stretch;
  background: transparent;
  border-radius: 0;
  color: var(--text);
  font-size: clamp(2rem, 8vw, 4rem);
  min-width: 3.25rem;
  padding: 0 .6rem;
}

.gallery-viewer__nav:hover {
  background: color-mix(in srgb, var(--accent), transparent 84%);
}

.gallery-viewer__caption {
  margin: 0;
}

.gallery-viewer__actions {
  border-top: 1px solid var(--line);
  padding-top: var(--space-md);
}

@media (max-width: 700px) {
  .gallery-viewer__panel {
    border-radius: var(--radius-md);
    inset: .5rem;
    max-height: calc(100vh - 1rem);
  }

  .gallery-viewer__stage {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .gallery-viewer__nav {
    display: none;
  }

  .gallery-viewer__image {
    max-height: 58vh;
  }
}
