.wp-site-blocks .reader .prose > :is(.wp-block-gallery,.gallery) {
  width:100%;
  max-width:var(--media-width,960px);
  margin-block:28px;
}

.prose .gallery {
  --gallery-columns:3;
  display:grid;
  grid-template-columns:repeat(var(--gallery-columns),minmax(0,1fr));
  gap:12px;
}
.prose .gallery-columns-1 {--gallery-columns:1}
.prose .gallery-columns-2 {--gallery-columns:2}
.prose :is(.gallery-columns-4,.gallery-columns-5,.gallery-columns-6,.gallery-columns-7,.gallery-columns-8,.gallery-columns-9) {--gallery-columns:4}
.prose .gallery .gallery-item {width:auto;max-width:none;margin:0;float:none;min-width:0}
.prose .gallery .gallery-icon {padding:0}
.prose .gallery .gallery-caption {margin:7px 0 0;color:var(--muted);font-size:.8rem}
.prose .gallery .gallery-icon img,
.prose .wp-block-gallery.has-nested-images:not(.is-cropped) figure.wp-block-image img {
  width:100%;
  aspect-ratio:4/3;
  object-fit:contain;
  height:auto;
  border:1px solid var(--line);
  border-radius:5px;
  background:var(--tint);
}
.prose .wp-block-gallery.has-nested-images:not(.is-cropped) figure.wp-block-image {
  justify-content:flex-start;
}
.prose .wp-block-gallery.has-nested-images:not(.is-cropped) figure.wp-block-image figcaption {
  position:static;
  margin:7px 0 0;
  padding:0;
  color:var(--muted);
  background:none;
  text-align:left;
}
.wojp-image-trigger {cursor:zoom-in}
button.wojp-image-trigger {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  max-width:100%;
  padding:0;
  border:0;
  background:none;
  vertical-align:top;
}
.prose .gallery-icon .wojp-image-trigger,
.prose .wp-block-gallery .wojp-image-trigger {display:block;width:100%}
.reader-opening .feature-image > .wojp-image-trigger {display:block;width:100%}
button.wojp-image-trigger:focus-visible,
a.wojp-image-trigger:focus-visible {outline:2px solid var(--focus);outline-offset:3px}

:root:has(.wojp-gallery-dialog[open]) {overflow:hidden}
.wojp-gallery-dialog {
  box-sizing:border-box;
  width:min(1100px,calc(100% - 24px));
  max-width:none;
  max-height:calc(100dvh - 24px);
  padding:0;
  margin:auto;
  overflow:auto;
  color:var(--ink);
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:9px;
}
.wojp-gallery-dialog::backdrop {background:rgba(13,14,15,.86)}
.wojp-gallery-panel {min-width:0;padding:12px}
.wojp-gallery-toolbar {
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 0 8px;
  color:var(--muted);
  font-size:.875rem;
}
.wojp-gallery-toolbar > span {margin-right:auto;font-variant-numeric:tabular-nums}
.wojp-gallery-toolbar a {padding:10px 4px;text-decoration:underline;text-underline-offset:3px}
.wojp-gallery-dialog button {
  display:grid;
  place-items:center;
  min-width:44px;
  min-height:44px;
  padding:0;
  border:1px solid var(--line);
  border-radius:5px;
  color:var(--ink);
  background:var(--tint);
  font-size:1.75rem;
  line-height:1;
}
.wojp-gallery-dialog [hidden] {display:none}
.wojp-gallery-stage {
  display:grid;
  grid-template-columns:44px minmax(0,1fr) 44px;
  align-items:center;
  gap:10px;
}
.wojp-gallery-stage figure {grid-column:2;grid-row:1;min-width:0;margin:0;text-align:center}
.wojp-gallery-stage button:first-child {grid-column:1;grid-row:1}
.wojp-gallery-stage button:last-child {grid-column:3;grid-row:1}
.wojp-gallery-stage img {width:auto;max-width:100%;height:auto;max-height:calc(100dvh - 172px);margin-inline:auto;object-fit:contain}
.wojp-gallery-stage figcaption {margin:12px auto 0;max-width:64ch;color:var(--muted);font-size:.875rem}
.wojp-gallery-stage [data-error] {padding:20px}
.wojp-gallery-stage:not(:has(button:not([hidden]))) {display:block}
@media(max-width:640px) {
  .prose .gallery:not(.gallery-columns-1) {--gallery-columns:2;gap:8px}
  .prose .wp-block-gallery.has-nested-images {--wp--style--unstable-gallery-gap:8px}
  .prose .wp-block-gallery.has-nested-images:not(.columns-1) figure.wp-block-image:not(#individual-image) {
    width:calc(50% - 4px);
    flex-grow:0;
  }
  .wojp-gallery-stage {grid-template-columns:44px minmax(0,1fr) 44px}
  .wojp-gallery-stage figure {grid-column:1/-1;grid-row:1}
  .wojp-gallery-stage button:first-child,
  .wojp-gallery-stage button:last-child {grid-row:2}
  .wojp-gallery-panel {padding:8px}
}


/* Thumbnails stay evenly spaced and keep screenshot details visible. */
.prose .wp-block-gallery.has-nested-images {align-items:start;--wp--style--unstable-gallery-gap:12px}
.prose .wp-block-gallery.has-nested-images:not(.is-cropped) figure.wp-block-image .wojp-image-trigger {background:var(--tint);border-radius:5px}
.prose .wp-block-gallery.has-nested-images:not(.is-cropped) figure.wp-block-image img {aspect-ratio:16 / 10}
.prose .wp-block-gallery.has-nested-images:not(.is-cropped) figure.wp-block-image figcaption {font-size:.8rem;line-height:1.45}
@media(hover:hover) {
  .prose .wp-block-gallery .wojp-image-trigger:hover img,
  .prose .gallery .wojp-image-trigger:hover img {box-shadow:0 0 0 2px var(--rule)}
}
@media(max-width:640px) {
  .prose .wp-block-gallery.has-nested-images {--wp--style--unstable-gallery-gap:8px}
}

