#gallery {
  --gallery-gap: 24px;
  scroll-margin-top: 105px;
  padding-top: 88px;
  padding-bottom: 88px;
}

#gallery .gallery-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin: 30px 0 28px;
}

#gallery .gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#gallery .gallery-filters button {
  border: 1px solid var(--line, #dedfd4);
  border-radius: 999px;
  background: transparent;
  color: var(--ink, #273b32);
  cursor: pointer;
  font-size: 11px;
  line-height: 1.2;
  padding: 9px 16px;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

#gallery .gallery-filters button:hover {
  border-color: var(--ink, #273b32);
  transform: translateY(-1px);
}

#gallery .gallery-filters button[aria-pressed="true"],
#gallery .gallery-filters button.active {
  border-color: var(--ink, #273b32);
  background: var(--ink, #273b32);
  color: #fff;
}

#photo-gallery-status {
  flex: 0 0 auto;
  color: var(--muted, #6d736b);
  font-size: 11px;
  margin: 0;
  text-align: right;
}

.photo-gallery-grid {
  column-count: 3;
  column-gap: var(--gallery-gap);
  column-fill: balance;
}

.gallery-card {
  width: 100%;
  display: block;
  position: relative;
  break-inside: avoid;
  border: 0;
  border-radius: 10px;
  background: var(--paper, #fffdf8);
  box-shadow: 0 7px 19px rgba(39, 59, 50, .09);
  color: var(--ink, #273b32);
  cursor: pointer;
  margin: 0 0 var(--gallery-gap);
  overflow: hidden;
  padding: 0;
  text-align: left;
  transform: translateZ(0);
  transition: box-shadow .25s ease, transform .25s ease;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  box-shadow: 0 12px 27px rgba(39, 59, 50, .17);
  transform: translateY(-3px);
}

.gallery-card:focus-visible {
  outline: 3px solid var(--orange, #b65d3f);
  outline-offset: 5px;
}

.gallery-card-visual {
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--green, #e7ebdf);
  isolation: isolate;
  line-height: 0;
}

.gallery-card-visual::before {
  content: '';
  position: absolute;
  z-index: 2;
  inset: 10px;
  border: 1px solid rgba(255, 253, 248, .84);
  opacity: .16;
  pointer-events: none;
  transition: inset .25s ease, opacity .25s ease;
}

.gallery-card-visual::after {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 28% 0 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(17, 38, 29, .12) 22%, rgba(17, 38, 29, .84) 100%);
  pointer-events: none;
}

.gallery-card-image {
  width: 100%;
  height: auto;
  display: block;
  background: var(--green, #e7ebdf);
  transform: scale(1);
  transition: transform .45s cubic-bezier(.2, .7, .25, 1);
}

.gallery-card:hover .gallery-card-image,
.gallery-card:focus-visible .gallery-card-image {
  transform: scale(1.035);
}

.gallery-card:hover .gallery-card-visual::before,
.gallery-card:focus-visible .gallery-card-visual::before {
  inset: 8px;
  opacity: .72;
}

.gallery-card-overlay {
  position: absolute;
  z-index: 3;
  right: 52px;
  bottom: 17px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #fff;
  line-height: 1.25;
  pointer-events: none;
}

.gallery-card-category {
  color: rgba(255, 253, 248, .83);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.15px;
  line-height: 1.3;
  text-transform: uppercase;
}

.gallery-card-title {
  font-family: var(--serif, 'DM Serif Display', Georgia, serif);
  font-size: clamp(18px, 2.2vw, 27px);
  line-height: 1.08;
  text-wrap: balance;
}

.gallery-card-expand {
  position: absolute;
  z-index: 4;
  right: 15px;
  bottom: 14px;
  display: grid;
  width: 33px;
  height: 33px;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, .7);
  border-radius: 50%;
  background: var(--orange, #b65d3f);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  opacity: .92;
  pointer-events: none;
  transition: background-color .2s ease, transform .2s ease;
}

.gallery-card:hover .gallery-card-expand,
.gallery-card:focus-visible .gallery-card-expand {
  background: #fff;
  color: var(--orange, #b65d3f);
  transform: rotate(4deg) scale(1.06);
}

#gallery-load-more {
  display: flex;
  min-width: 160px;
  margin: 26px auto 0;
  border: 1px solid var(--orange, #b65d3f);
  border-radius: 6px;
  background: transparent;
  color: var(--orange, #b65d3f);
  cursor: pointer;
  font-size: 12px;
  justify-content: center;
  padding: 12px 19px;
  transition: background-color .2s ease, color .2s ease, transform .2s ease;
}

#gallery-load-more:hover {
  background: var(--orange, #b65d3f);
  color: #fff;
  transform: translateY(-2px);
}

#gallery-load-more:disabled {
  cursor: default;
  opacity: .55;
  transform: none;
}

#gallery-help {
  max-width: 560px;
  margin: 20px auto 0;
  color: var(--muted, #6d736b);
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

/* The viewer is intentionally scoped so the site's booking and legacy dialogs remain unchanged. */
dialog.photo-viewer {
  width: min(1200px, calc(100% - 36px));
  max-width: 1200px;
  height: min(900px, calc(100dvh - 36px));
  max-height: calc(100dvh - 36px);
  overflow: hidden;
  padding: clamp(18px, 3vw, 34px);
  border: 1px solid rgba(222, 223, 212, .9);
  border-radius: 16px;
  background: var(--paper, #fffdf8);
}

dialog.photo-viewer::backdrop {
  background: rgba(24, 43, 34, .82);
  backdrop-filter: blur(5px);
}

dialog.photo-viewer[open] {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.photo-viewer-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 29px;
  padding-right: 45px;
}

.photo-viewer-topline p {
  margin: 0;
}

#photo-viewer-category {
  color: var(--orange, #b65d3f);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

#photo-viewer-count {
  color: var(--muted, #6d736b);
  font-size: 11px;
  text-align: right;
}

.photo-viewer-close {
  position: absolute;
  top: 14px;
  right: 17px;
  z-index: 5;
  width: 35px;
  height: 35px;
  border: 1px solid var(--line, #dedfd4);
  border-radius: 50%;
  background: transparent;
  color: var(--muted, #6d736b);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
  padding: 0 0 3px;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

.photo-viewer-close:hover {
  border-color: var(--orange, #b65d3f);
  background: var(--orange, #b65d3f);
  color: #fff;
  transform: rotate(5deg);
}

.photo-viewer-stage {
  position: relative;
  display: grid;
  min-height: 0;
  height: min(70vh, 700px);
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin: 17px 0 18px;
  padding: 12px;
  border: 1px solid rgba(222, 223, 212, .72);
  border-radius: 11px;
  background: #eef1e9;
  overflow: hidden;
}

.photo-viewer-pan {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--orange, #b65d3f) transparent;
  scrollbar-width: thin;
  touch-action: pan-x pan-y pinch-zoom;
}

.photo-viewer-pan.is-zoomed {
  align-items: flex-start;
  justify-content: flex-start;
}

#photo-viewer-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  flex: 0 0 auto;
  object-fit: contain;
  opacity: 1;
  transform: scale(1);
  transform-origin: center center;
  transition: opacity .2s ease, transform .28s ease;
}

#photo-viewer-image.is-loading {
  opacity: .3;
}

#photo-viewer-image.is-error {
  opacity: 0;
}

.photo-viewer-pan.is-zoomed #photo-viewer-image {
  max-width: none;
  max-height: none;
  transform-origin: top left;
  transform: scale(2);
}

.photo-viewer-arrow {
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line, #dedfd4);
  border-radius: 50%;
  background: rgba(255, 253, 248, .94);
  color: var(--ink, #273b32);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
  padding: 0 0 3px;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

#photo-prev {
  grid-column: 1;
  grid-row: 1;
}

#photo-next {
  grid-column: 3;
  grid-row: 1;
}

.photo-viewer-arrow:hover:not(:disabled),
.photo-viewer-arrow:focus-visible:not(:disabled) {
  border-color: var(--orange, #b65d3f);
  background: var(--orange, #b65d3f);
  color: #fff;
  transform: scale(1.05);
}

.photo-viewer-arrow:disabled {
  cursor: default;
  opacity: .32;
}

#photo-viewer-loading {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 20px;
  margin: 0;
  color: var(--muted, #6d736b);
  font-size: 11px;
  text-align: center;
}

.photo-viewer-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px 25px;
}

#photo-viewer-title {
  min-width: 0;
  margin: 0;
  color: var(--ink, #273b32);
  font-family: var(--serif, 'DM Serif Display', Georgia, serif);
  font-size: clamp(25px, 3vw, 39px);
  font-weight: 400;
  line-height: 1.08;
  text-wrap: balance;
}

#photo-viewer-source,
#photo-viewer-help {
  color: var(--muted, #6d736b);
  font-size: 10px;
  line-height: 1.6;
}

#photo-viewer-source {
  grid-column: 1;
  margin: 7px 0 0;
}

#photo-viewer-help {
  grid-column: 1 / -1;
  margin: 1px 0 0;
}

#photo-zoom {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  border: 1px solid var(--line, #dedfd4);
  border-radius: 999px;
  background: transparent;
  color: var(--ink, #273b32);
  cursor: pointer;
  font-size: 10px;
  padding: 9px 14px;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

#photo-zoom:hover,
#photo-zoom[aria-pressed="true"] {
  border-color: var(--ink, #273b32);
  background: var(--ink, #273b32);
  color: #fff;
}

@media (max-width: 1000px) {
  #gallery {
    padding-top: 70px;
    padding-bottom: 70px;
  }

  .photo-gallery-grid {
    column-count: 2;
  }
}

@media (max-width: 700px) {
  #gallery .gallery-toolbar {
    align-items: start;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
  }

  #photo-gallery-status {
    text-align: left;
  }

  .gallery-card-title {
    font-size: 22px;
  }

  dialog.photo-viewer {
    width: calc(100% - 20px);
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 16px;
  }

  .photo-viewer-topline {
    padding-right: 40px;
  }

  .photo-viewer-stage {
    height: min(66dvh, 600px);
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 6px;
    margin: 12px 0 14px;
    padding: 8px;
  }

  .photo-viewer-arrow {
    width: 37px;
    height: 37px;
  }

  .photo-viewer-footer {
    gap: 10px 15px;
  }
}

@media (max-width: 520px) {
  .photo-gallery-grid {
    column-count: 1;
  }

  #gallery .gallery-filters button {
    font-size: 10px;
    padding: 8px 12px;
  }

  .gallery-card {
    margin-bottom: 18px;
  }

  .gallery-card-overlay {
    right: 48px;
    bottom: 14px;
    left: 15px;
  }

  .gallery-card-category {
    font-size: 8px;
  }

  .gallery-card-title {
    font-size: 24px;
  }

  .gallery-card-expand {
    right: 12px;
    bottom: 11px;
    width: 31px;
    height: 31px;
  }

  .photo-viewer-topline {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }

  #photo-viewer-count {
    text-align: left;
  }

  .photo-viewer-close {
    top: 10px;
    right: 11px;
  }

  .photo-viewer-stage {
    height: min(63dvh, 510px);
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .photo-viewer-arrow {
    width: 33px;
    height: 33px;
    font-size: 21px;
  }

  #photo-viewer-title {
    font-size: 28px;
  }

  #photo-zoom {
    padding: 8px 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .gallery-card-image,
  .gallery-card-visual::before,
  .gallery-card-expand,
  #gallery .gallery-filters button,
  #gallery-load-more,
  .photo-viewer-close,
  .photo-viewer-arrow,
  #photo-viewer-image,
  #photo-zoom {
    transition: none;
  }
}
