* {
  box-sizing: border-box;
}
/* Cutout — the background falls away. Both images sit on the shared dot-grid desk; the
   preview backgrounds (checker, white, dark) apply only once there is a result. */
body[data-tool="cutout"] {
  --ui-accent: #665397;
  --ui-accent-hover: #53417e;
  --c-desk: #f3f4f7;
  --c-dot: #d3d9e2;
  --c-line: #dce1e8;
  --c-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  margin: 0;
}
body {
  font-size: 14px;
  line-height: 1.6;
}
body.editor {
  height: 100dvh;
  min-height: 480px;
  display: flex;
  flex-direction: column;
}
body.editor.has-tool-info {
  display: block;
  height: auto;
  overflow: visible;
}
body.editor.has-tool-info > #tool-workspace {
  height: calc(100dvh - var(--tool-header-height, 100px) - 44px);
  min-height: 460px;
}
.comparison-drop-zone {
  flex: 1;
  min-height: 0;
  display: flex;
}
.comparison-drop-zone > .comparison {
  width: 100%;
}
.cutout-example-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.cutout-example-pair > div > span {
  display: block;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}
.cutout-example-transparent {
  background: repeating-conic-gradient(#e8eaee 0% 25%, #fff 0% 50%) 0 0 / 24px 24px;
}
.tool-about .tool-about-example .cutout-example-transparent img {
  background: transparent;
}
.tool-about-related a > span {
  display: block;
}
@media (max-width: 540px) {
  .cutout-example-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}
button,
input {
  font: inherit;
}
button {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--ui-border, #dce1e8);
  border-radius: 3px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
button:hover:not(:disabled) {
  background: #f1eef6;
}
button:disabled {
  opacity: 0.42;
  cursor: default;
}
a {
  color: var(--ui-accent, #665397);
}
header {
  display: flex;
  align-items: center;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}
.brand-reading {
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}
header nav {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
header nav {
  margin-left: auto;
}
#import-actions,
#export-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
#export-actions {
  margin-left: auto;
}
#file-info {
  flex: 1 1 110px;
  min-width: 0;
  max-width: 260px;
  margin: 0;
  color: var(--ui-muted);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#file-info:empty {
  display: none;
}
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 8px 8px 4px;
}
#drop-zone.dragover {
  outline: 3px dashed var(--ui-accent);
  outline-offset: -4px;
  background: #f7f4fb;
}
.comparison {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.preview-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  overflow: hidden;
}
.section-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 48px;
  padding: 7px 12px 7px 16px;
  border-bottom: 1px solid var(--ui-border);
  flex-shrink: 0;
}
.section-heading > h2 {
  flex-shrink: 0;
}
.section-heading button:not(.background-swatch) {
  min-height: 32px;
  max-width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
h1 {
  margin: 0 0 5px;
  font-size: 25px;
  line-height: 1.5;
}
h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
/* Preview backgrounds are a view setting, so they float over the result instead of
   crowding the heading (which would wrap and push the image down on narrow screens). */
.background-options {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: #fff;
}
button.background-swatch {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid #bfc4ce;
  border-radius: 3px;
}
button.background-swatch[aria-pressed="true"] {
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}
.image-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: var(--c-desk);
  background-image: radial-gradient(var(--c-dot) 1px, transparent 1.2px);
  background-size: 20px 20px;
  background-position: 10px 10px;
}
/* A swatch always shows its own colour, even under the pointer. */
.background-options button.checker,
.background-options button.checker:hover:not(:disabled) {
  background: repeating-conic-gradient(#e8eaee 0% 25%, #fff 0% 50%) 0 0 / 10px 10px;
}
.background-options button.light,
.background-options button.light:hover:not(:disabled) {
  background: #fff;
}
.background-options button.dark-background,
.background-options button.dark-background:hover:not(:disabled) {
  background: #303641;
}
.background-options button.background-swatch:hover:not(:disabled) {
  border-color: var(--ui-accent);
}
.checker,
#result-stage[data-has-result="true"][data-background="checker"] {
  background: repeating-conic-gradient(#e8eaee 0% 25%, #fff 0% 50%) 0 0 / 20px 20px;
}
.light,
#result-stage[data-has-result="true"][data-background="light"] {
  background: #fff;
}
.dark-background,
#result-stage[data-has-result="true"][data-background="dark"] {
  background: #303641;
}
.image-stage img {
  position: absolute;
  inset: 0;
  padding: 20px;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.empty-state {
  color: var(--ui-muted);
  text-align: center;
  padding: 8px;
}
.empty-state p {
  font-size: 13px;
  margin: 0 0 4px;
}
/* Before a result: a dashed cut line with scissors, where the cut-out will appear. */
.result-draft {
  display: grid;
  justify-items: center;
  gap: 14px;
  max-height: 100%;
  overflow: auto;
}
.result-draft svg {
  width: 132px;
  overflow: visible;
}
.cut-line {
  fill: #fff;
  stroke: #a597c4;
  stroke-width: 1.4;
  stroke-dasharray: 4 3;
}
.result-draft.is-ready .draft-note {
  display: none;
}
#run-actions {
  display: grid;
  justify-items: center;
  gap: 10px;
}
body[data-tool] button.run-button {
  min-width: 220px;
  min-height: 56px;
  padding: 14px 28px;
  font-size: 18px;
  font-weight: 700;
}
.cut-scissors {
  fill: none;
  stroke: var(--ui-accent);
  stroke-width: 1.6;
  stroke-linecap: round;
}
.empty-state span {
  font-size: 12px;
}
/* Failures sit over the bottom of the work area, so no state change resizes the images. */
.notice {
  width: min(360px, 100%);
  text-align: left;
}
.notice.is-floating {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 3;
  width: min(480px, calc(100% - 32px));
  transform: translateX(-50%);
}
.result-draft:has(.notice[data-tone="error"]) svg {
  display: none;
}
.notice[data-tone="info"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.notice[data-tone="error"] {
  padding: 12px 14px;
  border: 1px solid #e3c3c6;
  border-left: 3px solid #a22e38;
  border-radius: 3px;
  background: #fff;
  color: #8f2530;
  font-size: 13px;
}
.notice #status {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* The download size matters only once there is an image to process. */
.result-draft:not(.is-ready) #download-note {
  display: none;
}
#download-note {
  max-width: 22em;
  margin: 2px 0 0;
  color: var(--ui-muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}
body[data-tool] #export-actions button.is-done {
  opacity: 1;
}
body[data-tool] #export-actions button.primary.is-done {
  background: var(--ui-accent-hover);
  border-color: var(--ui-accent-hover);
}
#export-actions button:not(.primary).is-done {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}
/* Working: the source image stays in view in the result area. */
.image-stage:has(#loading:not([hidden])) .result-draft {
  visibility: hidden;
}
.image-stage img.working-preview {
  z-index: 1;
  transition: opacity 0.3s;
}
#result-stage[data-busy="download"] .working-preview {
  opacity: 0.22;
}
#result-stage[data-busy="process"]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    100deg,
    transparent 30%,
    #ffffff00 40%,
    #ffffff73 50%,
    #c8b8ee40 55%,
    transparent 65%
  );
  background-size: 250% 100%;
  animation: c-scan 1.6s var(--c-ease) infinite;
  pointer-events: none;
}
@keyframes c-scan {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -20% 0;
  }
}
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 16px;
}
.loading-content {
  width: min(320px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: #fff;
  text-align: center;
}
/* While the background is removed, the progress is a small bar at the bottom. */
#result-stage[data-busy="process"] .loading-overlay {
  align-items: end;
}
#result-stage[data-busy="process"] .loading-content {
  width: auto;
  flex-direction: row;
  gap: 12px;
  padding: 8px 8px 8px 16px;
}
.loading-spinner {
  display: none;
}
/* When the result arrives, the cut line runs across and the background falls away. */
#result-stage.is-revealing .working-preview {
  animation: c-cut 1.1s cubic-bezier(0.45, 0.05, 0.35, 1) forwards;
}
#result-stage.is-revealing::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 2px;
  background: var(--ui-accent);
  box-shadow: 0 0 16px 3px #66539766;
  animation: c-cut-line 1.1s cubic-bezier(0.45, 0.05, 0.35, 1) forwards;
  pointer-events: none;
}
/* Both ends are explicit so the clip interpolates instead of switching halfway. */
@keyframes c-cut {
  from {
    clip-path: inset(0 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 100%);
  }
}
@keyframes c-cut-line {
  from {
    left: 0;
  }
  90% {
    opacity: 1;
  }
  to {
    left: 100%;
    opacity: 0;
  }
}
#loading-message {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
#loading-cancel {
  min-height: 32px;
  padding: 4px 16px;
  font-size: 12px;
  font-weight: 500;
}
#progress-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
#progress-percent {
  min-width: 4ch;
  color: var(--ui-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
progress {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 3px;
  background: #e9e5ef;
  accent-color: var(--ui-accent);
  display: block;
}
@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  #result-stage[data-busy="process"]::before,
  #result-stage.is-revealing::after {
    display: none;
  }
  #result-stage.is-revealing .working-preview {
    animation: none;
    opacity: 0;
  }
}
progress::-webkit-progress-bar {
  background: #e9e5ef;
  border-radius: 3px;
}
progress::-webkit-progress-value {
  background: var(--ui-accent);
  border-radius: 3px;
}
progress::-moz-progress-bar {
  background: var(--ui-accent);
  border-radius: 3px;
}
#error-detail {
  margin-top: 6px;
  font-size: 12px;
  color: #6b1f27;
}
summary {
  cursor: pointer;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 120px;
  overflow: auto;
}
dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px;
  color: inherit;
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  box-shadow: none;
}
dialog::backdrop {
  background: #27324766;
}
dialog h2,
#tour h2 {
  font-size: 20px;
  line-height: 1.5;
}
dialog p,
#tour p {
  font-size: 13px;
  line-height: 1.8;
}
.muted {
  color: var(--ui-muted);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
.eyebrow {
  color: var(--ui-accent);
  font-weight: 650;
}
#spotlight {
  position: fixed;
  z-index: 20;
  border: 2px solid #9e8abc;
  border-radius: 3px;
  box-shadow: 0 0 0 9999px #27324766;
  pointer-events: none;
}
#tour {
  position: fixed;
  z-index: 21;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
}
#tour .eyebrow {
  margin: 0 0 8px;
}
#tour .dialog-actions {
  gap: 6px;
  margin-top: 18px;
}
#tour .dialog-actions button {
  padding-inline: 13px;
}
[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .brand-reading {
    display: none;
  }
}
@media (max-width: 760px) {
  header .brand {
    flex: 1;
  }
  header nav {
    order: 1;
  }
  .has-tool-info header .brand {
    flex-basis: 100%;
  }
  .has-tool-info header nav {
    flex-basis: 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }
  #export-actions {
    margin-left: 0;
  }
  .comparison {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .workspace {
    padding: 6px 6px 3px;
  }
  .section-heading {
    min-height: 36px;
    padding: 4px 10px;
  }
  dialog {
    padding: 22px;
  }
  dialog h2 {
    font-size: 19px;
  }
  .dialog-actions button {
    font-size: 12px;
  }
}
@media (max-width: 360px) {
  header nav {
    gap: 5px;
  }
  body[data-tool] > header button,
  body[data-tool] > header .tool-directory-link {
    padding-inline: 7px;
  }
}
