.staging-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #141415;
  color: var(--ink);
}
.staging-dialog::backdrop { background: #141415; }

.staging-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.staging-empty { position: absolute; top: 40%; padding: 16px; color: var(--muted); text-align: center; }
.staging-frame {
  --staging-ratio: 1.7777778;
  --staging-split: 50%;
  position: relative;
  width: min(100%, calc(100dvh * var(--staging-ratio)));
  aspect-ratio: var(--staging-ratio);
}
.staging-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
#staging-after {
  object-fit: cover;
  clip-path: inset(0 calc(100% - var(--staging-split)) 0 0);
}
.staging-divider {
  position: absolute;
  inset: 0 auto 0 var(--staging-split);
  width: 2px;
  translate: -50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgb(0 0 0 / .55);
  pointer-events: none;
}
.staging-divider span {
  position: absolute;
  top: 43%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--accent);
  color: #141415;
  box-shadow: 0 4px 15px rgb(0 0 0 / .35);
  font-size: 21px;
}
.staging-split {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: none;
}
.staging-frame:focus-within .staging-divider span { outline: 2px solid #fff; outline-offset: 4px; }

.staging-compare, .staging-shell {
  position: absolute;
  z-index: 3;
  left: 50%;
  translate: -50%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
}
.staging-compare {
  top: var(--edge-top);
  display: flex;
  gap: 3px;
  padding: 4px;
}
.staging-compare > button { min-height: 34px; padding: 4px 13px; background: transparent; border-color: transparent; }
.staging-compare > button[aria-pressed="true"] { background: var(--accent); }
.staging-drawing-tools {
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: calc(100% - 2 * var(--gutter));
  padding-inline-start: 11px;
}
.staging-drawing-tools p { min-width: 0; color: var(--ink); font-size: .86rem; }

.staging-shell {
  bottom: var(--edge-bottom);
  display: flex;
  flex-direction: column;
  width: min(690px, calc(100% - 2 * var(--gutter)));
  max-height: min(55dvh, calc(100dvh - var(--edge-top) - var(--edge-bottom) - 65px));
  overflow: hidden;
}
.staging-progress {
  position: absolute;
  z-index: 4;
  bottom: var(--edge-bottom);
  left: 50%;
  translate: -50%;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(216px, calc(100% - 2 * var(--gutter)));
  max-height: calc(100dvh - var(--edge-top) - var(--edge-bottom));
  padding: 14px 16px 13px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgb(15 15 16 / .91);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  text-align: center;
}
.staging-progress-dial {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-auto-flow: column;
  align-content: center;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  width: clamp(84px, 17dvh, 98px);
  aspect-ratio: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.staging-progress-dial::before,
.staging-progress-dial::after {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  content: '';
  pointer-events: none;
}
.staging-progress-dial::before {
  z-index: -1;
  border: 1px solid rgb(255 255 255 / .15);
  background: radial-gradient(circle, rgb(255 255 255 / .055), transparent 70%);
}
.staging-progress-dial::after {
  background: conic-gradient(
    from 45deg,
    transparent 0deg 195deg,
    rgb(255 255 255 / .08) 216deg,
    rgb(255 255 255 / .46) 302deg,
    #fff 352deg 358deg,
    transparent 360deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: staging-progress-orbit 1.65s linear infinite;
}
@keyframes staging-progress-orbit { to { rotate: 1turn; } }
.staging-progress-dial > span {
  font-size: clamp(38px, 7dvh, 46px);
  font-weight: 690;
  line-height: 1;
  letter-spacing: -.04em;
}
.staging-progress-dial > small { color: var(--muted); font-size: .79rem; line-height: 1; }
.staging-progress-label { color: var(--ink); font-size: .94rem; line-height: 1.35; }
#staging-progress #staging-cancel {
  justify-content: center;
  min-height: 44px;
  padding-inline: 15px;
}
.staging-progress[data-overtime="true"] .staging-progress-dial::after {
  opacity: .65;
  animation-duration: 2.6s;
}
@media (prefers-reduced-motion: reduce) {
  .staging-progress-dial::after { animation: none; }
}
@media (max-height: 410px) {
  .staging-progress { gap: 5px; padding-block: 8px; }
  .staging-progress-dial { width: 70px; }
  .staging-progress-dial > span { font-size: 34px; }
}
.staging-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  padding: 15px 17px 10px;
  border-bottom: 1px solid var(--line);
}
.staging-header h2 { font-size: 20px; line-height: 1.2; font-weight: 680; }
.staging-header p { margin-top: 3px; color: var(--muted); font-size: .8rem; }
.staging-header p:empty { display: none; }
.staging-layout {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  min-height: 0;
  padding: 12px 17px 9px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(255 255 255 / .35) transparent;
}
.staging-layout > * { flex: none; }
.staging-generator-toggle {
  align-self: flex-start;
  min-height: 34px;
  padding: 5px 9px;
  font-size: .86rem;
}
.staging-generator-toggle::after {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-start: 9px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  translate: 0 -2px;
  rotate: 45deg;
  content: '';
}
.staging-generator-toggle[aria-expanded="true"]::after { translate: 0 1px; rotate: 225deg; }
.staging-fieldset { margin: 0 0 10px; padding: 0; min-width: 0; border: 0; }
.staging-fieldset legend { margin: 0 0 5px; padding: 0; color: var(--muted); font-size: .83rem; font-weight: 650; }
.staging-range-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.staging-range-actions button { min-height: 34px; padding: 4px 9px; font-size: .86rem; }
#staging-range-status { margin-inline-start: 3px; color: var(--muted); font-size: .8rem; }
.staging-presets, .staging-gallery {
  display: flex;
  gap: 5px;
  padding: 2px 2px 4px;
  margin-inline: -2px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(255 255 255 / .32) transparent;
}
.staging-presets button { flex: none; min-height: 33px; padding: 4px 9px; font-size: .86rem; }
.staging-edit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.staging-edit textarea {
  width: 100%;
  min-height: 62px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control);
  color: var(--ink);
  resize: vertical;
}
.staging-edit textarea::placeholder { color: var(--muted); }
.staging-edit textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.staging-dialog .staging-primary {
  min-width: 97px;
  padding-inline: 12px;
  background: var(--accent);
  border-color: var(--accent);
  color: #141415;
  font-weight: 680;
}
.staging-dialog .staging-primary:hover:enabled { background: #fff; }
.staging-dialog .staging-close { width: 35px; min-height: 35px; padding: 0; font-size: 22px; line-height: 1; }
.staging-status { color: var(--muted); font-size: .86rem; }
.staging-status:empty { display: none; }
.staging-status[data-error="true"] { color: #ffc3c3; }
.staging-visual-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 3px 17px 15px;
}
.staging-visual-actions :is(button, a), #staging-cancel {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--ink);
  text-decoration: none;
  font-size: .86rem;
}
.staging-visual-actions a:hover { background: var(--control-hover); }
.staging-visual-actions a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#staging-hide { margin-inline-start: auto; }
#staging-reopen {
  position: absolute;
  z-index: 3;
  right: var(--gutter);
  bottom: var(--edge-bottom);
  min-height: 42px;
  padding-inline: 14px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
}
#staging-reopen:hover { background: rgb(20 20 20 / .86); }
.staging-thumbnail {
  flex: 0 0 116px;
  min-height: 65px;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  text-align: left;
}
.staging-thumbnail img { display: block; width: 100%; height: 39px; object-fit: cover; }
.staging-thumbnail span { display: block; padding: 5px 7px; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .staging-shell { max-height: min(68dvh, calc(100dvh - var(--edge-top) - var(--edge-bottom) - 50px)); }
  .staging-header { padding: 10px 12px 8px; }
  .staging-header h2 { font-size: 17px; }
  .staging-layout { padding: 9px 12px 7px; gap: 8px; }
  .staging-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(99px, 1fr));
    margin-inline: 0;
    padding-inline: 0;
  }
  .staging-thumbnail img { height: 50px; }
  .staging-visual-actions { padding: 3px 12px 11px; }
  .staging-dialog .staging-primary { min-width: 74px; padding-inline: 8px; font-size: .86rem; }
  .staging-edit textarea { min-height: 56px; font-size: .86rem; }
  .staging-divider span { top: 31%; }
}

@media (max-height: 500px) and (pointer: coarse) {
  .staging-shell { max-height: min(78dvh, calc(100dvh - var(--edge-top) - var(--edge-bottom) - 50px)); }
}
