.ornament-gallery {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}
.ornament-wide {
  grid-column: 1 / -1;
}
.ornament-gallery figure img {
  display: block;
  width: 100%;
  height: auto;
  filter: none;
  transition: transform 0.24s ease;
}
.gallery-trigger {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid #d2c6af;
  background: #1a1714;
}
.gallery-trigger:hover img,
.gallery-trigger:focus-visible img {
  transform: scale(1.015);
}
.gallery-trigger:focus-visible {
  outline: 3px solid #933e40;
  outline-offset: 3px;
}
.gallery-zoom-badge {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  background: rgba(20, 17, 15, 0.86);
  color: #f8f2e7;
  border: 1px solid rgba(210, 198, 175, 0.65);
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  pointer-events: none;
}
body.has-open-gallery {
  overflow: hidden;
}
.gallery-modal[hidden] {
  display: none !important;
}
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 2.5vw, 2rem);
}
.gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 12, 10, 0.92);
  backdrop-filter: blur(4px);
}
.gallery-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 74rem);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: #181512;
  color: #f6efe2;
  border: 1px solid #6e5a44;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  padding: clamp(0.85rem, 2vw, 1.5rem);
}
.gallery-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(210, 198, 175, 0.24);
  padding-bottom: 0.65rem;
}
.gallery-counter {
  margin: 0;
  font: 600 0.9rem/1.3 Georgia, serif;
  color: #dfd3be;
}
.gallery-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.gallery-direct-link {
  color: #e6d7be;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.gallery-close,
.gallery-nav {
  appearance: none;
  background: #2a241e;
  color: #f9f3e8;
  border: 1px solid #9b8467;
  padding: 0.5rem 0.9rem;
  font: 600 0.9rem/1.2 inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
}
.gallery-close:hover,
.gallery-nav:hover {
  background: #8f393b;
  border-color: #d6b68a;
}
.gallery-close:focus-visible,
.gallery-nav:focus-visible,
.gallery-direct-link:focus-visible {
  outline: 2px solid #f0c987;
  outline-offset: 2px;
}
.gallery-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1.25rem);
  min-height: 0;
}
.gallery-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.gallery-image-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f0d0b;
  border: 1px solid rgba(210, 198, 175, 0.22);
  padding: 0.5rem;
  max-height: 68vh;
  overflow: hidden;
}
.gallery-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 64vh;
  width: auto;
  height: auto;
  object-fit: contain;
}
.gallery-caption {
  width: 100%;
  text-align: center;
  color: #efe6d5;
  display: grid;
  gap: 0.25rem;
}
.gallery-caption-main {
  font: 400 1.15rem/1.35 Georgia, serif;
}
.gallery-caption-alt,
.gallery-caption-origin {
  margin: 0;
  font-size: 0.88rem;
  color: #cabda7;
}
@media (max-width: 680px) {
  .gallery-modal {
    padding: 0.45rem;
  }
  .gallery-dialog {
    padding: 0.75rem;
    max-height: 96vh;
  }
  .gallery-stage {
    grid-template-columns: 1fr 1fr;
  }
  .gallery-figure {
    grid-column: 1 / -1;
    order: -1;
  }
  .gallery-image-wrap {
    max-height: 56vh;
  }
  .gallery-image-wrap img {
    max-height: 52vh;
  }
  .gallery-nav {
    width: 100%;
  }
}
