img { max-width: 100%; }
.gallery-count { font-size: 0.875em; color: #555; }
.gallery-scroll { max-width: 100%; overflow-x: auto; padding: 2px 0 8px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 8px;
  min-width: 900px;
}
.gallery-cell {
  box-sizing: border-box;
  margin: 0;
  padding: 5px;
  border: 1px solid #ddd;
  min-width: 0;
  aspect-ratio: 10 / 13;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.thumbnail { display: flex; flex: 1; min-height: 0; align-items: center; justify-content: center; }
.thumbnail img { display: block; width: 100%; height: 100%; object-fit: contain; }
.gallery-cell figcaption { margin-top: 5px; text-align: center; font-size: 12px; line-height: 1.4; white-space: nowrap; }
.gallery-cell.empty { border-color: #eee; }
.gallery-cell:not(.empty):hover { border-color: #777; }
a:focus-visible, .gallery-scroll:focus-visible { outline: 2px solid #00f; outline-offset: 2px; }
footer { margin: 1em 0 2em; }
footer p { margin-top: 1em; }
@media print {
  #content { max-width: none; }
  .gallery-scroll { overflow: visible; }
  .gallery-grid { min-width: 0; gap: 4px; }
  .gallery-cell { padding: 2px; break-inside: avoid; }
}
