/* ==========================================================================
   Shadowbox Studio: design system
   Warm graphite chrome around a cool dark-room viewport. LED amber is the one
   accent (actions, active state); CAD blue marks selected geometry.
   ========================================================================== */
:root {
  /* chrome: warm graphite */
  --surface-0: #151413;
  --surface-1: #1c1a18;
  --surface-2: #242220;
  --surface-3: #2d2a27;
  --surface-4: #37342f;
  --line: #2f2c28;
  --line-2: #3d3934;
  --line-3: #514c45;
  --text-1: #eee8de;
  --text-2: #b3aa9b;
  --text-3: #80786c;
  /* viewport: cool dark room */
  --stage-0: #0e1013;
  --stage-1: #14171b;
  --stage-2: #1b1f24;
  --stage-line: rgba(200, 215, 235, .08);
  /* accent and selection */
  --accent: #f3b55b;
  --accent-hi: #ffc979;
  --accent-ink: #241808;
  --accent-soft: rgba(243, 181, 91, .14);
  --select: #5fb0ff;
  --select-soft: rgba(95, 176, 255, .16);
  /* status */
  --good: #78c693;
  --good-soft: rgba(120, 198, 147, .12);
  --warn: #ec9f4a;
  --warn-soft: rgba(236, 159, 74, .13);
  --bad: #f06b5e;
  --bad-soft: rgba(240, 107, 94, .13);
  /* fabrication */
  --cut: #ff4d3d;
  --engrave: #4d7dff;
  --label: #3cc56c;
  --wood: #d4b483;
  --wood-edge: #6a4528;
  --wood-removed: rgba(212, 180, 131, .13);
  --wood-removed-line: rgba(212, 180, 131, .38);
  --engrave-wood: #7a5232;
  --ink-slit: #2a1a0e;
  --ov-bridge: #3d7dff;
  --ov-island: #ff4a3d;
  --ov-thin: #ff9a2e;
  --ov-dropped: #c04cff;

  /* type */
  --font: "Archivo", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --fs-xs: 11px;
  --fs-s: 12px;
  --fs-m: 13px;
  --fs-l: 15px;
  --fs-xl: 19px;
  /* space, radii, depth */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px;
  --r1: 3px; --r2: 5px; --r3: 8px;
  --shadow-float: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 6px 20px rgba(0, 0, 0, .42), 0 0 0 1px rgba(0, 0, 0, .35);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .4);
  --ease: cubic-bezier(.2, .7, .2, 1);

  --bar-h: 46px;
  --status-h: 26px;
  --inspector-w: 300px;
  --health-w: 312px;

  color-scheme: dark;
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: 1.4;
  color: var(--text-1);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 1800px) { :root { --inspector-w: 320px; --health-w: 340px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--surface-0); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--select); outline-offset: 1px; border-radius: var(--r1); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
::selection { background: var(--select-soft); }
kbd {
  font: 500 10.5px/1 var(--font); color: var(--text-2); padding: 2px 5px 3px; border-radius: var(--r1);
  border: 1px solid var(--line-3); border-bottom-width: 2px; background: var(--surface-2);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--line-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- icons ---------- */
.i { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle; }
.i-sm { width: 13px; height: 13px; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 32px; height: 32px; }

/* ==========================================================================
   Buttons and small controls
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 30px; padding: 0 12px; border-radius: var(--r2);
  border: 1px solid var(--line-3); background: var(--surface-3); color: var(--text-1);
  font-weight: 560; font-size: var(--fs-m); white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
}
.btn:hover:not(:disabled) { background: var(--surface-4); border-color: #615a51; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn-sm { height: 26px; padding: 0 9px; font-size: var(--fs-s); gap: 6px; }
.btn-lg { height: 38px; padding: 0 18px; font-size: var(--fs-l); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn-accent:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn-accent:disabled { background: var(--surface-3); border-color: var(--line-3); color: var(--text-3); opacity: 1; }
.btn-quiet { background: transparent; border-color: var(--line-2); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-3); }
.btn.pulse { box-shadow: 0 0 0 0 rgba(243, 181, 91, .55); animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(243, 181, 91, .5); } 70%, 100% { box-shadow: 0 0 0 7px rgba(243, 181, 91, 0); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: var(--r2); border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text-1); }
.icon-btn-sm { width: 22px; height: 22px; }
.icon-btn.done { color: var(--good); }

.link-btn {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 2px 0;
  color: var(--text-2); font-size: var(--fs-s); font-weight: 500;
}
.link-btn:hover { color: var(--text-1); }
.link-btn .i-sm { opacity: .8; }

.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: var(--fs-xs); font-weight: 560; white-space: nowrap;
}
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-note { background: rgba(255, 255, 255, .06); color: var(--text-2); }

/* ==========================================================================
   App frame
   ========================================================================== */
.app { display: grid; grid-template-rows: var(--bar-h) 1fr var(--status-h); height: 100vh; height: 100dvh; }

/* ---------- title bar ---------- */
.titlebar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--s4);
  padding: 0 var(--s2) 0 var(--s4); background: var(--surface-0); border-bottom: 1px solid var(--line);
  position: relative; z-index: 10;
}
.titlebar-start { display: flex; align-items: center; gap: var(--s3); min-width: 0; overflow: hidden; }
.titlebar-end { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); min-width: 0; }
.app { width: 100%; max-width: 100vw; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text-1); flex: none; }
.brand-mark { width: 24px; height: 24px; }
.brand-mark rect { fill: none; stroke: var(--text-1); stroke-width: 2; }
.brand-mark circle { fill: var(--accent); }
.brand-mark .brand-rays { stroke: var(--text-1); stroke-opacity: .42; stroke-width: 1.6; stroke-linecap: round; }
.brand-name { font-weight: 780; font-stretch: 118%; font-size: 15px; letter-spacing: -.01em; }
.brand-studio { font-weight: 420; font-stretch: 100%; color: var(--text-3); font-size: 15px; margin-left: -3px; }
.doc { display: flex; align-items: baseline; gap: 8px; min-width: 0; color: var(--text-2); }
.doc-sep { color: var(--line-3); }
.doc-name { font-weight: 560; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-state { font-size: var(--fs-xs); color: var(--warn); }

.workspaces {
  display: flex; gap: 2px; padding: 3px; border-radius: var(--r3); background: var(--surface-1);
  border: 1px solid var(--line);
}
.ws {
  display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 13px 0 11px; border: 0; border-radius: var(--r2);
  background: transparent; color: var(--text-3); font-weight: 560; position: relative;
  transition: color .15s, background .15s;
}
.ws:hover { color: var(--text-1); background: var(--surface-2); }
.ws[aria-selected="true"] { color: var(--text-1); background: var(--surface-3); box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 1px 2px rgba(0, 0, 0, .4); }
.ws[aria-selected="true"] .i { color: var(--accent); }
.ws::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -4px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform .2s var(--ease);
}
.ws[aria-selected="true"]::after { transform: scaleX(1); }

.run-state {
  display: flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: 13px;
  font-size: var(--fs-s); color: var(--text-2); white-space: nowrap; margin-right: var(--s1);
  transition: background .3s, color .3s;
}
.run-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.run-state[data-state="ready"] .run-dot { background: var(--accent); }
.run-state[data-state="busy"] { color: var(--text-1); }
.run-state[data-state="busy"] .run-dot { background: var(--accent); animation: blink 1s ease-in-out infinite; }
.run-state[data-state="done"] .run-dot { background: var(--good); }
.run-state[data-state="stale"] { color: var(--warn); }
.run-state[data-state="stale"] .run-dot { background: var(--warn); }
.run-state[data-state="error"] { color: var(--bad); }
.run-state[data-state="error"] .run-dot { background: var(--bad); }
.run-state.flash { animation: flash-ok 1.4s var(--ease); }
@keyframes flash-ok { 0% { background: rgba(120, 198, 147, .28); color: var(--text-1); } 100% { background: transparent; } }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- body grid ---------- */
.body { display: grid; grid-template-columns: var(--inspector-w) minmax(0, 1fr) auto; min-height: 0; }
.app.no-inspector .body { grid-template-columns: 0 minmax(0, 1fr) auto; }
.app.no-inspector .inspector { visibility: hidden; }

/* ---------- status bar ---------- */
.statusbar {
  display: flex; align-items: center; background: var(--surface-0); border-top: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--text-3); padding: 0 var(--s2); min-width: 0; overflow: hidden;
}
.sb-cell { display: flex; align-items: center; gap: 6px; padding: 0 10px; height: 100%; white-space: nowrap; }
.sb-cell + .sb-cell:not(:empty) { border-left: 1px solid var(--line); }
.sb-cell:empty { display: none; }
.sb-fill { flex: 1; }
.sb-num { color: var(--text-2); min-width: 0; }
.sb-btn { border: 0; background: none; color: var(--text-3); border-left: 1px solid var(--line); }
.sb-btn:hover { color: var(--text-1); }
.sb-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); display: inline-block; }
.sb-dot.busy { background: var(--accent); animation: blink 1s infinite; }

/* ==========================================================================
   Inspector
   ========================================================================== */
.inspector {
  display: grid; grid-template-rows: 1fr auto; min-height: 0; background: var(--surface-1);
  border-right: 1px solid var(--line); overflow: hidden;
}
.inspector-scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.inspector-foot { padding: 8px var(--s4); border-top: 1px solid var(--line); }

.source { padding: var(--s3) var(--s3) var(--s2); border-bottom: 1px solid var(--line); }
.source-card {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px;
  padding: 6px 6px 6px 6px; border-radius: var(--r3); background: var(--surface-2); border: 1px solid var(--line-2);
}
.source-thumb {
  width: 44px; height: 44px; border-radius: var(--r2); display: grid; place-items: center; color: var(--text-3);
  background: #efe9df; overflow: hidden;
}
.source-card:not(.loaded) .source-thumb { background: var(--surface-3); }
.source-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.source-meta { min-width: 0; }
.source-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-sub { color: var(--text-3); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-card .icon-btn { cursor: pointer; }
.source-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px 0; }
.source-row .link-btn { white-space: nowrap; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 268px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r3); box-shadow: var(--shadow-pop);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu [role=menuitem] {
  display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; width: 100%; text-align: left;
  border: 0; background: none; padding: 6px; border-radius: var(--r2);
}
.menu [role=menuitem]:hover, .menu [role=menuitem]:focus-visible { background: var(--surface-3); outline: none; }
.menu img { width: 34px; height: 34px; border-radius: var(--r1); background: #efe9df; object-fit: contain; padding: 2px; }
.menu strong { display: block; font-weight: 560; }
.menu small { color: var(--text-3); font-size: var(--fs-xs); }

/* groups */
.group { border-bottom: 1px solid var(--line); }
.group-h { margin: 0; font-size: inherit; }
.group-head {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; padding: 0 var(--s4) 0 12px;
  border: 0; background: none; text-align: left; font-weight: 640; font-size: var(--fs-m); color: var(--text-1);
}
.group-head:hover { background: rgba(255, 255, 255, .02); }
.group-chev { color: var(--text-3); transition: transform .18s var(--ease); }
.group-head[aria-expanded="false"] .group-chev,
.adv-toggle[aria-expanded="false"] .i { transform: rotate(-90deg); }
.group-title { flex: 1; }
.group-badge { font-size: var(--fs-xs); font-weight: 600; padding: 1px 7px; border-radius: 9px; }
.group-badge.is-bad { color: var(--bad); background: var(--bad-soft); }

.collapse { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s var(--ease); }
.collapse.collapsed { grid-template-rows: 0fr; }
.collapse-inner { overflow: hidden; min-height: 0; }
.group-fields { display: grid; gap: 13px; padding: 2px var(--s4) var(--s4) var(--s4); }
.adv .group-fields { padding: 12px 0 2px; }

.adv-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; padding: 4px 0 0;
  color: var(--text-3); font-size: var(--fs-s); font-weight: 560;
}
.adv-toggle:hover { color: var(--text-1); }
.adv-toggle .i { transition: transform .18s var(--ease); }
.adv-count { margin-left: auto; color: var(--accent); font-weight: 500; }

/* fields */
.field { display: grid; gap: 6px; }
.field-row { display: flex; align-items: center; gap: 6px; min-height: 26px; }
.field-head { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.field-label { color: var(--text-2); font-size: var(--fs-s); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.field-label.scrub { cursor: ew-resize; }
.field-label.scrub:hover, .scrubbing .field-label { color: var(--text-1); }
.field.modified .field-label { color: var(--text-1); }
.mod-dot {
  width: 14px; height: 14px; padding: 0; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; flex: none;
}
.mod-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); transition: transform .12s; }
.mod-dot:hover::before { transform: scale(1.5); }
.help-i { color: var(--text-3); display: inline-grid; opacity: .7; cursor: help; flex: none; }
.help-i:hover, .help-i:focus-visible { color: var(--text-1); opacity: 1; }
.field-help { margin: 0; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.45; }
.err { color: var(--bad); font-size: var(--fs-xs); line-height: 1.4; padding-left: 8px; border-left: 2px solid var(--bad); }

.num {
  display: flex; align-items: center; width: 92px; height: 26px; flex: none;
  border: 1px solid var(--line-2); border-radius: var(--r1); background: var(--surface-0);
  transition: border-color .12s, box-shadow .12s;
}
.num:hover { border-color: var(--line-3); }
.num:focus-within { border-color: var(--select); box-shadow: 0 0 0 3px var(--select-soft); }
.field.invalid .num { border-color: var(--bad); }
.num input {
  width: 100%; min-width: 0; border: 0; background: none; padding: 0 2px 0 8px; text-align: right;
  font-size: var(--fs-s); font-weight: 560; color: var(--text-1); -moz-appearance: textfield;
}
.num input::-webkit-inner-spin-button, .num input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.num input:focus { outline: none; }
.num .unit { padding: 0 7px 0 4px; color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }

.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 14px; margin: 0; background: none; cursor: pointer; --p: 50%; }
.slider::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--text-2) var(--p), var(--surface-4) var(--p));
}
.field.modified .slider::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--accent) var(--p), var(--surface-4) var(--p)); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; border-radius: 50%; margin-top: -4px;
  background: var(--text-1); border: 0; box-shadow: 0 0 0 3px var(--surface-1), 0 1px 3px rgba(0, 0, 0, .5);
  transition: transform .1s;
}
.slider:hover::-webkit-slider-thumb, .slider:active::-webkit-slider-thumb { transform: scale(1.25); }
.slider::-moz-range-track { height: 3px; border-radius: 2px; background: var(--surface-4); }
.slider::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--text-2); }
.field.modified .slider::-moz-range-progress { background: var(--accent); }
.slider::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--text-1); box-shadow: 0 0 0 3px var(--surface-1); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-btn {
  height: 22px; padding: 0 9px; border-radius: 11px; border: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font-size: var(--fs-xs); font-weight: 560; transition: background .12s, color .12s, border-color .12s;
}
.chip-btn:hover { color: var(--text-1); border-color: var(--line-3); }
.chip-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(243, 181, 91, .55); color: var(--accent-hi); }
.select { position: relative; }
.select select {
  appearance: none; -webkit-appearance: none; width: 100%; height: 28px; padding: 0 28px 0 9px; border-radius: var(--r1);
  border: 1px solid var(--line-2); background: var(--surface-0); color: var(--text-1); font-size: var(--fs-s); font-weight: 500;
  text-overflow: ellipsis; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.select select:hover { border-color: var(--line-3); }
.select select:focus-visible { outline: none; border-color: var(--select); box-shadow: 0 0 0 3px var(--select-soft); }
.select select option { background: var(--surface-2); color: var(--text-1); }
.select .i { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.group[data-group="setup"] { background: linear-gradient(180deg, rgba(243, 181, 91, .035), transparent 70%); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-compact .field-row { flex-direction: column; align-items: stretch; gap: 5px; }
.field-compact .num { width: 100%; }

.switch {
  appearance: none; -webkit-appearance: none; width: 30px; height: 17px; border-radius: 9px; margin: 0; flex: none;
  background: var(--surface-4); position: relative; cursor: pointer; transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--text-2); transition: transform .18s var(--ease), background .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(13px); background: var(--accent-ink); }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px;
  border-radius: var(--r2); background: var(--surface-0); border: 1px solid var(--line-2);
}
.segmented button {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0;
  height: 26px; padding: 0 8px; border: 0; border-radius: var(--r1); background: transparent;
  color: var(--text-3); font-size: var(--fs-s); font-weight: 560; white-space: nowrap;
  transition: background .12s, color .12s;
}
.segmented button span { overflow: hidden; text-overflow: ellipsis; }
.segmented button:hover { color: var(--text-1); }
.segmented button[aria-checked="true"], .segmented button[aria-pressed="true"] {
  background: var(--surface-3); color: var(--text-1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 1px 2px rgba(0, 0, 0, .45);
}
.segmented-glyph button { flex-direction: column; height: 46px; gap: 4px; font-size: var(--fs-xs); }
.segmented-glyph button .i { width: 17px; height: 17px; }
.segmented-glyph button[aria-checked="true"] .i { color: var(--accent); }

/* ==========================================================================
   Stage (viewport)
   ========================================================================== */
.stage {
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 40%, var(--stage-1) 0%, var(--stage-0) 70%);
}
.stage:fullscreen { background: var(--stage-0); }
.view { position: absolute; inset: 0; }
.view.enter { animation: view-in .22s var(--ease); }
@keyframes view-in { from { opacity: 0; } }

.vp { position: absolute; inset: 0; }
.vp-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; outline: none; }
.vp-svg.panning { cursor: grabbing; }
.vp-svg text { font-family: var(--font); }

.vp-top {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 3; pointer-events: none;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.vp-bar { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.vp-bar > * { pointer-events: auto; }
.vp-bar-r { margin-left: auto; }
.tool-group, .segmented-tool {
  display: flex; gap: 1px; padding: 3px; border-radius: var(--r3); background: rgba(28, 26, 24, .92);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-float); backdrop-filter: blur(6px);
}
.tool-group:empty { display: none; }
.segmented-tool { display: flex; }
.segmented-tool button { height: 28px; padding: 0 11px; }
.segmented-tool button[aria-checked="true"], .segmented-tool button[aria-pressed="true"] { background: var(--surface-4); }
.segmented-tool button[aria-pressed="true"] .i { color: var(--accent); }
.tool {
  display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border: 0; border-radius: var(--r2);
  background: transparent; color: var(--text-2); transition: background .12s, color .12s;
}
.tool:hover { background: var(--surface-3); color: var(--text-1); }
.tool[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.tool-zoom { min-width: 48px; font-size: var(--fs-s); font-weight: 560; color: var(--text-2); }

.vp-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 3; max-width: min(380px, calc(100% - 200px));
  padding: 10px 12px; border-radius: var(--r3); background: rgba(28, 26, 24, .92); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-float); font-size: var(--fs-s); color: var(--text-2); backdrop-filter: blur(6px);
}
.vp-legend p { margin: 3px 0 0; line-height: 1.45; }
.legend-title { color: var(--text-1); font-weight: 600; }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.legend-title + .legend-list { margin-top: 7px; }
.legend-list li { display: flex; align-items: center; gap: 8px; }
.legend-list i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); flex: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .12) inset; }
.legend-list b { margin-left: auto; padding-left: 16px; color: var(--text-1); font-weight: 600; }

.vp-scale {
  position: absolute; right: 14px; bottom: 14px; z-index: 3; display: grid; justify-items: end; gap: 3px;
  font-size: var(--fs-xs); color: var(--text-2); pointer-events: none;
}
.vp-scale i { display: block; height: 6px; border: 1.5px solid var(--text-2); border-top: 0; min-width: 20px; }

.stale-flag {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 12px; border-radius: 15px;
  background: rgba(40, 30, 18, .95); border: 1px solid rgba(236, 159, 74, .45); color: var(--warn);
  font-size: var(--fs-s); font-weight: 560; box-shadow: var(--shadow-float); animation: pop .2s var(--ease);
}
.stale-flag .link-btn { color: var(--accent-ink); background: var(--accent); padding: 3px 10px; border-radius: 11px; font-weight: 650; }

/* ---------- SVG drawing styles (mm space, --px = 1 screen px) ---------- */
.vp-svg { --px: 1; }
.vp-svg .dim-line, .vp-svg .dim-ext { fill: none; stroke: #9fd0ff; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.vp-svg .dim-ext { stroke-opacity: .45; stroke-dasharray: 3 3; }
.vp-svg .dim-tag rect { fill: var(--stage-0); stroke: rgba(159, 208, 255, .5); stroke-width: 1px; vector-effect: non-scaling-stroke; rx: calc(var(--px) * 3px); }
.vp-svg .dim-tag text { fill: #cfe7ff; font-size: calc(var(--px) * 11px); font-weight: 600; text-anchor: middle; dominant-baseline: central; }

.wall-img { transition: opacity .28s var(--ease); }
.wall-frame { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.g-guides .box-line { fill: none; stroke: rgba(243, 181, 91, .9); stroke-width: 1.4px; vector-effect: non-scaling-stroke; }
.g-guides .ring { fill: none; stroke: rgba(243, 181, 91, .5); stroke-width: 1px; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.g-guides text { fill: rgba(243, 181, 91, .95); font-size: calc(var(--px) * 11px); font-weight: 650; }
.g-box .box-hit { fill: transparent; stroke: transparent; stroke-width: 12px; vector-effect: non-scaling-stroke; pointer-events: none; }
.g-box.can-move .box-hit { pointer-events: all; cursor: grab; touch-action: none; }
.g-box.dragging .box-hit { cursor: grabbing; }
.g-box .box-ghost { fill: rgba(243, 181, 91, .14); stroke: rgba(243, 181, 91, .95); stroke-width: 1.6px; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; opacity: 0; pointer-events: none; }
.g-box.dragging .box-ghost, .g-box.moved .box-ghost, .g-box.can-move .box-hit:hover + .box-ghost { opacity: 1; }
.legend-tip { margin-top: 6px; color: var(--text-3); }
.g-outline path { fill: none; stroke: var(--select); stroke-width: 1px; stroke-opacity: .85; vector-effect: non-scaling-stroke; }

/* panels */
.panels-layout { position: absolute; inset: 0; display: grid; grid-template-columns: 236px 1fr; }
.parts { display: grid; grid-template-rows: auto 1fr; min-height: 0; background: rgba(21, 20, 19, .72); border-right: 1px solid var(--line); }
.parts-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 8px; font-weight: 640; }
.parts-count { color: var(--text-3); font-size: var(--fs-xs); font-weight: 500; }
.parts-list { overflow-y: auto; padding: 0 6px 12px; display: grid; align-content: start; gap: 2px; }
.sprite-host { position: absolute; width: 0; height: 0; }
.part-row {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 6px 8px 6px 6px; border: 1px solid transparent; border-radius: var(--r2); background: none; color: var(--text-1);
}
.part-row:hover { background: var(--surface-2); }
.part-row[aria-selected="true"] { background: var(--select-soft); border-color: rgba(95, 176, 255, .45); }
.part-thumb { width: 44px; height: 36px; background: var(--stage-0); border-radius: var(--r1); padding: 3px; }
.part-txt { min-width: 0; display: grid; }
.part-name { font-weight: 560; font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-meta { color: var(--text-3); font-size: var(--fs-xs); }
.part-meta b { color: var(--accent); font-weight: 600; }
.part-status { display: grid; }
.part-status.st-good { color: var(--good); opacity: .8; }
.part-status.st-warn { color: var(--warn); }
.panels-canvas { position: relative; min-width: 0; }

.p-removed { fill: var(--wood-removed); stroke: var(--wood-removed-line); stroke-width: 1px; vector-effect: non-scaling-stroke; fill-rule: evenodd; }
.p-wood { fill: var(--wood); stroke: var(--wood-edge); stroke-width: 1px; vector-effect: non-scaling-stroke; fill-rule: evenodd; }
.p-eng { fill: var(--engrave-wood); fill-rule: evenodd; }
.p-slit { fill: none; stroke: var(--ink-slit); stroke-width: 1.2px; vector-effect: non-scaling-stroke; }
.p-bridges { fill: var(--ov-bridge); }
.p-islands { fill: var(--ov-island); fill-opacity: .14; stroke: var(--ov-island); stroke-width: 1.2px; vector-effect: non-scaling-stroke; fill-rule: evenodd; }
.p-thin { fill: var(--ov-thin); }
.p-dropped { fill: var(--ov-dropped); }
.part-thumb .p-wood, .part-thumb .p-removed { stroke: none; }
.hide-bridges .p-bridges, .hide-islands .p-islands, .hide-thin .p-thin, .hide-removed .p-removed { display: none; }
.flash-thin .p-thin, .flash-bridges .p-bridges, .flash-islands .p-islands, .flash-dropped .p-dropped { animation: ov-flash .5s ease-in-out 3; }
@keyframes ov-flash { 50% { opacity: .15; } }
.wall-side path { stroke: var(--accent); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.wall-side text { fill: var(--accent); font-size: calc(var(--px) * 11px); font-weight: 600; }

.part-head {
  display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--r3); background: rgba(28, 26, 24, .92);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-float); max-width: 420px; backdrop-filter: blur(6px);
}
.part-title { font-size: var(--fs-l); font-weight: 680; display: flex; align-items: baseline; gap: 8px; }
.part-qty { color: var(--accent); font-size: var(--fs-m); }
.part-role { color: var(--text-2); font-size: var(--fs-s); line-height: 1.45; }
.part-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.part-actions { display: flex; gap: 6px; padding-top: 2px; }

.locator {
  position: absolute; right: 12px; bottom: 44px; z-index: 3; width: 150px; display: grid; gap: 6px; justify-items: center;
  padding: 10px; border-radius: var(--r3); background: rgba(28, 26, 24, .92); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-float); font-size: var(--fs-xs); color: var(--text-3); text-align: center;
}
.locator svg { width: 96px; height: 96px; overflow: visible; }
.loc-box { fill: rgba(212, 180, 131, .1); stroke: var(--text-3); stroke-width: 1.2px; vector-effect: non-scaling-stroke; fill-rule: evenodd; }
.loc-mark { fill: none; stroke: var(--select); stroke-width: 4px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.loc-arrow { stroke: var(--select); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.loc-fill { fill: var(--select-soft); stroke: var(--select); stroke-width: 2px; vector-effect: non-scaling-stroke; fill-rule: evenodd; }
.loc-led { fill: var(--accent); }

/* cut sheet */
.sheet-svg .bed { fill: #20242a; }
.sheet-svg .bed-card { fill: #1d1d22; }
.sheet-svg .bed-shadow { fill: #000; transform: translate(calc(var(--px) * 3px), calc(var(--px) * 5px)); opacity: .35; filter: blur(4px); }
.sheet-svg .bed-edge { fill: none; stroke: #59616d; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.sheet-svg .grid-minor { fill: none; stroke: rgba(200, 215, 235, .05); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.sheet-svg .grid-major { fill: none; stroke: rgba(200, 215, 235, .11); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.sheet-svg .rulers path { stroke: var(--text-3); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.sheet-svg .rl { fill: var(--text-3); font-size: calc(var(--px) * 10px); }
.sheet-svg .rl-x { text-anchor: middle; }
.sheet-svg .rl-y { text-anchor: end; dominant-baseline: central; }
.sheet-svg .bed-label { fill: var(--text-3); font-size: calc(var(--px) * 11px); dominant-baseline: hanging; }
.sheet-svg .offcut rect { fill: rgba(120, 198, 147, .05); stroke: rgba(120, 198, 147, .35); stroke-dasharray: 4 4; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.sheet-svg .offcut text { fill: rgba(120, 198, 147, .8); font-size: calc(var(--px) * 11px); font-weight: 560; text-anchor: middle; dominant-baseline: central; }
.sheet-svg .layer-cut path { stroke: var(--cut); stroke-width: 1px; vector-effect: non-scaling-stroke; fill: none; }
.sheet-svg .layer-eng path { fill: var(--engrave); fill-opacity: .75; }
.sheet-svg .layer-lbl path { fill: none; stroke: var(--label); stroke-width: 1.2px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sheet-svg[data-display="material"] .bed { fill: #2b2a27; }
.sheet-svg[data-display="material"] .bed-grid { opacity: .35; }
.sheet-svg[data-display="material"] .layer-cut path { fill: var(--wood); fill-rule: evenodd; stroke: var(--wood-edge); }
.sheet-svg[data-display="material"] .layer-eng path { fill: var(--engrave-wood); fill-opacity: 1; }
.sheet-svg.hide-cut .layer-cut, .sheet-svg.hide-eng .layer-eng, .sheet-svg.hide-lbl .layer-lbl,
.sheet-svg.hide-grid .bed-grid, .sheet-svg.hide-grid .rulers { display: none; }
.part-hits rect { fill: transparent; stroke: transparent; cursor: pointer; }
.part-hits rect:hover { fill: rgba(95, 176, 255, .07); stroke: rgba(95, 176, 255, .6); stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }
.part-hits rect.selected { fill: rgba(95, 176, 255, .1); stroke: var(--select); stroke-width: 1.5px; vector-effect: non-scaling-stroke; stroke-dasharray: none; }

.sheet-layout { grid-template-columns: 264px 1fr; }
.sheet-side { display: flex; flex-direction: column; overflow-y: auto; }
.sheet-side .parts-list { overflow: visible; }
.sheet-stats { margin: 12px 12px 4px; padding: 12px; border-radius: var(--r3); background: var(--surface-2); border: 1px solid var(--line-2); }
.stats-free { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; color: var(--good); font-size: var(--fs-xs); }
.sheet-part { grid-template-columns: 22px 1fr; padding: 6px 8px; }
.sheet-part-n { width: 22px; height: 22px; border-radius: var(--r1); display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; }
.sheet-part.selected .sheet-part-n { background: var(--select); color: #06121f; }
.sheet-part .part-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-hits rect.hot { fill: rgba(95, 176, 255, .1); stroke: rgba(95, 176, 255, .8); stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }
.stats-title { display: flex; align-items: center; gap: 8px; font-weight: 640; }
.stats-title .i { color: var(--accent); }
.stats-title span { margin-left: auto; color: var(--text-3); font-weight: 500; font-size: var(--fs-xs); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 10px 0 8px; }
.stats-grid dt { color: var(--text-3); font-size: var(--fs-xs); }
.stats-grid dd { margin: 1px 0 0; font-weight: 640; font-size: var(--fs-l); display: grid; gap: 4px; }
.meter { display: block; height: 3px; border-radius: 2px; background: var(--surface-4); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--good); border-radius: 2px; }
.stats-note { margin: 0; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.45; }
.hover-tip {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; display: grid; gap: 1px;
  padding: 7px 10px; border-radius: var(--r2); background: var(--surface-2); border: 1px solid var(--line-3);
  box-shadow: var(--shadow-pop); font-size: var(--fs-s); max-width: 280px;
}
.hover-tip .muted { color: var(--text-3); font-size: var(--fs-xs); }

/* 3D */
.vp-3d { background: #0f1114; }
.three-host { position: absolute; inset: 0; opacity: 0; transition: opacity .35s var(--ease); }
.three-host.ready { opacity: 1; }
.three-host canvas { display: block; width: 100% !important; height: 100% !important; }
.three-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.three-label {
  position: absolute; left: 0; top: 0; padding: 2px 7px; border-radius: var(--r1); white-space: nowrap;
  background: rgba(14, 16, 19, .88); border: 1px solid rgba(159, 208, 255, .45); color: #cfe7ff; font-size: var(--fs-xs); font-weight: 600;
}
.three-label-led { border-color: rgba(243, 181, 91, .6); color: var(--accent-hi); }
.three-pick {
  position: absolute; left: 50%; top: 58px; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px; border-radius: 17px; background: rgba(28, 26, 24, .94); border: 1px solid rgba(95, 176, 255, .5);
  box-shadow: var(--shadow-float); font-weight: 600; font-size: var(--fs-s); color: var(--text-1);
}
.three-pick .i { color: var(--select); }
.three-pick .link-btn { color: var(--select); margin-left: 4px; }
.three-hint { position: absolute; right: 14px; bottom: 12px; color: var(--text-3); font-size: var(--fs-xs); pointer-events: none; }

/* ---------- empty / busy / failure ---------- */
.empty {
  position: absolute; inset: 0; overflow-y: auto; display: grid; justify-items: center; align-content: center;
  gap: 14px; padding: 32px; text-align: center;
}
.empty-art { width: 340px; max-width: 80%; height: auto; margin-bottom: 4px; }
.empty-rays path { stroke: rgba(243, 181, 91, .22); stroke-width: 1; fill: none; }
.empty-motif path { fill: rgba(16, 14, 12, .9); stroke: rgba(243, 181, 91, .28); stroke-width: 1; }
.empty-box { fill: #2a2622; stroke: #5a524a; stroke-width: 1.5; }
.empty h1 { margin: 0; font-size: 26px; font-weight: 720; font-stretch: 110%; letter-spacing: -.015em; }
.empty > p { margin: 0; max-width: 46ch; color: var(--text-2); font-size: var(--fs-l); line-height: 1.5; }
.empty-actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.empty-actions .btn { cursor: pointer; }
.empty-or { color: var(--text-3); font-size: var(--fs-s); }
.examples { display: grid; grid-template-columns: repeat(5, 132px); gap: 10px; margin-top: 26px; }
.example {
  display: grid; gap: 2px; justify-items: start; text-align: left; padding: 6px 6px 9px; border-radius: var(--r3);
  background: var(--surface-1); border: 1px solid var(--line-2); transition: border-color .12s, background .12s, transform .12s;
}
.example:hover { border-color: var(--line-3); background: var(--surface-2); transform: translateY(-2px); }
.example-img { width: 100%; aspect-ratio: 1.2; border-radius: var(--r2); background: #efe9df; display: grid; place-items: center; overflow: hidden; margin-bottom: 6px; }
.example-img img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.example-name { font-weight: 600; font-size: var(--fs-s); padding: 0 2px; }
.example-meta { color: var(--text-3); font-size: var(--fs-xs); padding: 0 2px; }

.busy { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(10, 11, 13, .55); animation: view-in .2s; }
.busy-card {
  width: 340px; padding: 16px 18px; border-radius: var(--r3); background: var(--surface-1); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-pop); display: grid; gap: 10px;
}
.busy-head { display: flex; justify-content: space-between; font-weight: 640; }
.busy-time { color: var(--text-2); font-weight: 500; }
.busy-card p { margin: 0; color: var(--text-3); font-size: var(--fs-s); line-height: 1.45; }
.busy-card .btn { justify-self: end; }
.progress { height: 3px; border-radius: 2px; background: var(--surface-4); overflow: hidden; }
.progress i { display: block; width: 36%; height: 100%; border-radius: 2px; background: var(--accent); animation: indeterminate 1.3s var(--ease) infinite; }
@keyframes indeterminate { 0% { transform: translateX(-110%); } 100% { transform: translateX(290%); } }

.failure { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 32px; text-align: center; }
.failure > .i { color: var(--bad); }
.failure h2 { margin: 4px 0 0; font-size: var(--fs-xl); font-weight: 680; }
.failure p { margin: 0; max-width: 54ch; color: var(--text-2); line-height: 1.5; }
.failure-actions { margin-top: 8px; display: flex; gap: 8px; }

.drop-veil { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(10, 11, 13, .7); pointer-events: none; }
.drop-veil > div {
  display: grid; gap: 12px; justify-items: center; padding: 40px 64px; border-radius: 14px; color: var(--accent);
  border: 2px dashed rgba(243, 181, 91, .7); background: rgba(28, 26, 24, .9); font-weight: 620; font-size: var(--fs-l);
}

/* ==========================================================================
   Manufacturing check (right panel)
   ========================================================================== */
.health {
  width: var(--health-w); display: grid; grid-template-rows: auto 1fr; min-height: 0; background: var(--surface-1);
  border-left: 1px solid var(--line); transition: width .2s var(--ease);
}
.health.collapsed { width: 46px; grid-template-rows: 1fr; }
.health-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); }
.health-title { font-weight: 640; }
.health-scroll { overflow-y: auto; padding: 14px 14px 20px; min-height: 0; overscroll-behavior: contain; }
.health-empty { padding: 40px 24px; display: grid; justify-items: center; gap: 12px; text-align: center; color: var(--text-3); font-size: var(--fs-s); line-height: 1.5; }
.health-empty .i { color: var(--line-3); }

.verdict { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--r3); border: 1px solid; }
.verdict-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.verdict-icon .i { width: 19px; height: 19px; }
.verdict-title { font-weight: 680; font-size: var(--fs-l); }
.verdict-sub { color: var(--text-2); font-size: var(--fs-s); }
.v-good { border-color: rgba(120, 198, 147, .3); background: var(--good-soft); }
.v-good .verdict-icon { background: rgba(120, 198, 147, .18); color: var(--good); }
.v-warn { border-color: rgba(236, 159, 74, .3); background: var(--warn-soft); }
.v-warn .verdict-icon { background: rgba(236, 159, 74, .18); color: var(--warn); }
.v-bad { border-color: rgba(240, 107, 94, .32); background: var(--bad-soft); }
.v-bad .verdict-icon { background: rgba(240, 107, 94, .18); color: var(--bad); }

.tally { display: flex; gap: 12px; padding: 10px 2px 2px; font-size: var(--fs-xs); color: var(--text-2); }
.tally span { display: flex; align-items: center; gap: 4px; }
.t-good .i, .t-good.rail-n { color: var(--good); }
.t-warn .i, .t-warn.rail-n { color: var(--warn); }
.t-bad .i, .t-bad.rail-n { color: var(--bad); }

.health-h { margin: 18px 2px 8px; font-size: var(--fs-s); font-weight: 640; color: var(--text-2); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.check {
  display: grid; grid-template-columns: 18px 1fr auto 12px; gap: 9px; align-items: start; width: 100%; text-align: left;
  padding: 9px 8px 9px 9px; border-radius: var(--r2); border: 1px solid transparent; background: var(--surface-2);
  color: var(--text-1); position: relative; transition: background .12s, border-color .12s;
}
.check::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: transparent; }
.check.c-warn::before { background: var(--warn); }
.check.c-bad::before { background: var(--bad); }
.check:hover:not(.no-focus) { background: var(--surface-3); }
.check.active { border-color: rgba(95, 176, 255, .5); background: var(--select-soft); }
.check.no-focus { cursor: default; grid-template-columns: 18px 1fr auto; }
.check-icon { display: grid; padding-top: 1px; }
.c-good .check-icon { color: var(--good); }
.c-warn .check-icon { color: var(--warn); }
.c-bad .check-icon { color: var(--bad); }
.check-main { display: grid; gap: 2px; min-width: 0; }
.check-title { font-weight: 600; font-size: var(--fs-s); }
.check-detail { color: var(--text-3); font-size: var(--fs-xs); line-height: 1.42; }
.check-detail { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.check.active .check-detail, .check:focus-visible .check-detail { -webkit-line-clamp: unset; }
.check-value { font-weight: 640; font-size: var(--fs-s); white-space: nowrap; }
.c-warn .check-value { color: var(--warn); }
.c-bad .check-value { color: var(--bad); }
.check-go { color: var(--text-3); padding-top: 1px; transform: rotate(-90deg); }
.check:hover .check-go { color: var(--text-1); }

.figures { margin: 0; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.figures div { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.figures div:nth-child(odd) { border-right: 1px solid var(--line); }
.figures div:nth-last-child(-n+2) { border-bottom: 0; }
.figures div:nth-last-child(1):nth-child(odd) { grid-column: span 2; border-right: 0; }
.figures dt { color: var(--text-3); font-size: var(--fs-xs); }
.figures dd { margin: 1px 0 0; font-weight: 620; font-size: var(--fs-s); }
.health-foot { margin: 14px 2px 0; color: var(--text-3); font-size: var(--fs-xs); }

.health-rail { display: grid; justify-items: center; align-content: start; gap: 8px; padding: 8px 0; }
.rail-verdict { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; margin-top: 4px; }
.rail-verdict.v-good { background: rgba(120, 198, 147, .16); color: var(--good); border: 0; }
.rail-verdict.v-warn { background: rgba(236, 159, 74, .16); color: var(--warn); border: 0; }
.rail-verdict.v-bad { background: rgba(240, 107, 94, .16); color: var(--bad); border: 0; }
.rail-n { font-weight: 680; font-size: var(--fs-s); }

/* ==========================================================================
   Overlays: tooltip, toasts, dialogs
   ========================================================================== */
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: var(--r2); background: #0c0b0a; color: var(--text-1); border: 1px solid var(--line-2);
  font-size: var(--fs-s); font-weight: 500; box-shadow: var(--shadow-pop); white-space: nowrap; animation: tip-in .12s ease;
}
.tooltip-long { white-space: normal; max-width: 280px; line-height: 1.45; padding: 8px 10px; color: var(--text-2); }
.tooltip kbd { background: var(--surface-2); }
@keyframes tip-in { from { opacity: 0; } }

.toasts { position: fixed; left: 50%; bottom: calc(var(--status-h) + 14px); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; min-width: 300px; max-width: min(520px, calc(100vw - 32px));
  padding: 10px 8px 10px 12px; border-radius: var(--r3); background: var(--surface-2); border: 1px solid var(--line-3);
  box-shadow: var(--shadow-pop); animation: toast-in .22s var(--ease); font-size: var(--fs-s); line-height: 1.45;
}
.toast > .i { margin-top: 1px; }
.toast-success > .i { color: var(--good); }
.toast-error > .i { color: var(--bad); }
.toast-error { border-color: rgba(240, 107, 94, .45); }
.toast-info > .i { color: var(--select); }
.toast-warn > .i { color: var(--warn); }
.toast-body { flex: 1; display: grid; gap: 1px; color: var(--text-2); }
.toast-body strong { color: var(--text-1); font-weight: 640; }
.toast-body .link-btn { color: var(--accent); justify-self: start; font-weight: 600; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.dialog {
  padding: 0; border: 1px solid var(--line-3); border-radius: 10px; background: var(--surface-1); color: var(--text-1);
  box-shadow: var(--shadow-pop); max-height: calc(100vh - 64px); width: min(880px, calc(100vw - 48px));
}
.dialog[open] { animation: dlg-in .2s var(--ease); }
.dialog::backdrop { background: rgba(8, 8, 9, .62); backdrop-filter: blur(2px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.dialog-narrow { width: min(500px, calc(100vw - 32px)); }
.export-locked .dialog-head h2 { display: flex; align-items: center; gap: 8px; }
.export-locked .dialog-head h2 .i { color: var(--accent); }
.export-locked .dialog-body { display: block; padding: 16px 20px; color: var(--text-2); }
.export-locked .dialog-body p { margin: 0 0 12px; }
.locked-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.locked-list li { display: flex; gap: 10px; }
.locked-list .i { color: var(--good); margin-top: 2px; flex: none; }
.export-locked .dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
#projects-dialog .dialog-body { display: block; padding: 14px 20px; }
#projects-dialog .dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.project-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.project-list .skeleton { height: 58px; }
.project { display: flex; align-items: center; gap: 6px; border-radius: var(--r2); border: 1px solid var(--line); background: var(--surface-0); }
.project.is-open { border-color: rgba(243, 181, 91, .45); }
.project-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; background: none; color: inherit; text-align: left; border-radius: var(--r2); }
.project-open:hover { background: var(--surface-2); }
.project-thumb { width: 42px; height: 42px; flex: none; border-radius: var(--r1); background: #efe9df; overflow: hidden; display: grid; place-items: center; }
.project-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.project-meta { min-width: 0; display: grid; gap: 2px; }
.project-meta strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-meta small { color: var(--text-3); font-size: var(--fs-xs); }
.project .icon-btn { margin-right: 8px; flex: none; }
.project .icon-btn.confirm { width: auto; padding: 0 8px; color: var(--bad); font-size: var(--fs-xs); font-weight: 650; }
.project-empty { display: flex; align-items: center; gap: 12px; padding: 18px 4px; color: var(--text-2); }
.project-empty .i { color: var(--text-3); flex: none; }
.dialog-inner { display: grid; grid-template-rows: auto auto 1fr; max-height: calc(100vh - 66px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: var(--fs-xl); font-weight: 700; }
.dialog-head p { margin: 3px 0 0; color: var(--text-2); font-size: var(--fs-s); }
.dialog-body { overflow-y: auto; display: grid; grid-template-columns: 1fr 250px; min-height: 0; }
.banner { display: flex; align-items: center; gap: 10px; margin: 12px 20px 0; padding: 9px 10px 9px 12px; border-radius: var(--r2); font-size: var(--fs-s); }
.banner span { flex: 1; }
.banner-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(236, 159, 74, .35); }

.export-main { padding: 16px 20px 20px; display: grid; gap: 18px; align-content: start; }
.export-all {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left;
  padding: 12px; border-radius: var(--r3); border: 1px solid rgba(243, 181, 91, .4); background: var(--accent-soft); color: var(--text-1);
}
.export-all:hover { background: rgba(243, 181, 91, .2); }
.export-all-icon { width: 40px; height: 40px; border-radius: var(--r2); display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.export-all strong { display: block; font-weight: 660; }
.export-all span span { color: var(--text-2); font-size: var(--fs-s); }
.export-all.working { pointer-events: none; opacity: .8; }
.export-group h3 { margin: 0; font-size: var(--fs-m); font-weight: 650; }
.export-group > p { margin: 2px 0 8px; color: var(--text-3); font-size: var(--fs-s); }
.export-group ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.export-file { display: grid; grid-template-columns: 18px 1fr auto 28px; gap: 10px; align-items: center; padding: 7px 8px 7px 12px; }
.export-file + .export-file { border-top: 1px solid var(--line); }
.export-file:hover { background: var(--surface-2); }
.export-file > .i { color: var(--text-3); }
.ef-txt { display: grid; min-width: 0; }
.ef-name { font-weight: 560; font-size: var(--fs-s); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ef-desc { color: var(--text-3); font-size: var(--fs-xs); }
.ef-size { color: var(--text-3); font-size: var(--fs-xs); }
.preflight { padding: 16px 20px 20px 18px; border-left: 1px solid var(--line); background: var(--surface-0); }
.preflight h3 { margin: 0 0 10px; font-size: var(--fs-m); font-weight: 650; }
.preflight ol { margin: 0; padding: 0 0 0 18px; display: grid; gap: 10px; color: var(--text-2); font-size: var(--fs-s); line-height: 1.45; }
.preflight li::marker { color: var(--accent); font-weight: 650; }
.preflight strong { color: var(--text-1); font-weight: 600; }

.keys-dialog { width: min(480px, calc(100vw - 48px)); }
.keys { margin: 0; padding: 12px 20px 20px; display: grid; gap: 2px; }
.keys div { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.keys div:last-child { border-bottom: 0; }
.keys dt { display: flex; gap: 4px; flex-wrap: wrap; }
.keys dd { margin: 0; color: var(--text-2); font-size: var(--fs-s); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1400px) {
  :root { --inspector-w: 284px; --health-w: 296px; }
  .ws { padding: 0 11px 0 9px; }
}
@media (max-width: 1240px) {
  .ws span { display: none; }
  .ws { padding: 0 10px; }
  .ws::after { left: 8px; right: 8px; }
  .run-state span:last-child { display: none; }
  .examples { grid-template-columns: repeat(3, 132px); }
}
@media (max-height: 800px) {
  .sheet-stats .stats-note { display: none; }
  .empty-art { width: 260px; }
  .examples { margin-top: 14px; }
}
@media (max-width: 860px) {
  /* the document must be the only scroller: a 100%-high scrolling body inside a
     scrolling root lets a swipe slide the whole page away and strands it */
  html, body { height: auto; overflow: visible; }
  #sb-keys { display: none; }
  input[type="range"] { touch-action: pan-y; }   /* vertical swipes scroll, sideways drags slide */
  /* nothing inside the page may catch a one-finger swipe: the side panels are not
     scrollers here, and the drawing pans sideways while vertical swipes scroll the page */
  .app, .inspector { overflow: clip; }
  .inspector-scroll, .health-scroll { overflow: visible; overscroll-behavior: auto; scrollbar-gutter: auto; }
  .vp-svg { touch-action: pan-y; }
  .app { height: auto; grid-template-rows: auto auto auto; }
  .titlebar { grid-template-columns: 1fr auto; padding: 8px 12px; row-gap: 8px; }
  .workspaces { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .ws { flex: 1; justify-content: center; }
  .body { grid-template-columns: 1fr; }
  .inspector { border-right: 0; border-bottom: 1px solid var(--line); }
  .stage { height: 72vh; }
  .health, .health.collapsed { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .panels-layout { grid-template-columns: 1fr; grid-template-rows: 120px 1fr; }
  .parts-list { grid-auto-flow: column; grid-auto-columns: 200px; overflow-x: auto; }
  .locator, .three-hint, .brand-studio, .doc { display: none; }
  .dialog-body { grid-template-columns: 1fr; }
  .preflight { border-left: 0; border-top: 1px solid var(--line); }
  .examples { grid-template-columns: repeat(2, 1fr); width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
