/* Preserve every photograph's framing, including its embedded watermark. */
#galerie .section-header { margin-bottom: 28px; }
#galerie .gallery-updates { max-width: 70ch; margin-top: 12px; line-height: 1.7; }
#galerie .gallery-rights { color: var(--muted); font-size: 14px; }
#galerie .gallery-public { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 24px; align-items: stretch; }
#galerie .gallery-fig { display: flex; flex-direction: column; min-width: 0; aspect-ratio: auto; background: var(--soft); }
#galerie .gallery-fig > a { display: grid; place-items: center; width: 100%; height: auto; aspect-ratio: 4 / 3; min-height: 44px; background: var(--soft); }
#galerie .gallery-fig img { width: 100%; height: 100%; max-height: 100%; object-fit: contain; transform: none; transition: none; }
#galerie .gallery-fig:hover img { transform: none; }
#galerie .gallery-fig figcaption { position: static; flex: 1; padding: 12px 14px; background: var(--soft); color: var(--ink); font-size: 14px; line-height: 1.5; font-weight: 500; }
#galerie .gallery-fig > a:focus-visible { outline: 3px solid var(--leaf); outline-offset: -4px; }
.gallery-viewer-open { overflow: hidden; }
.gallery-viewer {
  width: min(1200px, calc(100vw - 40px));
  height: min(900px, calc(100vh - 40px));
  height: min(900px, calc(100dvh - 40px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 20px;
  border: 0;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}
.gallery-viewer::backdrop { background: var(--ink); opacity: .88; }
.gallery-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 16px; }
.gallery-viewer-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.gallery-viewer-title { margin: 0; font-family: var(--sans); font-size: 18px; line-height: 1.4; font-weight: 600; }
.gallery-viewer button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: 600 16px/1.4 var(--sans); cursor: pointer; }
.gallery-viewer button:hover { background: var(--soft); }
.gallery-viewer button:disabled { opacity: .45; cursor: default; }
.gallery-viewer button:focus-visible, .gallery-viewer a:focus-visible { outline: 3px solid var(--leaf); outline-offset: 3px; }
.gallery-viewer-stage { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; min-width: 0; min-height: 0; margin: 0; }
.gallery-viewer-image-wrap { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; background: var(--soft); border-radius: 8px; overflow: hidden; }
.gallery-viewer-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.gallery-viewer-image[hidden] { display: none; }
.gallery-viewer-status { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; background: var(--soft); color: var(--ink); }
.gallery-viewer-status:empty { display: none; }
.gallery-viewer-caption { margin: 0; max-height: 6em; overflow-y: auto; font-size: 16px; line-height: 1.5; }
.gallery-viewer-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 20px; }
.gallery-viewer-navigation { display: flex; align-items: center; gap: 8px; }
.gallery-viewer-count { margin: 0 6px; font-size: 14px; font-variant-numeric: tabular-nums; }
.gallery-viewer-original { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-size: 14px; }
@media (max-width: 900px) { #galerie .gallery-public { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) {
  #galerie .gallery-public { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
/* Let a phone photograph set the viewer height instead of filling the screen.
   Short landscape screens share the compact treatment; larger desktops retain
   their existing viewport-filling stage. The dialog scrolls if a long caption
   or a particularly short viewport needs more room. */
@media (max-width: 480px), (max-width: 960px) and (max-height: 480px) and (orientation: landscape) {
  .gallery-viewer {
    width: calc(100vw - 16px);
    height: fit-content;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .gallery-viewer[open] { grid-template-rows: auto auto auto; align-content: start; gap: 12px; }
  .gallery-viewer-title { font-size: 16px; }
  .gallery-viewer button { padding-inline: 10px; }
  .gallery-viewer-stage { grid-template-rows: auto auto; }
  .gallery-viewer-image { height: auto; max-height: max(80px, calc(100vh - 240px)); max-height: max(80px, calc(100dvh - 240px)); }
  /* Hidden photographs must leave enough normal-flow room for loading/errors. */
  .gallery-viewer-status:not(:empty) { position: static; min-height: 120px; padding: 20px; }
  .gallery-viewer-caption { max-height: none; overflow-y: visible; overflow-wrap: anywhere; }
  .gallery-viewer-footer { justify-content: center; gap: 0 12px; }
  .gallery-viewer-navigation { width: 100%; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) { .gallery-viewer, .gallery-viewer * { scroll-behavior: auto; animation: none; transition: none; } }
