#viewer {
  width: min(calc(100vw - 2rem), 76rem);
  max-width: none;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: clamp(0.75rem, 2vw, 1.4rem);
  overscroll-behavior: contain;
}

#viewer.viewer-expanded {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border-radius: 0;
}

.viewer-toolbar,
.viewer-navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.viewer-toolbar {
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

#viewer #close {
  margin: 0;
}

#viewer button {
  min-height: 44px;
}

#viewer button[aria-pressed="true"] {
  background: #c5ee52;
  color: #101416;
}

#viewer button[aria-disabled="true"] {
  opacity: 0.56;
  cursor: default;
}

#view-media img,
#view-media video {
  display: block;
  max-height: 68vh;
  max-height: 68dvh;
}

#view-media img {
  touch-action: pan-y pinch-zoom;
}

.viewer-expanded #view-media img,
.viewer-expanded #view-media video {
  max-height: 78vh;
  max-height: 78dvh;
}

.viewer-navigation {
  justify-content: space-between;
  margin-top: 0.75rem;
}

#view-count {
  min-width: 4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.viewer-caption {
  margin-top: 0.9rem;
}

.viewer-caption h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.viewer-caption p {
  margin: 0.35rem 0 0;
}

@media (max-width: 520px) {
  #viewer:not(.viewer-expanded) {
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
  }
}
