/* A single drawing surface keeps the two scientific renders in registration. */
:where(.paper-wipe, .pw-dialog) {
  --pw-paper: #fbfaf5;
  --pw-ink: #233a30;
  --pw-muted: #55645b;
  --pw-rule: #d1d6c9;
  --pw-soft: #efefe6;
  --pw-copper: #9a442a;
  --pw-green: #284d3e;
  color: var(--pw-ink);
  font-family: var(--sans, system-ui, sans-serif);
}
:where(.paper-wipe, .pw-dialog) *, :where(.paper-wipe, .pw-dialog) *::before,
:where(.paper-wipe, .pw-dialog) *::after { box-sizing: border-box; }
:where(.paper-wipe, .pw-dialog) [hidden] { display: none !important; }
:where(.paper-wipe, .pw-dialog) :is(button, select, input) { font-family: inherit; }
:where(.paper-wipe, .pw-dialog) :is(button, select, a):focus-visible {
  outline: 2px solid var(--pw-copper);
  outline-offset: 2px;
}
.paper-wipe {
  min-width: 0;
  container: paper-comparison / inline-size;
  margin-block: clamp(.68rem, 1.3vw, 1.05rem);
}
.paper-wipe .pw-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "stage" "scenes" "controls" "sources";
  align-items: start;
  gap: .85rem;
  max-width: 100%;
  margin: 0;
  padding: clamp(.55rem, 1.35vw, 1.15rem);
  background: var(--pw-paper);
  border: 1px solid var(--pw-rule);
  border-radius: .4rem;
}
.pw-shell > .pw-stage { grid-area: stage; }
.pw-shell > .pw-scene-list { grid-area: scenes; }
.pw-shell > .pw-controls { grid-area: controls; }
.pw-shell > .pw-footer { grid-area: sources; }
.pw-shell > .pw-status { grid-column: 1 / -1; }
.paper-wipe .pw-scene-list {
  display: flex;
  align-items: stretch;
  gap: .45rem;
  width: 100%;
  min-width: 0;
  padding: .18rem .12rem .38rem;
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #aab4a6 transparent;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
}
.paper-wipe .pw-scene {
  display: inline-grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  flex: 0 0 auto;
  align-items: center;
  gap: .45rem;
  min-height: 2.75rem;
  max-width: 13rem;
  padding: .2rem .53rem .2rem .22rem;
  margin: 0;
  font-size: .86rem;
  font-weight: 520;
  text-align: left;
  line-height: 1.25;
  color: #35463b;
  background: #f6f6ef;
  border: 1px solid var(--pw-rule);
  border-radius: .2rem;
  scroll-snap-align: start;
  scroll-margin: .22rem;
  cursor: pointer;
}
.paper-wipe .pw-scene .pw-thumb {
  width: 100%;
  height: 2rem;
  max-width: none;
  display: block;
  object-fit: cover;
  border-radius: .1rem;
}
.paper-wipe .pw-scene > span { min-width: 0; overflow-wrap: anywhere; }
.paper-wipe .pw-scene:hover { border-color: #96a290; }
.paper-wipe .pw-scene[aria-pressed="true"] {
  border-color: var(--pw-green);
  color: var(--pw-green);
  background: #e6eddf;
  box-shadow: inset 0 0 0 1px var(--pw-green);
  font-weight: 670;
}
.paper-wipe .pw-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: .64rem .75rem;
  min-width: 0;
}
.paper-wipe .pw-control {
  display: grid;
  min-width: 0;
  gap: .35rem;
  color: var(--pw-muted);
  font-size: .82rem;
  line-height: 1.25;
  font-weight: 590;
}
.paper-wipe .pw-control > span { display: flex; align-items: center; gap: .42rem; }
.paper-wipe .pw-control > span::before {
  content: "";
  width: .48rem;
  height: .48rem;
  background: var(--pw-copper);
}
.paper-wipe .pw-control:nth-of-type(2) > span::before { background: var(--pw-green); }
.paper-wipe .pw-select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 2.55rem;
  padding: .38rem 1.7rem .38rem .48rem;
  line-height: 1.28;
  font-size: .92rem;
  font-weight: 510;
  color: var(--pw-ink);
  background-color: #fffef9;
  border: 1px solid #b3bdac;
  border-radius: .15rem;
  cursor: pointer;
}
:where(.paper-wipe, .pw-dialog) :is(.pw-enlarge, .pw-close) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  width: fit-content;
  min-height: 2.55rem;
  padding: .4rem .72rem;
  margin: 0;
  border: 1px solid #b1bbaa;
  border-radius: .2rem;
  background: transparent;
  color: var(--pw-ink);
  font-weight: 550;
  font-size: .87rem;
  line-height: 1.3;
  cursor: pointer;
}
:where(.paper-wipe, .pw-dialog) :is(.pw-enlarge, .pw-close):hover { background: #ebeee3; }
:where(.paper-wipe, .pw-dialog) :is(.pw-enlarge, .pw-close) svg {
  display: block;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}
.pw-shell .pw-enlarge { grid-column: 1 / -1; }
:where(.paper-wipe, .pw-dialog) .pw-stage {
  position: relative;
  display: block;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: auto;
  aspect-ratio: var(--pw-ratio, 1.5);
  margin: 0;
  padding: 0;
  background: #26382e;
  border-radius: .2rem;
  user-select: none;
  -webkit-user-select: none;
}
:where(.paper-wipe, .pw-dialog) .pw-stage .pw-layer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
}
.pw-stage .pw-right { z-index: 0; }
.pw-stage .pw-left {
  z-index: 1;
  clip-path: inset(0 calc(100% - var(--pw-split, 50%)) 0 0);
}
.pw-stage .pw-divider {
  position: absolute;
  z-index: 2;
  inset-block: 0;
  left: var(--pw-split, 50%);
  width: 2px;
  background: #fffef8;
  box-shadow: 0 0 2px #17271ec7;
  transform: translateX(-50%);
  pointer-events: none;
}
.pw-stage .pw-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.45rem;
  height: 2.45rem;
  transform: translate(-50%, -50%);
  border: 1.5px solid #fffef7;
  border-radius: 50%;
  color: #fffef8;
  background: #294337ed;
  box-shadow: 0 1px 5px #0005;
  pointer-events: none;
}
.pw-stage .pw-handle svg { width: 1.3rem; height: 1.3rem; display: block; }
.pw-stage .pw-chip {
  position: absolute;
  z-index: 3;
  top: clamp(.45rem, 1.2vw, .95rem);
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .15rem .45rem;
  max-width: calc(50% - 1rem);
  padding: .29rem .48rem;
  border: 1px solid #ffffff66;
  border-radius: .16rem;
  color: #fffef8;
  background: #6c3323ed;
  font-size: clamp(.78rem, 1.1vw, .91rem);
  line-height: 1.18;
  text-align: left;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.pw-stage .pw-left-chip { left: clamp(.45rem, 1.2vw, .95rem); }
.pw-stage .pw-right-chip {
  right: clamp(.45rem, 1.2vw, .95rem);
  justify-content: flex-end;
  text-align: right;
  background: #243e32ee;
}
.pw-stage .pw-chip-name { font-weight: 640; }
.pw-stage .pw-chip-score { color: #fff9ed; font-variant-numeric: tabular-nums; font-size: .92em; }
.pw-stage .pw-range {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  opacity: 0;
  border: 0;
  background: transparent;
  direction: ltr;
  cursor: ew-resize;
  touch-action: pan-y;
}
.pw-range::-webkit-slider-runnable-track { width: 100%; height: 100%; background: transparent; }
.pw-range::-webkit-slider-thumb { appearance: none; width: 1px; height: 100%; border: 0; background: transparent; }
.pw-range::-moz-range-track { width: 100%; height: 100%; border: 0; background: transparent; }
.pw-range::-moz-range-thumb { width: 1px; height: 100%; border: 0; background: transparent; }
.pw-stage:has(.pw-range:focus-visible) {
  outline: 3px solid var(--pw-copper);
  outline-offset: 2px;
}
.pw-stage:has(.pw-range:focus-visible) .pw-handle {
  background: #1d3329;
  box-shadow: 0 0 0 3px #fffdf5, 0 0 0 5px #89432c;
}
:where(.paper-wipe, .pw-dialog) .pw-footer {
  position: static;
  display: grid;
  align-items: start;
  gap: .36rem;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: .54rem 0 0;
  border: 0;
  border-top: 1px solid var(--pw-rule);
  background: transparent;
  color: var(--pw-muted);
  font-size: .86rem;
  line-height: 1.48;
}
:where(.paper-wipe, .pw-dialog) .pw-origin { min-width: 0; margin: 0; color: inherit; line-height: inherit; }
:where(.paper-wipe, .pw-dialog) .pw-links { display: flex; min-width: 0; align-items: baseline; flex-wrap: wrap; gap: .22rem .86rem; }
:where(.paper-wipe, .pw-dialog) .pw-links a {
  color: var(--pw-copper);
  font-size: .84rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .16rem;
  overflow-wrap: anywhere;
}
.paper-wipe .pw-status { margin: 0; color: #873e28; font-size: .89rem; }
.paper-wipe .pw-status:empty { display: none; }

@container paper-comparison (min-width: 51rem) {
  .paper-wipe .pw-shell {
    grid-template-columns: minmax(0, 1.95fr) minmax(16.8rem, 1fr);
    grid-template-rows: max-content max-content 1fr;
    grid-template-areas:
      "stage scenes"
      "stage controls"
      "stage sources";
    column-gap: clamp(1rem, 2vw, 1.7rem);
    row-gap: .8rem;
  }
  .paper-wipe .pw-scene-list {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    align-content: start;
    gap: .36rem;
    max-height: 12.5rem;
    padding: .15rem .14rem .25rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-snap-type: none;
  }
  .paper-wipe .pw-scene { width: 100%; max-width: none; }
  .paper-wipe .pw-controls { padding-top: .68rem; border-top: 1px solid var(--pw-rule); }
  .paper-wipe .pw-status { grid-column: 1 / -1; }
}
@media (max-width: 570px) {
  .paper-wipe .pw-shell { padding: .45rem; gap: .65rem; }
  .paper-wipe .pw-scene { min-height: 2.75rem; }
  .paper-wipe .pw-select { min-height: 2.75rem; font-size: 1rem; }
  .pw-stage .pw-chip { padding: .23rem .36rem; font-size: .76rem; }
  .pw-stage .pw-handle { width: 2.1rem; height: 2.1rem; }
}
.pw-dialog {
  width: min(94vw, 78rem, calc(75dvh * var(--pw-ratio, 1.5) + 2.5rem));
  min-width: min(92vw, 21rem);
  max-width: 98vw;
  max-height: 95dvh;
  margin: auto;
  padding: clamp(.65rem, 1.4vw, 1.1rem);
  border: 1px solid #bcc6b7;
  border-radius: .35rem;
  color: var(--pw-ink);
  background: var(--pw-paper);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pw-dialog:not([open]) { display: none; }
.pw-dialog::backdrop { background: #122019cb; }
.pw-dialog-inner { display: grid; min-width: 0; gap: .6rem; }
.pw-dialog .pw-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  margin: 0;
}
.pw-dialog .pw-dialog-head :is(h2,h3,h4,strong) {
  margin: 0;
  color: var(--pw-ink);
  font: 550 clamp(1.05rem, 1.8vw, 1.45rem)/1.28 var(--serif, Georgia, serif);
}
.pw-dialog .pw-close { flex: 0 0 auto; }
.pw-dialog .pw-stage {
  width: min(100%, calc(75dvh * var(--pw-ratio, 1.5)));
  height: auto;
  justify-self: center;
}
.pw-dialog .pw-footer { padding-top: .45rem; }
@media (forced-colors: active) {
  .pw-stage .pw-handle, .pw-stage .pw-divider, .pw-stage .pw-chip {
    forced-color-adjust: none;
  }
  .paper-wipe .pw-scene[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
}
/* The ablation selector includes two individually attributed budget-assignment renders. */
@container paper-comparison (min-width: 51rem) {
  .paper-wipe[data-comparison-key="ablations"] .pw-controls { grid-template-columns: minmax(0, 1fr); }
}
@container paper-comparison (max-width: 34rem) {
  .paper-wipe[data-comparison-key="ablations"] .pw-controls { grid-template-columns: minmax(0, 1fr); }
}
