.image-count {
  position: absolute;
  right: 16px;
  bottom: 16px;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--text) 22%, transparent);
  border-radius: 999px;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(12px);
}

.gallery {
  margin-top: 34px;
}

.gallery-stage {
  display: grid;
  place-items: center;
  min-height: 300px;
  max-height: 520px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  touch-action: pan-y;
}

.gallery-stage:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

dialog .gallery-stage img {
  width: 100%;
  height: 100%;
  max-height: 480px;
  margin: 0;
  object-fit: contain;
  background: transparent;
}

.gallery-strip {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding: 4px 2px 8px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.gallery-thumb {
  flex: 0 0 76px;
  width: 76px;
  height: 58px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  opacity: 0.62;
  scroll-snap-align: center;
  transition: opacity 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.gallery-thumb:hover {
  opacity: 0.86;
}

.gallery-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  opacity: 1;
  transform: translateY(-2px);
}

.gallery-thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

dialog .gallery-thumb img {
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  object-fit: cover;
  background: #fff;
}

@media (max-width: 700px) {
  .gallery-stage {
    min-height: 220px;
    padding: 12px;
  }

  .gallery-thumb {
    flex-basis: 66px;
    width: 66px;
    height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-thumb { transition: none; }
}
