:root {
  --bg: #0b0d10; --bg2: #101318; --panel: #13161b; --raise: #1a1e25; --raise2: #222731; --line: #252a33; --line2: #323946;
  --ink: #e8eaee; --ink2: #9aa3b0; --ink3: #6b7482;
  --accent: #ff6b2c; --accent2: #ff8a52; --accent-soft: rgba(255, 107, 44, .14); --accent-line: rgba(255, 107, 44, .45);
  --ok: #3ccf8e; --ok-soft: rgba(60, 207, 142, .12); --warn: #f5b84a; --warn-soft: rgba(245, 184, 74, .12);
  --bad: #ff5a5f; --bad-soft: rgba(255, 90, 95, .13); --info: #6aa8ff; --info-soft: rgba(106, 168, 255, .12);
  --r: 12px; --r2: 8px; --soft: var(--raise); /* --soft kept for admin.html */
  --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .03) inset;
  font: 14px/1.45 "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
[hidden] { display: none !important; }
svg use { pointer-events: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
kbd { font: 11px ui-monospace, "Cascadia Mono", monospace; background: var(--raise2); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--ink); }
.muted { color: var(--ink2); } .small { font-size: 12px; }
.spacer { flex: 1; }
.btn svg, .ib svg, .fb svg, .ft svg, .sb svg, .step svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- top bar ---------- */
.top { height: 58px; display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--bg2); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-size: 18px; letter-spacing: -.4px; font-weight: 500; }
.brand svg { width: 30px; height: 30px; } .brand b { color: var(--accent); font-weight: 700; }
.divider { width: 1px; height: 24px; background: var(--line2); margin: 0 4px; }
.proj { border: 1px solid transparent; background: transparent; padding: 6px 10px; border-radius: 8px; font-weight: 600; width: 240px; color: var(--ink); }
.proj:hover { background: var(--raise); } .proj:focus { border-color: var(--line2); background: var(--raise); outline: none; }
.btn { display: inline-flex; align-items: center; gap: 7px; background: var(--raise); border: 1px solid var(--line2); border-radius: 9px; padding: 7px 12px; font-weight: 500; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--raise2); }
.btn .chev { width: 13px; height: 13px; opacity: .6; }
.btn.primary, .primary { background: linear-gradient(180deg, var(--accent2), var(--accent)); border: 0; color: #160a03; font-weight: 650; box-shadow: 0 4px 18px rgba(255, 107, 44, .28); }
.btn.primary:hover, .primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary { border-radius: 9px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ghost { background: var(--raise); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 12px; }
.ghost:hover { background: var(--raise2); }
.ghost.sm, .primary.sm { padding: 5px 10px; font-size: 13px; }
.link { background: none; border: 0; color: var(--accent2); padding: 0; font-weight: 600; font-size: 13px; }
.link:hover { text-decoration: underline; }
.iconset { display: flex; gap: 2px; background: var(--raise); border: 1px solid var(--line2); border-radius: 9px; padding: 2px; }
.ib { width: 32px; height: 30px; display: grid; place-items: center; background: none; border: 0; border-radius: 7px; color: var(--ink2); }
.ib:hover { background: var(--raise2); color: var(--ink); }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--raise); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; flex-direction: column; z-index: 20; }
.menu.open .menu-pop { display: flex; }
.menu-pop button { text-align: left; background: none; border: 0; border-radius: 7px; padding: 8px 10px; display: flex; justify-content: space-between; gap: 12px; }
.menu-pop button span { color: var(--ink3); font-size: 12px; }
.menu-pop button:hover { background: var(--raise2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 380px 1fr 310px; height: calc(100vh - 58px); }
.left, .right { background: var(--panel); min-height: 0; }
.left { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.right { border-left: 1px solid var(--line); overflow: auto; }

/* steps */
.pane { flex: 1; overflow: auto; padding: 14px; display: none; flex-direction: column; gap: 12px; min-height: 0; }
.pane.on { display: flex; }

/* case */
.case-sum { display: flex; gap: 12px; align-items: center; background: var(--raise); border: 1px solid var(--line2); border-radius: var(--r); padding: 12px; }
.case-sum .mini { width: 64px; height: 48px; flex: none; }
.case-sum .t { font-weight: 650; font-size: 15px; } .case-sum .s { color: var(--ink2); font-size: 12px; }
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ink2); }
.field input, .field select, .field textarea, .range select, select { border: 1px solid var(--line2); border-radius: 8px; padding: 7px 9px; font-size: 13px; color: var(--ink); background: var(--bg2); width: 100%; }
.field input:focus, .field select:focus, select:focus, textarea:focus { border-color: var(--accent-line); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.note { font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border: 1px solid rgba(245, 184, 74, .25); border-radius: 9px; padding: 8px 10px; margin-top: 10px; display: flex; gap: 8px; }
.case-src { color: var(--ink2); background: var(--bg2); border-color: var(--line2); align-items: flex-start; flex-wrap: wrap; line-height: 1.5; }
.case-src.typical { background: var(--warn-soft); border-color: rgba(245, 184, 74, .25); color: var(--ink); }
.case-src a { color: var(--accent2); }
.case-opt .acc { flex: none; font-size: 10.5px; }
.chip.custom { border-style: dashed; color: var(--accent2); }
.chip.custom.on { background: var(--accent); border-color: var(--accent); color: #160a03; border-style: solid; }
.custom-card { margin-top: 10px; background: var(--raise); border: 1px solid var(--line2); border-radius: var(--r); padding: 14px; }
.tips { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.notch-row { display: grid; grid-template-columns: 26px repeat(4, 1fr) 30px; gap: 5px; align-items: end; margin-top: 8px; }
.notch-row .nn { font-weight: 700; font-size: 12px; color: var(--ink2); padding-bottom: 8px; }
.notch-row .field input { padding: 6px; }
.notch-row .ib { height: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line2); background: var(--raise); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; white-space: nowrap; color: var(--ink2); transition: all .12s; }
.chip:hover { color: var(--ink); border-color: #46505f; }
.chip.on { background: var(--ink); color: #0b0d10; border-color: var(--ink); font-weight: 600; }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; box-shadow: 0 0 0 2px rgba(255, 255, 255, .08); }
.case-list { display: grid; gap: 6px; margin-top: 10px; }
.case-opt { display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); padding: 9px 10px; transition: border-color .12s, background .12s; }
.case-opt:hover { border-color: var(--line2); background: var(--raise); }
.case-opt.on { border-color: var(--accent-line); background: var(--accent-soft); }
.case-opt svg { width: 48px; height: 36px; flex: none; }
.case-opt .t { font-weight: 600; font-size: 13px; } .case-opt .s { font-size: 12px; color: var(--ink2); }
.h3 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink3); margin: 6px 0 -2px; }

/* tools */
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; flex: none; }
.cat { border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; color: var(--ink2); transition: all .12s; }
.cat:hover { border-color: var(--line2); color: var(--ink); background: var(--raise); }
.cat svg { width: 42px; height: 26px; }
.cat.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.catform { display: flex; flex-direction: column; gap: 12px; background: var(--raise); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .lbl { width: 58px; font-size: 12px; color: var(--ink2); flex: none; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; font-size: 12.5px; border-radius: 7px; color: var(--ink2); }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--raise2); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.range { display: flex; align-items: center; gap: 6px; }
.range select { width: auto; padding: 5px 8px; }
.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; }
.size { border: 1px solid var(--line2); background: var(--bg2); border-radius: 7px; padding: 5px 0; font-size: 12px; text-align: center; color: var(--ink3); text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .2); }
.size.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); font-weight: 600; text-decoration: none; }
.addbar { display: flex; gap: 8px; align-items: center; }
.addbar .primary { flex: 1; }
.preview-strip { background: radial-gradient(120% 140% at 50% 0%, #2a2e35, #1b1e23); border: 1px solid var(--line); border-radius: 9px; height: 70px; overflow: hidden; padding: 4px; }
.preview-strip svg { width: 100%; height: 100%; }
.qs { display: flex; flex-direction: column; gap: 5px; }
.qs button { text-align: left; border: 1px dashed var(--line2); background: transparent; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; color: var(--ink2); }
.qs button:hover { border-color: var(--accent-line); color: var(--ink); background: var(--accent-soft); }
.item-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.item-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line2); background: var(--bg2); border-radius: 9px; padding: 7px 9px; text-align: left; font-size: 12.5px; color: var(--ink); }
.item-btn:hover { border-color: var(--accent-line); }
.item-btn.on { border-color: var(--accent-line); background: var(--accent-soft); }
.item-btn svg { width: 46px; height: 24px; flex: none; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.acc { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; }
.acc::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.acc.exact { color: var(--ok); background: var(--ok-soft); }
.acc.standard { color: var(--info); background: var(--info-soft); }
.acc.typical { color: var(--warn); background: var(--warn-soft); }
.acc.spec { color: #e8c15a; background: rgba(232, 193, 90, .13); }
.acc.traced { color: var(--info); background: var(--info-soft); }
.acc.measured { color: var(--ok); background: var(--ok-soft); }
.acc.photo { color: #8fd3c7; background: rgba(143, 211, 199, .13); }
/* trace-from-photo dialog */
.photo-cta { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin: 0 0 12px; border: 1px dashed var(--line, #3a3f45);
  border-radius: 10px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.photo-cta:hover { border-color: var(--accent, #ff5b1f); }
.photo-cta b { display: block; }
.photo-cta small { opacity: .7; }
dialog:has(.dlg.trace) { width: min(760px, 94vw); max-height: 94vh; }
.dlg.trace { box-sizing: border-box; width: 100%; }
.dlg.trace .two > * { min-width: 0; }
.trace-stage { position: relative; background: #0d0f11; border-radius: 8px; overflow: hidden; display: grid; place-items: center; min-height: 260px; }
.trace-stage canvas, .trace-stage svg { max-width: 100%; max-height: 60vh; display: block; cursor: crosshair; }
.trace-steps { margin: 6px 0 10px; padding-left: 18px; font-size: 13px; opacity: .85; }
.trace-steps li.on { font-weight: 600; opacity: 1; }
/* catalogue: real models with their source-backed size */
.model-list { display: grid; gap: 6px; margin-bottom: 4px; }
.cat-model { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; padding: 8px 10px;
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; color: var(--ink); }
.cat-model:hover { border-color: var(--accent-line); }
.cat-model .ico svg { width: 46px; height: 28px; display: block; }
/* catalogue thumbnails use the same tool art as the Real view (one art style everywhere) */
.cat-model .ico img.art { width: 46px; height: 40px; display: block; object-fit: contain; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .5)); }
.cat-model .nm { display: grid; min-width: 0; } .cat-model .nm b { font-size: 13px; }
.cat-model .nm small { color: var(--ink2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-model .nm .sz { color: var(--ink3); font-size: 11px; }
.cat-model > .acc { align-self: start; white-space: nowrap; }

/* contents */
.grp { display: flex; align-items: center; gap: 10px; padding: 9px 10px; font-size: 13px; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); }
.grp:hover { border-color: var(--line2); background: var(--raise); }
.grp .bar { width: 4px; align-self: stretch; border-radius: 2px; }
.grp .n { flex: 1; min-width: 0; } .grp .n div:first-child { font-weight: 550; } .grp .c { color: var(--ink3); font-size: 11.5px; }
.grp button { border: 0; background: none; color: var(--ink3); padding: 4px 6px; border-radius: 6px; }
.grp button:hover { background: var(--bad-soft); color: var(--bad); }
.grp.sel { border-color: var(--accent-line); background: var(--accent-soft); }
.grp.out .c { color: var(--bad); }
#contents { display: flex; flex-direction: column; gap: 6px; }
.empty-list { text-align: center; color: var(--ink3); padding: 30px 10px; font-size: 13px; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.canvas { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none;
  background: radial-gradient(circle at 50% 45%, #171a20 0%, #0c0e11 75%); }
.canvas::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 22px 22px; }
#canvas { position: relative; width: 100%; height: 100%; display: block; user-select: none; }
/* Real view: the case sits on a wooden workbench top (owner 2026-11-20: "try wood table"; "the background should scale with
   the case"). The bench photo (site/img/bench-wood.webp, ComfyUI) is drawn INSIDE the canvas SVG in mm by render-real.js,
   so it zooms and pans with the case; its edges fade to this dark colour. Alternatives kept: bench-walnut.webp,
   concrete-polished.webp. */
.canvas.realbg {
  background: #140d08;
}
.canvas.realbg::before { display: none; }
.float.top-left { top: 62px; } /* case + layers sit under the toolbar so they never hide behind it */
.case-quick { background: transparent; color: var(--ink); border: 0; border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; max-width: 290px; cursor: pointer; }
.case-quick:hover { background: rgba(255, 255, 255, .06); }
.case-quick option, .case-quick optgroup { background: #1b1e24; color: var(--ink); }
/* a little life: the selected pocket glows and breathes; new tools flash once; the order button glows softly */
@keyframes sfGlow { 0%, 100% { filter: drop-shadow(0 0 1.5px rgba(255, 122, 51, .55)); } 50% { filter: drop-shadow(0 0 4.5px rgba(255, 122, 51, .95)); } }
#canvas .c-sel .c-pocket { animation: sfGlow 2.2s ease-in-out infinite; }
@keyframes sfArrive { 0% { filter: drop-shadow(0 0 9px rgba(120, 220, 255, .95)); } 100% { filter: drop-shadow(0 0 0 rgba(120, 220, 255, 0)); } }
#canvas .c-new .c-pocket { animation: sfArrive 1.4s ease-out 1; }
@keyframes sfCta { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 106, 31, .0), var(--shadow); } 50% { box-shadow: 0 0 18px 2px rgba(255, 106, 31, .45), var(--shadow); } }
#btnSubmit { animation: sfCta 3.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { #canvas .c-sel .c-pocket, #canvas .c-new .c-pocket, #btnSubmit { animation: none; } }
.float { position: absolute; top: 12px; display: flex; align-items: center; gap: 4px; background: rgba(22, 25, 31, .82); backdrop-filter: blur(10px); border: 1px solid var(--line2); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); z-index: 3; }
.float.top-left { left: 12px; } .float.top-right { right: 12px; }
.fb { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--ink2); }
.fb:hover { background: var(--raise2); color: var(--ink); }
.fb.icon { padding: 6px 7px; }
.fb.accent { color: var(--accent2); font-weight: 600; }
.fb.accent:hover { background: var(--accent-soft); }
.fsep { width: 1px; height: 20px; background: var(--line2); margin: 0 3px; }
.ft { display: inline-grid; place-items: center; width: 32px; height: 30px; border-radius: 8px; color: var(--ink3); cursor: pointer; }
.ft input { position: absolute; opacity: 0; pointer-events: none; }
.ft:hover { background: var(--raise2); }
.ft:has(input:checked) { color: var(--accent2); background: var(--accent-soft); }
.ft.wide { display: inline-flex; gap: 6px; width: auto; padding: 0 10px; font-size: 13px; font-weight: 600; }
/* Real view: render-real.js draws foam, pockets, tools and labels; the editing shapes stay on top for hit-testing */
#canvas.real .c-tool .c-pocket { fill: transparent; stroke: none; }
#canvas.real .c-tool > g { opacity: 0; }
#canvas.real .c-label, #canvas.real .c-margin { display: none; }
/* Real view: no drawing furniture. Rulers, plan case outline and plan foam stay in Plan view only. */
#canvas.real .c-ruler, #canvas.real .c-case, #canvas.real .c-notchlab { display: none; }
#canvas.real .c-sel .c-pocket { stroke: var(--accent); stroke-width: 1.3; }
#canvas.real .c-bad .c-pocket { stroke: var(--bad); stroke-width: 1.2; }
#optGridSize { width: auto; border: 0; background: transparent; padding: 4px 2px; font-size: 12px; color: var(--ink2); }
.layers { display: flex; gap: 2px; }
.selbar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; background: rgba(22, 25, 31, .9); backdrop-filter: blur(10px); border: 1px solid var(--line2); border-radius: 14px; padding: 5px; box-shadow: var(--shadow); z-index: 3; animation: rise .14s ease-out; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }
.selbar .nm { padding: 0 10px 0 8px; font-size: 13px; font-weight: 600; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; border-radius: 9px; padding: 7px 10px; font-size: 13px; color: var(--ink2); }
.sb:hover { background: var(--raise2); color: var(--ink); }
.sb.danger:hover { background: var(--bad-soft); color: var(--bad); }
.sb.on { color: var(--accent2); }
.sb kbd { margin-left: 2px; opacity: .7; font-size: 10px; }
.status { display: flex; gap: 18px; align-items: center; padding: 7px 16px; font-size: 12.5px; color: var(--ink2); background: var(--bg2); border-top: 1px solid var(--line); }
.status b { color: var(--ink); font-weight: 600; }
.status .bad { color: var(--bad); font-weight: 600; }
.status .good { color: var(--ok); font-weight: 600; }
.meter { width: 80px; height: 5px; border-radius: 3px; background: var(--raise2); overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 2; }
.empty-in { text-align: center; max-width: 320px; background: rgba(16, 19, 24, .78); backdrop-filter: blur(6px); border: 1px solid var(--line2); border-radius: 16px; padding: 22px 24px; }
.empty-in svg { width: 120px; color: var(--ink3); }
.empty-in h3 { margin: 10px 0 4px; font-size: 16px; }
.empty-in p { color: var(--ink2); margin: 0; font-size: 13px; }
.hud { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); background: rgba(232, 234, 238, .95); color: #0b0d10; font-weight: 550; border-radius: 9px; padding: 7px 12px; font-size: 12.5px; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 4; white-space: nowrap; }
.hud.on { opacity: 1; }

/* ---------- canvas drawing ---------- */
.c-case { fill: #3a414c; stroke: #4c5563; stroke-width: .6; }
.c-foam { stroke: #000; stroke-opacity: .5; filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .6)); }
.c-grid { stroke: #fff; stroke-opacity: .05; }
.c-grid.major { stroke-opacity: .11; }
.c-depth { font: 800 8px system-ui; fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: 1.2px; }
.c-depthview .c-pocket { stroke: rgba(160, 200, 255, .5); }
.depthbar { position: relative; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line2); background: var(--foam, #2b2e33); display: flex; flex-direction: column; }
.depthbar .db-cut { background: hsl(212 70% 32%); display: flex; align-items: center; padding: 0 10px; min-height: 18px; }
.depthbar .db-base { flex: 1; background: #3a3f46; display: flex; align-items: center; padding: 0 10px; min-height: 18px; }
.depthbar span { font-size: 11.5px; font-weight: 600; color: #e8eaee; }
.cutlist { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.cutlist th { text-align: left; color: var(--ink3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 4px 6px; }
.cutlist td { padding: 4px 6px; border-top: 1px solid var(--line); }
.c-notch { fill: #3a414c; stroke: #4c5563; stroke-width: .5; }
.c-notchlab { font: 700 5px system-ui; fill: #9aa3b0; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.c-margin { fill: none; stroke: #fff; stroke-opacity: .16; stroke-dasharray: 3 3; }
.c-ruler text { font: 9px system-ui; fill: #6b7482; }
.c-ruler line { stroke: #4a525e; }
.c-pocket { fill: #08090b; stroke: #000; stroke-width: .4; }
.c-tool { cursor: grab; }
.c-tool:active { cursor: grabbing; }
.c-body { fill-rule: evenodd; fill: #c3c9d1; stroke: #6f7882; stroke-width: .5; }
.c-line { fill: none; stroke: #6f7882; stroke-width: .5; }
.c-hole { fill: #1d2025; stroke: #6f7882; stroke-width: .4; }
.c-dark { fill: #3e444c; }
.c-grip { fill: #353b43; stroke: none; }
.c-brand { fill: var(--brand, #8d949c); stroke: rgba(0, 0, 0, .35); stroke-width: .4; }
.c-batt { fill: #343a41; stroke: #16191d; stroke-width: .5; }
.c-metal { fill: #b2b8bf; stroke: #6a717a; stroke-width: .4; }
.c-tool .c-line { stroke: #8a929b; }
.c-label { font: 600 5px system-ui; fill: #d9dce1; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.c-sel .c-pocket { stroke: var(--accent); stroke-width: 1.3; filter: drop-shadow(0 0 2px rgba(255, 107, 44, .7)); }
.c-bad .c-pocket { stroke: var(--bad); stroke-width: 1.2; }
/* Plan view (owner 2026-11-22: "the non real version needs to look better, not black and grey, just pick one colour"):
   every tool is one flat colour, a solid silhouette on a darker band of the same colour for the pocket's clearance.
   --plan / --plan-deep are set from the foam colour in renderCanvas (orange on dark foams, blue on orange/red/yellow foams). */
#canvas:not(.real) .c-tool:not(.c-depthview) .c-pocket { fill: var(--plan-deep, #8a3f17); stroke: none; }
#canvas:not(.real) .c-tool:not(.c-depthview) > g * { fill: var(--plan, #ff9a57); stroke: none; }
#canvas:not(.real) .c-tool:not(.c-depthview) > g .c-line { display: none; }
#canvas:not(.real) .c-sel .c-pocket { stroke: #fff; stroke-width: 1.1; filter: none; animation: none; }
#canvas:not(.real) .c-bad .c-pocket { stroke: var(--bad); stroke-width: 1.4; }
#canvas:not(.real) .c-label { fill: var(--plan, #ff9a57); }
.c-selbox { fill: none; stroke: var(--accent); stroke-width: .6; stroke-dasharray: 2 1.5; pointer-events: none; }
.c-marquee { fill: rgba(255, 107, 44, .08); stroke: var(--accent); stroke-width: .5; }

/* ---------- right ---------- */
.sect { border-bottom: 1px solid var(--line); }
.sect-h { display: flex; align-items: center; gap: 8px; padding: 13px 16px; list-style: none; cursor: default; }
summary.sect-h { cursor: pointer; }
summary.sect-h::-webkit-details-marker { display: none; }
summary.sect-h::after { content: ''; width: 7px; height: 7px; border-right: 1.6px solid var(--ink3); border-bottom: 1.6px solid var(--ink3); transform: rotate(45deg); margin: -3px 2px 0 4px; transition: transform .15s; }
details:not([open]) > summary.sect-h::after { transform: rotate(-45deg); margin-top: 0; }
.sect-h h2 { font-size: 12px; margin: 0; flex: 1; text-transform: uppercase; letter-spacing: .08em; color: var(--ink2); font-weight: 700; }
.sect-b { padding: 0 16px 16px; }
.badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; }
.check { display: flex; gap: 10px; font-size: 13px; padding: 9px 10px; border-radius: 10px; margin-bottom: 6px; align-items: flex-start; }
.check .i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #0b0d10; flex: none; margin-top: 1px; }
.check.ok { background: var(--ok-soft); } .check.ok .i { background: var(--ok); }
.check.warn { background: var(--warn-soft); } .check.warn .i { background: var(--warn); }
.check.bad { background: var(--bad-soft); } .check.bad .i { background: var(--bad); }
.check.info { background: var(--info-soft); } .check.info .i { background: var(--info); }
.check[style*=pointer]:hover { filter: brightness(1.2); }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.sw { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line2); }
.sw.on { box-shadow: 0 0 0 2px var(--accent); }
.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; font-size: 12.5px; color: var(--ink2); }
.slider input { grid-column: 1 / -1; accent-color: var(--accent); width: 100%; }
.slider b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sel-name { font-weight: 650; font-size: 15px; margin-bottom: 4px; }
.sel-sub { font-size: 12px; color: var(--ink2); margin-bottom: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.tip { font-size: 12.5px; color: var(--ink2); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tip p { margin: 0 0 8px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 12px; }
.sizebox { border: 1px solid var(--line2); background: var(--bg2); border-radius: 10px; padding: 10px; }
.sizebox.typical { border-color: rgba(245, 184, 74, .35); }
.sizebox summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.sizebox p { margin: 6px 0 0; }

/* ---------- shared with admin.html ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.sec-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sec-h h2 { font-size: 14px; margin: 0; flex: 1; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--line2); border-radius: 18px; padding: 0; width: min(600px, 94vw); background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(4, 5, 7, .65); backdrop-filter: blur(3px); }
.dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { margin: 0; font-size: 19px; }
.dlg .field input, .dlg .field textarea { padding: 9px 11px; }
.dlg .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg .acts { display: flex; justify-content: flex-end; gap: 8px; }
.summary-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13px; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; }
.thumbs svg { height: 130px; border-radius: 8px; flex: none; }

@media (max-width: 1250px) { .app { grid-template-columns: 340px 1fr 280px; } .proj { width: 160px; } }
@media print {
  html, body { overflow: visible; background: #fff; }
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { position: absolute; left: 0; top: 0; }
}

/* ---- 2026-11-21 layout: choose a case, then fill it; right-panel tabs ---- */
.pane-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pane-h h2 { font-size: 17px; margin: 0; font-weight: 700; color: var(--ink); }
.case-card { display: flex; align-items: center; gap: 12px; background: var(--raise); border: 1px solid var(--line2); border-radius: var(--r); padding: 10px 12px; }
.case-card .mini { width: 56px; height: 42px; flex: none; }
.case-card .cc-t { flex: 1; min-width: 0; }
.case-card .t { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-card .s { color: var(--ink2); font-size: 12px; }
.case-card .cc-b { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.brandrow { flex: none; }
.brand-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px 6px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--raise); color: var(--ink2); border: 1.5px solid var(--line2); cursor: pointer; transition: border-color .12s, background .12s; }
.bchip i { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); }
.bchip:hover { border-color: var(--bc, var(--line2)); color: var(--ink); }
.bchip.on { box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.bchip.on i { background: currentColor !important; opacity: .55; }
.right { display: flex; flex-direction: column; }
.rtabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px 10px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.rtab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px 10px; background: none; border: 0; border-bottom: 2.5px solid transparent;
  color: var(--ink3); font-size: 12px; font-weight: 600; cursor: pointer; position: relative; }
.rtab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rtab:hover { color: var(--ink); }
.rtab.on { color: var(--ink); border-bottom-color: var(--accent); }
.rtab .cnt { position: absolute; top: 4px; right: 10px; min-width: 18px; padding: 1px 5px; border-radius: 9px; background: var(--accent); color: #160a03; font-size: 10.5px; font-weight: 700; }
.rtab .cnt:empty { display: none; }
.rpane { display: none; padding-top: 14px; }
.rpane.on { display: block; }
.sect-h.sub { padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
/* fit check stays in view under whichever tab is open */
.right { overflow: hidden; }
.right .rpane.on { flex: 1; min-height: 0; overflow: auto; }
.right #checkCard { flex: none; max-height: 38%; overflow: auto; border-top: 1px solid var(--line2); border-bottom: 0; background: var(--panel); }
.chip .cdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; box-shadow: 0 0 0 2px rgba(0, 0, 0, .3); }
/* category icons all light (owner 2026-11-21: the power-tool one drew black) */
.cat-ico.power svg, .cat-ico.other svg { filter: brightness(0) invert(.88); }
/* free-rotate handle above the selection */
.c-rot { cursor: grab; }
.c-rot line { stroke: var(--accent); stroke-width: .8; vector-effect: non-scaling-stroke; }
.c-rot circle { fill: #fff; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.c-rot path { fill: none; stroke: #1a1a1a; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.c-rot:active { cursor: grabbing; }
/* layer tabs drawn above the case's top-left (zoom with it): coloured pill, number + foam thickness, tool count */
.lst text { font-family: inherit; dominant-baseline: central; font-size: 11px; fill: #a9b2bd; }
.lst-tab { cursor: pointer; }
.lst-tab .bg { fill: rgba(30, 34, 40, .85); stroke: #3d444e; stroke-width: 1; }
.lst-tab:hover .bg { fill: #2c3138; stroke: #59616c; }
.lst-tab .mm { fill: #77818d; font-weight: 400; }
.lst-tab text.n { text-anchor: end; font-weight: 700; fill: #8b95a2; }
.lst-tab .pill { opacity: .6; }
.lst-tab.on .bg { fill: rgba(255, 122, 51, .14); stroke: var(--accent); stroke-width: 1.4; }
.lst-tab.on text { fill: #f3f5f7; font-weight: 650; }
.lst-tab.on .pill { opacity: 1; }
.lst-tab.add .bg { fill: none; stroke-dasharray: 3 2; }
.lst-tab.add text { fill: #8b95a2; font-size: 10.5px; }
.lst-tab.add:hover text { fill: var(--accent); }
.lst .lst-sug { font-size: 10px; fill: #6c7682; }
.lst .lst-sug.warn { fill: var(--warn); }
/* tool search */
.toolsearch { flex: none; }
.ts-in { display: flex; align-items: center; gap: 8px; background: var(--raise); border: 1px solid var(--line2); border-radius: 10px; padding: 0 10px; }
.ts-in:focus-within { border-color: var(--accent); }
.ts-in input { flex: 1; background: none; border: 0; outline: none; color: var(--ink); font: inherit; font-size: 13.5px; padding: 10px 0; }
.ts-ico svg { width: 17px; height: 17px; fill: none; stroke: var(--ink3); stroke-width: 2; stroke-linecap: round; display: block; }
.ts-filters { display: flex; flex-direction: column; gap: 6px; }
.ts-filters .chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* auto-align guides while dragging (owner 2026-11-21) */
.c-guide{stroke:#ff7a3d;stroke-width:.5;stroke-dasharray:3 2;vector-effect:non-scaling-stroke;pointer-events:none}
.ft.ft-txt{width:auto;padding:0 9px;gap:5px;display:inline-flex;align-items:center}
.ft.ft-txt span{font-size:12px;font-weight:600}

/* ===== foam sections + side view (owner 2026-11-21) ===== */
#canvas .c-seam { stroke: #ff9a5c; stroke-width: .8; stroke-dasharray: 4 2.5; fill: none; pointer-events: none; }
#canvas .c-secsel { fill: none; stroke: var(--accent2, #ff8a4c); stroke-width: .9; stroke-dasharray: 2 2; pointer-events: none; opacity: .8; }
#canvas .c-sectag { cursor: pointer; }
#canvas .c-sectag rect { fill: rgba(16, 18, 22, .78); stroke: rgba(255, 255, 255, .22); stroke-width: .3; }
#canvas .c-sectag text { fill: #d8dce2; font-size: 4.6px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
#canvas .c-sectag.on rect { fill: var(--accent2, #ff8a4c); stroke: none; }
#canvas .c-sectag.on text { fill: #16120e; }
#canvas .c-div { cursor: grab; }
#canvas .c-div line { stroke: #ff8a4c; stroke-width: 2.4; opacity: .85; }
#canvas .c-div circle { fill: #ff8a4c; stroke: #fff; stroke-width: .8; }
#canvas .c-div:hover line { stroke-width: 3.4; }
#canvas .lst-sec rect { fill: rgba(255, 138, 76, .16); stroke: rgba(255, 138, 76, .6); stroke-width: .8; }
#canvas .lst-sec text { fill: #ffb48a; font-size: 11px; font-weight: 700; dominant-baseline: central; }
/* 3D view: small, in the right-hand panel under the tools (owner 2026-11-21: "put the 3d image on the right under the
   tools… have it select layer with it"); big, over the whole design area */
.sv-slot { flex: none; padding: 10px 10px 8px; border-bottom: 1px solid var(--line2); }
.sv-slot:empty { display: none; }
.sideview { position: relative; width: 100%; height: 200px; display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 45%, rgba(38, 42, 49, .96), rgba(20, 22, 26, .96) 78%); border: 1.5px solid #2ef2ff; border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(46, 242, 255, .25), 0 0 14px rgba(46, 242, 255, .45), inset 0 0 18px rgba(46, 242, 255, .12); }
.sideview:not(.big)::before { content: '3D'; position: absolute; left: 10px; top: 7px; font: 700 11px/1 var(--font, inherit); letter-spacing: .12em; color: #2ef2ff; text-shadow: 0 0 8px rgba(46, 242, 255, .8); z-index: 1; }
/* small: just the view (click a sheet to pick its layer) and the expand button; the controls live in the big preview */
.sideview:not(.big) .sv-bar, .sideview:not(.big) .sv-legend { display: none; }
.sideview:not(.big) .sv-wrap { padding: 6px; cursor: pointer; }
.sideview .sv-expand { position: absolute; top: 6px; right: 6px; width: 26px; height: 24px; z-index: 1; }
.sideview.big .sv-expand { display: none; }
/* the full 3D preview: the card grows over the whole design area */
.sideview.big { position: absolute; left: 14px; top: 66px; right: 14px; bottom: 14px; width: auto; height: auto; z-index: 5; box-shadow: var(--shadow); background: radial-gradient(ellipse at 50% 45%, #2a2e35, #16181c 80%); }
.sideview.big .sv-wrap { padding: 4px 24px 18px; }
.sideview .sv-bar .ib { width: 26px; height: 24px; }
.sideview #svBig { margin-left: auto; }
.sideview #svMin { margin-left: 0; }
.sv-legend { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 10px 0; font-size: 11px; }
.sv-legend .lg { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .03); color: var(--ink2, #b6bcc6); cursor: pointer; }
.sv-legend .lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sv-legend .lg.on { border-color: #ff9a5c; color: #fff; background: rgba(255, 138, 76, .14); }
.sv-legend .lg.case { cursor: default; }
.sv-legend .lg b { font-weight: 700; color: #fff; }
.sideview[hidden] { display: none; }
.sideview .sv-bar { gap: 8px; padding: 7px 8px 2px 12px; font-size: 12px; }
.sideview .sv-hint { padding: 0 12px 6px; font-size: 11px; color: var(--ink3, #8b93a0); }
/* isometric view (section-view.js isoSVG) */
.iv .iv-slab { cursor: pointer; }
.iv .iv-slab:hover path { filter: brightness(1.45); }
.iv .iv-slab path { stroke: rgba(0, 0, 0, .6); stroke-width: .9; stroke-linejoin: round; }
.iv .iv-layer.on .iv-slab path:last-child { stroke: #ff9a5c; stroke-width: 1.6; }
/* exploded view: sheets slide apart when a layer is picked (owner 2026-11-21: "give it some movement… like an
   architecture drawing"); dashed guide lines join the corners, stretched to each gap */
.iv .iv-layer { transition: transform .6s cubic-bezier(.22, .9, .25, 1); }
.iv .iv-guide { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; pointer-events: none;
  transform-box: fill-box; transform-origin: 50% 0; transition: transform .6s cubic-bezier(.22, .9, .25, 1); }
.sv-wrap.still .iv-layer, .sv-wrap.still .iv-guide { transition: none; }
.iv .iv-case path { stroke: rgba(0, 0, 0, .25); stroke-width: .5; }
.iv .iv-glass { pointer-events: none; }
.iv .iv-glass path { fill-opacity: .1; stroke: rgba(255, 255, 255, .28); stroke-width: .8; stroke-linejoin: round; }
.iv .iv-rimtop { stroke: rgba(0, 0, 0, .45); stroke-width: .6; pointer-events: none; }
/* wireframe: every edge shows, layers in their colours, pockets as their top outline and floor outline */
.iv.wire .iv-slab path { fill: var(--lc); fill-opacity: .035; stroke: var(--lc); stroke-width: .9; stroke-opacity: .85; filter: none; }
.iv.wire .iv-slab:hover path { fill-opacity: .16; }
.iv.wire .iv-layer.on .iv-slab path { stroke-width: 1.6; stroke-opacity: 1; fill-opacity: .1; }
.iv.wire .iv-band { display: none; }
.iv.wire .iv-case path, .iv.wire .iv-glass path, .iv.wire .iv-rimtop { fill: none; stroke: rgba(205, 212, 222, .45); stroke-width: .7; }
.iv.wire .iv-pk { fill: none; }
.iv.wire .iv-floor { fill: none; stroke: rgba(255, 255, 255, .35); stroke-width: .6; stroke-dasharray: 2 2; clip-path: none; }
.iv.wire .iv-rim { stroke: rgba(255, 255, 255, .85); stroke-width: .8; }
.iv .iv-rim { stroke: rgba(0, 0, 0, .7); stroke-width: .5; pointer-events: none; }
.iv .iv-rim.sel { stroke: #ff8a4c; stroke-width: 1.4; }
.iv .iv-pk, .iv .iv-cut, .iv .iv-band { pointer-events: none; }
.iv .iv-cut.gh { opacity: .35; }
.iv .iv-lid { fill: none; stroke: rgba(255, 255, 255, .4); stroke-width: .8; stroke-dasharray: 5 4; pointer-events: none; }
.iv .iv-edge { fill: none; stroke: rgba(255, 255, 255, .18); stroke-width: .6; stroke-dasharray: 2 3; pointer-events: none; }
.iv text { font-family: inherit; text-anchor: middle; dominant-baseline: central; pointer-events: none; paint-order: stroke; stroke: rgba(12, 13, 15, .85); stroke-width: 2.5px; stroke-linejoin: round; }
.iv .iv-t { fill: #e6e9ee; font-weight: 700; }
.iv .iv-name { fill: var(--ink2, #b6bcc6); font-weight: 600; pointer-events: auto; cursor: pointer; }
.iv .iv-name.on { fill: #ffb48a; }
.iv .iv-free { fill: rgba(255, 255, 255, .6); }
.iv .iv-over { fill: #ff6b5c; font-weight: 700; }
.iv .iv-proud { fill: #ffcf5c; font-weight: 700; }
.iv .iv-dim { fill: #e6e9ee; font-weight: 600; }
.sv-bar { display: flex; align-items: center; gap: 12px; padding: 6px 12px; font-size: 12.5px; }
.sv-bar .ib { margin-left: auto; width: 26px; height: 24px; }
.seg.sm button { padding: 3px 8px; font-size: 12px; }
.sv-wrap { flex: 1; min-height: 0; padding: 0 12px 8px; }
.sv-wrap svg { width: 100%; height: 100%; display: block; }
.sv .sv-case { opacity: .9; }
.sv .sv-rim { stroke: rgba(255, 255, 255, .35); stroke-width: .6; stroke-dasharray: 3 2; }
.sv .sv-dim, .sv .sv-axis { fill: var(--ink3, #8b93a0); font-size: 8px; dominant-baseline: central; }
.sv .sv-axis { text-anchor: middle; }
.sv .sv-slab { cursor: pointer; }
.sv .sv-slab:hover rect:first-child { filter: brightness(1.35); }
.sv .sv-t { fill: #e6e9ee; font-size: 7.5px; font-weight: 700; dominant-baseline: central; pointer-events: none; }
.sv .sv-pk { fill: #0b0c0e; stroke: rgba(0, 0, 0, .8); stroke-width: .3; pointer-events: none; }
.sv .sv-pk.sel { fill: #2a1a10; stroke: #ff8a4c; }
.sv .sv-tool { fill: none; stroke: rgba(230, 236, 244, .55); stroke-width: .45; stroke-dasharray: 1.6 1.2; pointer-events: none; }
.sv .sv-tool.sel { stroke: #ffb48a; }
.sv .sv-tool.proud { stroke: #ffcf5c; }
.sv .sv-free { fill: rgba(255, 255, 255, .45); font-size: 7.5px; text-anchor: middle; dominant-baseline: central; }
.sv .sv-over { fill: #ff6b5c; font-size: 6px; font-weight: 700; text-anchor: middle; }
.sv .sv-name { fill: var(--ink2, #b6bcc6); font-size: 8.5px; font-weight: 600; text-anchor: middle; cursor: pointer; }
.sv .sv-name.on { fill: #ffb48a; }
.sv .sv-div { stroke: #ff9a5c; stroke-width: .7; stroke-dasharray: 3 2; }
.sec-presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 10px; }
.sec-pre { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 9px; color: var(--ink2); font-size: 11px; }
.sec-pre.on { border-color: var(--accent2, #ff8a4c); color: var(--ink); background: var(--accent-soft, rgba(255, 138, 76, .12)); }
.sec-pre svg { width: 30px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.sec-row { border: 1px solid var(--line2); border-radius: 10px; padding: 8px 9px; margin-bottom: 7px; cursor: pointer; }
.sec-row.on { border-color: var(--accent2, #ff8a4c); background: rgba(255, 138, 76, .06); cursor: default; }
.sec-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sec-top .sec-use { margin-left: auto; max-width: 140px; }
.sec-stack { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 4px; align-items: center; }
.sec-lay { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 6px; border: 1px solid var(--line2); border-radius: 8px; }
.sec-lay.on { border-color: var(--ink3); }
.sec-lay i { width: 12px; height: 6px; border-radius: 3px; display: inline-block; }
.sec-lay select { padding: 1px 2px; font-size: 12px; }
.muted.small.bad { color: var(--bad); }
.thumbs .thumb small { display: block; text-align: center; color: var(--ink3); margin-top: 3px; }

/* "To be traced": models still drawn from the generic shape, folded away (owner 2026-11-21) */
.to-trace { margin: 8px 0 10px; border: 1px dashed var(--line2); border-radius: 12px; background: rgba(255, 255, 255, .02); }
.to-trace > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 9px 12px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2, #b6bcc6); }
.to-trace > summary::-webkit-details-marker { display: none; }
.to-trace > summary::before { content: '▸'; color: var(--ink3, #8b93a0); transition: transform .15s; }
.to-trace[open] > summary::before { transform: rotate(90deg); }
.to-trace > summary .n { padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, .08); font-size: 11px; letter-spacing: 0; }
.to-trace > summary small { flex-basis: 100%; text-transform: none; letter-spacing: 0; color: var(--ink3, #8b93a0); font-size: 11px; }
.to-trace > .model-list { padding: 0 8px 8px; opacity: .85; }

/* side-on depth gauge beside the case (owner 2026-11-21: "really obvious how the foam sits in the box") */
#canvas .dg text { dominant-baseline: central; font-family: inherit; pointer-events: none; }
#canvas .dg-title { fill: #2ef2ff; font-size: 12px; font-weight: 800; letter-spacing: .14em; text-anchor: middle; }
#canvas .dg-case { fill: #6b717b; stroke: rgba(0, 0, 0, .5); stroke-width: .6; }
#canvas .dg-rim { stroke: #2ef2ff; stroke-width: 1.2; stroke-dasharray: 4 3; }
#canvas .dg-small { fill: #9aa1ab; font-size: 10px; }
#canvas .dg-depth { fill: #e6e9ee; font-size: 12px; font-weight: 700; }
#canvas .dg-sheet { cursor: pointer; }
#canvas .dg-sheet rect:first-child { stroke: rgba(0, 0, 0, .6); stroke-width: .6; }
#canvas .dg-sheet:hover rect:first-child { filter: brightness(1.4); }
#canvas .dg-sheet.on rect:first-child { stroke: #fff; stroke-width: 1.4; }
#canvas .dg-sheet.over rect:first-child { stroke: #ff4d4d; stroke-width: 1.6; }
#canvas .dg-t { fill: #fff; font-size: 12px; font-weight: 800; text-anchor: middle; }
#canvas .dg-here { fill: #fff; }
#canvas .dg-heret { fill: #fff; font-size: 13px; font-weight: 800; }
#canvas .dg-free { fill: url(#none); fill: rgba(255, 255, 255, .04); stroke: rgba(255, 255, 255, .25); stroke-width: .6; stroke-dasharray: 3 2; }
#canvas .dg-over { fill: rgba(255, 60, 60, .22); stroke: #ff4d4d; stroke-width: 1.4; stroke-dasharray: 4 2; pointer-events: none; animation: dg-blink 1.2s ease-in-out infinite; }
#canvas .dg-warn { fill: #ff5c5c; font-size: 13px; font-weight: 900; text-anchor: middle; letter-spacing: .04em; }
#canvas .dg-warn2 { fill: #ff9a9a; font-size: 10px; font-weight: 600; text-anchor: middle; }
@keyframes dg-blink { 50% { fill-opacity: .45; } }

/* ---------- phones (owner 2026-11-21: "make the tools work well for mobile too… make touch controls good") ----------
   One panel at a time, picked from a bottom bar; the design area fills the screen; bigger touch targets. */
.mnav { display: none; }
@media (max-width: 820px) {
  html, body { overscroll-behavior: none; }
  .top { height: 52px; padding: 0 10px; gap: 6px; }
  .top .divider, .top .spacer + .iconset #btnRedo { display: none; }
  .top .proj { width: 0; flex: 1; min-width: 60px; font-size: 14px; }
  .top .brand span { display: none; }
  #btnFile { padding: 8px 10px; } #btnFile .chev, #btnFile { font-size: 0; } #btnFile svg:first-child { width: 18px; height: 18px; }
  #btnSubmit { padding: 9px 12px; font-size: 13px; }
  .app { grid-template-columns: 1fr !important; height: calc(100dvh - 52px - 62px); }
  .app > .left, .app > .stage, .app > .right { display: none !important; }
  body[data-m="tools"] .app > .left, body[data-m="design"] .app > .stage, body[data-m="insert"] .app > .right { display: flex !important; }
  .app > .left, .app > .right { overflow: auto; border: 0; }
  .mnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: 62px; z-index: 20; background: var(--bg2); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); }
  .mnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; color: var(--ink3, #8b93a0); font: 600 11.5px/1 inherit; }
  .mnav button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mnav button.on { color: var(--accent, #ff6b2c); }
  /* the floating toolbar scrolls sideways instead of overflowing */
  .float.top-right { left: 8px; right: 8px; top: 8px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .float.top-right::-webkit-scrollbar { display: none; }
  .float .ft, .float .fb { min-height: 40px; min-width: 40px; }
  .selbar { bottom: 10px; max-width: calc(100% - 16px); overflow-x: auto; }
  .selbar .sb { min-width: 52px; min-height: 48px; }
  .selbar .nm { display: none; }
  .sideview.big { left: 6px; right: 6px; top: 60px; bottom: 6px; }
  .sideview.big .sv-bar { flex-wrap: wrap; }
  .cat-model, .item-btn, .chip, .bchip { min-height: 44px; }
  .rtabs .rtab { min-height: 48px; }
}
@media (max-width: 820px) {
  #btnSubmit { font-size: 0; gap: 6px; } #btnSubmit::after { content: 'Order'; font-size: 13.5px; font-weight: 700; }
  .float.top-right > * { flex: none; white-space: nowrap; }
  .float .fb, .float .ft { white-space: nowrap; }
  .status { font-size: 11px; gap: 10px; flex-wrap: nowrap; overflow: hidden; }
}

/* phones: performance (owner 2026-11-21: "performance on mobile needs work"). The blurred glass bars re-blur the canvas on
   every frame of a drag, the selected pocket's glow re-filters the SVG nonstop, and the foam and every catalogue picture
   carry a drop-shadow; on a phone these are swapped for flat equivalents */
@media (max-width: 820px) {
  .float, .selbar, .empty-in, dialog::backdrop { backdrop-filter: none; }
  .float, .selbar { background: rgba(22, 25, 31, .96); }
  #canvas .c-sel .c-pocket, #btnSubmit, #canvas .dg-over { animation: none; }
  .c-foam, .c-sel .c-pocket, .cat-model .ico img.art { filter: none; }
  #canvas { touch-action: none; }
}
/* case pictures in the picker (tools/art/case_art.py) */
.case-pic { width: 56px; height: 44px; object-fit: contain; display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); }
@media (max-width: 820px) { .case-pic { filter: none; } }

/* "foam for anything" worlds (LOCAL-ONLY preview, data-mode="all") */
.world-row { margin-bottom: 12px; }
.world-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line2); background: var(--raise); color: var(--ink2); font-size: 12.5px; cursor: pointer; }
.wchip:hover { color: var(--ink); border-color: #4a515c; }
.wchip.on { background: var(--accent); border-color: var(--accent); color: #1a0b03; font-weight: 600; }
.wchip .wi { font-size: 14px; line-height: 1; }
.thing-list { display: grid; gap: 6px; margin-bottom: 12px; }
.thing { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line2); background: var(--raise); color: var(--ink); text-align: left; cursor: pointer; }
.thing:hover { border-color: var(--accent); }
.thing .th-shape { flex: none; width: 34px; max-height: 26px; border-radius: 4px; background: linear-gradient(135deg, #ff9a57, #b9561f); }
.thing .th-shape.round { width: 24px; height: 24px; border-radius: 50%; }
.thing .nm { display: flex; flex-direction: column; } .thing .nm small { color: var(--ink3); }
.mini { display: flex; flex-direction: column; font-size: 11.5px; color: var(--ink3); } .mini input { width: 78px; }
