.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  touch-action: none;
  overscroll-behavior: none;
}

.photo-viewer[hidden] {
  display: none !important;
}

.photo-viewer__scrim {
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: #000;
  cursor: zoom-out;
}

.photo-viewer__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}

.photo-viewer__img {
  pointer-events: auto;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
  touch-action: none;
}

.photo-viewer__close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 30;
  width: 44px;
  height: 44px;
  padding: 0;
  line-height: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: grid;
  grid-template: 1fr / 1fr;
  place-items: center;
  cursor: pointer;
}

.photo-viewer__close svg {
  display: block;
}

.photo-viewer__counter {
  position: absolute;
  top: max(16px, env(safe-area-inset-top) + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.photo-viewer__prev,
.photo-viewer__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  line-height: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  display: grid;
  grid-template: 1fr / 1fr;
  place-items: center;
  cursor: pointer;
}

.photo-viewer__prev svg,
.photo-viewer__next svg {
  display: block;
}

.photo-viewer__prev {
  left: max(10px, env(safe-area-inset-left));
}

.photo-viewer__next {
  right: max(10px, env(safe-area-inset-right));
}

.photo-viewer__prev[hidden],
.photo-viewer__next[hidden] {
  display: none;
}

html.photo-viewer-open,
html.photo-viewer-open body,
html.file-viewer-open,
html.file-viewer-open body {
  overflow: hidden;
}

[data-vy-photo] {
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}

/* In-app file/PDF viewer — PWA has no browser X */
.file-viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: #0b0d12;
  overscroll-behavior: none;
}

.file-viewer[hidden] {
  display: none !important;
}

.file-viewer__scrim {
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: #0b0d12;
  cursor: default;
}

.file-viewer__bar {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
}

.file-viewer__title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-viewer__dl {
  flex-shrink: 0;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}

.file-viewer__close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  line-height: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: grid;
  grid-template: 1fr / 1fr;
  place-items: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.file-viewer__close svg {
  display: block;
}

.file-viewer__stage {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.file-viewer__frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.file-viewer__frame[hidden] {
  display: none;
}

.file-viewer__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #fff;
}

.file-viewer__fallback[hidden] {
  display: none;
}

.file-viewer__fallback-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-viewer__fallback-hint {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

@media (display-mode: standalone) {
  .photo-viewer__close,
  .file-viewer__close {
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .photo-viewer,
  .file-viewer {
    transition: none;
  }
}
