.photo-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  inline-size: 100%;
  block-size: var(--photo-stage-height, 100%);
  min-block-size: var(--photo-stage-min-height, 18rem);
  background: #141414;
  color: #f5f0e8;
}
.photo-stage__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #141414;
  filter: grayscale(1);
  opacity: .5;
}
/* 18 November 2026: over a room's own ink (createPhotoStage surround:'reflections') the backdrop keeps its 50% and
   its three mirrored copies but no ground of its own, so the room's ink shows through around the photograph. Its
   last min(96px, 12%) toward each stage edge fades into the ink, so the stage leaves no rectangle in it. The opacity
   here is the reflections' strength over the ink, apart from Darkroom's plain backdrop above: inside the stage the
   eye sees ink x (1 - opacity x mask) + reflections x opacity x mask, where the mask is 1 beyond the feather and
   fades to 0 across it. */
.photo-stage__backdrop[data-photo-stage-ground="room"] {
  background: transparent;
  opacity: .5;
  --feather: min(96px, 12%);
  mask-image:
    linear-gradient(to right, rgb(0 0 0 / 0), rgb(0 0 0 / .156) calc(var(--feather) * .25), rgb(0 0 0 / .5) calc(var(--feather) * .5),
      rgb(0 0 0 / .844) calc(var(--feather) * .75), #000 var(--feather), #000 calc(100% - var(--feather)),
      rgb(0 0 0 / .844) calc(100% - var(--feather) * .75), rgb(0 0 0 / .5) calc(100% - var(--feather) * .5),
      rgb(0 0 0 / .156) calc(100% - var(--feather) * .25), rgb(0 0 0 / 0)),
    linear-gradient(to bottom, rgb(0 0 0 / 0), rgb(0 0 0 / .156) calc(var(--feather) * .25), rgb(0 0 0 / .5) calc(var(--feather) * .5),
      rgb(0 0 0 / .844) calc(var(--feather) * .75), #000 var(--feather), #000 calc(100% - var(--feather)),
      rgb(0 0 0 / .844) calc(100% - var(--feather) * .75), rgb(0 0 0 / .5) calc(100% - var(--feather) * .5),
      rgb(0 0 0 / .156) calc(100% - var(--feather) * .25), rgb(0 0 0 / 0));
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}
.photo-stage__ink,
.photo-stage__reflection {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  pointer-events: none;
}
.photo-stage__ink { opacity: .72; }
/* A held or edited photo lends a little of its edge colour to the moving room ink. */
.photo-stage__backdrop[data-photo-stage-tint] { filter: saturate(.28); --photo-reflection-gray: 0; }
.photo-stage__reflection { opacity: 0; }
.photo-stage[data-photo-stage-reflections] .photo-stage__reflection--far {
  opacity: 1;
  filter: grayscale(var(--photo-reflection-gray, 1)) blur(24px) brightness(.74);
}
.photo-stage[data-photo-stage-reflections] .photo-stage__reflection--middle {
  --reflection-reach: 400px;
  opacity: 1;
  filter: grayscale(var(--photo-reflection-gray, 1)) blur(10px) brightness(.74);
}
.photo-stage[data-photo-stage-reflections] .photo-stage__reflection--near {
  --reflection-reach: 160px;
  opacity: 1;
  filter: grayscale(var(--photo-reflection-gray, 1)) blur(2px) brightness(.74);
}
.photo-stage__reflection--near,
.photo-stage__reflection--middle {
  /* Smoothstep feathers crossfade blur levels over one constant-opacity field. */
  mask-image:
    linear-gradient(to right,
      rgb(0 0 0 / 0) calc(var(--photo-left, 0px) - var(--reflection-reach) * 1),
      rgb(0 0 0 / 0.043) calc(var(--photo-left, 0px) - var(--reflection-reach) * 0.875),
      rgb(0 0 0 / 0.156) calc(var(--photo-left, 0px) - var(--reflection-reach) * 0.75),
      rgb(0 0 0 / 0.5) calc(var(--photo-left, 0px) - var(--reflection-reach) * 0.5),
      rgb(0 0 0 / 0.844) calc(var(--photo-left, 0px) - var(--reflection-reach) * 0.25),
      rgb(0 0 0 / 0.957) calc(var(--photo-left, 0px) - var(--reflection-reach) * 0.125),
      #000 var(--photo-left, 0px),
      #000 calc(var(--photo-left, 0px) + var(--photo-width, 100%)),
      rgb(0 0 0 / 0.957) calc(var(--photo-left, 0px) + var(--photo-width, 100%) + var(--reflection-reach) * 0.125),
      rgb(0 0 0 / 0.844) calc(var(--photo-left, 0px) + var(--photo-width, 100%) + var(--reflection-reach) * 0.25),
      rgb(0 0 0 / 0.5) calc(var(--photo-left, 0px) + var(--photo-width, 100%) + var(--reflection-reach) * 0.5),
      rgb(0 0 0 / 0.156) calc(var(--photo-left, 0px) + var(--photo-width, 100%) + var(--reflection-reach) * 0.75),
      rgb(0 0 0 / 0.043) calc(var(--photo-left, 0px) + var(--photo-width, 100%) + var(--reflection-reach) * 0.875),
      rgb(0 0 0 / 0) calc(var(--photo-left, 0px) + var(--photo-width, 100%) + var(--reflection-reach) * 1)),
    linear-gradient(to bottom,
      rgb(0 0 0 / 0) calc(var(--photo-top, 0px) - var(--reflection-reach) * 1),
      rgb(0 0 0 / 0.043) calc(var(--photo-top, 0px) - var(--reflection-reach) * 0.875),
      rgb(0 0 0 / 0.156) calc(var(--photo-top, 0px) - var(--reflection-reach) * 0.75),
      rgb(0 0 0 / 0.5) calc(var(--photo-top, 0px) - var(--reflection-reach) * 0.5),
      rgb(0 0 0 / 0.844) calc(var(--photo-top, 0px) - var(--reflection-reach) * 0.25),
      rgb(0 0 0 / 0.957) calc(var(--photo-top, 0px) - var(--reflection-reach) * 0.125),
      #000 var(--photo-top, 0px),
      #000 calc(var(--photo-top, 0px) + var(--photo-height, 100%)),
      rgb(0 0 0 / 0.957) calc(var(--photo-top, 0px) + var(--photo-height, 100%) + var(--reflection-reach) * 0.125),
      rgb(0 0 0 / 0.844) calc(var(--photo-top, 0px) + var(--photo-height, 100%) + var(--reflection-reach) * 0.25),
      rgb(0 0 0 / 0.5) calc(var(--photo-top, 0px) + var(--photo-height, 100%) + var(--reflection-reach) * 0.5),
      rgb(0 0 0 / 0.156) calc(var(--photo-top, 0px) + var(--photo-height, 100%) + var(--reflection-reach) * 0.75),
      rgb(0 0 0 / 0.043) calc(var(--photo-top, 0px) + var(--photo-height, 100%) + var(--reflection-reach) * 0.875),
      rgb(0 0 0 / 0) calc(var(--photo-top, 0px) + var(--photo-height, 100%) + var(--reflection-reach) * 1));
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}
.photo-stage > .photo-stage__image {
  position: absolute;
  z-index: 1;
  inset: auto;
  left: 0;
  top: 0;
  inline-size: 100%;
  block-size: 100%;
  max-inline-size: none;
  max-block-size: none;
  margin: 0;
  object-fit: contain;
  object-position: center;
  transform-origin: 50% 50%;
  touch-action: auto;
  user-select: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  filter: none;
}
.photo-stage > .photo-stage__image[hidden] { display: none !important; }
.photo-stage__segment {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  contain: strict;
}
@media (prefers-reduced-motion: reduce) {
  .photo-stage > .photo-stage__image { transform: none !important; }
}
@media (forced-colors: active) {
  .photo-stage__backdrop { display: none; }
  .photo-stage { background: Canvas; }
}

/* A foreground owned by Capture or an editor provides the sharp pixels and all input. */
.photo-stage.photo-surround { position: absolute; inset: 0; z-index: 0; min-block-size: 0; inline-size: 100%; block-size: 100%; pointer-events: none; background: transparent; }
.photo-surround[hidden], .photo-surround > .photo-stage__image { display: none !important; }

:is(.upload-studio-compare, .mflow-preview, .sp-cropper):has(> .photo-surround) { position: relative; isolation: isolate; }
:is(.upload-studio-compare, .mflow-preview, .sp-cropper) > .photo-surround { z-index: -1; }
