.image-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.image-gallery-item {
  display: flex;
  flex-direction: column;
  margin: 0;
  border: 1px solid #ddd;
  background: #fafaf8;
}

.image-gallery-link {
  display: flex;
  flex: 1;
  align-items: center;
  background: #eee;
}

.image-gallery-thumbnail {
  display: block;
  width: 100%;
  height: auto;
  transition: opacity 120ms ease;
}

.image-gallery-link:hover .image-gallery-thumbnail,
.image-gallery-link:focus-visible .image-gallery-thumbnail {
  opacity: 0.82;
}

.image-gallery-link:focus-visible {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

.image-gallery-item figcaption {
  padding: 0.7rem 0.8rem 0.8rem;
  color: #555;
  font-size: 0.9rem;
  line-height: 1.45;
}

.image-gallery-dialog {
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #222;
  background: #fafaf8;
  font: inherit;
  overflow: hidden;
}

.image-gallery-dialog::backdrop {
  background: rgb(0 0 0 / 0.62);
}

.image-gallery-dialog-actions {
  position: fixed;
  z-index: 1;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  margin: 0;
}

.image-gallery-dialog button {
  padding: 0.35rem 0.65rem;
  border: 1px solid #000;
  border-radius: 0;
  color: #222;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.image-gallery-dialog button:hover {
  background: #eee;
}

.image-gallery-dialog img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 540px) {
  .image-gallery {
    grid-template-columns: 1fr;
  }
}
