/* cutout: the background-removal editor. A dark booth around the picture, like a control room's monitor wall:
   the picture is the only bright thing, the active tool has the red "on air" light. Loaded after app.css. */
.cx-host { position: fixed; inset: 0; z-index: 1000; }
.cx { --cx-bg: #0e0e0f; --cx-panel: #161618; --cx-raise: #1f1f22; --cx-line: #29292d; --cx-line2: #3a3a3f; --cx-text: #ededee; --cx-dim: #9a9aa2; --cx-red: #e3262b;
  position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--cx-bg); color: var(--cx-text); font-family: var(--body); font-size: 14px;
  opacity: 0; transition: opacity var(--mid) var(--ease); user-select: none; -webkit-user-select: none; }
.cx.in { opacity: 1; }
.cx.out { opacity: 0; transition-duration: .2s; }
.cx button { font: inherit; color: inherit; }
.cx .ic { flex: none; }
.cx bdi { unicode-bidi: isolate; }

/* ---------- top bar */
.cx-top { height: 56px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; background: var(--cx-panel); border-bottom: 1px solid var(--cx-line); }
.cx-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; padding-inline-start: 4px; }
.cx-title b { font-family: var(--head); font-weight: 400; font-size: 18px; white-space: nowrap; }
.cx-name { color: var(--cx-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 26vw; }
.cx-grow { flex: 1; }
.cx-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-inline-start: 1px solid var(--cx-line); }
.cx-ib { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: none; cursor: pointer;
  transition: background var(--fast), color var(--fast), transform var(--fast), opacity var(--fast); }
.cx-ib:hover { background: var(--cx-raise); }
.cx-ib:active { transform: scale(.92); }
.cx-ib:disabled { opacity: .3; pointer-events: none; }
.cx-ib.on { background: var(--cx-text); color: var(--cx-bg); }
.cx-ib.sm { width: 30px; height: 30px; border-radius: 8px; }
.cx-zv { min-width: 58px; height: 32px; border: 1px solid var(--cx-line2); border-radius: 8px; background: none; cursor: pointer; font-variant-numeric: tabular-nums; font-size: 13px; transition: background var(--fast); }
.cx-zv:hover { background: var(--cx-raise); }
.cx-save { width: 52px; height: 40px; margin-inline-start: 6px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: var(--cx-red); color: #fff; cursor: pointer;
  box-shadow: 0 0 0 0 rgba(227, 38, 43, .5); transition: transform var(--fast), opacity var(--fast), box-shadow var(--mid); }
.cx-save:hover { box-shadow: 0 0 0 4px rgba(227, 38, 43, .22); }
.cx-save:active { transform: scale(.94); }
.cx-save:disabled { opacity: .35; pointer-events: none; }
/* a small working light next to the title while the worker is busy */
.cx-work { width: 8px; height: 8px; border-radius: 50%; background: var(--cx-red); align-self: center; opacity: 0; transform: scale(.4); transition: opacity var(--fast), transform var(--fast); }
.cx-work.on { opacity: 1; transform: none; animation: pulse 1s infinite; }

/* ---------- the three columns */
.cx-body { flex: 1; min-height: 0; display: flex; }
.cx-tools { flex: none; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; background: var(--cx-panel); border-inline-end: 1px solid var(--cx-line); overflow-y: auto; }
.cx-tool { position: relative; width: 46px; height: 46px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; background: none; color: var(--cx-dim); cursor: pointer;
  transition: background var(--fast), color var(--fast), transform var(--fast); animation: rise var(--mid) var(--ease) backwards; animation-delay: calc(var(--i, 0) * 30ms); }
.cx-tool:hover { background: var(--cx-raise); color: var(--cx-text); }
.cx-tool:active { transform: scale(.92); }
.cx-tool:disabled { opacity: .3; }
.cx-tool.on { background: var(--cx-raise); color: var(--cx-text); }
/* the tally light of the active tool */
.cx-tool::before { content: ''; position: absolute; inset-inline-start: -9px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--cx-red); box-shadow: 0 0 10px var(--cx-red);
  transform: scaleY(0); transition: transform var(--mid) var(--ease); }
.cx-tool.on::before { transform: none; }

/* ---------- the picture */
.cx-stage { position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none; cursor: crosshair;
  background: radial-gradient(circle at 1px 1px, #1c1c1f 1px, transparent 1.5px) 0 0 / 22px 22px, #101012; }
.cx-stage.tool-erase, .cx-stage.tool-restore, .cx-stage.tool-mark, .cx-stage.tool-edge { cursor: none; }
.cx-stage.tool-hand, .cx-stage.tool-auto, .cx-stage.grab { cursor: grab; }
.cx-stage.grabbing { cursor: grabbing; }
.cx-wrap { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; animation: cxIn .42s var(--ease) backwards; }
.cx-wrap.anim { transition: transform var(--mid) var(--ease); }
@keyframes cxIn { from { opacity: 0; } to { opacity: 1; } }
.cx-wrap canvas { position: absolute; top: 0; left: 0; display: block; }
.cx-cv { box-shadow: 0 0 0 var(--px, 1px) rgba(255, 255, 255, .08), 0 calc(20 * var(--px, 1px)) calc(60 * var(--px, 1px)) rgba(0, 0, 0, .55); transition: background-color var(--mid); }
.cx-cv.checker { background: conic-gradient(#d4d4d6 25%, #f4f4f5 0 50%, #d4d4d6 0 75%, #f4f4f5 0) 0 0 / var(--ck, 24px) var(--ck, 24px); }
.cx-oc { opacity: 0; transition: opacity var(--fast); pointer-events: none; }
.cx-oc.on { opacity: 1; }
.cx-oc.full { clip-path: none !important; }
.cx-mc { pointer-events: none; }
.cx-wrap.pixels canvas { image-rendering: pixelated; }
.cx-svg { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.cx-svg * { vector-effect: non-scaling-stroke; fill: none; }
.cx-ring { stroke: #fff; stroke-width: 1.5; }
.cx-ring2 { stroke: rgba(0, 0, 0, .7); stroke-width: 3.5; }
.cx-lpath2 { stroke: #000; stroke-width: 2; }
.cx-lpath { stroke: #fff; stroke-width: 2; stroke-dasharray: 6 5; animation: cxAnts .6s linear infinite; }
.cx-lfirst { stroke: #fff; stroke-width: 2; fill: var(--cx-red) !important; }
@keyframes cxAnts { to { stroke-dashoffset: -11; } }

.cx-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--cx-dim); text-align: center; padding: 24px; animation: fade var(--mid); }
.cx-fail { color: var(--cx-text); }
.cx-fail > span { max-width: 360px; }
.cx-spin { width: 26px; height: 26px; border: 2px solid var(--cx-line2); border-top-color: var(--cx-red); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.cx-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 10, 11, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade var(--mid); z-index: 5; }
.cx-busy-in { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 260px; padding: 22px 26px; background: var(--cx-panel); border: 1px solid var(--cx-line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); animation: rise var(--mid) var(--ease) backwards; }
.cx-bar { width: 100%; height: 4px; border-radius: 2px; background: var(--cx-line); overflow: hidden; }
.cx-bar i { display: block; height: 100%; background: var(--cx-red); transform-origin: right; transition: transform .2s linear; }
.cx-mb { color: var(--cx-dim); font-size: 12px; font-variant-numeric: tabular-nums; }

/* the line under the picture that says what the active tool does */
.cx-hint { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 28px); padding: 7px 14px; border-radius: 20px; background: rgba(22, 22, 24, .86); border: 1px solid var(--cx-line);
  color: var(--cx-dim); font-size: 13px; text-align: center; pointer-events: none; animation: cxHint var(--mid) var(--ease) backwards; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.cx-hint b { color: var(--cx-text); font-weight: 600; }
@keyframes cxHintOut { to { opacity: 0; } }
@keyframes cxHint { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translateX(-50%); } }
.cx-msg { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(560px, calc(100% - 28px)); display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 12px;
  background: var(--cx-raise); border: 1px solid var(--cx-line2); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .45); animation: cxDrop var(--mid) var(--ease) backwards; z-index: 6; font-size: 13.5px; }
.cx-msg.err { border-color: rgba(227, 38, 43, .6); }
.cx-msg.err > .ic { color: var(--cx-red); }
.cx-msg > span { flex: 1; }
@keyframes cxDrop { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translateX(-50%); } }
.cx-ask { position: absolute; top: 14px; left: 50%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 10px 12px; width: max-content; max-width: calc(100% - 28px);
  background: var(--cx-raise); border: 1px solid var(--cx-line2); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); z-index: 7;
  transform: translate(-50%, -140%); opacity: 0; pointer-events: none; transition: transform var(--mid) var(--ease), opacity var(--mid); }
.cx-ask.in { transform: translateX(-50%); opacity: 1; pointer-events: auto; }

/* the before / after divider */
.cx-div { position: absolute; top: 0; bottom: 0; width: 0; z-index: 4; cursor: ew-resize; touch-action: none; animation: fade var(--mid); }
.cx-div::before { content: ''; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.cx-div::after { content: ''; position: absolute; top: 0; bottom: 0; left: -14px; width: 28px; }
.cx-div-h { position: absolute; top: 50%; left: 0; transform: translate(-50%, -50%); width: 36px; height: 36px; border-radius: 50%; background: #fff; color: #111; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(0, 0, 0, .4); z-index: 1; }
.cx-div-l, .cx-div-r { position: absolute; top: 12px; padding: 3px 9px; border-radius: 10px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; white-space: nowrap; }
.cx-div-l { right: 10px; } .cx-div-r { left: 10px; }

/* ---------- the options panel */
.cx-panel { flex: none; width: 300px; background: var(--cx-panel); border-inline-start: 1px solid var(--cx-line); display: flex; flex-direction: column; min-height: 0; }
.cx-panel-tab { display: none; }
.cx-panel-in { flex: 1; overflow-y: auto; padding: 4px 16px 24px; overscroll-behavior: contain; }
.cx-sec { padding: 14px 0 16px; border-bottom: 1px solid var(--cx-line); }
.cx-sec:last-child { border-bottom: 0; }
.cx-sec h3 { display: flex; align-items: center; gap: 8px; font-family: var(--head); font-size: 15px; margin-bottom: 12px; color: var(--cx-text); }
.cx-sec h3 .ic { color: var(--cx-dim); }
.cx-opts > * { animation: rise var(--mid) var(--ease) backwards; }
.cx-opts > *:nth-child(2) { animation-delay: 30ms; } .cx-opts > *:nth-child(3) { animation-delay: 60ms; } .cx-opts > *:nth-child(4) { animation-delay: 90ms; } .cx-opts > *:nth-child(5) { animation-delay: 120ms; }
.cx-note { margin: 8px 0 0; color: var(--cx-dim); font-size: 12.5px; line-height: 1.5; }
.cx-row { display: flex; gap: 8px; margin-top: 12px; }
.cx-row .cx-btn { flex: 1; justify-content: center; }

.cx-cards { display: grid; gap: 8px; margin-bottom: 14px; }
.cx-card { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto auto; column-gap: 10px; align-items: center; text-align: start; padding: 12px; border: 1px solid var(--cx-line2); border-radius: 12px; background: var(--cx-raise); cursor: pointer;
  transition: border-color var(--fast), background var(--fast), transform var(--fast); }
.cx-card:hover { border-color: var(--cx-text); }
.cx-card:active { transform: scale(.98); }
.cx-card:disabled { opacity: .4; pointer-events: none; }
.cx-card .ic { grid-row: 1 / span 3; color: var(--cx-text); }
.cx-card b { font-weight: 600; font-size: 14.5px; }
.cx-card small { color: var(--cx-dim); font-size: 12.5px; line-height: 1.4; }
.cx-card em { font-style: normal; color: var(--cx-dim); font-size: 11.5px; margin-top: 3px; opacity: .8; }

.cx-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border: 1px solid var(--cx-line2); border-radius: 9px; background: var(--cx-raise); cursor: pointer; white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), transform var(--fast), opacity var(--fast); }
.cx-btn:hover { border-color: var(--cx-text); }
.cx-btn:active { transform: scale(.96); }
.cx-btn:disabled { opacity: .35; pointer-events: none; }
.cx-btn.sm { height: 30px; padding: 0 9px; font-size: 13px; }
.cx-btn.wide { width: 100%; justify-content: center; margin-top: 4px; white-space: normal; height: auto; min-height: 36px; padding: 6px 12px; }
.cx-btn.danger { background: var(--cx-red); border-color: var(--cx-red); color: #fff; }

/* slider: a thin line with a white knob */
.cx-slider { display: block; margin: 0 0 14px; }
.cx-sl-top { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--cx-dim); margin-bottom: 4px; }
.cx-sl-top span { flex: 1; }
.cx-sl-top b { color: var(--cx-text); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.cx-track { position: relative; display: block; height: 26px; }
.cx-track::before { content: ''; position: absolute; inset-inline: 0; top: 11px; height: 4px; border-radius: 2px; background: var(--cx-line2); }
.cx-track i { position: absolute; top: 11px; height: 4px; border-radius: 2px; background: var(--cx-text); transition: width .08s linear; }
.cx-track input { position: absolute; inset: 0; width: 100%; height: 26px; margin: 0; background: none; -webkit-appearance: none; appearance: none; cursor: pointer; }
.cx-track input:focus { outline: none; box-shadow: none; }
.cx-track input::-webkit-slider-runnable-track { height: 26px; background: none; }
.cx-track input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: 4px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(255, 255, 255, .0), 0 2px 6px rgba(0, 0, 0, .5); transition: box-shadow var(--fast), transform var(--fast); }
.cx-track input:hover::-webkit-slider-thumb, .cx-track input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(255, 255, 255, .16), 0 2px 6px rgba(0, 0, 0, .5); }
.cx-track input:active::-webkit-slider-thumb { transform: scale(1.12); }
.cx-track input::-moz-range-track { height: 4px; background: none; }
.cx-track input::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }

/* segmented choice with a sliding light */
.cx-seg { position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); padding: 3px; margin-bottom: 14px; border-radius: 11px; background: var(--cx-bg); border: 1px solid var(--cx-line); }
.cx-seg-pill { position: absolute; top: 3px; bottom: 3px; inset-inline-start: 3px; width: calc((100% - 6px) / var(--n)); border-radius: 8px; background: var(--cx-raise); box-shadow: inset 0 0 0 1px var(--cx-line2);
  transform: translateX(calc(var(--k) * -100%)); transition: transform var(--mid) var(--ease); }
.cx-seg button { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 4px 6px; border: 0; background: none; color: var(--cx-dim); cursor: pointer; font-size: 13px; line-height: 1.25; transition: color var(--fast); }
.cx-seg button.on { color: var(--cx-text); }
.cx-seg button.keep.on .ic { color: #46d678; }
.cx-seg button.drop.on .ic { color: #ff5050; }

.cx-toggle { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 0; border: 0; background: none; cursor: pointer; text-align: start; color: var(--cx-dim); font-size: 13.5px; transition: color var(--fast); }
.cx-toggle span { flex: 1; }
.cx-toggle.on { color: var(--cx-text); }
.cx-toggle i { position: relative; width: 36px; height: 20px; flex: none; border-radius: 10px; background: var(--cx-line2); transition: background var(--mid); }
.cx-toggle i::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--mid) var(--ease); }
.cx-toggle.on i { background: var(--cx-red); }
.cx-toggle.on i::after { transform: translateX(-16px); }

.cx-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.cx-sw { width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); transition: transform var(--fast), box-shadow var(--fast); }
.cx-sw:hover { transform: scale(1.1); }
.cx-sw.on { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 0 0 2px var(--cx-panel), 0 0 0 4px var(--cx-text); }
.cx-sw.checker { background: conic-gradient(#cfcfd1 25%, #fff 0 50%, #cfcfd1 0 75%, #fff 0) 0 0 / 12px 12px; }

/* ---------- touch screens: bigger targets */
@media (pointer: coarse) {
  .cx-ib { width: 44px; height: 44px; }
  .cx-tool { width: 50px; height: 50px; }
  .cx-track, .cx-track input, .cx-track input::-webkit-slider-runnable-track { height: 32px; }
  .cx-track::before, .cx-track i { top: 14px; }
  .cx-track input::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: 4px; }
  .cx-sw { width: 36px; height: 36px; }
}

/* ---------- phone: tools along the bottom, options in a drawer above them */
@media (max-width: 760px) {
  .cx-top { height: 52px; padding: 0 4px; gap: 2px; }
  .cx-title b { font-size: 16px; }
  .cx-name, .cx-zoom .cx-zv, .cx-zoom .cx-ib:nth-child(1), .cx-zoom .cx-ib:nth-child(3) { display: none; }
  .cx-group { padding: 0 2px; border: 0; }
  .cx-save { width: 46px; margin-inline-start: 2px; }
  .cx-body { flex-direction: column; }
  .cx-stage { order: 1; }
  .cx-panel { order: 2; width: auto; border: 0; border-top: 1px solid var(--cx-line); max-height: 46vh; display: grid; grid-template-rows: auto 0fr; transition: grid-template-rows var(--mid) var(--ease); }
  .cx-panel.open { grid-template-rows: auto 1fr; }
  .cx-panel-in { min-height: 0; padding: 0 14px; }
  .cx-panel.open .cx-panel-in { padding-bottom: 14px; }
  .cx-panel-tab { display: flex; align-items: center; justify-content: center; gap: 4px; height: 30px; border: 0; background: none; color: var(--cx-dim); cursor: pointer; }
  .cx-panel-tab .ic:last-child { transition: transform var(--mid) var(--ease); transform: rotate(180deg); }
  .cx-panel.open .cx-panel-tab .ic:last-child { transform: none; }
  .cx-tools { order: 3; width: auto; flex-direction: row; justify-content: flex-start; padding: 6px 8px calc(6px + var(--safe-b)); border: 0; border-top: 1px solid var(--cx-line); overflow-x: auto; overflow-y: hidden; gap: 2px; }
  .cx-tool::before { inset-inline-start: 10px; inset-inline-end: 10px; top: -7px; bottom: auto; width: auto; height: 3px; transform: scaleX(0); }
  .cx-tool.on::before { transform: none; }
  .cx-hint { bottom: 8px; font-size: 12px; padding: 5px 11px; animation: cxHint var(--mid) var(--ease) backwards, cxHintOut .4s ease 6s forwards; }
  .cx-tool { width: 44px; height: 46px; }
  .cx-cards { grid-template-columns: repeat(3, 1fr); }
  .cx-card { grid-template-columns: 1fr; grid-template-rows: auto; justify-items: center; text-align: center; padding: 10px 6px; row-gap: 3px; }
  .cx-card .ic { grid-row: auto; }
  .cx-card small { display: none; }
}
