.photo-gallery { min-width: 0; max-width: 100%; }
.photo-gallery [hidden] { display: none !important; }
.photo-gallery .gallery-slide { margin: 0 0 16px; scroll-margin-top: 24px; }
.gallery-image-link { display: block; border-radius: 12px; }
.photo-gallery .gallery-slide img { display: block; width: 100%; height: auto; aspect-ratio: 1.5; object-fit: contain; background: var(--panel); }
.photo-gallery figcaption { overflow-wrap: anywhere; }
.photo-gallery figcaption a { text-decoration: underline; }
.gallery-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin: 12px 0; }
.gallery-controls span { font-size: 13px; color: var(--muted); }
.gallery-thumbnails { display: flex; gap: 10px; overflow-x: auto; padding: 8px; max-width: 100%; }
.gallery-thumbnails a { flex: 0 0 88px; border: 2px solid transparent; border-radius: 8px; padding: 2px; }
.gallery-thumbnails a[aria-current] { border-color: var(--accent); }
.photo-gallery .gallery-thumbnails img { display: block; width: 100%; height: 59px; object-fit: cover; border-radius: 4px; }
.gallery-dialog { width: min(1100px, calc(100% - 24px)); max-width: calc(100% - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); padding: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.gallery-dialog:not([open]) { display: none; }
.gallery-dialog::backdrop { background: #000c; }
.gallery-dialog-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.photo-gallery .gallery-dialog img { display: block; width: 100%; height: auto; max-height: 65vh; max-height: 65dvh; object-fit: contain; }
.photo-gallery :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (max-width: 760px) {
  .gallery-controls button { padding: 10px 12px; min-height: 44px; }
  .gallery-dialog { padding: 12px; }
  .photo-gallery .gallery-dialog img { max-height: 55vh; max-height: 55dvh; }
}
@media (prefers-reduced-motion: reduce) {
  .photo-gallery, .photo-gallery * { scroll-behavior: auto; animation: none; transition: none; }
}
