.source-dialog {
  width: min(52rem, calc(100vw - 2rem));
  max-width: none;
  max-height: min(55rem, calc(100dvh - 2rem));
  padding: 0;
  border: 1px solid #414141;
  border-radius: 12px;
  background: white;
  color: var(--charcoal);
  box-shadow: 0 20px 65px #0007;
}
.source-dialog[open] {
  display: flex;
  flex-direction: column;
}
.source-dialog::backdrop {
  background: #141414b3;
}
.source-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--charcoal);
  color: white;
}
.source-header h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.4;
}
.source-name {
  margin: .15rem 0 0;
  color: #d2d2d2;
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.source-name:empty,
.source-dialog [hidden],
.source-status:empty {
  display: none;
}
.source-close,
.source-attach {
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 640;
  white-space: nowrap;
  padding: .45rem .75rem;
  background: transparent;
}
.source-close { color: white; }
.source-close:hover { background: #292929; }
.source-attach { color: var(--link); }
.source-attach:hover { background: #fff1f1; }
.source-dialog mark {
  background: #ffe4a1;
  color: #37280d;
  border-radius: 2px;
  box-decoration-break: clone;
  padding: .04em .1em;
}
.source-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: #f2f2f2;
}
.source-scroll:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: -2px;
}
.source-extracted {
  margin: .7rem auto;
  padding: clamp(.8rem, 3.5vw, 2rem);
  width: calc(100% - 1.4rem);
  background: white;
  border: 1px solid #dedede;
  font-size: .93rem;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.source-extracted:empty { display: none; }
.source-original {
  padding: .7rem;
}
.source-original:empty { display: none; }
.source-sheet {
  position: relative;
  margin-inline: auto;
  overflow: hidden;
  background: white;
  box-shadow: 0 1px 6px #0003;
}
.source-sheet canvas { display: block; }
.source-highlight {
  position: absolute;
  background: #ffd36b;
  mix-blend-mode: multiply;
  border-radius: 2px;
  pointer-events: none;
}
.source-text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  transform-origin: 0 0;
  text-size-adjust: none;
  pointer-events: none;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inverse: calc(1 / var(--min-font-size));
}
.source-text-layer span {
  position: absolute;
  white-space: pre;
  color: transparent;
  transform-origin: 0 0;
  font-size: calc(var(--text-scale-factor) * var(--font-height, 0px));
  transform: rotate(var(--rotate, 0deg)) scaleX(var(--scale-x, 1)) scale(var(--min-font-size-inverse));
}
.source-text-layer[data-main-rotation='90'] { transform: rotate(90deg) translateY(-100%); }
.source-text-layer[data-main-rotation='180'] { transform: rotate(180deg) translate(-100%, -100%); }
.source-text-layer[data-main-rotation='270'] { transform: rotate(270deg) translateX(-100%); }
body > .hiddenCanvasElement { display: none; }
.source-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem 1rem;
  flex-wrap: wrap;
  padding: .65rem 1.25rem;
  border-top: 1px solid var(--line);
}
.source-footer:has(.source-status:empty):not(:has(button)) { display: none; }
.source-status {
  flex: 1 1 16rem;
  margin: 0;
  color: var(--sub);
  font-size: .85rem;
}
@media (max-width: 38rem) {
  .source-dialog {
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
  }
  .source-header,
  .source-footer { padding-inline: .9rem; }
  .source-original { padding-inline: .35rem; }
}
