:root {
  --cutout-bg: #091222;
  --cutout-panel: rgba(15, 25, 43, 0.96);
  --cutout-line: rgba(133, 162, 202, 0.22);
  --cutout-text: #eef5ff;
  --cutout-muted: #91a3bb;
  --cutout-blue: #4b8cff;
  --cutout-cyan: #20d5e8;
  --cutout-violet: #8264f4;
  --cutout-danger: #ff7680;
}

.cutout-workspace { gap: 16px; }
.cutout-panel { border: 1px solid var(--cutout-line); border-radius: 8px; background: var(--cutout-panel); box-shadow: 0 18px 44px rgba(0,0,0,.2); overflow: hidden; }
.cutout-intro { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: min(1380px, 100%); min-height: 128px; margin: 0 auto; padding: 18px; border-color: rgba(75,140,255,.38); }
.cutout-kicker { color: #72b6ff; font-size: 12px; font-weight: 850; letter-spacing: .08em; }
.cutout-intro h1 { margin: 7px 0 4px; color: var(--cutout-text); font-size: 40px; letter-spacing: 0; }
.cutout-intro p { margin: 0; color: var(--cutout-muted); line-height: 1.6; }
.cutout-intro .credit-pill { flex: 0 0 auto; }

.cutout-steps { display: grid; grid-template-columns: repeat(4, 1fr); width: min(1380px, 100%); margin: 16px auto; border: 1px solid var(--cutout-line); border-radius: 10px; background: rgba(11,21,38,.86); overflow: hidden; }
.cutout-steps > div { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 48px; padding: 0 14px; border-right: 1px solid var(--cutout-line); color: #70839d; }
.cutout-steps > div:last-child { border-right: 0; }
.cutout-steps b { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid #41516a; border-radius: 50%; font-size: 11px; }
.cutout-steps span { display: grid; color: #b8c7da; font-size: 12px; font-weight: 760; }
.cutout-steps small { margin-top: 2px; color: #71849e; font-size: 10px; font-weight: 600; }
.cutout-steps .active { background: #12223a; color: #fff; }
.cutout-steps .active b { border-color: #4b8cff; background: #4b8cff; color: #fff; }
.cutout-steps .done b { border-color: #14584c; background: #14584c; color: #69f0c1; }

.cutout-board { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; width: min(1380px, 100%); margin: 0 auto 16px; }
.cutout-main { min-width: 0; }
.cutout-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 12px 15px; border-bottom: 1px solid rgba(133,162,202,.15); }
.cutout-panel-head h2 { margin: 0; color: var(--cutout-text); font-size: 15px; }
.cutout-panel-head small { color: var(--cutout-muted); font-size: 11px; }
.cutout-preview-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.cutout-btn, .cutout-segmented button, .cutout-mode-grid button, .cutout-brush-modes button { min-height: 36px; border: 1px solid #2d4361; border-radius: 8px; padding: 0 13px; background: #14233a; color: #dce8f8; font: inherit; font-size: 12px; font-weight: 760; cursor: pointer; }
.cutout-btn:hover:not(:disabled), .cutout-mode-grid button:hover, .cutout-brush-modes button:hover { border-color: #4e719d; background: #192b47; }
.cutout-btn.primary { border-color: transparent; background: linear-gradient(90deg, #3d83f5, #7a60ef); color: #fff; }
.cutout-btn.send { border-color: rgba(32,213,232,.48); color: #bbf8ff; }
.cutout-btn.subtle { background: transparent; }
.cutout-btn.wide { width: 100%; }
.cutout-btn:disabled { opacity: .42; cursor: not-allowed; }
.cutout-segmented { display: flex; border: 1px solid #2d4361; border-radius: 9px; padding: 2px; background: #0a1425; }
.cutout-segmented button { min-height: 30px; border: 0; border-radius: 6px; padding: 0 9px; background: transparent; color: #8193aa; }
.cutout-segmented button.active { background: #29466e; color: #f5f9ff; }

.cutout-preview-layout { display: grid; grid-template-columns: 116px minmax(0, 1fr); min-height: 520px; }
.cutout-batch-rail { display: flex; min-width: 0; height: 520px; flex-direction: column; border-right: 1px solid var(--cutout-line); padding: 10px 8px; background: #0b1424; }
.cutout-batch-title { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 8px; color: #8da0b9; font-size: 10px; font-weight: 760; }
.cutout-batch-title b { color: #dfe9f6; }
.cutout-batch-list { display: grid; align-content: start; flex: 0 1 auto; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.cutout-batch-item { position: relative; width: 100%; aspect-ratio: 1; border: 1px solid #2b3c57; border-radius: 6px; padding: 3px; background: #0f1a2d; cursor: pointer; overflow: hidden; }
.cutout-batch-item.active { border-color: var(--cutout-cyan); box-shadow: 0 0 0 1px var(--cutout-cyan); }
.cutout-batch-item img { width: 100%; height: 100%; border-radius: 4px; object-fit: contain; }
.cutout-batch-state { position: absolute; right: 3px; bottom: 3px; min-width: 23px; border-radius: 4px; padding: 3px 4px; background: rgba(7,13,24,.9); color: #a9b8cb; font-size: 8px; font-weight: 850; text-align: center; }
.cutout-batch-item > i { position: absolute; top: 4px; right: 4px; display: none; width: 18px; height: 18px; border-radius: 4px; background: rgba(7,13,24,.88); color: #dce8f8; font-size: 13px; font-style: normal; line-height: 18px; text-align: center; }
.cutout-batch-item:hover > i { display: block; }
.cutout-batch-item[data-status="done"] .cutout-batch-state { color: #59e2ae; }
.cutout-batch-item[data-status="failed"] .cutout-batch-state { color: #ff8c94; }
.cutout-batch-item[data-status="processing"] .cutout-batch-state { color: #7fe8f6; }
.cutout-batch-add { display: grid; place-items: center; width: 100%; min-height: 38px; margin-top: 8px; border: 1px dashed #3a5576; border-radius: 6px; background: transparent; color: #8fa4bd; font-size: 20px; cursor: pointer; }

.cutout-canvas-wrap { position: relative; display: grid; place-items: center; min-width: 0; min-height: 520px; overflow: hidden; background-color: #172235; user-select: none; }
.cutout-canvas-wrap.checker { background-image: linear-gradient(45deg,#d8dde4 25%,transparent 25%),linear-gradient(-45deg,#d8dde4 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#d8dde4 75%),linear-gradient(-45deg,transparent 75%,#d8dde4 75%); background-position: 0 0,0 10px,10px -10px,-10px 0; background-size: 20px 20px; background-color: #f4f6f8; }
.cutout-canvas-wrap.white { background: #fff; }
.cutout-canvas-wrap.solid { background: #cfd8e6; }
.cutout-canvas-wrap.is-empty { background: radial-gradient(circle at center, rgba(96,165,250,.12), transparent 48%), rgba(2,6,23,.22); }
.cutout-empty { position: absolute; inset: 16px; z-index: 20; display: grid; place-items: center; border: 1px dashed rgba(148,163,184,.42); border-radius: 16px; background: linear-gradient(135deg, rgba(37,99,235,.14), rgba(15,23,42,.9)), rgba(2,6,23,.82); color: #92a6c1; cursor: pointer; }
.cutout-empty-inner { display: grid; justify-items: center; gap: 8px; max-width: 360px; padding: 28px; text-align: center; }
.cutout-empty strong { color: var(--cutout-text); font-size: 18px; }
.cutout-empty span:last-child { color: var(--cutout-muted); font-size: 13px; line-height: 1.5; }
.cutout-upload-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: rgba(96,165,250,.14); color: #bfdbfe; font-size: 28px; }
.cutout-stage { position: relative; transform: translate(var(--pan-x, 0px), var(--pan-y, 0px)) scale(var(--zoom, 1)); transform-origin: center; touch-action: none; }
.cutout-preview-image { display: block; max-width: min(680px, calc(100vw - 520px)); max-height: 455px; object-fit: contain; }
#cutoutResultCanvas { cursor: crosshair; }
.cutout-canvas-badge { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 150px); border-radius: 6px; padding: 6px 9px; background: rgba(7,14,25,.8); color: #c9d8e9; font-size: 10px; }
.cutout-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; border: 1px solid #314766; border-radius: 8px; background: rgba(8,17,31,.92); overflow: hidden; }
.cutout-zoom button { width: 34px; height: 32px; border: 0; background: transparent; color: #d9e7f8; font-size: 18px; cursor: pointer; }
.cutout-zoom span { min-width: 46px; color: #b9cbe0; font-size: 10px; font-weight: 800; text-align: center; }
.cutout-processing { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(6,14,27,.72); backdrop-filter: blur(3px); }
.cutout-processing > div { display: grid; place-items: center; gap: 10px; width: 220px; color: #fff; }
.cutout-processing i { width: 100%; height: 4px; border-radius: 99px; background: rgba(255,255,255,.16); overflow: hidden; }
.cutout-processing i b { display: block; width: 24%; height: 100%; background: var(--cutout-cyan); transition: width .3s; }
.cutout-spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.22); border-top-color: var(--cutout-cyan); border-radius: 50%; animation: cutout-spin .8s linear infinite; }
@keyframes cutout-spin { to { transform: rotate(360deg); } }
.cutout-statusbar { display: flex; justify-content: space-between; gap: 12px; min-height: 44px; padding: 12px 14px; border-top: 1px solid var(--cutout-line); color: #91a4bd; font-size: 11px; }
.cutout-statusbar .ok { display: inline-flex; align-items: center; gap: 7px; color: #a8e7cd; }
.cutout-statusbar .ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #36d399; }
.cutout-statusbar .processing { color: #75dfff; }
.cutout-statusbar .failed { color: var(--cutout-danger); }

.cutout-side { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; position: sticky; top: 12px; height: 622px; }
.cutout-side-scroll { display: grid; grid-auto-rows: max-content; align-content: start; gap: 12px; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.cutout-section { display: grid; gap: 12px; padding: 14px; }
.cutout-section-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: -2px; color: #c7d4e5; font-size: 12px; font-weight: 800; }
.cutout-section-label small { color: var(--cutout-muted); font-size: 10px; font-weight: 500; }
.cutout-mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cutout-mode-grid button { display: grid; align-content: center; gap: 4px; min-height: 82px; padding: 10px; text-align: left; }
.cutout-mode-grid button strong { color: #e9f2ff; font-size: 12px; }
.cutout-mode-grid button span { color: #8093aa; font-size: 10px; line-height: 1.4; }
.cutout-mode-grid button.active { border-color: var(--cutout-cyan); background: rgba(32,213,232,.08); }
.cutout-field { display: grid; gap: 6px; color: #aebed1; font-size: 11px; font-weight: 700; }
.cutout-field input, .cutout-field select { width: 100%; min-height: 38px; border: 1px solid #304766; border-radius: 7px; padding: 0 10px; background: #0d182a; color: #eef5ff; font: inherit; }
.cutout-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; color: #c5d2e2; font-size: 12px; }
.cutout-switch { position: relative; flex: 0 0 auto; width: 38px; height: 22px; }
.cutout-switch input { position: absolute; opacity: 0; }
.cutout-switch i { position: absolute; inset: 0; border-radius: 11px; background: #344057; cursor: pointer; }
.cutout-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .16s ease; }
.cutout-switch input:checked + i { background: var(--cutout-blue); }
.cutout-switch input:checked + i::after { transform: translateX(16px); }
.cutout-run-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: -4px; color: #7589a2; font-size: 10px; }
.cutout-candidates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }
.cutout-candidate { position: relative; aspect-ratio: 1; border: 1px solid #304766; border-radius: 7px; padding: 3px; background: #0b1628; cursor: pointer; overflow: hidden; }
.cutout-candidate.active { border-color: var(--cutout-cyan); box-shadow: 0 0 0 1px var(--cutout-cyan); }
.cutout-candidate img { width: 100%; height: 100%; object-fit: contain; }
.cutout-candidate span { position: absolute; right: 3px; bottom: 3px; border-radius: 4px; padding: 2px 4px; background: rgba(4,10,20,.86); color: #d8faff; font-size: 8px; }
.cutout-brush-modes, .cutout-mini-actions, .cutout-batch-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cutout-brush-modes button.active { border-color: var(--cutout-cyan); color: #c5fbff; }
.cutout-range { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; color: #aebed1; font-size: 11px; }
.cutout-range input { width: 100%; accent-color: var(--cutout-cyan); }
.cutout-action-panel { z-index: 2; flex: 0 0 auto; }
.cutout-primary-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
.cutout-primary-actions > .cutout-btn { min-height: 43px; }
.cutout-primary-actions > .cutout-btn.send, .cutout-primary-actions > .cutout-batch-actions { grid-column: 1 / -1; }

.cutout-history { width: min(1380px, 100%); margin: 0 auto 48px; }
.cutout-history .cutout-panel-head > div { display: grid; gap: 4px; }
.cutout-history-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: start; gap: 12px; padding: 14px; }
.cutout-history-empty { grid-column: 1 / -1; display: grid; place-items: center; min-height: 110px; border: 1px dashed #304766; border-radius: 8px; color: var(--cutout-muted); font-size: 12px; }
.cutout-history-item { align-self: start; display: grid; min-width: 0; border: 1px solid #2b3f5b; border-radius: 7px; background: #0a1527; overflow: hidden; }
.cutout-history-thumb { position: relative; display: grid; place-items: center; width: 100%; min-height: 0; aspect-ratio: 1; overflow: hidden; border: 0; border-bottom: 1px solid #263b58; padding: 7px; background-color: #f4f6f8; background-image: linear-gradient(45deg,#d8dde4 25%,transparent 25%),linear-gradient(-45deg,#d8dde4 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#d8dde4 75%),linear-gradient(-45deg,transparent 75%,#d8dde4 75%); background-position: 0 0,0 8px,8px -8px,-8px 0; background-size: 16px 16px; cursor: pointer; }
.cutout-history-thumb img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.cutout-history-info { display: grid; align-content: start; gap: 3px; min-width: 0; min-height: 48px; padding: 9px 9px 4px; }
.cutout-history-info strong { overflow: hidden; color: #e8f1fd; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.cutout-history-info small { color: #758aa5; font-size: 9px; }
.cutout-history-actions { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 7px 9px 9px; }
.cutout-history-actions button { min-height: 30px; border: 1px solid #304766; border-radius: 6px; background: #12213a; color: #d7e5f7; font: inherit; font-size: 10px; font-weight: 760; cursor: pointer; }
.cutout-history-actions button:last-child { width: 34px; color: #bdf8ff; }
.cutout-history-actions button:hover { border-color: #4f719c; background: #182c49; }

.cutout-modal[hidden] { display: none; }
.cutout-modal { position: fixed; inset: 0; z-index: 10020; display: grid; place-items: center; padding: 20px; background: rgba(3,8,18,.74); }
.cutout-dialog { width: min(720px, 94vw); max-height: 80vh; border: 1px solid #314866; border-radius: 12px; background: #101b2e; box-shadow: 0 24px 70px rgba(0,0,0,.48); overflow: auto; }
.cutout-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--cutout-line); }
.cutout-dialog-head h2 { margin: 0; color: #f1f6ff; font-size: 15px; }
.cutout-dialog-head button { width: 32px; height: 32px; border: 0; background: transparent; color: #a9bbd0; font-size: 22px; cursor: pointer; }
.cutout-works-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 14px; }
.cutout-work-option { display: grid; gap: 6px; border: 1px solid #2b3f5b; border-radius: 7px; padding: 5px; background: #0a1527; color: #b8c8dc; cursor: pointer; }
.cutout-work-option img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.cutout-work-option span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.cutout-send-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
.cutout-send-options button { display: grid; gap: 5px; min-height: 74px; border: 1px solid #2e4564; border-radius: 8px; padding: 12px; background: #111f35; color: #e5effc; text-align: left; cursor: pointer; }
.cutout-send-options button span { color: #8498b2; font-size: 10px; }
.cutout-send-options button:disabled { opacity: .45; cursor: not-allowed; }
.cutout-send-step { padding: 14px; }
.cutout-send-step > p { margin: 10px 0 0; color: #a8bad0; font-size: 11px; line-height: 1.6; }
.cutout-send-step > small { display: block; margin-top: 10px; color: #7388a4; font-size: 10px; }
.cutout-send-step .cutout-send-options { padding: 12px 0 0; }
.cutout-send-back { border: 0; padding: 0; background: transparent; color: #7fcce8; font: inherit; font-size: 11px; font-weight: 760; cursor: pointer; }
.cutout-send-mode-options button { min-height: 92px; }
.cutout-send-mode-options button:hover { border-color: #21c5df; background: #132943; }
.cutout-toast { position: fixed; z-index: 10040; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); border: 1px solid #365477; border-radius: 8px; padding: 11px 14px; background: #101d31; color: #e8f2ff; font-size: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.42); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.cutout-toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .cutout-board { grid-template-columns: minmax(0, 1fr) 310px; }
  .cutout-preview-image { max-width: min(560px, calc(100vw - 450px)); }
  .cutout-history-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .cutout-intro, .cutout-steps, .cutout-board, .cutout-history { width: calc(100vw - 36px); }
  .cutout-intro { align-items: flex-start; min-height: 0; }
  .cutout-intro h1 { font-size: 30px; }
  .cutout-steps { grid-template-columns: 1fr 1fr; }
  .cutout-steps > div:nth-child(2) { border-right: 0; }
  .cutout-board { grid-template-columns: 1fr; }
  .cutout-side { position: static; height: auto; }
  .cutout-side-scroll { overflow: visible; }
  .cutout-preview-layout { grid-template-columns: 1fr; min-height: 0; }
  .cutout-batch-rail { display: grid; grid-template-columns: minmax(0,1fr) 44px; grid-template-rows: auto auto; gap: 7px; height: auto; border-right: 0; border-bottom: 1px solid var(--cutout-line); }
  .cutout-batch-title { grid-column: 1 / -1; margin: 0; }
  .cutout-batch-list { display: flex; overflow-x: auto; overflow-y: hidden; }
  .cutout-batch-item { flex: 0 0 62px; }
  .cutout-batch-add { width: 44px; min-height: 44px; margin: 0; }
  .cutout-canvas-wrap { min-height: 390px; }
  .cutout-preview-image { max-width: 92vw; max-height: 350px; }
  .cutout-works-list { grid-template-columns: repeat(3, 1fr); }
  .cutout-history-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .cutout-intro { display: grid; }
  .cutout-intro .credit-pill { justify-self: start; }
  .cutout-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cutout-steps > div { justify-content: center; gap: 5px; min-width: 0; padding: 0 4px; border-right: 1px solid var(--cutout-line); }
  .cutout-steps > div:last-child { border-right: 0; }
  .cutout-steps b { flex: 0 0 auto; width: 20px; height: 20px; }
  .cutout-steps span { display: block; min-width: 0; font-size: 10px; white-space: nowrap; }
  .cutout-steps small { display: none; }
  .cutout-panel-head { align-items: flex-start; }
  .cutout-main > .cutout-panel-head { display: grid; }
  .cutout-preview-actions { display: grid; grid-template-columns: 1fr 1fr; justify-content: stretch; width: 100%; }
  .cutout-preview-actions > .cutout-segmented { grid-column: 1 / -1; }
  .cutout-preview-actions > .cutout-btn { min-width: 0; padding: 0 8px; }
  .cutout-segmented { width: 100%; }
  .cutout-segmented button { flex: 1; }
  .cutout-statusbar { display: grid; line-height: 1.5; }
  .cutout-send-options, .cutout-works-list { grid-template-columns: 1fr 1fr; }
  .cutout-history-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
