.tool-shell:has(.cut-workbench) { width: min(100%, 1080px); }
.cut-workbench { --cut-space: 14px; display: grid; gap: var(--cut-space); }
.cut-workbench [hidden] { display: none !important; }
.cut-workbench button, .cut-workbench select { min-height: 42px; }
.cut-workbench-status {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--soft-blue);
  color: var(--navy);
  font-size: 12px;
  line-height: 1.45;
}
.cut-workbench-status[data-error="true"] { background: var(--red-bg); color: var(--red); }
.cut-upload .drop { min-height: 112px; }
.cut-target { margin-top: 10px; }
.cut-target :is(select, input) { min-height: 44px; min-width: 0; font-size: 16px; }
.cut-upload-action .fine { overflow-wrap: anywhere; }
.cut-workbench[data-ready="true"] .cut-upload .drop { min-height: 44px; padding: 5px 10px; }
.cut-workbench[data-ready="true"] .cut-upload .drop-content { flex-direction: row; flex-wrap: wrap; gap: 7px; justify-content: center; }
.cut-workbench[data-ready="true"] .cut-upload .drop-icon { width: 24px; height: 24px; }
.cut-workbench[data-ready="true"] .cut-upload .drop strong,
.cut-workbench[data-ready="true"] .cut-upload .file-name { margin: 0; }
.cut-workbench[data-ready="true"] .cut-upload .drop small:not(.file-name),
.cut-workbench[data-ready="true"] .cut-upload-action .fine { display: none; }
.cut-workbench[data-ready="true"] .cut-upload-action { justify-content: flex-end; margin-top: 7px; }
.cut-workbench[data-ready="true"] .cut-upload-action .btn { color: var(--navy); background: var(--cloud); border-color: var(--line); }
.cut-workbench-result { min-width: 0; scroll-margin-top: calc(var(--header) + 51px); }
.cut-workbench-header, .cut-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.cut-workbench-header { margin-bottom: 9px; }
.cut-workbench-header h2 { margin: 0; color: var(--navy); font-size: 16px; }
.cut-workbench-header h2:focus { outline: none; }
.cut-workbench-header span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cut-workbench-editor {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  grid-template-areas: "preview options" "download options";
  grid-template-rows: max-content max-content;
  gap: 11px 14px;
  align-items: start;
}
.cut-workbench[data-review="true"] .cut-workbench-editor {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "preview";
  grid-template-rows: auto;
}
.cut-workbench-preview {
  grid-area: preview;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  scroll-margin-top: calc(var(--header) + 47px);
}
.cut-preview-header strong { color: var(--navy); font-size: 12px; }
.cut-segments { display: flex; gap: 4px; flex-wrap: wrap; }
.cut-segments .btn { padding-inline: 10px; }
.cut-segments .btn[aria-pressed="true"] { background: var(--soft-blue); border-color: #99c4fa; color: #124f9d; }
.cut-picture {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  direction: ltr;
  min-width: 0;
  height: clamp(230px, 50vh, 510px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #eaf0f6;
}
.cut-picture canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: repeating-conic-gradient(#e4e9ef 0 25%, #fff 0 50%) 50% / 18px 18px;
  box-shadow: 0 1px 5px #172b4330;
}
.cut-picture[data-zoomed="true"] {
  display: flex;
  align-items: flex-start;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.cut-picture[data-zoomed="true"] canvas { flex: none; margin: auto; max-width: none; max-height: none; }
.cut-picture[data-zoomed="true"][data-brush="off"] canvas,
.cut-picture[data-zoomed="true"] #cut-original { cursor: grab; }
.cut-picture[data-panning="true"] canvas { cursor: grabbing !important; }
#cut-result:is([data-brush="erase"], [data-brush="restore"], [data-brush="outline"]) { touch-action: none; cursor: crosshair; }
#cut-result[data-brush^="subject"] { touch-action: manipulation; cursor: crosshair; }
.cut-picture[aria-busy="true"] #cut-result { cursor: progress; }
.cut-outline-guide { position: absolute; z-index: 1; overflow: visible; pointer-events: none; }
.cut-outline-guide path { stroke-linecap: round; stroke-linejoin: round; }
#cut-outline-shadow { fill: none; stroke: #172539; stroke-width: 4px; }
#cut-outline-path { fill: #80c3ff35; fill-rule: evenodd; stroke: #d2ecff; stroke-width: 2px; }
.cut-outline-guide circle { fill: #fff; stroke: #172539; stroke-width: 2px; }
.cut-outline-guide circle.selected { fill: #88ccff; stroke-width: 2.5px; }
.cut-outline-actions { display: grid; gap: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #f7faff; }
.cut-outline-actions .btn { min-height: 44px; }
.cut-brush-indicator {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  border: 2px solid #c23643;
  border-radius: 50%;
  background: #c2364318;
  box-shadow: 0 0 0 1px #fff;
  transform: translate(-50%, -50%);
}
.cut-brush-indicator[data-brush="restore"] { border-color: #147a58; background: #147a5818; }
.cut-preview-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.cut-preview-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.cut-preview-actions .cut-restore-action { border-color: #99c4fa; background: var(--soft-blue); color: #124f9d; }
.cut-edit-tools { display: grid; gap: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #f7faff; }
.cut-edit-tools .cut-brush-buttons { margin-top: 0; }
.cut-pick-subject { border-color: #99c4fa; color: #124f9d; }
.cut-precision-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 112px); gap: 10px; align-items: start; }
.cut-precision-controls .cut-field input { min-height: 42px; }
.cut-precision-controls select { min-width: 0; }
.cut-subject-status { margin: 0; color: var(--navy); font-size: 12px; line-height: 1.45; }
.cut-subject-status[data-error="true"] { color: var(--red); }
.cut-workbench-options { grid-area: options; display: grid; gap: 9px; min-width: 0; }
.cut-options-card {
  display: grid;
  min-inline-size: 0;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.cut-options-card legend, .cut-options-card summary, .cut-position-options summary {
  padding-inline: 5px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 750;
}
.cut-background-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cut-background-choice {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  padding: 7px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cloud);
  color: var(--navy);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.cut-background-choice:hover { border-color: #98b8dc; background: #f7faff; }
.cut-background-choice[aria-pressed="true"] { border-color: var(--blue-dark); background: var(--soft-blue); color: #124f9d; }
.cut-background-swatch { display: block; width: 25px; height: 19px; border: 1px solid #b3c2d2; border-radius: 5px; }
[data-cut-background="transparent"] .cut-background-swatch { background: repeating-conic-gradient(#dce4ee 0 25%, #fff 0 50%) 0 0 / 8px 8px; }
[data-cut-background="white"] .cut-background-swatch { background: #fff; }
[data-cut-background="black"] .cut-background-swatch { background: #141c28; }
[data-cut-background="custom"] .cut-background-swatch { background: conic-gradient(#ff8498, #f6c872, #80d4ad, #7bb2ff, #ff8498); }
[data-cut-background="photo"] .cut-background-swatch { background: radial-gradient(circle at 76% 24%, #fff0a6 0 11%, transparent 13%), linear-gradient(146deg, transparent 54%, #598d8c 56%), linear-gradient(31deg, #92c4af 49%, #afd7fa 51%); }
[data-cut-background="blur"] .cut-background-swatch { background: radial-gradient(ellipse at 30% 50%, #bb6be3, transparent 80%), radial-gradient(ellipse at 80% 60%, #ffd37d, transparent 70%), #83b4ed; }
.cut-mode-panel { display: grid; gap: 8px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.cut-colour-field { display: flex; gap: 8px; justify-content: space-between; align-items: center; color: var(--navy); font-size: 12px; font-weight: 700; }
#cut-colour { width: 62px; height: 42px; padding: 4px; }
.cut-field { display: grid; gap: 4px; min-width: 0; color: var(--navy); font-size: 12px; font-weight: 650; }
.cut-field > span { display: flex; justify-content: space-between; gap: 5px; align-items: baseline; }
.cut-field output { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.cut-field input[type="range"] { min-height: 32px; margin: 0; padding: 0; }
.cut-watermark input[type="text"] { min-width: 0; min-height: 44px; font-size: 16px; }
.cut-watermark input[type="color"] { width: 62px; height: 42px; padding: 4px; }
.cut-photo-picker { position: relative; display: grid; place-items: center; min-height: 42px; cursor: pointer; }
.cut-photo-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cut-photo-picker:focus-within { outline: 3px solid #2f80ed59; outline-offset: 2px; }
.cut-photo-name { margin: 0; color: var(--navy); font-size: 12px; overflow-wrap: anywhere; }
.cut-position-options { min-width: 0; }
.cut-position-options summary, .cut-details summary, .cut-quickstart > summary { padding: 4px 0; cursor: pointer; }
.cut-options-card > .cut-field, .cut-details .cut-check, .cut-details .cut-preview-help, .cut-brush-buttons, .cut-position-options .cut-field { margin-top: 7px; }
.cut-check { display: flex; align-items: center; gap: 7px; min-height: 36px; color: var(--navy); font-size: 12px; font-weight: 650; }
.cut-check input { accent-color: var(--blue); }
.cut-history { display: flex; gap: 7px; flex-wrap: wrap; }
#cut-brush-done { justify-self: start; }
.cut-workbench-download { grid-area: download; display: grid; grid-template-columns: minmax(68px, 100px) minmax(0, 1fr); gap: 7px; }
.cut-workbench-download .cut-preview-help, #cut-save-photo, #cut-open-photo, .cut-photo-preview { grid-column: 1 / -1; }
.cut-photo-preview { display: grid; justify-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.cut-photo-preview p { margin: 0; text-align: center; color: var(--muted); font-size: 12px; }
.cut-photo-preview img { display: block; max-width: 100%; max-height: 46vh; object-fit: contain; }
.cut-image-copy:empty { display: none; }
.cut-quickstart { margin: 12px 0 0; }
.cut-quickstart > summary { color: var(--navy); font-size: 12px; font-weight: 700; }

@media (max-width: 730px) {
  /* Keep review and acceptance jumps from competing with an active phone scroll. */
  html:has(#cut-workbench[data-ready="true"]) { scroll-behavior: auto; }
  body:has(#cut-workbench[data-ready="true"]) > .topbar,
  body:has(#cut-workbench[data-ready="true"]) > #app > .tool-switcher { position: relative; top: auto; }
  .cut-workbench[data-ready="true"] :is(.cut-workbench-result, .cut-workbench-preview) { scroll-margin-top: 12px; }
  .cut-workbench-editor { grid-template-columns: minmax(0, 1fr); grid-template-areas: "preview" "download" "options"; grid-template-rows: none; }
  .cut-picture { height: clamp(190px, 40vh, 390px); }
  .cut-background-choice { min-height: 48px; }
}
@media (max-width: 450px) {
  .cut-workbench { --cut-space: 9px; padding: 9px; }
  .cut-workbench-preview { padding: 7px; }
  .cut-upload-action { flex-wrap: wrap; gap: 7px; }
  .cut-upload-action .btn { width: 100%; }
  .cut-workbench[data-ready="true"] .cut-upload-action .btn { width: auto; min-height: 36px; }
  .cut-preview-actions > button { flex: 1 1 auto; }
  .cut-workbench-download { grid-template-columns: 75px minmax(0, 1fr); }
}
