/* Render gallery: image-led grid, scrolling style and place chips, full-screen native-dialog lightbox.
   Mobile first (one column, 44 px targets); page theme tokens from layout.css keep dark mode. */
.gallery { display: grid; gap: 16px; min-width: 0; max-width: 100%; }
.gallery-chips { display: flex; gap: 8px; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; padding: 2px; }
.gallery-chips::-webkit-scrollbar { display: none; }
.gallery-chips:empty { display: none; }
.gallery-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 0 16px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel);
  color: var(--ink); font: 600 14px var(--f-body); white-space: nowrap; cursor: pointer; }
.gallery-chip[aria-pressed="true"] { border-color: var(--forest); background: var(--forest); color: var(--panel); }
.gallery-chip:focus-visible, .gallery-tile button:focus-visible, .gallery-lightbox button:focus-visible {
  outline: 3px solid var(--sun); outline-offset: 2px; }
.gallery-swatches { display: inline-flex; }
.gallery-swatches i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid #0003; margin-left: -4px; }
.gallery-swatches i:first-child { margin-left: 0; }
.gallery-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.gallery-tile { margin: 0; min-width: 0; }
.gallery-tile button { display: block; width: 100%; padding: 0; border: 0; border-radius: 6px;
  overflow: hidden; background: var(--panel); cursor: zoom-in; }
.gallery-tile img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: contain; }
.gallery-tile figcaption { display: grid; gap: 2px; padding-top: 8px; font-size: 14px; }
.gallery-tile figcaption span { color: var(--muted); font-size: 12px; }
.gallery-stale { justify-self: start; margin-top: 4px; padding: 2px 8px; border-radius: 10px;
  background: color-mix(in srgb, var(--sun) 18%, transparent); color: var(--ink); font: normal 12px var(--f-body); }
.gallery-note, .gallery-empty { margin: 0; color: var(--muted); font-size: 13px; }
.gallery-contents { border-top: 1px solid var(--line); padding-top: 4px; }
.gallery-contents summary { padding: 12px 0; cursor: pointer; font: 600 16px var(--f-display); }
.gallery-palette { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; margin: 0 0 12px; padding: 0; }
.gallery-palette li { display: grid; gap: 4px; font: 10px var(--f-data); color: var(--muted); }
.gallery-palette i { display: block; width: 54px; height: 34px; border: 1px solid var(--line); }
.gallery-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px 28px;
  list-style: none; margin: 0; padding: 0; }
.gallery-items li { display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px;
  overflow-wrap: anywhere; font-size: 14px; }
.gallery-items a { color: var(--forest); font-weight: 600; }
.gallery-more { justify-self: start; min-height: 44px; padding: 0 16px; border: 1px solid var(--line);
  border-radius: 22px; background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; }
.gallery-lightbox { box-sizing: border-box; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
  margin: 0; padding: 0; border: 0; background: #0b0f10; color: #e4ebe8; overflow-y: auto; }
.gallery-lightbox[open] { display: flex; flex-direction: column; }
.gallery-lightbox::backdrop { background: #000d; }
.gallery-lightbox-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 8px 8px; background: #0b0f10e6; }
.gallery-lightbox-bar [data-counter] { flex: 1; text-align: center; font: 13px var(--f-data); }
.gallery-lightbox button { min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid #ffffff40;
  border-radius: 22px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.gallery-lightbox figure { flex: 1; display: flex; flex-direction: column; justify-content: center;
  margin: 0; min-height: 0; }
.gallery-lightbox img { display: block; width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; }
.gallery-lightbox figcaption { padding: 10px 16px; text-align: center; font-size: 14px; }
.gallery-lightbox [data-package] { max-width: 900px; margin: 0 auto; padding: 0 16px 16px; }
.styles-package { margin-top: 10px; font-size: 14px; overflow-wrap: anywhere; }
.styles-package summary { cursor: pointer; padding: 12px 0; }
.styles-package p { white-space: pre-line; }
.styles-package ul { padding-left: 20px; }
.styles-package li { margin-bottom: 8px; }
.styles-package h4 { margin: 12px 0 6px; }
.styles-package a { color: inherit; }
@media (min-width: 720px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-grid > .gallery-tile:first-child { grid-column: 1 / -1; }
  .gallery-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-lightbox img { max-height: calc(100dvh - 120px); }
}
@media (min-width: 1200px) {
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery-grid > .gallery-tile:first-child { grid-column: span 2; grid-row: span 2; }
  .gallery-items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  .gallery-tile img { transition: opacity .18s; }
  .gallery-tile button:hover img { opacity: .9; }
}
