/* ============================================================
   Build System Studio  —  app.css
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root{
  --bg:#12151c; --bg2:#1b1f27; --bg3:#232834; --bg4:#2c323f;
  --line:#333a48; --line2:#3f485a;
  --txt:#dfe3ea; --txt-dim:#9aa2b1; --txt-faint:#6b7382;
  --accent:#4a9eff; --accent-dim:#2f6fbf;
  --good:#39c07a; --warn:#e6a23c; --bad:#e35d6a;
  --hole:#ffb300; --stud:#33d6c2;
}
html,body{ height:100%; }
body{
  background:var(--bg); color:var(--txt);
  font-family:'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  font-size:13px; overflow:hidden; -webkit-font-smoothing:antialiased;
}
.hidden{ display:none !important; }

/* ---------- top bar ---------- */
#topbar{
  height:50px; display:flex; align-items:center; gap:18px;
  background:var(--bg2); border-bottom:1px solid var(--line);
  padding:0 16px; position:relative; z-index:20;
}
.brand{ font-weight:600; font-size:15px; letter-spacing:.2px; white-space:nowrap; }
.brand-mark{ color:var(--accent); font-size:17px; }
.tabs{ display:flex; gap:4px; }
.tab{
  background:transparent; border:1px solid transparent; color:var(--txt-dim);
  padding:7px 14px; border-radius:7px; cursor:pointer; font-size:12.5px;
  font-weight:500; transition:.12s;
}
.tab:hover{ color:var(--txt); background:var(--bg3); }
.tab.active{ background:var(--accent); color:#fff; }
.tab-soon{ opacity:.5; }
.asm-title{
  color:var(--txt-dim); font-size:12.5px; font-weight:500;
  padding:5px 10px; border-radius:6px;
  background:rgba(255,255,255,0.04); border:1px solid var(--line);
  white-space:nowrap; max-width:320px; overflow:hidden; text-overflow:ellipsis;
}
.asm-title:empty{ display:none; }
.asm-title .asm-ver{ color:var(--accent); margin-left:6px; font-weight:600; }
.topbar-right{ margin-left:auto; display:flex; align-items:center; gap:12px; }
#status-msg{ color:var(--txt-dim); font-size:12px; min-width:40px; text-align:right; }
#status-msg.flash{ color:var(--good); }

/* ---------- layout ---------- */
.mode-view{ position:absolute; top:50px; left:0; right:0; bottom:0; display:flex; }
.viewport{ flex:1; position:relative; min-width:0; background:#10131a; }
.viewer-canvas{ display:block; width:100%; height:100%; }
.panel{
  width:288px; background:var(--bg2); display:flex; flex-direction:column;
  overflow:hidden;
}
.panel-left{ border-right:1px solid var(--line); }
.panel-right{ border-left:1px solid var(--line); width:312px; position:relative; }
.panel-resize{
  position:absolute; left:-3px; top:0; bottom:0; width:8px;
  cursor:ew-resize; z-index:7;
}
.panel-resize:hover{ background:var(--accent-dim); }
.panel-resize:active{ background:var(--accent); }
.panel-scroll{ overflow-y:auto; flex:1; min-height:0; }
.panel-scroll::-webkit-scrollbar{ width:10px; }
.panel-scroll::-webkit-scrollbar-thumb{ background:var(--bg4); border-radius:5px; }

/* The builder's left panel has two sibling views (library / animate)
   wrapped in a div each so they can be swapped. The wrapper itself
   must participate in the panel's flex column (flex:1 + min-height:0)
   so #b-partlist inside it can grow and scroll — without this, the
   wrapper collapses to its content height and the part list runs off
   the bottom of the panel with no scrollbar. */
#b-library-view, #b-animate-view{
  display:flex; flex-direction:column; flex:1; min-height:0;
}
#b-library-view.hidden, #b-animate-view.hidden{ display:none; }

/* ---------- panel sections ---------- */
.section{ border-bottom:1px solid var(--line); }
.section-head{
  padding:9px 13px; font-size:11.5px; font-weight:700; letter-spacing:.7px;
  text-transform:uppercase; color:var(--txt-dim); display:flex;
  align-items:center; justify-content:space-between;
}
.section-body{ padding:10px 13px; }
.section-body.tight{ padding:6px 8px; }

/* ---------- buttons ---------- */
.btn{
  background:var(--bg4); color:var(--txt); border:1px solid var(--line2);
  padding:7px 12px; border-radius:6px; cursor:pointer; font-size:12px;
  font-weight:500; transition:.12s; font-family:inherit;
}
.btn:hover{ background:var(--line2); }
.btn:active{ transform:translateY(1px); }
.btn-primary{ background:var(--accent); border-color:var(--accent); color:#fff; }
.btn-primary:hover{ background:#5aa8ff; }
.btn-ghost{ background:transparent; border-color:transparent; color:var(--txt-dim); }
.btn-ghost:hover{ background:var(--bg3); color:var(--txt); }
.btn-danger{ background:transparent; border-color:var(--bad); color:var(--bad); }
.btn-danger:hover{ background:var(--bad); color:#fff; }
.btn-sm{ padding:5px 9px; font-size:12px; }
/* The Instructions topbar uses a View-1 / View-2 segmented control —
   the active button gets the accent fill, inactive stays default. */
.btn.view-pick.active{ background:var(--accent); color:#fff; border-color:var(--accent); }
.btn-block{ width:100%; }
.btn-row{ display:flex; gap:7px; }
.btn-row .btn{ flex:1; }
.btn:disabled{ opacity:.4; cursor:not-allowed; }

/* ---------- inputs ---------- */
input[type=text],select{
  width:100%; background:var(--bg); color:var(--txt);
  border:1px solid var(--line2); border-radius:6px; padding:6px 8px;
  font-size:12px; font-family:inherit;
}
input[type=text]:focus,select:focus{ outline:none; border-color:var(--accent); }
label.field{ display:block; margin-bottom:9px; }
label.field .lab{ display:block; font-size:11.5px; color:var(--txt-dim); margin-bottom:4px; }

/* ---------- part list ---------- */
.list-row{
  display:flex; align-items:center; gap:9px; padding:7px 13px; cursor:pointer;
  border-left:3px solid transparent; transition:.1s;
}
.list-row:hover{ background:var(--bg3); }
.list-row.selected{ background:var(--bg3); border-left-color:var(--accent); }
.row-dot{ width:13px; height:13px; border-radius:3px; flex:none;
  border:1px solid rgba(255,255,255,.18); }
.row-main{ flex:1; min-width:0; }
.row-name{ font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row-sub{ font-size:10.5px; color:var(--txt-faint); }
.row-badge{
  font-size:10px; background:var(--bg4); color:var(--txt-dim);
  padding:2px 6px; border-radius:9px; flex:none;
}
/* Per-member multiplier editor in expanded link groups (Keyed / Gear
   Mesh / manual links). Lives at the end of each joint row so the
   numeric multiplier is right next to the joint it controls. */
.link-member-ctl{
  display:inline-flex; align-items:center; gap:3px; margin-left:6px;
}
.link-factor-x{ color:var(--txt-faint); font-size:10px; }
.link-factor{
  width:52px; padding:1px 3px; font-size:11px;
  background:#222; color:#ddd; border:1px solid #444; border-radius:3px;
  font-variant-numeric:tabular-nums;
}
.link-factor:focus{ outline:none; border-color:var(--accent); }
.link-rm{ color:#e85858; cursor:pointer; font-size:11px; padding:0 2px; }
.link-rm:hover{ color:#ff8080; }
.link-add-btn{
  margin:4px 0 4px 18px; font-size:11px;
  background:rgba(255,255,255,0.04); border:1px dashed var(--line2);
}
.link-add-btn:hover{ background:rgba(255,255,255,0.08); }

/* Driver radio on a link member row. */
.link-driver{ display:inline-flex; align-items:center; cursor:pointer; margin-right:1px; }
.link-driver input{ cursor:pointer; accent-color:var(--accent); width:12px; height:12px; }

/* Inline drive slider (link driver + loose movable joints). */
.drive-ctl{
  display:flex; align-items:center; gap:6px;
  margin:2px 6px 4px 20px; padding:1px 0;
}
.drive-range{
  flex:1; min-width:60px; height:16px; cursor:pointer; accent-color:var(--accent);
}
.drive-val{
  width:44px; color:#ffc04a; font-size:11px; font-variant-numeric:tabular-nums;
  text-align:right; background:#222; border:1px solid #444; border-radius:3px; padding:1px 3px;
}
.drive-val:focus{ outline:none; border-color:var(--accent); }
.drive-deg{ color:#888; font-size:11px; margin-left:-2px; }
.drive-reset{
  color:var(--txt-faint); cursor:pointer; font-size:13px; line-height:1;
  padding:0 3px; border-radius:3px;
}
.drive-reset:hover{ color:#fff; background:var(--accent-dim); }

/* Motion Group — a container node, tinted teal to read apart from links. */
.tree-motion > .tree-label{
  border-left:2px solid #5bd6c0; background:rgba(91,214,192,0.06);
}
.mg-remove{ color:var(--txt-faint); cursor:pointer; font-size:14px; line-height:1; padding:0 3px; }
.mg-remove:hover{ color:#ff8080; }
/* Motion-group driver radio (teal to match the group). */
.mg-driver{ display:inline-flex; align-items:center; cursor:pointer; margin-right:2px; }
.mg-driver input{ cursor:pointer; accent-color:#5bd6c0; width:12px; height:12px; }
/* Passenger angle readout — a plain read-only value, not an editable box. */
.rm-angle-in.passenger{
  background:transparent; border-color:transparent; color:#9fdccb;
  cursor:default; text-align:right;
}

/* Per-row Dev / Official library chips. Grey by default; light green
   when a matching .bspart.json is indexed in that library folder. */
.row-chips{ display:flex; flex-direction:column; gap:2px; flex:none; }
.lib-chip{
  font-size:9px; padding:1px 5px; border-radius:8px;
  background:var(--bg4); color:var(--txt-faint); letter-spacing:.4px;
  font-weight:600; text-align:center; min-width:38px;
}
.lib-chip.matched{ background:#3ac661; color:#0a1a0a; }
/* collapsible folder-group header in the parts list */
.list-group-head{
  display:flex; align-items:center; gap:6px; padding:6px 11px;
  font-size:11px; font-weight:700; letter-spacing:.5px; text-transform:uppercase;
  color:var(--txt-dim); cursor:pointer; user-select:none;
  background:var(--bg2); border-top:1px solid var(--line);
  position:sticky; top:0; z-index:1;
}
.list-group-head:hover{ background:var(--bg3); color:var(--txt); }
.list-group-head .tw{ width:12px; font-size:10px; color:var(--txt-faint); }
.list-group-head:first-child{ border-top:none; }

/* ---------- snap point list ---------- */
.snap-row{
  display:flex; align-items:center; gap:8px; padding:5px 7px; border-radius:5px;
  font-size:11.5px;
}
.snap-row:hover{ background:var(--bg3); }
.snap-row.selected{
  background:rgba(47,111,208,.28);
  box-shadow:inset 3px 0 0 var(--accent);
}
.snap-chip{ width:11px; height:11px; border-radius:50%; flex:none;
  border:1px solid rgba(255,255,255,.25); }
.snap-row .sp-type{
  flex:1; min-width:0; background:var(--bg); color:var(--txt);
  border:1px solid var(--line2); border-radius:5px; padding:3px 5px;
  font-size:11px; font-family:inherit;
}
.snap-row .sp-label{ flex:1; color:var(--txt-dim); }
.snap-row .sp-del{ color:var(--txt-faint); cursor:pointer; padding:1px 5px; border-radius:4px; }
.snap-row .sp-del:hover{ color:var(--bad); background:var(--bg4); }

/* ---------- colour palette ---------- */
.pal-select-wrap{ margin-bottom:8px; }
.pal-select{
  width:100%; padding:4px 6px; font-size:12px;
  color:var(--txt); background:var(--bg2);
  border:1px solid var(--line); border-radius:6px; cursor:pointer;
}
.swatches{ display:flex; flex-wrap:wrap; gap:6px; }
.swatch{
  width:24px; height:24px; border-radius:5px; cursor:pointer;
  border:2px solid transparent; position:relative;
}
.swatch:hover{ transform:scale(1.08); }
.swatch.selected{ border-color:#fff; box-shadow:0 0 0 1px var(--bg2); }
.swatch.dark-swatch:not(.selected){ border-color:#6b7382; }

/* ---------- assembly tree ---------- */
.tree{ font-size:13.5px; }
.tree-node{ user-select:none; }
.tree-group > .tree-label{
  display:flex; align-items:center; gap:7px; padding:3px 8px; cursor:pointer;
  font-weight:600; border-radius:5px; color:var(--txt);
}
.tree-group > .tree-label:hover{ background:var(--bg3); }
.tree-inst{
  display:flex; align-items:center; gap:8px; padding:2px 8px; cursor:pointer;
  border-radius:5px; border-left:3px solid transparent; color:var(--txt);
}
.tree-inst:hover{ background:var(--bg3); }
.tree-inst.selected{ background:var(--bg3); border-left-color:var(--accent); }
.tree-inst.in-assign{ background:rgba(74,158,255,.13); border-left-color:var(--good); }
.tree-act{
  flex:none; cursor:pointer; color:var(--txt-dim);
  font-size:14px; line-height:1; padding:3px 6px; border-radius:4px;
  background:var(--bg3); border:1px solid var(--line2);
}
.tree-act:hover{ color:#fff; background:var(--accent-dim); border-color:var(--accent); }
.tree-label.drop-target{
  outline:1px dashed var(--good); outline-offset:-2px;
}
.tree-label.drop-target:hover{ background:rgba(57,192,122,.16); }
.tree-children{ padding-left:14px; border-left:1px solid var(--line2); margin-left:9px; }
.tw{ width:14px; text-align:center; color:var(--txt-dim); flex:none; font-size:12px; }
.eye{ cursor:pointer; color:var(--txt-dim); flex:none; font-size:14px; }
.eye:hover{ color:var(--txt); }
.eye.off{ color:var(--txt-faint); opacity:.55; }
.tree-name{ flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.count-pill{
  font-size:11px; color:var(--txt); background:var(--bg4);
  padding:1px 7px; border-radius:9px; flex:none;
}

/* ---------- filters ---------- */
.filter-row{
  display:flex; align-items:center; gap:8px; padding:5px 6px;
  font-size:12.5px; cursor:pointer; border-radius:4px;
}
.filter-row:hover{ background:var(--bg3); }
.filter-row input{ accent-color:var(--accent); }
.filter-row .fr-dot{ width:12px;height:12px;border-radius:3px;flex:none; }
.filter-row .fr-name{ flex:1; color:var(--txt); }
.filter-row .fr-count{ color:var(--txt-dim); font-size:11px; }

/* ---------- viewport overlays ---------- */
.view-toolbar{
  position:absolute; top:12px; left:12px; display:flex; gap:5px; z-index:5;
}
.view-toolbar .btn{ background:rgba(27,31,39,.9); }
.fps-counter{
  position:absolute; top:8px; left:12px; z-index:5;
  background:rgba(27,31,39,.9); color:var(--txt-dim);
  border:1px solid var(--line2); border-radius:6px;
  padding:3px 8px; font-size:11px; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-variant-numeric:tabular-nums; letter-spacing:.3px;
  pointer-events:none; user-select:none;
}
.view-recenter-btn{
  background:rgba(27,31,39,.9); color:var(--txt);
  border:1px solid var(--line2); border-radius:6px;
  cursor:pointer;
}
.view-recenter-btn:hover{ background:var(--line2); }
.view-hint{
  position:absolute; bottom:14px; left:50%; transform:translateX(-50%);
  background:rgba(27,31,39,.94); border:1px solid var(--line2);
  padding:8px 16px; border-radius:8px; font-size:12px; z-index:5;
  color:var(--txt-dim); pointer-events:none; max-width:80%; text-align:center;
}
.view-hint b{ color:var(--accent); }
.placement-banner{
  position:absolute; top:12px; left:50%; transform:translateX(-50%);
  background:var(--accent); color:#fff; padding:8px 18px; border-radius:8px;
  font-size:12.5px; font-weight:600; z-index:6; display:flex; gap:14px;
  align-items:center; box-shadow:0 4px 16px rgba(0,0,0,.4);
}
.placement-banner .btn{ background:rgba(255,255,255,.18); border-color:transparent;
  color:#fff; }
.empty-note{
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  color:var(--txt-faint); text-align:center; font-size:13px; line-height:1.7;
  pointer-events:none;
}
.empty-note .big{ font-size:34px; opacity:.4; display:block; margin-bottom:6px; }

/* ---------- overlays / modals ---------- */
.overlay{
  position:fixed; inset:0; background:rgba(8,10,14,.72);
  display:flex; align-items:center; justify-content:center; z-index:50;
}
.overlay-panel{
  background:var(--bg2); border:1px solid var(--line2); border-radius:12px;
  box-shadow:0 18px 60px rgba(0,0,0,.6); display:flex; flex-direction:column;
  max-height:88vh;
}
.overlay-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:13px 16px; border-bottom:1px solid var(--line); font-weight:600;
}
.overlay-foot{ padding:10px 16px; border-top:1px solid var(--line); }
.preview-panel{ width:min(720px, 92vw); }
.preview-viewport{ height:min(540px, 68vh); position:relative; background:#10131a; }
.hint{ color:var(--txt-faint); font-size:11.5px; }

/* ---- Help (nested-tab teaching guide) ---- */
.help-panel{ width:min(980px, 95vw); height:min(86vh, 780px); }
.help-body{ padding:0; display:flex; flex-direction:column; overflow:hidden; flex:1; min-height:0; }
.help-tabs{ display:flex; gap:4px; padding:10px 14px 0; border-bottom:1px solid var(--line); flex:none; }
.help-tab{ padding:7px 18px; border:1px solid transparent; border-bottom:none;
  border-radius:8px 8px 0 0; background:transparent; color:var(--txt-dim);
  cursor:pointer; font-size:13px; font-weight:600; }
.help-tab:hover{ color:var(--txt); }
.help-tab.active{ background:var(--bg3); color:var(--txt); border-color:var(--line2); }
.help-main{ display:flex; flex:1; min-height:0; }
.help-side{ width:214px; flex:none; border-right:1px solid var(--line);
  overflow-y:auto; padding:8px; }
.help-sub{ display:block; width:100%; text-align:left; padding:7px 10px; margin:1px 0;
  border-radius:6px; background:transparent; border:none; color:var(--txt-dim);
  cursor:pointer; font-size:12.5px; }
.help-sub:hover{ color:var(--txt); background:rgba(255,255,255,.03); }
.help-sub.active{ background:var(--bg3); color:var(--txt); font-weight:600; }
.help-content{ flex:1; overflow-y:auto; padding:20px 28px 34px; line-height:1.6; }
.help-content h3{ color:var(--txt); font-size:16.5px; margin:0 0 12px; }
.help-content h4{ color:var(--accent); font-size:13px; margin:20px 0 6px;
  text-transform:uppercase; letter-spacing:.03em; }
.help-content p{ color:var(--txt-dim); font-size:13px; margin:0 0 10px; }
.help-content ul, .help-content ol{ color:var(--txt-dim); font-size:13px;
  margin:0 0 10px; padding-left:20px; }
.help-content li{ margin:5px 0; }
.help-content code{ background:var(--bg4); padding:1px 5px; border-radius:4px;
  font-size:12px; color:var(--txt); }
.help-content b{ color:var(--txt); }
.help-lead{ color:var(--txt); font-size:13.5px; margin-bottom:14px; }
kbd{ display:inline-block; background:var(--bg4); border:1px solid var(--line2);
  border-bottom-width:2px; border-radius:5px; padding:1px 7px;
  font:600 11.5px ui-monospace,Menlo,Consolas,monospace; color:var(--txt); }
.help-keys{ width:100%; border-collapse:collapse; font-size:13px; margin:4px 0 12px; }
.help-keys td{ padding:7px 8px; border-bottom:1px solid var(--line);
  color:var(--txt-dim); vertical-align:top; }
.help-keys td:first-child{ white-space:nowrap; width:1%; padding-right:16px; }
details.deeper{ margin:10px 0 14px; border:1px solid var(--line2);
  border-radius:8px; background:rgba(255,255,255,.02); }
details.deeper > summary{ cursor:pointer; padding:8px 12px; color:var(--accent);
  font-size:12.5px; font-weight:600; list-style:none; user-select:none; }
details.deeper > summary::before{ content:'\25B8'; margin-right:7px;
  display:inline-block; font-size:10px; }
details.deeper[open] > summary::before{ content:'\25BE'; }
details.deeper > summary::-webkit-details-marker{ display:none; }
details.deeper .deeper-body{ padding:0 14px 10px; }
details.deeper .deeper-body p, details.deeper .deeper-body li{ font-size:12.5px; }
.help-fig{ margin:14px 0 16px; }
.help-fig svg{ display:block; width:100%; max-width:520px; height:auto;
  border:1px solid var(--line2); border-radius:8px; background:#12151b; }
.help-fig figcaption{ color:var(--txt-faint); font-size:11.5px; margin-top:7px;
  max-width:520px; }

/* ---------- quick-lookup palette (Builder, hotkey 's') ----------
   Command-palette-style overlay: search box on top, scrollable list
   of matches under it. Sized so ~5 rows are visible before the list
   needs to scroll. Click or Enter picks the highlighted part. */
.quicklookup{
  position:fixed; top:120px; left:50%; transform:translateX(-50%);
  width:380px; background:var(--bg2); border:1px solid var(--line);
  border-radius:8px; box-shadow:0 12px 36px rgba(0,0,0,0.45);
  z-index:60; display:flex; flex-direction:column; overflow:hidden;
}
.quicklookup.hidden{ display:none; }
.quicklookup-input{
  width:100%; box-sizing:border-box; padding:10px 12px;
  background:var(--bg2); color:var(--txt);
  border:none; border-bottom:1px solid var(--line);
  font-size:13.5px; outline:none;
}
.quicklookup-results{
  /* 5 rows of 44px + a fraction of the 6th so users know to scroll */
  max-height:222px; overflow-y:auto;
}
.quicklookup-row{
  display:flex; align-items:center; gap:9px;
  padding:6px 10px; cursor:pointer; border-bottom:1px solid var(--line);
}
.quicklookup-row:last-child{ border-bottom:none; }
.quicklookup-row.selected,
.quicklookup-row:hover{ background:var(--bg3); }
.quicklookup-row .part-thumb{
  width:32px; height:32px; flex:0 0 32px; border-radius:4px;
  background:var(--bg4); object-fit:cover;
}
.quicklookup-row .ql-name{
  font-size:12.5px; color:var(--txt); flex:1; min-width:0;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.quicklookup-row .ql-cat{
  font-size:10.5px; color:var(--txt-faint); margin-left:6px;
}
.quicklookup-empty{
  padding:14px 12px; color:var(--txt-faint); font-size:12px; text-align:center;
}

/* ---------- placeholder ---------- */
.placeholder{
  margin:auto; text-align:center; color:var(--txt-dim); line-height:1.7;
}
.placeholder h2{ color:var(--txt); margin-bottom:10px; font-weight:600; }

/* ---------- misc ---------- */
.muted{ color:var(--txt-dim); font-size:12.5px; line-height:1.5; }
.empty-list{ padding:16px 13px; color:var(--txt-faint); font-size:12px;
  text-align:center; line-height:1.6; }
.divider{ height:1px; background:var(--line); margin:9px 0; }
.kv{ display:flex; justify-content:space-between; font-size:12.5px;
  padding:3px 0; color:var(--txt-dim); }
.kv b{ color:var(--txt); font-weight:600; }
.tag{ display:inline-block; font-size:10px; padding:2px 7px; border-radius:9px;
  background:var(--bg4); color:var(--txt-dim); }

/* ============================================================
   Stage 3 - Instructions
   ============================================================ */
#ins-viewport{ background:#eceef1; }
textarea{
  width:100%; background:var(--bg); color:var(--txt);
  border:1px solid var(--line2); border-radius:6px; padding:7px 8px;
  font-size:12px; font-family:inherit; resize:vertical; min-height:62px;
}
textarea:focus{ outline:none; border-color:var(--accent); }
.step-row{
  display:flex; align-items:center; gap:9px; padding:7px 11px; cursor:pointer;
  border-left:3px solid transparent; transition:.1s;
}
.step-row:hover{ background:var(--bg3); }
.step-row.selected{ background:var(--bg3); border-left-color:var(--accent); }
.step-num{
  width:23px; height:23px; border-radius:50%; background:var(--bg4);
  color:var(--txt); font-size:11.5px; font-weight:700; flex:none;
  display:flex; align-items:center; justify-content:center;
}
.step-row.selected .step-num{ background:var(--accent); color:#fff; }
.step-row .row-main{ flex:1; min-width:0; }
/* Capture slot thumbnails in the step list — empty = dashed box,
   filled = thumbnail of the last capture for that view. Two slots
   per step (main + secondary) and per Complete row. */
/* Page-preview button — sits left of the capture thumbnails on each row. */
.step-preview{
  flex:none; cursor:pointer; font-size:15px; line-height:1; padding:2px 4px;
  border-radius:4px; opacity:.65; margin-right:1px;
}
.step-preview:hover{ opacity:1; background:var(--bg4); }
.step-thumbs{ display:flex; gap:3px; flex:none; align-items:center; }
.capslot{
  width:22px; height:22px; border:1px dashed var(--line2);
  border-radius:3px; background:var(--bg); overflow:hidden;
  display:inline-block;
}
.capslot.filled{ border:1px solid var(--line); padding:0; }
.capslot img{ width:100%; height:100%; object-fit:cover; display:block; }
.capslot.filled:hover{ border-color:var(--accent); }
.capslot.filled img{ cursor:zoom-in; }
/* imported-photo slots carry a tiny camera badge so an external picture is
   visually distinct from a 3D capture in the step list */
.capslot.filled.photo{ position:relative; border-color:var(--accent); }
.capslot.filled.photo::after{
  content:'\1F4F7'; position:absolute; right:-2px; bottom:-3px;
  font-size:9px; line-height:1; text-shadow:0 0 2px #000;
}

/* full-size thumbnail viewer (click a captured step image) */
.ins-lightbox{
  position:fixed; inset:0; z-index:1000; display:flex;
  align-items:center; justify-content:center;
  background:rgba(8,10,14,.88); cursor:zoom-out;
}
.ins-lightbox img{
  max-height:100vh; max-width:100vw; width:auto; height:auto;
  box-shadow:0 12px 60px rgba(0,0,0,.6); border-radius:4px;
}
/* PDF page preview — A4 portrait fit to the window height. */
.ins-page-preview{
  height:94vh; width:calc(94vh * 210 / 297); max-width:96vw;
  border:0; border-radius:4px; background:#fff;
  box-shadow:0 12px 60px rgba(0,0,0,.6);
}
.ins-lightbox-hint{
  position:absolute; bottom:14px; left:0; right:0; text-align:center;
  color:#c9cfdb; font-size:12px; opacity:.8; pointer-events:none;
}
.step-actions{ display:flex; gap:1px; flex:none; }
.step-actions span{
  color:var(--txt-faint); cursor:pointer; padding:2px 5px;
  border-radius:4px; font-size:12px; line-height:1;
}
.step-actions span:hover{ color:var(--txt); background:var(--bg4); }
.gen-card{
  background:var(--bg3); border:1px solid var(--line2); border-radius:8px;
  padding:12px; text-align:center;
}
.gen-card .big{ font-size:30px; opacity:.5; }
.parts-line{
  display:flex; align-items:center; gap:7px; font-size:11.5px;
  padding:3px 0; color:var(--txt-dim);
}
.parts-line .row-dot{ width:11px; height:11px; }
.tree-inst.grounded{
  background:rgba(47,111,208,.13); border-left-color:var(--accent);
}
.tree-inst.excluded{
  opacity:.45; text-decoration:line-through;
}
.ground-mark{
  flex:none; width:14px; text-align:center; color:var(--txt-dim);
  font-size:13px; line-height:1;
}
.tree-inst.grounded .ground-mark{ color:var(--accent); }
.tree-arrow-row{
  display:flex; flex-wrap:wrap; align-items:center; gap:5px;
  padding:4px 6px 4px 4px; font-size:11px;
}
.arrow-btn{
  background:var(--bg3); color:var(--txt-dim); border:1px solid var(--line2);
  border-radius:4px; padding:3px 7px; font-size:11px; font-family:inherit;
  cursor:pointer; transition:.1s;
}
.arrow-btn:hover{ background:var(--bg4); color:var(--txt); }
.arrow-btn b{ color:var(--txt); font-weight:600; }
.arrow-btn.picking{
  background:var(--good); border-color:var(--good); color:#fff;
}
.arrow-btn.picking b{ color:#fff; }
.toggle-row{
  display:flex; align-items:center; justify-content:space-between;
  font-size:12px; padding:5px 0;
}
.switch{
  width:36px; height:20px; background:var(--bg4); border-radius:11px;
  position:relative; cursor:pointer; flex:none; transition:.13s;
  border:1px solid var(--line2);
}
.switch.on{ background:var(--accent); border-color:var(--accent); }
.switch::after{
  content:''; position:absolute; width:14px; height:14px; border-radius:50%;
  background:#fff; top:2px; left:2px; transition:.13s;
}
.switch.on::after{ left:18px; }
.ins-overlay{
  position:absolute; inset:0; background:rgba(16,19,26,.8);
  display:flex; align-items:center; justify-content:center; z-index:10;
  color:var(--txt); font-size:14px; flex-direction:column; gap:14px;
}
.spinner{
  width:34px; height:34px; border:3px solid var(--line2);
  border-top-color:var(--accent); border-radius:50%;
  animation:spin 0.8s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg); } }

/* Inline loading state for the parts-library panel. The library load
   path can take several seconds on first hit (parse + DOM build for
   hundreds of catalogue entries), so we show a spinner + live count
   instead of a frozen-looking empty list. */
.lib-loading{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:10px; padding:30px 16px; color:var(--muted, #888); font-size:12px;
  text-align:center; line-height:1.45;
}
.lib-loading .spinner{ width:26px; height:26px; border-width:2px; }
.lib-loading .lib-loading-title{ color:var(--txt, #e8ecf2); font-size:13px; font-weight:500; }

/* status colours shared by the 3MF export results + other logs */
.log-ok{ color:#6fcb6f; }
.log-fail{ color:#e07060; }

/* Save-button state: green when the build matches the last save, amber
   when there are unsaved edits. Higher specificity than .btn-primary so
   it wins on the Builder's primary Save button. */
.btn.save-clean{ background:#2a9d52; border-color:#2a9d52; color:#fff; }
.btn.save-clean:hover{ background:#33b85f; border-color:#33b85f; }
.btn.save-dirty{ background:#e0a528; border-color:#e0a528; color:#1a1d24; }
.btn.save-dirty:hover{ background:#edb43c; border-color:#edb43c; }

#ins-caption{ pointer-events:auto; }
#ins-caption b:hover{ color:var(--accent); }

.version{
  font-size:10.5px; color:var(--txt-faint); font-weight:600;
  letter-spacing:.4px; background:var(--bg4); padding:2px 7px;
  border-radius:9px; margin-left:3px; vertical-align:middle;
}
.part-thumb{
  width:38px; height:38px; border-radius:6px; flex:none;
  object-fit:cover; background:var(--bg4); border:1px solid var(--line2);
}
.lib-folder-head{
  display:flex; align-items:center; gap:7px; padding:6px 10px;
  cursor:pointer; user-select:none; font-size:12px; font-weight:600;
  color:var(--txt-dim); text-transform:uppercase; letter-spacing:.4px;
  background:var(--bg2); border-bottom:1px solid var(--line);
}
.lib-folder-head:hover{ color:var(--txt); }
.lib-folder-name{ flex:1; min-width:0;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.lib-part-row{ padding-left:22px; }

.view-toolbar select.view-select{
  background:rgba(27,31,39,.92); color:var(--txt);
  border:1px solid var(--line2); border-radius:6px;
  padding:4px 6px; font-size:11px; font-family:inherit; cursor:pointer;
}

/* ---------- topbar mode tools (beside the tabs) ---------- */
.mode-tools{ display:flex; align-items:center; gap:7px; }
select.topbar-select{
  width:auto; background:var(--bg3); color:var(--txt);
  border:1px solid var(--line2); border-radius:6px; padding:5px 8px;
  font-size:11.5px; font-family:inherit; cursor:pointer;
}
.topbar-toggle{
  background:var(--bg3); color:var(--txt-dim); border:1px solid var(--line2);
  padding:6px 11px; border-radius:6px; cursor:pointer; font-size:11.5px;
  font-weight:500; font-family:inherit; transition:.12s;
  display:flex; align-items:center; gap:6px; white-space:nowrap;
}
.topbar-toggle:hover{ background:var(--bg4); color:var(--txt); }
.topbar-toggle.on{ background:var(--accent); border-color:var(--accent); color:#fff; }
.topbar-toggle kbd{
  font-family:inherit; font-size:9.5px; line-height:1;
  background:rgba(255,255,255,.16); border-radius:3px; padding:1px 4px;
}
.topbar-toggle.on kbd{ background:rgba(255,255,255,.26); }
