/* ═══════════════════════════════════════════════════════════════════
   proposal.css — Proposal Builder (own page, own stylesheet).
   Self-contained: tokens mirrored from style.css :root so the editor
   feels like AIP without loading the 500KB admin stylesheet. Impeccable
   MCP polish may land here later — keep tokens as the palette source.
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --bg: #12111a;
  --bg2: #0e0d14;
  --bg3: #1a1827;
  --surface: rgba(255, 255, 255, 0.04);
  --surface2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.13);
  --accent: #7C3AED;
  --accent2: #a78bfa;
  --text: #e8e6f0;
  --text2: #9b97ad;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.hidden { display: none !important; }

/* ── Buttons / inputs ── */
.btn {
  border: 1px solid var(--border2); background: var(--surface); color: var(--text);
  border-radius: 9px; padding: 8px 14px; font-size: .86rem; font-weight: 600;
}
.btn:hover { background: var(--surface2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #6d31d4; }
.btn-ghost { background: none; border-color: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-danger { color: var(--red); }
.pin { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: .72rem; font-weight: 700; border: 1px solid var(--border2); }
.pin-draft { color: var(--text2); }
.pin-sent { color: var(--accent2); border-color: rgba(167,139,250,.4); background: rgba(124,58,237,.12); }
.pin-completed { color: var(--green); border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.1); }
.pin-lost { color: var(--red); border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.08); }

.pfield { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pfield > span { font-size: .68rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.pfield input, .pfield select, .pfield textarea {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: .88rem; padding: 8px 10px; outline: none;
  width: 100%; min-width: 0;
}
.pfield input:focus, .pfield select:focus { border-color: var(--accent); }
.muted { color: var(--text2); }
.tnum { font-variant-numeric: tabular-nums; }

/* ── App frame ── */
#app { display: flex; flex-direction: column; height: 100vh; }
#topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--bg2); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
#topbar h1 { font-size: .95rem; margin: 0; font-weight: 700; white-space: nowrap; }
#p-title-input {
  background: none; border: 1px solid transparent; border-radius: 8px; color: var(--text);
  font-size: .95rem; font-weight: 700; padding: 4px 8px; min-width: 120px; max-width: 320px;
}
#p-title-input:hover { border-color: var(--border2); }
#p-title-input:focus { border-color: var(--accent); outline: none; background: var(--bg3); }
.tab-switch { display: flex; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.tab-switch button { border: none; background: none; color: var(--text2); border-radius: 8px; padding: 6px 16px; font-size: .82rem; font-weight: 700; }
.tab-switch button.on { background: var(--accent); color: #fff; }
#save-dot { font-size: .72rem; color: var(--text2); min-width: 64px; text-align: right; }

/* ── List screen ── */
#list-screen { padding: 28px; max-width: 1060px; margin: 0 auto; width: 100%; overflow-y: auto; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.list-head h1 { margin: 0; font-size: 1.25rem; }
#plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.pcard {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
}
.pcard:hover { border-color: var(--border2); }
.pcard .cover { aspect-ratio: 16/9; background: var(--bg2); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; overflow: hidden; }
.pcard .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .meta { padding: 11px 13px; display: flex; flex-direction: column; gap: 6px; }
.pcard .nm { font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .sub { font-size: .75rem; color: var(--text2); display: flex; justify-content: space-between; gap: 8px; align-items: center; }

/* ── Editor: 3 columns ── */
#editor-screen { flex: 1; display: flex; min-height: 0; }
#rail {
  width: 208px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
#rail .rail-head { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; }
#rail .rail-head span { font-size: .7rem; font-weight: 800; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; }
#slides { flex: 1; overflow-y: auto; padding: 4px 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.slide {
  border: 1px solid var(--border); border-radius: 11px; overflow: hidden; cursor: pointer;
  background: var(--bg3); position: relative; flex-shrink: 0;
}
.slide.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.slide img { width: 100%; height: auto; max-height: 170px; object-fit: cover; display: block; }
.slide.sel { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2); }
.slide.sel::after { content: '✓'; position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .62rem; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.slide.ind-top { box-shadow: 0 -3px 0 0 var(--accent); }
.slide.ind-bot { box-shadow: 0 3px 0 0 var(--accent); }
.slide-del {
  position: absolute; top: 6px; right: 6px; display: none;
  background: rgba(0,0,0,.55); border: none; border-radius: 7px; color: #fff;
  font-size: .72rem; padding: 3px 6px;
}
.slide:hover .slide-del { display: block; }
.slide-del:hover { background: var(--accent); }
.slide .cap { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: .74rem; }
.slide .cap .num { color: var(--text2); font-weight: 700; }
.slide .cap .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.slide .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-empty { background: var(--text2); opacity: .5; }
.dot-working { background: var(--amber); }
.dot-complete { background: var(--green); }

#stage-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#stage-tools { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
#stage { flex: 1; display: flex; align-items: safe center; justify-content: safe center; padding: 18px; min-height: 0; overflow: auto; }
#canvas-box { position: relative; max-width: 100%; max-height: 100%; user-select: none; }
#canvas-box > img#scene-img { max-width: 100%; max-height: calc(100vh - 250px); display: block; border-radius: 12px; }
#canvas-box.adding { cursor: crosshair; }
.plc {
  position: absolute; border: 2px solid var(--accent2); border-radius: 8px;
  background: rgba(124, 58, 237, 0.16); cursor: move;
}
.plc.on { border-color: #fff; background: rgba(124, 58, 237, 0.3); box-shadow: 0 0 0 1px var(--accent); }
.plc .tag {
  position: absolute; top: -22px; left: -2px; background: var(--accent); color: #fff;
  font-size: .66rem; font-weight: 800; border-radius: 6px; padding: 2px 7px; white-space: nowrap;
}
.plc .rs { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: nwse-resize; }
#slide-sum { padding: 8px 14px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text2); display: flex; gap: 18px; flex-wrap: wrap; }
#slide-sum b { color: var(--text); }

#panel {
  width: 316px; flex-shrink: 0; background: var(--bg2); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px;
}
.pcardlet { background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.pcardlet h3 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); display: flex; justify-content: space-between; align-items: center; }
.row2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 9px; }
.note { font-size: .7rem; color: var(--text2); line-height: 1.45; }
.pick-results { max-height: 190px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pick-results button { display: flex; width: 100%; justify-content: space-between; gap: 8px; background: none; border: none; border-bottom: 1px solid var(--border); color: var(--text); padding: 7px 10px; font-size: .82rem; text-align: left; }
.pick-results button:last-child { border-bottom: none; }
.pick-results button:hover { background: var(--surface2); }

/* ── Summary ── */
#summary-screen { flex: 1; overflow-y: auto; padding: 26px; }
.sum-wrap { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.stat .k { font-size: .68rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stat .v { font-size: 1.25rem; font-weight: 800; margin-top: 4px; }
.sum-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.sum-table th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); padding: 7px 9px; border-bottom: 1px solid var(--border2); }
.sum-table td { padding: 8px 9px; border-bottom: 1px solid var(--border); vertical-align: top; }
.sum-table td.r, .sum-table th.r { text-align: right; }
.alt { font-size: .74rem; color: var(--text2); }
.svc { display: flex; flex-direction: column; gap: 10px; }
.svc-row { display: flex; gap: 10px; align-items: flex-start; background: var(--bg2); border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px; flex-wrap: wrap; }
.svc-row.sel { border-color: var(--green); }
.svc-row .ttl { font-weight: 700; min-width: 150px; display: flex; align-items: center; gap: 8px; }
.internal-tag { font-size: .62rem; font-weight: 800; color: var(--amber); border: 1px solid rgba(251,191,36,.4); border-radius: 999px; padding: 1px 7px; }

/* ── Overlay modal ── */
.ov { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.ov .box { background: var(--bg3); border: 1px solid var(--border2); border-radius: 15px; width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 13px; }
.ov h2 { margin: 0; font-size: 1rem; }

/* ── Gate ── */
#gate { height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--text2); }

/* ── Toast ── */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--border2); color: var(--text); border-radius: 11px; padding: 10px 16px; font-size: .85rem; z-index: 99; box-shadow: 0 12px 32px rgba(0,0,0,.5); }

/* ── Print: the CLIENT VIEW — only #print-root renders. Internal-only
     values (interest %, costs) are never written into #print-root. ── */
#print-root { display: none; }
@media print {
  body { background: #fff; color: #111; }
  #app, #toast { display: none !important; }
  #print-root { display: block; font-size: 12px; color: #111; }
  #print-root h1 { font-size: 22px; margin: 0 0 2px; }
  #print-root .sub { color: #555; margin-bottom: 18px; }
  #print-root h2 { font-size: 14px; margin: 22px 0 8px; border-bottom: 1.5px solid #111; padding-bottom: 4px; }
  #print-root table { width: 100%; border-collapse: collapse; }
  #print-root th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: #555; padding: 5px 6px; border-bottom: 1px solid #999; }
  #print-root td { padding: 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
  #print-root td.r, #print-root th.r { text-align: right; }
  #print-root .photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  #print-root .photos figure { margin: 0; break-inside: avoid; }
  #print-root .photos img { width: 100%; border-radius: 6px; }
  #print-root .photos figcaption { font-size: 10px; color: #555; margin-top: 3px; }
  #print-root .totals td { font-weight: 700; }
  #print-root .svc-p { border: 1px solid #ccc; border-radius: 8px; padding: 9px 12px; margin-bottom: 8px; break-inside: avoid; }
  #print-root .svc-p b { display: block; margin-bottom: 2px; }
  #print-root .fine { font-size: 9.5px; color: #666; margin-top: 14px; }
}

/* ── Photo drag & drop ── */
#dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border2); border-radius: 18px;
  padding: 70px 60px; color: var(--text); font-size: .95rem;
  transition: border-color .15s, background .15s;
}
#dropzone:hover { border-color: var(--accent2); background: var(--surface); }
#dropzone.ro { cursor: default; opacity: .5; }
#editor-screen.dropping #stage { outline: 2px dashed var(--accent); outline-offset: -10px; border-radius: 18px; background: rgba(124,58,237,.06); }
#editor-screen.dropping #dropzone { border-color: var(--accent); background: rgba(124,58,237,.1); }

/* ── Composer visuals inside placement boxes ── */
.plc { overflow: visible; }
.plc-pot, .plc-plant {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 0; pointer-events: none; user-select: none;
}
.plc-pot { width: 100%; max-height: 62%; object-fit: contain; object-position: bottom; z-index: 2; }
.plc-plant { width: 94%; max-height: 86%; object-fit: contain; object-position: bottom; bottom: 30%; z-index: 1; }
.plc.has-visual { background: transparent; border-color: rgba(167,139,250,.25); }
.plc.has-visual.on { border-color: #fff; background: rgba(124,58,237,.08); }
.plc-gen {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.6); color: #fff; font-size: .64rem; font-weight: 700;
  border-radius: 999px; padding: 3px 9px; white-space: nowrap; z-index: 3;
}

/* ── P3: render layer ── */
.tab-mini button { padding: 5px 11px; font-size: .72rem; }
.rnd-count { font-size: .72rem; color: var(--text2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.rnd-stale { font-size: .68rem; color: #fbbf24; border: 1px dashed rgba(251,191,36,.45); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.stage-col { display: flex; flex-direction: column; align-items: safe center; gap: 10px; margin: auto; min-height: 0; }
#zoom-sizer { flex: none; }
#canvas-box.render-mode { cursor: default; }
.rnd-badge {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  background: rgba(16,185,129,.92); color: #06281c; font-size: .68rem; font-weight: 800;
  padding: 4px 11px; border-radius: 999px; pointer-events: none;
}
.rnd-badge-try { background: rgba(124,58,237,.88); color: #fff; }
.rnd-busy {
  position: absolute; inset: 0; z-index: 6; border-radius: 12px;
  display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center;
  background: rgba(10,9,16,.55); backdrop-filter: blur(2px);
  color: #fff; font-weight: 700; font-size: .88rem;
}
.rnd-busy .sp { width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.25); border-top-color: #a78bfa; border-radius: 50%; animation: rndspin 1s linear infinite; }
@keyframes rndspin { to { transform: rotate(360deg); } }
#rnd-strip { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
.rnd-att { position: relative; width: 110px; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--bg3); }
.rnd-att img { width: 100%; height: 66px; object-fit: contain; display: block; background: #1b1a25; }
.rnd-att.on { border-color: var(--accent); }
.rnd-att .ok { position: absolute; top: 4px; right: 4px; background: #10b981; color: #06281c; font-size: .62rem; font-weight: 800; border-radius: 999px; padding: 2px 7px; }

/* ── Split placement boxes: pot + plant each in their own rect ── */
.pbx { position: absolute; border-radius: 8px; cursor: move; box-sizing: border-box; }
/* Selection chrome uses OUTLINE, never border: a border would shrink the
   content box and the DOM fit would stop matching the export canvas. */
.pbx.on { outline: 2px solid #fff; outline-offset: -2px; }
.pbx-plant { z-index: 1; }
.pbx-pot { z-index: 2; }
.pbx-union { z-index: 999; position: absolute; outline: 2px solid var(--accent2); background: rgba(124,58,237,.16); border-radius: 8px; pointer-events: none; }
.pbx:not(.has-img) { outline: 2px dashed rgba(167,139,250,.6); outline-offset: -2px; background: rgba(124,58,237,.10); }
.pbx.on:not(.has-img) { background: rgba(124,58,237,.22); }
.pbx.part-on { outline-color: #fff; }
.pbx-clip { position: absolute; inset: 0; overflow: hidden; border-radius: 6px; pointer-events: none; }
.pbx-img { position: absolute; max-width: none; user-select: none; }
.pbx-lab {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: .64rem; font-weight: 700; color: #e9d5ff; background: rgba(0,0,0,.45);
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; pointer-events: none;
}
.pbx .tag {
  position: absolute; top: -22px; left: -2px; background: var(--accent); color: #fff;
  font-size: .66rem; font-weight: 800; border-radius: 6px; padding: 2px 7px; white-space: nowrap;
  cursor: grab; pointer-events: auto;
}
/* 8 transform handles: corners scale freely, edges move one axis.
   They protrude outside the box so a 3%-tall box is still grabbable. */
.pbx .rs {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .12s; z-index: 4;
}
.pbx.on .rs, .pbx:hover .rs { opacity: 1; }
.pbx .rs-nw { left: -7px; top: -7px; cursor: nwse-resize; }
.pbx .rs-ne { right: -7px; top: -7px; cursor: nesw-resize; }
.pbx .rs-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.pbx .rs-se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.pbx .rs-n { left: 50%; top: -7px; margin-left: -9px; cursor: ns-resize; border-radius: 4px; width: 18px; }
.pbx .rs-s { left: 50%; bottom: -7px; margin-left: -9px; cursor: ns-resize; border-radius: 4px; width: 18px; }
.pbx .rs-w { top: 50%; left: -7px; margin-top: -9px; cursor: ew-resize; border-radius: 4px; height: 18px; }
.pbx .rs-e { top: 50%; right: -7px; margin-top: -9px; cursor: ew-resize; border-radius: 4px; height: 18px; }
.pbx.part-on { box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.pbx-clip.flip { transform: scaleX(-1); }

/* Snap guides — drawn only while something is moving, killed on release. */
#guides { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.gl { position: absolute; }
.gl-v { top: 0; bottom: 0; width: 1px; margin-left: -0.5px; }
.gl-h { left: 0; right: 0; height: 1px; margin-top: -0.5px; }
.gl-canvas { background: #22d3ee; box-shadow: 0 0 4px rgba(34,211,238,.8); }
.gl-object { background: #f472b6; box-shadow: 0 0 4px rgba(244,114,182,.8); }
.gl-floor  { background: #34d399; box-shadow: 0 0 6px rgba(52,211,153,.9); }

/* Zoom: a transform on the canvas, a sizer behind it for the scrollbars. */
#zoom-sizer { position: relative; }
#canvas-box.zoomed {
  transform-origin: top left;
  position: absolute; top: 0; left: 0;   /* out of the sizer's flow, so the
                                            sizer's size can't feed back into
                                            the layout the transform scales */
}
body.panning, body.panning * { cursor: grab !important; }
#ctx-menu .ks { float: right; opacity: .45; font-size: .72rem; margin-left: 14px; }

/* ── Slide context menu ── */
#ctx-menu {
  position: fixed; z-index: 300; min-width: 190px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: 0 12px 34px rgba(0,0,0,.5);
}
#ctx-menu button { text-align: left; background: none; border: none; color: var(--text); font-size: .82rem; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
#ctx-menu button:hover:not(:disabled) { background: var(--bg3); }
#ctx-menu button:disabled { opacity: .4; cursor: default; }
#ctx-menu button.danger { color: #f87171; }
#ctx-menu hr { border: none; border-top: 1px solid var(--border); margin: 3px 6px; }

/* ── Plant crop editor ── */
#crop-wrap {
  position: relative; display: inline-block; align-self: center; max-width: 100%;
  overflow: hidden; border-radius: 10px; touch-action: none;
  background: repeating-conic-gradient(#2a2938 0% 25%, #201f2c 0% 50%) 0 0 / 18px 18px;
}
#crop-wrap img { max-width: 100%; max-height: 56vh; display: block; }
#crop-rect { position: absolute; border: 2px solid var(--accent2); box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; border-radius: 4px; }
#crop-rect .rs { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: nwse-resize; }


/* ── P4: variant strip, fit chips, product layer ── */
.varstrip { display: flex; gap: 6px; flex-wrap: wrap; }
.varstrip .var {
  position: relative; width: 46px; height: 46px; padding: 0; border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border); background: var(--bg3); cursor: pointer;
}
.varstrip .var img { width: 100%; height: 100%; object-fit: contain; display: block; background: #1b1a25; }
.varstrip .var.on { border-color: var(--accent); }
.varstrip .var:disabled { cursor: default; opacity: .6; }
.varstrip .var .nocut-dot {
  position: absolute; right: 1px; bottom: 0; font-size: .58rem; font-style: normal;
  background: rgba(0,0,0,.6); border-radius: 4px; padding: 0 2px;
}
.fitnote { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fitnote .showall { display: flex; align-items: center; gap: 5px; cursor: pointer; margin-left: auto; }
.fitchip { font-size: .66rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.fitchip.fit-fits { background: rgba(16,185,129,.16); color: #34d399; }
.fitchip.fit-snug { background: rgba(251,191,36,.16); color: #fbbf24; }
.fitchip.fit-no { background: rgba(248,113,113,.14); color: #f87171; }
.fitchip.fit-unknown { background: var(--bg3); color: var(--text2); }
.fitline { font-size: .74rem; border-radius: 8px; padding: 6px 9px; background: var(--bg3); }
.fitline.fit-fits { color: #34d399; }
.fitline.fit-snug { color: #fbbf24; }
.fitline.fit-no { color: #f87171; background: rgba(248,113,113,.1); }
.prodrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.prodrow .tgl { display: flex; align-items: center; gap: 6px; font-size: .8rem; cursor: pointer; }
.prodrow input[type=range] { flex: 1; min-width: 90px; accent-color: var(--accent); }
.pbx-shadow { position: absolute; pointer-events: none; }
.pbx-prod .pbx-clip { overflow: hidden; }
.pbx-flag {
  position: absolute; top: -10px; right: -8px; z-index: 5; background: #fbbf24; color: #3a2c05;
  font-size: .66rem; font-weight: 800; border-radius: 999px; padding: 1px 6px;
}
.tbar-sep { width: 1px; height: 20px; background: var(--border); }
.zoomctl { display: flex; align-items: center; background: var(--bg3); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.zoomctl button { border: none; background: none; color: var(--text2); font-size: .78rem; font-weight: 700; padding: 5px 9px; cursor: pointer; }
.zoomctl button:hover { background: var(--surface); color: var(--text); }

/* Narrow windows: the rail and panel must yield before the stage does. */
@media (max-width: 1200px) {
  #rail { width: 150px; }
  #panel { width: 300px; }
}
@media (max-width: 1000px) {
  #rail { width: 120px; }
  #panel { width: 260px; }
  #stage { padding: 10px; }
}

.note.warn { color: #fbbf24; border-left: 2px solid rgba(251,191,36,.5); padding-left: 8px; }

/* Nothing internal may reach paper: overlays, menus and toasts are
   editor furniture and would print over (or instead of) the deliverable. */
@media print {
  .ov, #ctx-menu, #toast, #guides { display: none !important; }
}

/* Rotate grip — on a stalk above the box, clear of the corner handles. */
.pbx .rot-grip {
  position: absolute; left: 50%; top: -30px; width: 18px; height: 18px; margin-left: -9px;
  border-radius: 50%; background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.5); cursor: grab; opacity: 0; transition: opacity .12s; z-index: 5;
}
.pbx .rot-grip::before {                 /* the stalk */
  content: ''; position: absolute; left: 50%; top: 16px; width: 2px; height: 12px;
  margin-left: -1px; background: var(--accent);
}
.pbx .rot-grip i {
  position: absolute; inset: 3px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent; /* a little ⟳ */
}
.pbx.on .rot-grip, .pbx:hover .rot-grip { opacity: 1; }
.pbx .rot-grip:active { cursor: grabbing; }
#rot-badge {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 60;
  background: rgba(0,0,0,.72); color: #fff; font-family: ui-monospace, monospace;
  font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; pointer-events: none;
}

/* A render in flight marks its own placement — not the whole stage. */
@keyframes pbxpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(167,139,250,.55); } 50% { box-shadow: 0 0 0 6px rgba(167,139,250,0); } }
.pbx.rendering { animation: pbxpulse 1.6s ease-out infinite; border-radius: 10px; }

/* Magic-select foreground layers: painted over the placements, inert to
   the pointer so you can still grab what's behind them. */
/* A cut-out is a real layer: grabbable, and drawn over the placements so
   whatever you tuck behind it stays behind it. */
.fg-box { position: absolute; cursor: move; }
.fg-box img { width: 100%; height: 100%; display: block; object-fit: fill; user-select: none; pointer-events: none; }
.fg-box.on { outline: 2px dashed #22d3ee; outline-offset: 2px; }
.fg-box .tag {
  position: absolute; top: -22px; left: -2px; background: #22d3ee; color: #06222a;
  font-size: .66rem; font-weight: 800; border-radius: 6px; padding: 2px 7px; white-space: nowrap;
}
.fg-box .rs { opacity: 1; border-color: #22d3ee; }
.fg-row { display: flex; align-items: center; gap: 7px; padding: 4px 2px; border-radius: 8px; cursor: pointer; }
.fg-row.on { background: var(--bg3); }
.fg-row img { width: 40px; height: 40px; object-fit: contain; background: #1b1a25; border-radius: 8px; }
.fg-row span { flex: 1; font-size: .82rem; }
#cut-wrap { position: relative; border-radius: 10px; overflow: hidden; background: var(--bg3); touch-action: none; max-height: 54vh; }
#cut-wrap canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.cutbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--text2); }
.cutbar label { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 180px; }
.cutbar input[type=range] { flex: 1; accent-color: var(--accent); }
