/* Web workbench. Image composition remains in app.js. */
html, body { width: 100%; height: 100%; min-width: 320px; overflow: hidden; }
body { background: #f3f1ec; }
.redthread-workbench {
  --line: #dedbd4;
  --muted: #817b73;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 348px;
  grid-template-rows: 80px minmax(0, 1fr);
  width: 100%; height: 100vh; height: 100dvh; min-height: 0;
  overflow: hidden; background: #f5f3ef;
}
.redthread-workbench button { cursor: pointer; }
.redthread-workbench button:disabled { cursor: not-allowed; }
.redthread-workbench :is(button, input, select, textarea):focus-visible {
  outline: 2px solid var(--wine); outline-offset: 3px;
}
.workbench-topbar {
  grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center;
  justify-content: space-between; gap: 18px; padding: 0 28px;
  border-bottom: 1px solid var(--line); background: #faf9f6;
}
.workbench-brand, .workbench-topbar-actions { display: flex; align-items: center; gap: 13px; }
.workbench-brand img { flex: none; border-radius: 10px; }
.workbench-brand-name { display: block; font: 24px/1.15 Georgia, serif; letter-spacing: -.6px; }
.workbench-brand-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: 1.6px; }
.workbench-export-note { margin-right: 6px; color: var(--muted); font-size: 11px; }
.redthread-workbench #exportButton { position: static; display: inline-flex; min-width: 124px; min-height: 44px; padding: 0 22px; border-radius: 11px; font-size: 13px; box-shadow: none; }
.redthread-workbench #exportButton:disabled { color: #76716a; background: #e4e1db; opacity: 1; }
.redthread-workbench #mobileStepNav {
  grid-column: 1; grid-row: 2; position: static; display: flex; flex-direction: column;
  align-items: stretch; gap: 12px; width: auto; height: auto; min-height: 0;
  padding: 26px 10px; margin: 0; overflow-y: auto;
  border: 0; border-right: 1px solid var(--line); background: #f9f8f5;
}
.redthread-workbench .step-button {
  display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; position: relative; width: 100%; min-height: 74px; padding: 12px 4px;
  border: 1px solid transparent; border-radius: 15px; color: var(--muted);
  background: transparent; font-size: 12px; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.redthread-workbench .step-button::before { display: none; }
.redthread-workbench .step-button svg { width: 24px; height: 24px; }
.redthread-workbench .step-button:hover { background: #eeebe5; color: var(--ink); }
.redthread-workbench .step-button.active { color: var(--wine); border-color: #ede4df; background: #fff; box-shadow: 0 5px 20px #503b2f08; }
.redthread-workbench .stage {
  grid-column: 2; grid-row: 2; position: relative; display: flex; flex-direction: column;
  width: auto; height: auto; min-width: 0; min-height: 0; padding: 28px 38px 16px;
  overflow: hidden; border: 0; box-shadow: none;
  background: radial-gradient(ellipse at 35% 15%, #fff9, transparent 75%), #f2f0eb;
}
.redthread-workbench .stage::before { display: none; }
.workbench-stage-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 14px; width: 100%; max-width: 800px; margin: 0 auto 20px; }
.workbench-stage-eyebrow { margin: 0 0 7px; color: var(--wine); font-size: 10px; letter-spacing: 2px; }
.workbench-stage-head h1 { font-family: Georgia, "Songti SC", "STSong", serif; font-size: 24px; line-height: 1.35; letter-spacing: 0; }
.workbench-canvas-size { color: #969087; font-size: 10px; letter-spacing: .6px; white-space: nowrap; }
.workbench-canvas-viewport { display: grid; flex: 1 1 auto; min-height: 0; min-width: 0; place-items: center; width: 100%; }
.redthread-workbench .canvas-wrap {
  flex: none; width: var(--workbench-canvas-width, min(100%, 420px)); height: auto;
  max-width: 100%; max-height: 100%; aspect-ratio: 3 / 4; padding: 0;
  border-radius: 1px; background: #e5ded3;
  box-shadow: 0 15px 48px #47392f22, 0 2px 5px #47392f0d;
}
.redthread-workbench #canvas { width: 100%; height: 100%; aspect-ratio: 3 / 4; }
.redthread-workbench .canvas-label { display: none; }
.redthread-workbench canvas.direct-manipulation { cursor: grab; touch-action: none; }
.redthread-workbench canvas.direct-manipulation:active { cursor: grabbing; }
.redthread-workbench .mask-confirm-button { top: 14px; right: 14px; }
.workbench-canvas-hint { flex: none; min-height: 17px; margin: 16px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; text-align: center; }
.redthread-workbench .controls {
  grid-column: 3; grid-row: 2; position: relative; display: block; flex: none;
  width: auto; height: auto; min-width: 0; min-height: 0; padding: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  border: 0; border-left: 1px solid var(--line); background: #faf9f6;
  backdrop-filter: none; scrollbar-width: thin; scrollbar-color: #d9d4cd transparent;
}
.workbench-inspector-head { display: flex; align-items: baseline; gap: 14px; padding: 29px 24px 24px; border-bottom: 1px solid var(--line); }
.workbench-step-number { color: var(--wine); font: italic 21px Georgia, serif; }
.workbench-inspector-head h2 { margin: 0; font: 23px/1.4 Georgia, "Songti SC", "STSong", serif; }
.workbench-inspector-head p { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.redthread-workbench .controls > .section { display: none; }
.redthread-workbench .controls > .section.active-step { display: block; min-height: 0; overflow: visible; padding: 24px !important; border: 0; }
.redthread-workbench .section-title { display: none; }
.redthread-workbench .mobile-compact-controls { display: flex; }
.redthread-workbench .mobile-segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; margin: 0 0 24px; padding: 4px; border-radius: 11px; background: #eae7e1; }
.redthread-workbench .mobile-segmented button { min-height: 39px; border: 0; border-radius: 8px; padding: 6px 8px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 500; }
.redthread-workbench .mobile-segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 2px 6px #47392f08; }
.redthread-workbench .controls [data-step="2"] .mobile-switch-group { display: none !important; margin: 0; border: 0; background: none; }
.redthread-workbench .controls [data-step="2"] .mobile-switch-group.mobile-selected { display: block !important; }
.redthread-workbench .control-group summary { display: none; }
.redthread-workbench .control-group-body { padding: 0; border: 0; }
.redthread-workbench .controls .range { display: grid; grid-template-columns: 66px minmax(0,1fr) 36px; gap: 8px; min-height: 44px; margin: 8px 0; }
.redthread-workbench .range label, .redthread-workbench .range output { color: var(--muted); font-size: 11px; }
.redthread-workbench input[type="range"] { min-width: 0; min-height: 36px; }
.redthread-workbench .mobile-tool-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 22px; }
.redthread-workbench .mobile-tool-note { width: 100%; margin: 0 0 8px; color: var(--muted); font-size: 11px; line-height: 1.6; text-align: left; }
.redthread-workbench .button.secondary { background: #fff; }
.redthread-workbench .button.mini { min-height: 34px; padding: 0 12px; font-size: 11px; }
.redthread-workbench :is(input[type="text"], select) { height: 42px; min-width: 0; background: #fff; border-radius: 8px; font-size: 13px; }
.redthread-workbench .hint { display: block; margin-top: 18px; color: var(--muted); font-size: 11px; line-height: 1.8; }
.redthread-workbench .upload-grid { display: grid; grid-template-columns: 1fr; }
.redthread-workbench .source-upload-card,
.redthread-workbench .controls [data-step="1"].subject-ready .source-upload-card {
  display: grid; grid-template-columns: 36px minmax(0,1fr) auto; height: auto;
  min-height: 82px; padding: 15px 12px; gap: 10px; border: 1px dashed #cfc6bc; background: #fff;
}
.redthread-workbench .controls [data-step="1"].subject-ready .source-upload-mark { display: grid !important; }
.redthread-workbench .source-upload-card strong { font-size: 13px; }
.redthread-workbench #sourceState { display: block; max-width: 100%; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.redthread-workbench .source-upload-card .upload-action { display: block; color: var(--wine) !important; }
.redthread-workbench .source-upload-mark { width: 34px; height: 34px; }
.redthread-workbench .auto-cutout { margin-top: 20px; padding: 0; border: 0; background: none; }
.redthread-workbench .cleanup-tools.show { margin-top: 0; padding-top: 0; border: 0; }
.redthread-workbench .cutout-icon-bar { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.redthread-workbench .cutout-icon-button { min-height: 73px; height: auto; padding: 10px 3px; gap: 5px; background: #fff; }
.redthread-workbench .cutout-icon-button.active { color: var(--wine); background: #f6ece9; box-shadow: none; }
.cutout-tool-name { font-size: 10px; line-height: 1.5; }
.redthread-workbench .subject-upload-link { display: flex; flex-wrap: wrap; min-height: 40px; margin-top: 16px; font-size: 10px; background: none; }
.redthread-workbench .cutout-tool-popover.show { position: static; display: grid; padding: 10px 0 0; margin-top: 12px; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; background: none; backdrop-filter: none; }
.redthread-workbench .cutout-tool-popover .range { display: none; }
.redthread-workbench .cutout-tool-popover.mode-brush .brush-control,
.redthread-workbench .cutout-tool-popover.mode-magic .magic-control { display: grid; }
.redthread-workbench .progress-label.show { display: block !important; }
.redthread-workbench #generateTextButton { width: 100%; margin: 0 0 20px; min-height: 39px; font-size: 11px; }
.redthread-workbench #mobileGenerateTextButton { display: none; }
.redthread-workbench .text-editor-toolbar { display: block; }
.redthread-workbench .text-panel-switch { width: 100%; }
.redthread-workbench .text-item-tabs { gap: 8px; margin: 0 0 14px; }
.redthread-workbench .text-item-editor { margin-bottom: 14px; }
.redthread-workbench .text-remove-button { width: 38px; height: 42px; background: #fff; }
.redthread-workbench .text-tool-note { display: block; margin: 12px 0; }
.redthread-workbench .style-panel { display: none; }
.redthread-workbench .style-panel.mobile-selected { display: block; }
.redthread-workbench .style-color-grid.mobile-selected { display: grid; grid-template-columns: 1fr; gap: 22px; }
.redthread-workbench .style-panel .field { margin: 0 !important; }
.redthread-workbench .style-panel .field > label { display: block; margin-bottom: 12px; font-size: 11px; }
.redthread-workbench .paper-scroll-row { display: flex; flex-direction: column; gap: 18px; }
.redthread-workbench .paper-upload-swatch { display: flex; flex-direction: row; width: 100%; min-height: 48px; height: auto; aspect-ratio: auto; gap: 8px; border-style: dashed; background-color: #fff; }
.redthread-workbench .paper-upload-swatch strong { font-size: 11px; }
.redthread-workbench .paper-picker { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; overflow: visible; padding: 3px; }
.redthread-workbench .paper-picker .paper-swatch { width: 100%; min-width: 0; height: auto; aspect-ratio: 1; }
.redthread-workbench .preset-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-bottom: 22px; }
.redthread-workbench .preset-card { min-height: 48px; font-size: 11px; background: #fff; }
.redthread-workbench .preset-card.active { background: var(--wine); }
.redthread-workbench .controls [data-step="5"] > #anchorButton { display: flex; min-height: 46px; font-size: 12px; }
.redthread-workbench .controls [data-step="5"] > .two { display: grid !important; grid-template-columns: 1fr; gap: 20px; margin-top: 24px !important; }
.redthread-workbench .field label { font-size: 11px; }
.redthread-workbench .field { gap: 8px; }
.redthread-workbench .mobile-redline-controls { display: flex; margin-top: 22px; }
.redthread-workbench #templateNext { width: 100%; min-height: 42px; }
.redthread-workbench #mobileAnchorShortcut { display: none; }
.redthread-workbench .color-row { grid-template-columns: minmax(0,1fr) 48px; }
.redthread-workbench input[type="color"] { width: 48px; height: 42px; background: #fff; }
.redthread-workbench [hidden] { display: none !important; }
@media (max-width: 1100px) {
  .redthread-workbench { grid-template-columns: 76px minmax(0,1fr) 310px; }
  .redthread-workbench .stage { padding: 26px 24px 16px; }
  .redthread-workbench #mobileStepNav { padding-left: 7px; padding-right: 7px; }
  .workbench-inspector-head { padding: 26px 20px 22px; }
  .redthread-workbench .controls > .section.active-step { padding: 20px !important; }
}
@media (max-width: 760px) {
  .redthread-workbench { grid-template-columns: minmax(0,1fr); grid-template-rows: 60px minmax(0,1fr) min(31dvh, 250px) calc(64px + env(safe-area-inset-bottom, 0px)); }
  .workbench-topbar { grid-column: 1; grid-row: 1; gap: 8px; padding: 0 14px; }
  .workbench-brand { gap: 9px; }
  .workbench-brand img { width: 32px; height: 32px; border-radius: 8px; }
  .workbench-brand-name { font-size: 20px; }
  .workbench-brand-subtitle { margin-top: 2px; font-size: 9px; letter-spacing: 1px; }
  .workbench-export-note { display: none; }
  .redthread-workbench #exportButton { min-width: 88px; min-height: 37px; padding: 0 13px; font-size: 12px; }
  .redthread-workbench .stage { grid-column: 1; grid-row: 2; width: auto; height: auto; padding: 12px 18px 8px; box-shadow: none; border-bottom: 1px solid var(--line); }
  .workbench-stage-head { margin-bottom: 10px; }
  .workbench-stage-head h1 { font-size: 16px; }
  .workbench-stage-eyebrow { display: none; }
  .workbench-canvas-size { font-size: 9px; }
  .workbench-canvas-hint { min-height: 15px; margin-top: 8px; font-size: 10px; }
  .redthread-workbench .controls { grid-column: 1; grid-row: 3; width: auto; height: auto; min-height: 0; border: 0; }
  .workbench-inspector-head { gap: 9px; padding: 14px 18px 10px; border: 0; }
  .workbench-step-number { font-size: 16px; }
  .workbench-inspector-head h2 { font-family: inherit; font-size: 14px; }
  .workbench-inspector-head p { display: none; }
  .redthread-workbench .controls > .section.active-step { padding: 0 18px 18px !important; }
  .redthread-workbench #mobileStepNav { grid-column: 1; grid-row: 4; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 5px; padding: 5px 10px env(safe-area-inset-bottom, 0px); overflow: hidden; border: 0; border-top: 1px solid var(--line); }
  .redthread-workbench .step-button { min-height: 52px; padding: 6px; gap: 3px; border-radius: 10px; font-size: 10px; }
  .redthread-workbench .step-button svg { width: 21px; height: 21px; }
  .redthread-workbench .mobile-segmented { margin-bottom: 12px; }
  .redthread-workbench .mobile-segmented button { min-height: 34px; font-size: 11px; }
  .redthread-workbench :is(input[type="text"], select) { font-size: 16px; }
  .redthread-workbench .cutout-icon-bar { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .redthread-workbench .cutout-icon-button { min-height: 64px; padding: 7px 3px; }
  .redthread-workbench .hint { font-size: 10px; margin-top: 12px; }
  .redthread-workbench .paper-picker { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .redthread-workbench .paper-upload-swatch { min-height: 42px; }
  .redthread-workbench .paper-scroll-row { gap: 12px; }
  .redthread-workbench .preset-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
  .redthread-workbench .preset-card { min-height: 40px; font-size: 10px; }
  .redthread-workbench .style-color-grid.mobile-selected { grid-template-columns: 1fr 1fr; gap: 14px; }
  .redthread-workbench .controls [data-step="5"] > .two { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px !important; }
  .redthread-workbench .mask-confirm-button { width: 34px; height: 34px; top: 9px; right: 9px; font-size: 20px; }
}
@media (max-width: 760px) and (max-height: 500px) and (orientation: landscape) {
  .redthread-workbench { grid-template-columns: 62px minmax(0,1fr) 280px; grid-template-rows: 54px minmax(0,1fr); }
  .workbench-topbar { grid-column: 1 / -1; }
  .redthread-workbench #mobileStepNav { grid-column: 1; grid-row: 2; display: flex; gap: 3px; padding: 6px; border-top: 0; border-right: 1px solid var(--line); overflow-y: auto; }
  .redthread-workbench .stage { grid-column: 2; grid-row: 2; padding: 10px 14px; border: 0; }
  .redthread-workbench .controls { grid-column: 3; grid-row: 2; border-left: 1px solid var(--line); }
  .workbench-canvas-size, .workbench-canvas-hint { display: none; }
  .redthread-workbench .cutout-icon-bar { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .redthread-workbench *, .redthread-workbench *::before { transition: none !important; }
}
