.viewer-open { overflow: hidden; }
.viewer {
  position: fixed;
  inset: 0;
  width: min(100% - 32px, 1100px);
  height: min(94vh, 1050px);
  height: min(94dvh, 1050px);
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  padding: 0;
  border: none;
  background: #211f1e;
  color: #fff;
}
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer::backdrop { background: rgb(29 24 22 / 86%); }
.viewer-stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: #151413;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.viewer-stage.is-zoomed { cursor: grab; }
.viewer-equipment .viewer-stage { background: var(--paper); }
.viewer-stage.is-zoomed:active { cursor: grabbing; }
.viewer-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.viewer-bar, .viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px clamp(10px, 2vw, 24px);
}
.viewer-bar { padding-top: max(7px, env(safe-area-inset-top)); }
.viewer-footer { min-height: 60px; padding-bottom: max(7px, env(safe-area-inset-bottom)); }
.viewer-counter { font-size: .94rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.viewer-caption { line-height: 1.3; }
.viewer-controls { display: flex; gap: 4px; flex-shrink: 0; }
.viewer button {
  min-height: 44px;
  min-width: 44px;
  padding: 5px 12px;
  border: 1px solid #85817e;
  border-radius: 2px;
  color: inherit;
  background: transparent;
  font: inherit;
  font-size: .94rem;
  cursor: pointer;
  touch-action: manipulation;
}
.viewer .viewer-in, .viewer .viewer-out { font-size: 1.35rem; line-height: 1; }
.viewer button:is(:hover, :focus-visible) { color: #292523; background: white; }
.viewer button[aria-disabled="true"] { border-color: #514d4a; color: #b5afab; background: transparent; cursor: default; }
.viewer button:focus-visible { outline: 3px solid #8cc5fb; outline-offset: 2px; }
@media (max-width: 560px), (max-height: 500px) {
  .viewer { width: 100%; height: 100%; }
}
@media (max-width: 560px) {
  .viewer-footer { flex-wrap: wrap; }
  .viewer-footer .viewer-controls { margin-inline-start: auto; }
}
