.ptp-generator {
  --ptp-primary: #4f46e5;
  --ptp-primary-dark: #3730a3;
  --ptp-panel: #fff;
  --ptp-workspace: #161925;
  --ptp-border: #e4e7ec;
  --ptp-radius: 22px;
  --ptp-workspace-height: 680px;
  --ptp-text: #18202f;
  --ptp-muted: #687186;
  --ptp-soft-bg: #f7f8fb;
  width: 100%;
  color: var(--ptp-text);
  font-family: inherit;
  line-height: 1.5;
}

.ptp-generator,
.ptp-generator * {
  box-sizing: border-box;
}

.ptp-generator [hidden] {
  display: none !important;
}

.ptp-generator button,
.ptp-generator input {
  font: inherit;
}

.ptp-shell {
  display: grid;
  grid-template:
    "intro workspace" auto
    "upload workspace" auto
    "controls workspace" minmax(0, 1fr)
    "actions workspace" auto /
    minmax(310px, 360px) minmax(0, 1fr);
  max-width: 1500px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--ptp-border);
  border-radius: var(--ptp-radius);
  background: var(--ptp-panel);
  box-shadow: 0 24px 65px rgba(20, 27, 45, 0.11);
}

.ptp-intro,
.ptp-upload-card,
.ptp-controls,
.ptp-actions {
  position: relative;
  z-index: 2;
  min-width: 0;
  padding-right: 27px;
  padding-left: 27px;
  border-right: 1px solid var(--ptp-border);
  background: var(--ptp-panel);
}

.ptp-intro {
  grid-area: intro;
  padding-top: 28px;
  padding-bottom: 19px;
}

.ptp-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--ptp-primary);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.ptp-eyebrow::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ptp-primary) 13%, transparent);
  content: "";
}

.ptp-intro h2 {
  margin: 0 0 8px;
  color: var(--ptp-text);
  font-size: clamp(25px, 2.2vw, 32px);
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.ptp-intro p {
  margin: 0;
  color: var(--ptp-muted);
  font-size: 14px;
  line-height: 1.55;
}

.ptp-upload-card {
  grid-area: upload;
  padding-bottom: 20px;
}

.ptp-upload-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 13px 14px;
  border: 1.5px dashed color-mix(in srgb, var(--ptp-primary) 40%, var(--ptp-border));
  border-radius: 15px;
  background: color-mix(in srgb, var(--ptp-primary) 4%, var(--ptp-panel));
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.ptp-upload-zone:hover,
.ptp-upload-zone.is-dragging {
  border-color: var(--ptp-primary);
  background: color-mix(in srgb, var(--ptp-primary) 8%, var(--ptp-panel));
  transform: translateY(-1px);
}

.ptp-upload-icon {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: var(--ptp-primary);
  color: #fff;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--ptp-primary) 27%, transparent);
}

.ptp-upload-copy {
  min-width: 0;
}

.ptp-upload-copy strong,
.ptp-upload-copy small {
  display: block;
}

.ptp-upload-copy strong {
  overflow: hidden;
  color: var(--ptp-text);
  font-size: 13px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ptp-upload-copy small {
  margin-top: 2px;
  color: var(--ptp-muted);
  font-size: 11px;
}

.ptp-privacy {
  margin: 9px 2px 0;
  color: #5e687a;
  font-size: 10.5px;
}

.ptp-privacy span {
  margin-right: 3px;
  color: #198754;
  font-weight: 800;
}

.ptp-error {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 12px;
}

.ptp-controls {
  grid-area: controls;
  padding-top: 20px;
  padding-bottom: 21px;
  border-top: 1px solid var(--ptp-border);
  background: linear-gradient(180deg, var(--ptp-soft-bg), var(--ptp-panel) 65%);
}

.ptp-section-heading,
.ptp-range-label,
.ptp-range-ends,
.ptp-zoom-row,
.ptp-workspace-toolbar,
.ptp-file-meta,
.ptp-toolbar-actions {
  display: flex;
  align-items: center;
}

.ptp-section-heading {
  justify-content: space-between;
  margin-bottom: 12px;
}

.ptp-section-heading > div,
.ptp-range-label label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ptp-section-heading h3 {
  margin: 0;
  color: var(--ptp-text);
  font-size: 13px;
  font-weight: 730;
}

.ptp-step {
  display: inline-grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--ptp-primary) 10%, var(--ptp-panel));
  color: var(--ptp-primary);
  font-size: 10px;
  font-weight: 800;
}

.ptp-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #198754;
  font-size: 10px;
  font-weight: 700;
}

.ptp-status-dot::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.ptp-status-dot.is-busy {
  color: #d97706;
}

.ptp-mode-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.ptp-mode {
  display: flex;
  min-width: 0;
  min-height: 57px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 7px 2px;
  border: 1px solid var(--ptp-border);
  border-radius: 10px;
  background: var(--ptp-panel);
  color: #667085;
  cursor: pointer;
  font-size: 9px;
  font-weight: 680;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.ptp-mode:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--ptp-primary) 45%, var(--ptp-border));
}

.ptp-mode.is-active {
  border-color: color-mix(in srgb, var(--ptp-primary) 55%, #fff);
  background: color-mix(in srgb, var(--ptp-primary) 8%, #fff);
  color: var(--ptp-primary-dark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ptp-primary) 14%, transparent);
}

.ptp-mode:disabled,
.ptp-icon-button:disabled,
.ptp-toolbar-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ptp-mode-icon {
  position: relative;
  display: block;
  width: 22px;
  height: 17px;
  overflow: hidden;
  border-radius: 3px;
}

.ptp-icon-edges {
  background: repeating-linear-gradient(135deg, currentColor 0 1px, transparent 1px 5px);
}

.ptp-icon-thin::before,
.ptp-icon-thin::after {
  position: absolute;
  right: 1px;
  left: 1px;
  height: 1px;
  background: currentColor;
  content: "";
  transform: rotate(-17deg);
}

.ptp-icon-thin::before { top: 5px; }
.ptp-icon-thin::after { top: 11px; }

.ptp-icon-threshold {
  border: 1px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.ptp-icon-adaptive {
  border: 1px solid currentColor;
  background: radial-gradient(circle at 30% 35%, currentColor 0 2px, transparent 2.5px), radial-gradient(circle at 70% 65%, currentColor 0 3px, transparent 3.5px);
}

.ptp-icon-color {
  background: conic-gradient(#ef4444, #f59e0b, #22c55e, #3b82f6, #a855f7, #ef4444);
}

.ptp-control-block,
.ptp-zoom-control {
  margin-top: 18px;
}

.ptp-range-label {
  justify-content: space-between;
  margin-bottom: 9px;
  color: #414b5e;
  font-size: 11px;
  font-weight: 680;
}

.ptp-range-label output {
  min-width: 28px;
  color: var(--ptp-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  text-align: right;
}

.ptp-range {
  --ptp-range-progress: 50%;
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.ptp-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--ptp-primary) 0 var(--ptp-range-progress), #dce0e8 var(--ptp-range-progress) 100%);
}

.ptp-range::-moz-range-track {
  height: 5px;
  border: 0;
  border-radius: 99px;
  background: linear-gradient(to right, var(--ptp-primary) 0 var(--ptp-range-progress), #dce0e8 var(--ptp-range-progress) 100%);
}

.ptp-range::-webkit-slider-thumb {
  width: 17px;
  height: 17px;
  margin-top: -6px;
  appearance: none;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--ptp-primary);
  box-shadow: 0 1px 5px rgba(27, 35, 53, 0.27);
}

.ptp-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--ptp-primary);
  box-shadow: 0 1px 5px rgba(27, 35, 53, 0.27);
}

.ptp-range:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ptp-range-ends {
  justify-content: space-between;
  margin-top: 2px;
  color: #9299a7;
  font-size: 9px;
}

.ptp-zoom-control {
  padding-top: 16px;
  border-top: 1px solid var(--ptp-border);
}

.ptp-zoom-row {
  gap: 8px;
}

.ptp-zoom-row .ptp-range {
  flex: 1 1 auto;
}

.ptp-icon-button {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--ptp-border);
  border-radius: 8px;
  background: var(--ptp-panel);
  color: #3c4657;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.ptp-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-top: 18px;
  padding-bottom: 24px;
  border-top: 1px solid var(--ptp-border);
}

.ptp-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.ptp-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ptp-button-primary {
  background: var(--ptp-primary);
  color: #fff;
  box-shadow: 0 9px 22px color-mix(in srgb, var(--ptp-primary) 23%, transparent);
}

.ptp-button-primary:hover:not(:disabled) {
  background: var(--ptp-primary-dark);
}

.ptp-button-secondary {
  padding-right: 12px;
  padding-left: 12px;
  border-color: var(--ptp-border);
  background: #fff;
  color: #394458;
}

.ptp-button-ghost {
  grid-column: 1 / -1;
  min-height: 32px;
  padding: 3px;
  background: transparent;
  color: #727b8b;
  font-size: 10px;
}

.ptp-button:disabled {
  box-shadow: none;
  cursor: not-allowed;
  filter: grayscale(0.25);
  opacity: 0.48;
}

.ptp-workspace {
  grid-area: workspace;
  display: flex;
  min-width: 0;
  height: var(--ptp-workspace-height);
  flex-direction: column;
  padding: 14px;
  background: #eef0f5;
}

.ptp-workspace-toolbar {
  flex: 0 0 44px;
  min-width: 0;
  justify-content: space-between;
  gap: 15px;
  padding: 0 4px 10px;
}

.ptp-file-meta {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.ptp-file-name {
  display: block;
  max-width: 360px;
  overflow: hidden;
  color: #30394a;
  font-size: 11px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ptp-file-size {
  color: #7a8291;
  font-size: 9px;
}

.ptp-toolbar-actions {
  gap: 6px;
}

.ptp-toolbar-button {
  padding: 5px 9px;
  border: 1px solid #d9dde6;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: #5a6474;
  cursor: pointer;
  font-size: 10px;
  font-weight: 660;
}

.ptp-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: calc(var(--ptp-radius) - 8px);
  outline: none;
  background-color: var(--ptp-workspace);
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0);
  background-size: 18px 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 6px 18px rgba(29, 35, 54, 0.15);
  touch-action: none;
  user-select: none;
}

.ptp-viewport.is-pannable { cursor: grab; }
.ptp-viewport.is-panning { cursor: grabbing; }

.ptp-stage {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.32);
  will-change: transform;
}

.ptp-stage canvas,
.ptp-original-layer {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.ptp-result-canvas { z-index: 1; }
.ptp-original-layer { z-index: 2; overflow: hidden; }
.ptp-original-canvas { z-index: 1; }

.ptp-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 28px;
  color: rgba(255, 255, 255, 0.46);
  text-align: center;
}

.ptp-empty-art {
  width: 110px;
  margin-bottom: 12px;
  color: rgba(255, 255, 255, 0.26);
}

.ptp-empty-art svg { display: block; width: 100%; }

.ptp-empty-state strong {
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 680;
}

.ptp-empty-state span {
  margin-top: 4px;
  font-size: 11px;
}

.ptp-compare-divider {
  position: absolute;
  z-index: 6;
  width: 46px;
  margin-left: -23px;
  outline: none;
  cursor: ew-resize;
  touch-action: none;
}

.ptp-compare-divider::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(20, 25, 38, 0.22), 0 0 12px rgba(0, 0, 0, 0.25);
  content: "";
  transform: translateX(-50%);
}

.ptp-divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  width: 43px;
  height: 43px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--ptp-primary);
  color: #fff;
  box-shadow: 0 5px 17px rgba(0, 0, 0, 0.32);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  transform: translate(-50%, -50%);
  transition: transform 140ms ease, background-color 140ms ease;
}

.ptp-compare-divider:hover .ptp-divider-handle,
.ptp-compare-divider.is-dragging .ptp-divider-handle {
  background: var(--ptp-primary-dark);
  transform: translate(-50%, -50%) scale(1.08);
}

.ptp-label {
  position: absolute;
  z-index: 5;
  top: 15px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: 7px;
  background: rgba(18, 22, 33, 0.74);
  color: #fff;
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  backdrop-filter: blur(7px);
}

.ptp-label-original { left: 15px; }
.ptp-label-result { right: 15px; }

.ptp-processing {
  position: absolute;
  z-index: 8;
  right: 16px;
  bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  background: rgba(20, 24, 36, 0.86);
  color: #fff;
  font-size: 10px;
  font-weight: 650;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}

.ptp-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ptp-spin 720ms linear infinite;
}

@keyframes ptp-spin { to { transform: rotate(360deg); } }

.ptp-workspace-tip {
  flex: 0 0 auto;
  margin: 8px 3px 0;
  color: #767f8f;
  font-size: 9.5px;
  text-align: center;
}

.ptp-noscript {
  max-width: 1500px;
  margin: 10px auto;
  padding: 12px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.ptp-generator :where(button, input, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ptp-primary) 35%, transparent);
  outline-offset: 2px;
}

.ptp-viewport:focus-visible {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--ptp-primary) 75%, #fff), 0 6px 18px rgba(29, 35, 54, 0.15);
}

@media (max-width: 1100px) and (min-width: 821px) {
  .ptp-shell { grid-template-columns: 310px minmax(0, 1fr); }
  .ptp-intro,
  .ptp-upload-card,
  .ptp-controls,
  .ptp-actions { padding-right: 20px; padding-left: 20px; }
  .ptp-mode { font-size: 8px; }
}

@media (max-width: 820px) {
  .ptp-shell {
    grid-template:
      "intro" auto
      "upload" auto
      "workspace" minmax(460px, 64vh)
      "controls" auto
      "actions" auto /
      minmax(0, 1fr);
  }

  .ptp-intro,
  .ptp-upload-card,
  .ptp-controls,
  .ptp-actions {
    padding-right: clamp(20px, 5vw, 38px);
    padding-left: clamp(20px, 5vw, 38px);
    border-right: 0;
  }

  .ptp-workspace {
    height: auto;
    min-height: 460px;
    border-top: 1px solid var(--ptp-border);
  }

  .ptp-mode-grid { gap: 9px; }
  .ptp-mode { min-height: 64px; font-size: 10px; }
  .ptp-actions { grid-template-columns: minmax(0, 1fr) auto; }
}

@media (max-width: 540px) {
  .ptp-shell { grid-template-rows: auto auto minmax(390px, 58vh) auto auto; border-radius: min(var(--ptp-radius), 16px); }
  .ptp-intro { padding-top: 22px; }
  .ptp-intro h2 { font-size: 26px; }
  .ptp-upload-copy strong { white-space: normal; }
  .ptp-upload-copy small { line-height: 1.3; }
  .ptp-workspace { min-height: 390px; padding: 9px; }
  .ptp-workspace-toolbar { padding-right: 1px; padding-left: 1px; }
  .ptp-file-name { max-width: 160px; }
  .ptp-mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ptp-mode { min-height: 60px; }
  .ptp-label { top: 10px; }
  .ptp-label-original { left: 10px; }
  .ptp-label-result { right: 10px; }
  .ptp-workspace-tip { font-size: 9px; }
  .ptp-actions { grid-template-columns: 1fr 1fr; }
  .ptp-button-primary { grid-column: 1 / -1; }
  .ptp-button-secondary { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .ptp-generator *,
  .ptp-generator *::before,
  .ptp-generator *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
