#evidence-dialog {
  width: min(1120px, calc(100% - 40px));
  height: min(840px, calc(100dvh - 48px));
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid #b8a89d;
  background: var(--paper);
  box-shadow: 0 18px 75px #1e0e144d;
}

#evidence-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: evidence-appear 180ms ease-out;
}

#evidence-dialog::backdrop {
  background: #201118c9;
  animation: evidence-backdrop 180ms ease-out;
}

html:has(#evidence-dialog[open]) {
  overflow: hidden;
}

.evidence-header,
.evidence-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(12px, 2vw, 24px);
}

.evidence-header h3 {
  margin: 0;
  font-size: clamp(.9rem, 1.7vw, 1.12rem);
  line-height: 1.45;
}

.evidence-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}

.evidence-stage {
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: #e9e2d8;
  border-block: 1px solid #d1c4ba;
}

.evidence-stage:focus-visible {
  outline-offset: -3px;
}

.evidence-stage[data-zoomed] {
  cursor: grab;
}

.evidence-stage[data-panning] {
  cursor: grabbing;
  user-select: none;
}

.evidence-canvas {
  display: grid;
  place-items: center;
  width: max-content;
  height: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 12px;
}

#evidence-image {
  display: block;
  width: var(--evidence-width, 0px);
  max-width: none;
  height: auto;
  margin: 0;
  background: white;
  box-shadow: 0 4px 20px #3a291717;
}

.evidence-footer {
  position: relative;
  min-height: 58px;
}

.evidence-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.evidence-button,
.evidence-original {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--wine);
  font-size: 1.15rem;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 140ms, border-color 140ms;
}

.evidence-button[aria-disabled="true"] {
  color: var(--muted);
  opacity: .54;
  cursor: default;
}

.evidence-button:not([aria-disabled="true"]):hover,
.evidence-original:hover {
  border-color: #d3c4b7;
  background: #ecdfd2;
}

.evidence-position,
.evidence-fit,
.evidence-original {
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.evidence-position {
  min-width: 44px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.evidence-fit {
  min-width: 72px;
}

.evidence-original {
  display: inline-flex;
  justify-content: center;
  gap: 5px;
  text-decoration: underline;
  text-underline-offset: .22em;
}

.evidence-close {
  font-size: 1.5rem;
}

.evidence-announcement {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

@keyframes evidence-appear {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes evidence-backdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 520px) {
  #evidence-dialog {
    width: calc(100% - 16px);
    height: calc(100dvh - 24px);
  }

  .evidence-header,
  .evidence-footer {
    padding: 6px 8px;
    gap: 4px;
  }

  .evidence-button,
  .evidence-original {
    min-height: 44px;
  }

  .evidence-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }

  .evidence-controls {
    gap: 0;
  }

  .evidence-position { min-width: 34px; }
  .evidence-fit { min-width: 58px; }
  .evidence-original { justify-self: end; }
}

@media (max-width: 394px) {
  .evidence-footer {
    grid-template-columns: 1fr auto;
  }

  .evidence-original {
    grid-column: 1 / -1;
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  #evidence-dialog[open],
  #evidence-dialog::backdrop {
    animation: none;
  }

  .evidence-button,
  .evidence-original {
    transition: none;
  }
}
