#gallery { scroll-margin-block-start: 84px; }
.gallery-page {
  padding: clamp(32px, 6vw, 88px) max(3.6vw, 16px) clamp(50px, 8vw, 110px);
  color: var(--ink);
  background: var(--paper);
}
.gallery-wrap { max-width: 1280px; margin-inline: auto; }
.gallery-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: 20px;
  padding-block-end: clamp(28px, 4vw, 55px);
}
.gallery-heading p { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.gallery-heading h1 { margin: 0; font-size: clamp(2.6rem, 6.6vw, 6rem); font-weight: 550; line-height: 1.4; letter-spacing: -.04em; }
.gallery-heading .gallery-credit { font-size: .85rem; }
.gallery-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-block: 1px solid var(--line);
  padding-block: 12px;
  margin-block-end: 0;
  flex-wrap: wrap;
}
.gallery-filters { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.gallery-filters button {
  position: relative;
  min-height: 44px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
}
.gallery-filters button[aria-pressed="true"] { color: var(--ink); }
.gallery-filters button[aria-pressed="true"]::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: currentColor; }
#galleryCount { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.gallery-exhibition { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(30px, 6vw, 80px) clamp(20px, 6vw, 90px); list-style: none; padding: 0; margin: 0; align-items: start; }
.gallery-exhibition li { grid-column: span 5; min-width: 0; }
.gallery-exhibition li:nth-child(4n+1), .gallery-exhibition li:nth-child(4n+4) { grid-column: span 7; }
.gallery-exhibition li:nth-child(even) { margin-block-start: clamp(25px, 6vw, 80px); }
.gallery-exhibition li[hidden] { display: none; }
.gallery-exhibition a { display: block; color: inherit; text-decoration: none; }
.gallery-exhibition img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  border-radius: 3px;
  background: var(--theme-surface, #e8e1db);
}
.gallery-exhibition a > span { display: block; margin-block-start: 16px; font-size: 1rem; }
.gallery-exhibition a:hover > span { text-decoration: underline; text-underline-offset: 6px; }
.gallery-exhibition.is-filtered li { grid-column: span 6; margin-block-start: 0; }
.gallery-end { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-block-start: clamp(50px, 8vw, 110px); padding-block-start: 25px; border-top: 1px solid var(--line); }
.gallery-end p { color: var(--muted); margin: 0; }
.gallery-end a, .work-gallery header > a { color: inherit; text-underline-offset: 6px; min-height: 44px; display: inline-flex; align-items: center; }
.gallery-page :is(a, button):focus-visible { outline: 2px solid currentColor; outline-offset: 6px; }
@media (max-width: 700px) {
  .gallery-exhibition { gap: 32px 16px; }
  .gallery-exhibition li, .gallery-exhibition li:nth-child(4n+1), .gallery-exhibition li:nth-child(4n+4) { grid-column: span 6; }
  .gallery-exhibition li:nth-child(even) { margin-block-start: 32px; }
  .gallery-exhibition.is-filtered li { margin-block-start: 0; }
  .gallery-exhibition a > span { font-size: .875rem; margin-block-start: 10px; }
  .gallery-filters { gap: 4px 16px; }
  .gallery-filters button { font-size: .875rem; }
}

.gallery-layouts { display: flex; padding: 4px; gap: 3px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--ink) 3%, transparent); }
.gallery-layouts button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: .875rem; cursor: pointer; }
.gallery-layouts button[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--line); box-shadow: 0 2px 6px #0000000a; }
.gallery-layouts svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.gallery-view-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 75px; padding-block: 14px; }
.gallery-view-meta p { margin: 0; margin-inline-start: auto; font-size: .875rem; color: var(--muted); }
#galleryFilmControls:not([hidden]) { display: flex; direction: ltr; gap: 6px; }
#galleryFilmControls button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: transparent; font-size: 1.5rem; cursor: pointer; }
#galleryFilmControls button:disabled { opacity: .3; cursor: default; }
.gallery-exhibition a { overflow: hidden; }
.gallery-exhibition img { transition: filter .3s ease; }
.gallery-exhibition a:hover img { filter: brightness(1.06); }
.gallery-exhibition[data-layout="grid"] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px 24px; }
.gallery-exhibition[data-layout="grid"] li { grid-column: auto; margin-block-start: 0; }
.gallery-exhibition[data-layout="grid"] img { aspect-ratio: 4 / 5; }
.gallery-exhibition[data-layout="film"] {
  display: flex;
  direction: ltr;
  gap: clamp(18px, 3vw, 40px);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
  padding: 8px 0 24px;
}
.gallery-exhibition[data-layout="film"] li { flex: 0 0 min(68%, 520px); margin-block-start: 0; scroll-snap-align: center; direction: rtl; }
.gallery-exhibition[data-layout="film"] img { height: min(60dvh, 590px); aspect-ratio: auto; object-fit: contain; }
.gallery-exhibition[data-layout="film"] a > span { text-align: center; }
.gallery-photo-viewport { width: 100%; max-height: 72dvh; overflow: auto; border-radius: 8px; direction: ltr; scrollbar-width: thin; }
.gallery-photo-viewport img { margin-inline: auto; }
.gallery-photo-viewport.is-zoomed { cursor: zoom-out; }
.gallery-photo-viewport.is-zoomed img { width: 160%; max-width: none; max-height: none; }
.gallery-photo-viewport:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.work-gallery-controls { flex-wrap: wrap; }
.work-gallery-dialog { padding-block-start: 50px; }
.work-gallery-dialog .work-gallery-close { min-width: 36px; }
@media (max-width: 700px) {
  .gallery-layouts { width: 100%; }
  .gallery-layouts button { flex: 1; padding-inline: 8px; }
  .gallery-exhibition[data-layout="grid"] { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 25px 14px; }
  .gallery-exhibition[data-layout="film"] li { flex-basis: 86%; }
  .gallery-exhibition[data-layout="film"] img { height: min(55dvh, 500px); }
  .gallery-view-meta p { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) { .gallery-exhibition img { transition: none; } }
