html.portfolio-viewing { overflow: hidden; }

.folio-viewer {
  --fv-ink: #252523;
  --fv-paper: #faf9f6;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  border: 0;
  overflow: hidden;
  color: var(--fv-ink);
  background: var(--fv-paper);
  font: 400 max(16px, 1rem)/1.4 Arial, Helvetica, sans-serif;
}

.folio-viewer[open] {
  display: block;
}

.folio-viewer::backdrop { background: #faf9f6; }
.folio-viewer *, .folio-viewer { box-sizing: border-box; }
.folio-viewer [hidden] { display: none !important; }

.fv-header, .fv-tools, .fv-pages {
  display: flex;
  align-items: center;
}

.fv-header {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) clamp(12px, 3vw, 48px) 4px;
  pointer-events: none;
}

.fv-pages, .fv-tools, .fv-end {
  pointer-events: auto;
  background: var(--fv-paper);
}

.fv-end {
  position: absolute;
  z-index: 2;
  right: max(12px, 3vw, env(safe-area-inset-right));
  bottom: max(3px, env(safe-area-inset-bottom));
  display: flex;
  gap: clamp(16px, 2vw, 28px);
  padding-inline: 6px;
  color: #5d5c57;
}

.fv-counter {
  color: #5d5c57;
  font: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.folio-viewer button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--fv-ink);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.folio-viewer button:disabled { color: #aaa9a3; cursor: default; }
.folio-viewer :focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }

.folio-viewer button svg {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}

.fv-stage {
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.fv-stage .fv-image, .fv-stage .fv-pdf-tile {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.fv-stage .fv-image {
  inset: 50% auto auto 50%;
  object-fit: fill;
  transform-origin: center;
  cursor: zoom-in;
}

.fv-stage .fv-pdf-tile { z-index: 1; pointer-events: none; }
.fv-stage[data-zoomed] .fv-image { cursor: grab; }
.fv-stage[data-dragging] .fv-image { cursor: grabbing; }

.fv-message {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: #5d5c57;
  text-align: center;
}

.fv-message a { color: var(--fv-ink); }

@media (hover: hover) {
  .folio-viewer button:enabled:hover { background: #eae9e3; }
}

@media (max-width: 600px) {
  .fv-header { padding-inline: max(6px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-right)); }
}

@media (max-width: 330px) {
  .folio-viewer button { min-width: 40px; }
  .fv-header { gap: 3px; padding-inline: 4px; }
}
