html.journal-gallery-open {
  overflow: hidden;
}

.journal-gallery-open-item {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

:is(.journal-gallery-open-item, .journal-gallery-prev, .journal-gallery-next,
    #journal .journal-controls button, .journal-gallery-controls button):is(:focus, :focus-visible) {
  outline: none !important;
  box-shadow: none !important;
}

.journal-gallery-view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: #eeeee9;
  overflow: hidden;
}

.journal-gallery-view[open] {
  display: grid;
  place-items: center;
}

.journal-gallery-view::backdrop {
  background: rgba(5, 6, 5, .88);
}

.journal-gallery-stage img,
.journal-gallery-stage video {
  display: block;
  width: auto;
  height: auto;
  max-width: min(calc(100vw - 116px), 1600px);
  max-height: calc(100vh - 126px);
  max-height: calc(100dvh - 126px);
  object-fit: contain;
}

.journal-gallery-view button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: 27px/1 var(--mono, monospace);
  cursor: pointer;
}

.journal-gallery-view button:is(:hover, :focus-visible) {
  color: var(--green, #009b67);
}

.journal-gallery-close {
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
}

.journal-gallery-prev,
.journal-gallery-next {
  top: 50%;
  transform: translateY(-50%);
}

.journal-gallery-prev { left: max(8px, env(safe-area-inset-left)); }
.journal-gallery-next { right: max(8px, env(safe-area-inset-right)); }

.journal-gallery-count {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  font: 12px/1.5 var(--mono, monospace);
  pointer-events: none;
}

@media (max-width: 600px) {
  .journal-gallery-stage img,
  .journal-gallery-stage video {
    max-width: 94vw;
    max-height: calc(100dvh - 170px);
  }

  .journal-gallery-prev,
  .journal-gallery-next {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: none;
  }
}

.journal-gallery-view .journal-gallery-close {
  top: clamp(18px, 3vw, 48px);
  right: clamp(18px, 3vw, 48px);
  width: 49px;
  height: 49px;
  padding: 8px;
  transition: transform .22s ease, color .18s ease;
}

.journal-gallery-view .journal-gallery-close svg {
  width: 29px;
  height: 29px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.journal-gallery-view .journal-gallery-close:is(:focus, :focus-visible) {
  outline: none !important;
  border: 0 !important;
  box-shadow: none !important;
}

.journal-gallery-view .journal-gallery-close:not(:hover) {
  color: var(--white, #eeeee9);
  transform: none;
}

.journal-gallery-view .journal-gallery-close:not(:hover) svg {
  filter: drop-shadow(0 0 2px rgba(241, 244, 235, .32));
}

.journal-gallery-view .journal-gallery-close:hover {
  transform: rotate(90deg);
}

.journal-gallery-view :is(.journal-gallery-prev, .journal-gallery-next) {
  width: 46px;
  height: 70px;
}

.journal-gallery-prev { left: clamp(12px, 3.2vw, 56px); }
.journal-gallery-next { right: clamp(12px, 3.2vw, 56px); }

.journal-gallery-view :is(.journal-gallery-prev, .journal-gallery-next) svg {
  width: 26px;
  height: 40px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 600px) {
  .journal-gallery-view .journal-gallery-close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
  }

  .journal-gallery-view .journal-gallery-close svg { width: 25px; height: 25px; }
  .journal-gallery-view :is(.journal-gallery-prev, .journal-gallery-next) { width: 34px; height: 52px; }
  .journal-gallery-view :is(.journal-gallery-prev, .journal-gallery-next) svg { width: 20px; height: 32px; }
}

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