.pe {
  --pe-ink: var(--ink);
  --pe-muted: var(--muted);
  --pe-soft: var(--well);
  --pe-edge: var(--line);
  --pe-accent: var(--orange);
  background: linear-gradient(140deg, #24252a, var(--panel) 46%);
  color: var(--pe-ink);
  padding: 24px;
  border-radius: 26px;
  box-shadow:
    inset 0 0 0 1px #4c494b,
    0 16px 48px #03040655;
  font: 400 15px/1.5 var(--serif, Georgia, serif);
}
.pe [hidden] {
  display: none !important;
}
.pe button,
.pe select,
.pe input {
  font: inherit;
}
.pe button {
  cursor: pointer;
}
.pe :disabled {
  cursor: default;
}
.pe-body {
  display: grid;
  grid-template-columns: minmax(0, 1.525fr) minmax(0, 1fr);
  grid-template-areas: 'stage inspector' 'metadata inspector';
  grid-template-rows: 1fr auto;
  gap: 8px 24px;
}
.pe-document-meta {
  grid-area: metadata;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pe-upload-terms {
  margin: 0;
  color: var(--pe-muted);
  font-size: 14px;
  line-height: 1.5;
}
.pe-stage {
  grid-area: stage;
  position: relative;
  display: grid;
  align-items: center;
  justify-items: center;
  flex: 1;
  min-height: 500px;
  overflow: hidden;
  border-radius: 16px;
  background:
    radial-gradient(circle, #9298a42e .8px, transparent 1px) 50% 50% / 16px 16px,
    radial-gradient(ellipse at 50% 25%, #24272d, var(--well) 76%);
  box-shadow: inset 0 0 0 1px var(--line);
}
.pe-dropping .pe-stage {
  outline: 3px dashed var(--pe-accent);
  outline-offset: -5px;
  background: var(--copper-veil);
}
.pe-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  align-self: stretch;
  width: 100%;
  border: 0;
  padding: 24px;
  background: transparent;
  color: var(--pe-ink);
  text-align: center;
}
.pe-drop::before {
  content: '';
  position: absolute;
  inset: 17px;
  pointer-events: none;
  --mark: linear-gradient(#8c8077, #8c8077);
  background:
    var(--mark) left top / 14px 1px, var(--mark) left top / 1px 14px,
    var(--mark) right top / 14px 1px, var(--mark) right top / 1px 14px,
    var(--mark) left bottom / 14px 1px, var(--mark) left bottom / 1px 14px,
    var(--mark) right bottom / 14px 1px, var(--mark) right bottom / 1px 14px;
  background-repeat: no-repeat;
}
.pe-drop:focus-visible {
  outline-offset: -4px;
}
.pe-drop:hover .pe-upload-icon {
  background: #51372a;
  transform: translateY(-2px);
}
.pe-upload-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--copper-veil);
  box-shadow: inset 0 0 0 1px var(--copper-line), 0 4px 15px #0003;
  color: var(--pe-accent);
  transition:
    transform 0.18s ease,
    background 0.18s ease;
  margin-bottom: 24px;
}
.pe-drop strong {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}
.pe-drop small {
  margin-top: 8px;
  font-size: 14px;
  color: var(--pe-muted);
}
.pe .mobile-label {
  display: none;
}
.pe-image-wrap {
  position: relative;
  isolation: isolate;
  user-select: none;
  line-height: 0;
  --pe-ratio: 1.63;
  width: min(100%, calc(540px * var(--pe-ratio)));
  aspect-ratio: var(--pe-ratio);
  background: repeating-conic-gradient(#fff 0 25%, #ebebed 0 50%) 0 0/14px 14px;
}
.pe-loaded .pe-stage {
  padding: 12px;
  min-height: 260px;
  background: var(--well);
}
.pe canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  touch-action: none;
  cursor: crosshair;
}
.pe-box {
  position: absolute;
  border: 1.5px solid var(--pe-accent);
  box-shadow: 0 0 0 1px #fff8;
  pointer-events: none;
}
.pe-protection {
  position: absolute;
  pointer-events: none;
  border: 2px dashed #ffcb79;
  background: #ffcb7930;
  z-index: 2;
}
.pe-ai [data-protect].pe-protect-button {
  color: #ffcb79;
  background: transparent;
  border-color: #ffcb7966;
}
.pe-ai [data-protect].pe-protect-button[aria-pressed='true'] {
  background: #ffcb7922;
}
.pe-box i {
  position: absolute;
  width: 7px;
  height: 7px;
  background: white;
  border: 1.5px solid var(--pe-accent);
  transform: translate(-50%, -50%);
}
.pe-box i:nth-child(1) {
  left: 0;
  top: 0;
}
.pe-box i:nth-child(2) {
  left: 100%;
  top: 0;
}
.pe-box i:nth-child(3) {
  left: 0;
  top: 100%;
}
.pe-box i:nth-child(4) {
  left: 100%;
  top: 100%;
}
.pe-inspector {
  grid-area: inspector;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.pe-modes {
  display: flex;
  align-items: center;
  padding: 4px;
  margin-top: 16px;
  border-radius: 15px;
  background: var(--pe-soft);
}
.pe-modes button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--pe-muted);
  border-radius: 12px;
  padding: 8px 5px;
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
}
.pe-modes button[aria-pressed='true'] {
  background: var(--raised);
  box-shadow: inset 0 0 0 1px #55545a;
  color: var(--pe-ink);
}
.pe-inspector label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-weight: 500;
  font-size: 14px;
}
.pe-pdf,
.pe-detected,
.pe-settings,
.pe-inspector details {
  margin-top: 16px;
}
.pe-text-fields {
  display: grid;
  gap: 12px;
}
.pe-recent-download {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--pe-edge);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--pe-ink);
  background: var(--raised);
}
.pe-ai-elapsed {
  margin-top: 5px;
  color: var(--pe-muted);
  font-variant-numeric: tabular-nums;
}
.pe-inspector input:not([type='color']),
.pe-inspector select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 15px;
  border: 1px solid var(--control-line);
  border-radius: 16px;
  color: var(--pe-ink);
  background: var(--pe-soft);
  font-weight: 400;
  font-size: 16px;
}
.pe-inspector input::placeholder {
  color: #a8a6ae;
}
.pe-inspector details {
  border: 1px solid var(--pe-edge);
  border-radius: 14px;
  padding: 10px 14px;
}
.pe-inspector details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
  font-size: 14px;
  list-style: none;
}
.pe-inspector details summary::-webkit-details-marker {
  display: none;
}
.pe-inspector details[open] summary svg {
  transform: rotate(180deg);
}
.pe-inspector details label {
  margin-top: 12px;
}
.pe-inspector details small,
.pe-pdf small {
  display: block;
  margin-top: 9px;
  font-size: 12px;
  color: var(--pe-muted);
}
.pe-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pe-inspector input[type='color'] {
  height: 42px;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--pe-edge);
  border-radius: 10px;
  background: var(--pe-soft);
}
.pe .pe-apply {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--pe-accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 16px;
  padding: 10px;
  margin-top: 24px;
}
.pe .pe-apply:hover:not(:disabled) {
  background: #ffc7a6;
}
.pe .pe-apply:disabled {
  color: #d3c0b5;
  background: #493d38;
}
.pe [data-status] {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--pe-muted);
}
.pe-samples {
  margin-top: 16px;
  border: 1px solid var(--copper-line);
  border-radius: 14px;
  background: var(--copper-veil);
  padding: 13px;
}
.pe-samples label {
  color: #ffd5bb;
}
.pe-samples select {
  height: 37px;
  background: var(--well);
  border-color: #7c6a60;
  border-radius: 9px;
  font-size: 14px;
}
.pe-filebar,
.pe-settings,
.pe-save-row,
.pe-fileinfo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pe-filebar {
  justify-content: space-between;
  min-width: 0;
}
.pe-fileinfo {
  min-width: 0;
  max-width: 100%;
  flex-wrap: nowrap;
}
.pe-fileinfo span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pe-fileinfo small {
  font-size: 11px;
  color: var(--pe-muted);
  white-space: nowrap;
}
.pe-filebar button,
.pe-settings button,
.pe-save-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--pe-edge);
  border-radius: 10px;
  background: var(--raised);
  color: var(--pe-ink);
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.4;
}
.pe-save-row {
  margin-top: 14px;
}
.pe-save-row button[data-download] {
  background: var(--ink);
  color: var(--paper);
  border-color: transparent;
  margin-left: auto;
}
.pe-save-row button:disabled,
.pe-settings button:disabled {
  opacity: 0.5;
}
.pe-settings button[aria-pressed='true'] {
  background: var(--copper-veil);
  color: #ffd5bb;
  border-color: var(--copper-line);
}
@media (prefers-reduced-motion: reduce) {
  .pe-upload-icon {
    transition: none;
  }
}
@media (max-width: 1023px) {
  .pe-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'stage' 'inspector' 'metadata';
    grid-template-rows: auto;
  }
  .pe:not(.pe-loaded) .pe-body {
    grid-template-areas: 'stage' 'metadata' 'inspector';
  }
  .pe-stage { min-height: 260px; }
}
@media (max-width: 760px) {
  .pe {
    padding: 16px;
    border-radius: 24px;
  }
  .pe-body {
    gap: 16px;
  }
  .pe-text-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .pe-text-fields .pe-word {
    min-width: 0;
  }
  .pe-text-fields .pe-word:only-child,
  .pe-text-fields .pe-word:has(+ [hidden]) {
    grid-column: 1 / -1;
  }
  .pe-text-fields input:not([type='color']) {
    padding-inline: 9px;
  }
  .pe-stage {
    min-height: 232px;
  }
  .pe .desktop-label {
    display: none;
  }
  .pe .mobile-label {
    display: inline;
  }
  .pe-drop small {
    font-size: 13px;
  }
  .pe-upload-icon {
    width: 62px;
    height: 62px;
  }
  .pe-loaded .pe-stage {
    min-height: 160px;
    padding: 6px;
  }
  .pe-image-wrap {
    width: min(100%, calc(410px * var(--pe-ratio)));
  }
}

.pe-ai {
  margin-top: 9px;
  display: grid;
  gap: 5px;
}
.pe-ai button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  border: 1px solid var(--copper-line);
  border-radius: 12px;
  color: var(--pe-ink);
  background: var(--copper-veil);
}
.pe-ai button:disabled {
  opacity: .65;
}
.pe-ai small {
  color: var(--pe-muted);
  font-size: 12px;
  line-height: 1.45;
}
.pe [data-ai-progress] {
  accent-color: var(--pe-accent);
  width: 100%;
  height: 6px;
  margin-top: 10px;
}
