/* A pair is a comparison, not a crop or a two-slide carousel. */
.post-gallery { min-width:0; width:100%; }
.gallery-track { min-width:0; display:grid; gap:8px; }
.post-gallery[data-count="2"] .gallery-track { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; }
.post-gallery:not([data-count="1"]) .post-media { width:100%; max-width:none; margin:0; align-content:start; gap:8px; }
.post-gallery:not([data-count="1"]) .media-link { width:100%; height:auto; min-height:0; max-height:none; aspect-ratio:4/5; background:var(--surface); border-radius:12px; }
.post-gallery:not([data-count="1"]) .media-link img { width:100%; height:100%; max-width:100%; max-height:100%; object-fit:contain; }
.post-gallery:not([data-count="1"]):not([data-count="2"]) .gallery-track { display:flex; gap:0; overflow-x:auto; overscroll-behavior-x:contain; scroll-snap-type:x mandatory; scrollbar-width:thin; }
.post-gallery:not([data-count="1"]):not([data-count="2"]) .post-media { flex:0 0 100%; scroll-snap-align:start; scroll-snap-stop:always; }
.post-gallery:not([data-count="1"]):not([data-count="2"]) { max-width:560px; }
.post-gallery .post-media figcaption { font-size:13px; line-height:20px; }
.gallery-navigation { display:flex; justify-content:center; align-items:center; gap:12px; margin-top:8px; }
.gallery-arrow { width:44px; min-width:44px; height:44px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; background:var(--surface); color:var(--ink); touch-action:manipulation; }
.gallery-arrow:disabled { opacity:.3; cursor:default; }
.gallery-arrow:not(:disabled):hover { background:#e8e8e8; }
.gallery-counter { font-size:13px; font-variant-numeric:tabular-nums; min-width:64px; text-align:center; }
.gallery-open { color:var(--muted); margin-top:4px; }
.post-gallery [hidden],.image-viewer [hidden] { display:none!important; }
.post-gallery .image-open-label { max-width:calc(100% - 24px); }
.image-viewer[open] { grid-template-rows:auto minmax(0,1fr) auto auto; gap:12px; padding:max(12px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left)); }
.viewer-controls { gap:8px; }
.viewer-controls [data-viewer-counter] { font-size:14px; font-variant-numeric:tabular-nums; text-align:center; }
.viewer-stage { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; gap:12px; align-items:center; min-height:0; }
.viewer-stage>.gallery-arrow { background:#242424; color:#fff; }
.viewer-stage>.gallery-arrow:hover { background:#3b3b3b; }
.viewer-viewport { height:100%; width:100%; touch-action:pan-x pan-y pinch-zoom; }
.viewer-viewport>img { flex-shrink:0; }
.viewer-caption { text-align:center; overflow-wrap:anywhere; max-height:18vh; overflow-y:auto; }
.viewer-thumbnails { display:flex; gap:8px; overflow-x:auto; padding:4px; min-height:0; justify-self:center; max-width:100%; scrollbar-width:thin; }
.viewer-thumbnails button { flex:0 0 48px; width:48px; height:60px; border:2px solid transparent; border-radius:6px; overflow:hidden; background:#282828; opacity:.55; }
.viewer-thumbnails button[aria-current="true"] { border-color:#fff; opacity:1; }
.viewer-thumbnails img { width:100%; height:100%; object-fit:contain; }
.viewer-error { text-align:center; }
.viewer-error button { min-height:44px; margin:12px; text-decoration:underline; }
.image-viewer.is-zoomed .viewer-viewport>img { width:200%; }
@media(max-width:600px) {
  .viewer-stage { position:relative; display:flex; }
  .viewer-stage>.gallery-arrow { position:absolute; z-index:1; bottom:8px; }
  .viewer-stage>[data-viewer-prev] { left:4px; }
  .viewer-stage>[data-viewer-next] { right:4px; }
  .viewer-thumbnails button { flex-basis:44px; width:44px; height:55px; }
  .post-gallery[data-count="2"] .image-open-label { display:none; }
}
@media(prefers-reduced-motion:reduce) { .gallery-track { scroll-behavior:auto; } }
/* Overlay controls mirror the approved carousel; captions remain below pixels. */
.post-gallery { position:relative; }
.gallery-navigation { position:absolute; top:0; left:0; width:100%; aspect-ratio:4/5; margin:0; padding:0 8px; justify-content:space-between; pointer-events:none; direction:ltr; }
.gallery-navigation .gallery-arrow { pointer-events:auto; background:rgba(255,255,255,.92); }
.gallery-navigation .gallery-counter { position:absolute; top:12px; right:12px; padding:5px 10px; border-radius:20px; color:white; background:rgba(0,0,0,.7); }
.viewer-controls { flex-wrap:wrap; }
.viewer-controls [data-viewer-grid] { width:44px; display:flex; align-items:center; justify-content:center; }
.image-viewer.is-library[open] { grid-template-rows:auto minmax(0,1fr); }
.is-library .viewer-stage,.is-library .viewer-caption { display:none; }
.is-library .viewer-thumbnails { display:grid; grid-template-columns:repeat(auto-fill,minmax(88px,1fr)); gap:12px; width:100%; height:100%; overflow-y:auto; align-content:start; }
.is-library .viewer-thumbnails button { width:100%; height:auto; aspect-ratio:4/5; opacity:1; }
.is-library [data-viewer-zoom] { display:none; }
@media(min-width:900px) {
 .is-library[data-count="2"] .viewer-thumbnails { grid-template-columns:repeat(2,minmax(0,1fr)); align-content:stretch; }
 .is-library[data-count="2"] .viewer-thumbnails button { height:100%; min-height:0; aspect-ratio:auto; }
}
