/* Varahi CAD — precision-instrument industrial dark theme */

/* Varahi brand — dark / sovereign surface set (BRAND.md "Dark / sovereign
   surfaces"). An operator console is not an inverted light theme, so these are
   the guideline's own dark values rather than flipped light ones.

   The colour budget is per view: blue ~60%, neutrals ~30%, orange <=10%.
   --accent is Varahi Blue stepped to 300, because on #0B1418 Blue 500 is too
   low-contrast for text, and it carries every active and interactive state —
   that is where the 60% comes from. --decide is Orange 300 and marks exactly
   one thing on this surface: the point where a person decides, which here is
   applying an alternative. If two things are orange, neither is urgent. */
:root {
  --bg: #0B1418;              /* brand: dark surface */
  --panel: #142329;           /* brand: raised */
  --panel-2: #0F1B20;         /* between surface and raised, for inset wells */
  --line: #23383F;            /* brand: border */
  --line-soft: #18272D;
  --line-strong: #2F4A54;     /* hover/emphasis border, one step up from --line */
  --text: #E8EEF0;            /* brand: text primary */
  /* Blue 300 is the guideline's "text secondary", and on a marketing page,
     where secondary text is sparse, that is right. On a dense tool it becomes
     the colour of almost every word — 43 uses against 39 of --text — and the
     whole UI reads as a cyan terminal rather than as Varahi. So on this
     surface Blue 300 is the eyebrow and label colour it is on the site, and
     secondary body text is a neutral. See ../BRAND.md. */
  --text-dim: #9FB0B8;        /* secondary body text, 8.3:1 on --bg */
  --eyebrow: #66B4C4;         /* Blue 300 — section headings, kickers, labels */
  --fill: #007A94;            /* Varahi Blue 500 — solid CTA/active fill */
  --fill-hover: #006A80;      /* Blue 600, the site's hover */
  --on-fill: #FFFFFF;         /* white on the fill, 4.99:1 */
  --text-faint: #7E959D;      /* captions and axis labels; still legible on --bg */
  --accent: #66B4C4;          /* Varahi Blue 300 — active, interactive, focus */
  --accent-dim: #66B4C42e;
  --decide: #FF9A4D;          /* Orange 300 — ONE thing per surface */
  --warn: #C9922F;            /* warning #9A5B00 stepped up; a warning is not
                                 a decision, so it is deliberately not --decide */
  --good: #35A877;            /* success #15784B stepped up for a dark ground */
  --bad: #DF6259;             /* error #B3261E stepped up for a dark ground */
  --mono: "JetBrains Mono", Consolas, ui-monospace, monospace;
  --sans: Inter, "Segoe UI", Calibri, system-ui, sans-serif;
  --radius: 6px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ---------- top bar ---------- */
#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

/* Endorsed-tier lockup (BRAND.md "Naming"): the product's own wordmark with
   "by Varahi Technologies" below and left-aligned. The guideline sets the
   endorsement at 40% of the product-name width, which is a ratio written for a
   marketing hero — at a 56px application bar the phrase cannot be a third the
   width of four letters. The hierarchy is kept: subordinate weight, size and
   colour, below, left-aligned, on first and only appearance. */
#brand {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  text-decoration: none;
  /* The bar is a flex row with a flexible nav in it, so the lockup has to say
     it does not shrink — otherwise the logotype is squeezed and clipped. */
  flex: 0 0 auto;
  /* Clear space: X = half the placed logotype height (38px), per BRAND.md. */
  padding: 0 19px 0 5px;
}
#brand-logo { display: block; flex: 0 0 auto; width: 120px; height: auto; }
#brand .brand-rule {
  width: 1px;
  height: 22px;
  background: var(--line);
}
#brand .brand-mark {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.18em;
  color: var(--text);
}
#brand:hover .brand-mark { color: var(--eyebrow); }

/* Tabular figures anywhere a number sits under another number (BRAND.md
   "Typography"). */
.metric .value, .driver-value, .batch-line, .cost-band-range,
#bom table, .alt-deltas, #vol-hud {
  font-variant-numeric: tabular-nums;
}

#techniques {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  background: var(--panel-2);
  width: fit-content;
  margin: 0 auto;
}

#topbar-right { display: flex; align-items: center; gap: 8px; }

/* ---------- buttons (quiet default) ---------- */
button {
  font: 12px/1 var(--sans);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
  transition: color .12s, background .12s, border-color .12s;
}
button:hover { color: var(--text); border-color: var(--line-strong); background: #ffffff08; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#export-stl { font-weight: 600; }

/* segmented technique pills */
.tech-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--text-dim);
  background: transparent;
  font-weight: 500;
  white-space: nowrap;
}
.tech-btn:hover { color: var(--text); background: #ffffff0a; border-color: transparent; }
.tech-btn.active {
  color: var(--on-fill);
  background: var(--fill);
  font-weight: 600;
}

/* ---------- main 3-column layout ---------- */
main {
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  height: calc(100vh - var(--topbar-h));
}

#left, #copilot {
  overflow-y: auto;
  background: var(--panel);
  padding: 14px;
}
#left { border-right: 1px solid var(--line); }
#copilot { border-left: 1px solid var(--line); }

#left h2, #copilot h2 { /* eyebrow/kicker role — Blue 300, mono, per BRAND.md */
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: var(--mono);
  color: var(--eyebrow);
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
#left h2:first-child, #copilot h2:first-child { margin-top: 0; }
/* The left panel's own title, above its section eyebrows. */
#left h2.browser-title {
  font: 600 13px/1.2 var(--sans);
  letter-spacing: .01em;
  text-transform: none;
  color: var(--text);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
#left h2.browser-title + h2 { margin-top: 0; }

/* ---------- templates ---------- */
#templates { display: flex; flex-wrap: wrap; gap: 6px; }

.template-btn { padding: 6px 10px; border-radius: var(--radius); }
.template-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}

/* ---------- parameters ---------- */
#params { display: flex; flex-direction: column; gap: 10px; }
/* setPanelOwner() hides Parameters with [hidden]; the display above outranks
   the UA rule, so without this the sliders stayed up over a loaded example. */
#params[hidden] { display: none; }

.param-row { display: block; }
.param-row label,
.param-row > span {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.param-row .row,
.param-row {
  align-items: center;
}
.param-row input[type="range"] {
  width: calc(100% - 62px);
  vertical-align: middle;
}
.param-row input[type="number"],
.param-row output,
.param-row .value {
  display: inline-block;
  width: 56px;
  margin-left: 6px;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 5px;
  vertical-align: middle;
}

/* range styling */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

/* ---------- manufacturing controls ---------- */
#mfg { display: flex; flex-direction: column; gap: 10px; }
#mfg label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
}
select, input[type="number"] {
  font: 12px var(--sans);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
}
select:hover, input[type="number"]:hover { border-color: var(--line-strong); }
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
#qty { width: 100%; }

/* ---------- use-phase panel ----------
   The panel shipped with no styles at all, so its labels and inputs ran
   together into the note underneath it. Same shape as #mfg above, which is the
   block it sits under. */
#usephase { display: flex; flex-direction: column; gap: 10px; }
#usephase label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
}
#usephase select, #usephase input[type="number"] { width: 100%; }
.usephase-fields { display: flex; flex-direction: column; gap: 10px; }
/* applyMode() hides the fields that belong to another mode, and the panel
   hides the whole block when the profile is Off, both with the hidden
   attribute. A bare `display: flex` above outranks the user-agent's
   `[hidden] { display: none }`, which put "Efficiency (%)" and "kW per kg" on
   screen for a direct-mode duty. Restore it at matching specificity. */
#usephase label[hidden], .usephase-fields[hidden] { display: none; }
.usephase-sub {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.usephase-hint { font-size: 10.5px; line-height: 1.5; color: var(--text-faint); }

/* Duty-cycle rows. Each point is its own card because the left rail is narrow
   and a name + two numbers will not sit on one line at this width. */
.usephase-duty { display: flex; flex-direction: column; gap: 8px; }
.duty-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.duty-head { display: flex; align-items: center; gap: 6px; }
.duty-name {
  flex: 1;
  min-width: 0;
  font: 11px var(--sans);
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 2px 0;
}
.duty-name:focus { outline: none; border-bottom-color: var(--accent); }
.duty-del {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}
.duty-del:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); }
.duty-del:disabled { opacity: 0.35; cursor: default; }
.duty-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.duty-nums label[hidden] { display: none; }
.duty-add {
  align-self: flex-start;
  font: 11px var(--sans);
  color: var(--accent);
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
}
.duty-add:hover { border-color: var(--accent); border-style: solid; }
.usephase-duty-sum {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
/* The hours ceiling is a real constraint, not a style: say so when it bites. */
.usephase-duty-sum.full { color: var(--warn); }
/* The preset's note, source and attribution basis concatenated — useful, long,
   and not worth pushing the Bodies list off the panel. Capped and scrollable. */
.usephase-note {
  max-height: 8.5em;
  overflow-y: auto;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-faint);
}

.model-tree { padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.tree-node { display: block; width: 100%; box-sizing: border-box; padding: 5px 8px; border: 0; background: transparent; color: var(--text-dim); text-align: left; font-size: 11px; }
.tree-origin { color: var(--text); font-weight: 600; }
button.tree-node { cursor: pointer; }
button.tree-node:hover, button.tree-node.selected { background: var(--panel-2); color: var(--accent); }
.tree-plane { padding-left: 20px; }
.tree-body { padding-left: 20px; }

/* Planes: three cards under Origin. The swatch is the colour of the plane's
   normal axis, the same red/green/blue family as the viewport's X/Y/Z labels
   (Right faces X, Front faces Y, Top faces Z). The selected card takes the
   brand's active fill. */
.plane-group { padding: 4px 8px 6px 20px; }
.plane-group-label { font: 600 10px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--eyebrow); margin: 2px 0 5px; }
.plane-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.plane-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 6px 7px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font: 600 11px var(--sans); text-align: left; cursor: pointer;
}
.plane-card:hover { border-color: var(--line-strong); }
.plane-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.plane-card.selected { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.plane-swatch { width: 14px; height: 9px; border-radius: 2px; transform: skewX(-24deg); margin-left: 2px; background: var(--accent); }
.plane-card[data-plane="XZ"] .plane-swatch { background: var(--good); }
.plane-card[data-plane="XY"] .plane-swatch { background: var(--accent); }
.plane-card[data-plane="YZ"] .plane-swatch { background: var(--bad); }
.plane-card.selected .plane-swatch { box-shadow: 0 0 0 1px var(--on-fill); }
.plane-id { font: 10px var(--mono); color: var(--text-faint); }
.plane-card.selected .plane-id { color: var(--on-fill); opacity: 0.8; }
.plane-status { min-height: 1.4em; margin-top: 5px; font-size: 10.5px; line-height: 1.4; color: var(--text-dim); }
.plane-status.locked { color: var(--warn); }
/* Offset planes: one row each under the three cards, selectable like them,
   with the plane they are offset from and by how much. */
.plane-offsets { display: flex; flex-direction: column; gap: 4px; margin-top: 5px; }
.plane-row {
  display: flex; align-items: center; gap: 7px; padding: 5px 7px; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font: 600 11px var(--sans); text-align: left; cursor: pointer;
}
.plane-row:hover { border-color: var(--line-strong); }
.plane-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.plane-row.selected { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.plane-row .plane-swatch { flex: none; opacity: 0.7; }
.plane-row[data-base="XZ"] .plane-swatch { background: var(--good); }
.plane-row[data-base="YZ"] .plane-swatch { background: var(--bad); }
.plane-row .plane-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plane-row .plane-id { flex: none; }
.plane-row.selected .plane-id { color: var(--on-fill); opacity: 0.8; }
.plane-row .plane-del { flex: none; padding: 0 5px; border: 0; background: none; color: inherit; opacity: 0.6; font-size: 13px; line-height: 1; cursor: pointer; }
.plane-row .plane-del:hover { opacity: 1; }
/* a kept sketch drawn on an offset plane, indented under its row */
.plane-sketch {
  margin: -1px 0 0 18px; padding: 3px 7px; border: 0; border-left: 1px solid var(--line);
  background: none; color: var(--text-dim); font: 500 10.5px var(--sans); text-align: left; cursor: pointer;
}
.plane-sketch::before { content: "\2514  "; opacity: 0.6; }
.plane-sketch:hover { color: var(--text); }
.plane-sketch:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- viewport ---------- */
#plane-picker { position:absolute; inset:0; z-index:20; display:grid; place-items:center; background:rgba(8,12,20,.72); }
#plane-picker[hidden] { display:none; }
.plane-picker-card { background:#182231; border:1px solid #52647b; border-radius:12px; padding:24px; text-align:center; box-shadow:0 18px 60px #0009; }
.plane-picker-card h2 { margin:0 0 8px; }
.plane-picker-card p { color:#aebbd0; }
#create-sketch-start { padding:12px 24px; background:#2878bd; color:white; border:0; border-radius:7px; font-weight:700; cursor:pointer; }
.plane-picker-actions { display:flex; gap:12px; margin:20px 0; }
.plane-picker-actions button { min-width:150px; min-height:112px; padding:16px 10px; background:linear-gradient(145deg,rgba(102,180,196,.24),rgba(37,54,77,.82)); color:#eef5ff; border:1px solid rgba(122,190,204,.65); border-radius:8px; cursor:pointer; box-shadow:inset 0 0 0 1px rgba(255,255,255,.04); }
.plane-picker-actions button[data-plane="XZ"] { background:linear-gradient(145deg,rgba(224,91,91,.20),rgba(37,54,77,.82)); }
.plane-picker-actions button[data-plane="YZ"] { background:linear-gradient(145deg,rgba(99,193,116,.20),rgba(37,54,77,.82)); }
.plane-picker-actions button:hover, .plane-picker-actions button.selected { transform:translateY(-2px); border-color:var(--accent); box-shadow:0 8px 22px #0005; background-color:rgba(102,180,196,.36); }
.plane-picker-actions button:disabled { opacity:.45; cursor:not-allowed; }
.plane-preview { display:block; width:58px; height:38px; margin:0 auto 10px; border:1px solid currentColor; opacity:.7; background:rgba(255,255,255,.10); }
.preview-xy { transform:perspective(80px) rotateX(55deg); }
.preview-xz { transform:perspective(80px) rotateY(28deg); }
.preview-yz { transform:perspective(80px) rotateY(-28deg); }
.plane-picker-actions button strong { display:block; font-size:13px; margin-bottom:10px; }
.plane-picker-actions button small { color:#c4d8df; }
.plane-picker-actions button:hover { background:#35618b; }
#viewport {
  position: relative;
  background: var(--bg);
  min-width: 0;
  overflow: hidden;
}
#viewport canvas, #gl {
  display: block;
  width: 100%;
  height: 100%;
}
#view-cube {
  position: absolute;
  top: 72px;
  right: 18px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 38px);
  grid-template-rows: repeat(3, 30px);
  gap: 2px;
  transform: perspective(180px) rotateX(-8deg) rotateY(-8deg);
  transform-style: preserve-3d;
}
.cube-face {
  border: 1px solid #6c8793;
  border-radius: 3px;
  background: #294650dd;
  color: #d9ecf1;
  font: 8px var(--mono);
  cursor: pointer;
}
.cube-face:hover, .cube-face.active { background: var(--accent); color: #071014; }
#view-axis-indicator { position:absolute; top:18px; left:18px; z-index:5; width:54px; height:54px; border:1px solid var(--line); border-radius:50%; background:#0c1014cc; font:700 11px var(--mono); }
#view-axis-indicator span { position:absolute; }
.axis-x { right:3px; top:22px; color:#e05b5b; }
.axis-y { left:7px; bottom:5px; color:#63c174; }
.axis-z { left:22px; top:3px; color:#62a9e8; }
.cube-top { grid-column: 2; grid-row: 1; }
.cube-left { grid-column: 1; grid-row: 2; }
.cube-front { grid-column: 2; grid-row: 2; }
.cube-right { grid-column: 3; grid-row: 2; }
.cube-back { grid-column: 1; grid-row: 3; }
.cube-bottom { grid-column: 2; grid-row: 3; }
#view-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: #0c1014dd;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 16px #0006;
}
#view-controls button, #view-controls select {
  min-width: 42px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--text-dim);
  font: 10px var(--mono);
  cursor: pointer;
}
#view-controls button:hover, #view-controls button.active { background: var(--accent); color: #071014; }
#view-controls select { min-width: 82px; }
#view-controls .grid-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px 0 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--text-dim);
  font: 10px var(--mono);
  cursor: pointer;
  user-select: none;
}
#view-controls .grid-toggle:hover { border-color: var(--line-strong); color: var(--text); }
#view-controls .grid-toggle input { margin: 0; accent-color: var(--accent); cursor: pointer; }
#viewport-hud {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font: 11px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  background: #0c1014cc;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  pointer-events: none;
}

@media (max-width: 900px) {
  #view-controls { right: 8px; top: 8px; max-width: calc(100% - 16px); flex-wrap: wrap; }
  #view-cube { right: 10px; top: 118px; }
  #view-axis-indicator { top: 8px; left: 8px; }
  .plane-picker-actions { flex-direction: column; max-height: 55vh; overflow:auto; }
  .plane-picker-actions button { min-height: 76px; }
  .plane-preview { display:inline-block; vertical-align:middle; margin:0 10px 0 0; width:42px; height:28px; }
}

/* ---------- co-pilot: impact ---------- */
#impact { display: flex; flex-direction: column; gap: 14px; }

.impact-headline {
  display: flex;
  gap: 10px;
}
.impact-headline .metric {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.metric .value {
  display: block;
  font: 700 28px/1.15 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
}
.metric .label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 3px;
}
.metric.cost .value { color: var(--accent); }
.metric.carbon .value { color: var(--good); }

/* batch line + confidence badge */
.batch-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font: 13px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* per-part headline (parts in their own material) */
.perpart-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

/* drivers */
.drivers { display: flex; flex-direction: column; gap: 9px; }
.driver-row { display: flex; flex-direction: column; gap: 3px; }
.driver-bar {
  position: relative;
  height: 8px;
  background: var(--line);
  border-radius: 3px;
  overflow: visible;
}
.driver-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width .3s ease;
}
.driver-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font: 12.5px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.driver-name { color: var(--text-dim); text-transform: capitalize; }
.driver-value { font-weight: 700; }

/* narrative */
.narrative {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-dim);
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 10px;
}

/* auto-reasoning: appears on its own the moment numbers land */
.impact-insight {
  margin: 10px 0 2px;
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--accent-dim), transparent);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
}

/* header: title + loader */
.insight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.insight-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.insight-spark { font-size: 11px; line-height: 1; }
.impact-insight.thinking .insight-spark {
  animation: insight-spin 1.4s linear infinite;
}
@keyframes insight-spin { to { transform: rotate(360deg); } }

/* loader (only while thinking) */
.insight-loader {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
}
.impact-insight.thinking .insight-loader { display: inline-flex; }
.insight-dots { display: inline-flex; gap: 3px; }
.insight-dots .dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: insight-dot 1.2s ease-in-out infinite;
}
.insight-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.insight-dots .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes insight-dot { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

/* body */
.impact-insight .insight-body {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
}
/* skeleton shimmer while thinking (no text yet) */
.impact-insight.thinking .insight-body {
  min-height: 2.6em;
  border-radius: 4px;
  background: linear-gradient(100deg, #ffffff08 30%, #ffffff14 50%, #ffffff08 70%);
  background-size: 200% 100%;
  animation: insight-shimmer 1.3s linear infinite;
}
@keyframes insight-shimmer { to { background-position: -200% 0; } }
/* blinking caret while tokens stream in */
.impact-insight.streaming .insight-body::after {
  content: "▍";
  color: var(--accent);
  animation: insight-blink 1s steps(2, start) infinite;
}
@keyframes insight-blink { to { opacity: 0; } }
.insight-actions { margin-top: 8px; }
/* The decision point (BRAND.md: "Orange marks one thing per surface — the
   action, the number, or the decision point"). On this surface that is
   accepting an alternative: the moment a person changes the design. Nothing
   else here is orange. */
.insight-apply {
  font: 500 12px/1 var(--sans);
  color: #101418;
  background: var(--decide);
  border: 1px solid var(--decide);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
}
.insight-apply:hover { filter: brightness(1.08); color: #101418; }

/* alternatives */
.alternatives { display: flex; flex-direction: column; gap: 8px; }

.alt-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: transform .12s ease, border-color .12s, box-shadow .12s;
}
.alt-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 4px 14px #00000059;
}
.alt-card .delta,
.alt-card .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.delta.good, .good { color: var(--good); }
.delta.bad, .bad { color: var(--bad); }

.alt-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.alt-actions button { padding: 5px 10px; font-size: 11px; }

button.apply {
  color: var(--accent);
  background: transparent;
  border-color: var(--accent);
  font-weight: 600;
}
button.apply:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }

button.thumb {
  padding: 5px 8px;
  line-height: 1;
}
button.thumb:hover { border-color: var(--good); color: var(--good); }

/* trace link */
.trace-link {
  font: 11px var(--mono);
  color: var(--text-faint);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-faint);
}
.trace-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* badge */
.badge {
  display: inline-block;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  vertical-align: middle;
}

/* ---------- states ---------- */
.pending {
  color: var(--text-faint);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.error {
  color: var(--bad);
  border: 1px solid #e5533c55;
  background: #e5533c14;
  border-radius: var(--radius);
  padding: 10px 12px;
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- narrow screens ----------
   Three columns at every width: the AI panel stays beside the viewport, never
   under it. Below 1180px the side panels narrow instead, so the viewport keeps
   the middle. (The old rule moved #copilot under the viewport at 900px.) */
@media (max-width: 1180px) {
  main { grid-template-columns: 200px minmax(0, 1fr) 280px; }
  #left, #copilot { padding: 12px 10px; }
}

/* A BOM row whose own material/process pair the service rejected. Shown, not
   swallowed: a blank cell reads as "nothing to price", which is a lie. */
.bom-table td.bom-err { color: var(--bad); font-weight: 600; cursor: help; }
.bom-table tr.bom-row-err td.comp { color: var(--bad); }

/* ---------- New design (top bar): confirm dialog + blank-viewport hint ---------- */
#new-design-confirm { position:absolute; inset:0; z-index:21; display:grid; place-items:center; background:rgba(8,12,20,.72); }
#new-design-confirm[hidden] { display:none; }
#new-design-confirm .plane-picker-card { max-width:360px; }
.new-design-actions { display:flex; justify-content:center; gap:10px; margin-top:18px; }
.new-design-actions button { min-width:96px; padding:8px 18px; }
.new-design-clear { background:#2878bd; color:#fff; border-color:#2878bd; font-weight:700; }
.new-design-clear:hover { background:#3389d1; color:#fff; border-color:#3389d1; }
#viewport-empty { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); z-index:5; pointer-events:none;
  padding:10px 16px; border:1px dashed var(--line-strong); border-radius:8px; background:rgba(8,12,20,.55);
  color:var(--text-dim); font-size:13px; white-space:nowrap; }
#viewport-empty[hidden] { display:none; }

/* ---------- files (files.js): design name, unsaved marker, confirm ---------- */
#design-name { display: inline-flex; align-items: center; gap: 6px; max-width: 280px; margin-left: 14px; padding: 3px 8px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius); color: var(--text-dim); font-size: 12.5px; cursor: text; }
#design-name:hover { border-color: var(--line); color: var(--text); }
#design-name .dn-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#design-name .dn-dirty { color: var(--accent); font-size: 11px; }
#design-name .dn-dirty[hidden] { display: none; }
#file-confirm { position:absolute; inset:0; z-index:21; display:grid; place-items:center; background:rgba(8,12,20,.72); }
#file-confirm[hidden] { display:none; }
#file-confirm .plane-picker-card { max-width:380px; }
#file-confirm .file-confirm-go { background: var(--fill); color: var(--on-fill); border-color: var(--fill); font-weight:700; }
#file-confirm .file-confirm-go:hover { background: var(--fill-hover); border-color: var(--fill-hover); }

/* Hide / Show (main.js visEye): an eye on each sketch, plane, axis and point
   row, and on the group headings. A hidden row stays in the tree, dimmed. */
.vis-eye {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; border: 0; border-radius: 3px;
  background: none; color: inherit; opacity: 0.7; cursor: pointer;
}
.vis-eye:hover { opacity: 1; background: var(--panel-3, rgba(127,127,127,.15)); }
.vis-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; opacity: 1; }
.vis-eye.off { opacity: 0.45; }
.vis-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.vis-head .vis-eye { width: 16px; height: 16px; color: var(--text-dim); }
.is-hidden:not(.plane-card-cell) > :not(.vis-eye):not(.plane-del):not(.ftree-del) { opacity: 0.45; }
.is-hidden:not(.plane-card-cell) .plane-name, .is-hidden .ftree-name { font-style: italic; }
.plane-card-cell { position: relative; min-width: 0; display: flex; }
.plane-card-cell .plane-card { flex: 1; }
.plane-card-cell > .vis-eye { position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; }
.plane-card-cell .plane-card.selected ~ .vis-eye { color: var(--on-fill); }
/* origin planes start hidden (never drawn before), so only the swatch dims */
.plane-card-cell.is-hidden .plane-swatch { opacity: 0.35; }
.plane-card-cell.is-hidden > .vis-eye { opacity: 0.6; }
.plane-sketch-row { display: flex; align-items: center; gap: 2px; }
.plane-sketch-row .plane-sketch { flex: 1; min-width: 0; text-align: left; }
.construct-head { margin: 4px 0 1px; }
/* ---------- shell: topbar menus, bodies list, copilot tabs ---------- */

/* dropdown menus in topbar */
.menu { position: relative; display: inline-block; }
.menu-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 130px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px #0008;
  padding: 4px;
  z-index: 50;
}
.menu.open .menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-list button {
  border: 0;
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  width: 100%;
}
.menu-list button:hover { background: var(--accent-dim); color: var(--text); }
.menu.open > .menu-btn { color: var(--text); border-color: var(--accent); }

#tool-move.active, #tool-rotate.active {
  color: var(--on-fill);
  background: var(--fill);
  border-color: var(--fill);
  font-weight: 600;
}
#settings-btn { padding: 7px 10px; font-size: 14px; line-height: 1; }
#export-stl:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- ⌘K intent bar ---------- */
#ai-btn { color: var(--accent); border-color: var(--accent); }
#intent {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(640px, 86%);
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px #000a;
}
#intent[hidden] { display: none; }
.intent-star { color: var(--accent); font-size: 15px; }
#intent-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 14px var(--sans);
  outline: none;
}
.intent-hint { font: 10px var(--mono); color: var(--text-faint); white-space: nowrap; }

/* ---------- bodies list (left panel) ---------- */
#bodies { display: flex; flex-direction: column; gap: 2px; }
.bodies-empty { color: var(--text-faint); font-size: 12px; padding: 4px 2px; }
.body-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}
.body-row:hover { background: #ffffff08; }
.body-row.selected { border-color: var(--accent); background: var(--accent-dim); }
.body-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text);
}
.body-tag {
  margin-left: 6px;
  font: 9px/1 var(--mono);
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 4px;
  vertical-align: middle;
}
.body-eye, .body-del {
  border: 0;
  padding: 2px 5px;
  font-size: 11px;
  line-height: 1;
  color: var(--text-dim);
  background: transparent;
}
.body-eye.off { opacity: .4; }
.body-color {
  width: 14px; height: 14px; padding: 0; margin: 0 4px 0 0;
  border: 1px solid var(--line); border-radius: 3px;
  background: transparent; cursor: pointer; flex: none; vertical-align: middle;
}
.body-color::-webkit-color-swatch-wrapper { padding: 0; }
.body-color::-webkit-color-swatch { border: 0; border-radius: 2px; }
.body-color::-moz-color-swatch { border: 0; border-radius: 2px; }
.body-del:hover { color: var(--bad); background: transparent; }

/* component headers (assembly feature tree) */
.comp-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 3px;
  margin-top: 4px;
  cursor: pointer;
  user-select: none;
}
.comp-header:first-child { margin-top: 0; }
.comp-header:hover { background: #ffffff08; border-radius: 4px; }
.comp-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.comp-count {
  flex: 0 0 auto;
  font: 9px/1 var(--mono);
  color: var(--text-faint);
}
.comp-mat {
  flex: 0 0 auto;
  font: 9px/1 var(--mono);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 2px 4px;
}
.body-row.indented { margin-left: 12px; border-left: 1px solid var(--line-soft); padding-left: 8px; }

/* ---------- explode slider (topbar) ---------- */
#explode-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 10px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
#explode-wrap[hidden] { display: none; }
#explode { width: 90px; }

/* ---------- BOM table ---------- */
.bom-table {
  width: 100%;
  border-collapse: collapse;
  font: 11.5px var(--mono);
  font-variant-numeric: tabular-nums;
}
.bom-table th {
  text-align: left;
  font: 9px/1.2 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.bom-table th.n, .bom-table td.n { text-align: right; }
.bom-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  white-space: nowrap;
}
.bom-table td.idx { color: var(--text-faint); }
.bom-table td.comp { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.bom-table td.mat { color: var(--text-dim); }
.bom-table tbody tr:hover td { background: #ffffff06; }
.bom-table tfoot .bom-total td {
  border-top: 1px solid var(--accent);
  border-bottom: 0;
  font-weight: 700;
  color: var(--accent);
  padding-top: 8px;
}
.bom-table tfoot .bom-total td.comp { color: var(--accent); }

/* ---------- DFM findings ---------- */
#dfm { display: flex; flex-direction: column; gap: 6px; }
#dfm:not(:empty) { margin-bottom: 10px; }
.dfm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  font: 12px/1.4 var(--sans);
}
.dfm-warn { border-color: #C9922F66; background: #C9922F0f; color: var(--text); }
.dfm-info { color: var(--text-dim); }
.dfm-msg { flex: 1; min-width: 0; }
.dfm-btn {
  flex: 0 0 auto;
  font: 11px var(--sans);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
.dfm-btn:hover { border-color: var(--good); color: var(--good); }
.dfm-ai:hover { border-color: var(--accent); color: var(--accent); }
.dfm-ok { border-color: var(--good); color: var(--good); }

/* ---------- assembly checks (interference / tolerance) ---------- */
#checks { display: flex; flex-direction: column; gap: 6px; }
#checks:not(:empty) { margin-bottom: 10px; }
.dfm-chip {
  align-self: flex-start;
  font: 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  padding: 2px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
}
.checks-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.checks-row { display: flex; justify-content: space-between; gap: 8px; font: 12px var(--sans); }
.checks-k { color: var(--text-dim); }
.checks-v { font: 12px var(--mono); color: var(--text); }
.checks-v.good { color: var(--good); }
.checks-v.warn { color: var(--warn); }
.checks-v.bad { color: var(--bad); }

/* ---------- copilot tabs ---------- */
#copilot { display: flex; flex-direction: column; min-height: 0; }
#copilot-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}
#copilot-tabs button {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
#copilot-tabs button:hover { color: var(--text); background: #ffffff0a; }
#copilot-tabs button.active {
  color: var(--on-fill);
  background: var(--fill);
}
#copilot .tab-pane { display: none; flex: 1; min-height: 0; overflow-y: auto; }
#copilot .tab-pane.active { display: block; }
#copilot #tab-chat.active { display: flex; flex-direction: column; overflow: hidden; }

/* ---------- structural (physics) card ---------- */
#physics:not(:empty), #pareto:not(:empty) { margin-bottom: 10px; }
.phys-card, .pareto-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--panel-2);
}
.phys-head, .pareto-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.phys-title, .pareto-title {
  font: 10px/1 var(--mono);
  letter-spacing: .1em;
  font-weight: 700;
  color: var(--text-dim);
}
.phys-sub, .pareto-sub {
  font: 9px/1 var(--mono);
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.phys-empty { font-size: 11px; color: var(--text-faint); padding: 2px 0; }

.phys-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.phys-tile {
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 6px 8px;
}
.phys-k {
  font: 9px/1.2 var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 3px;
}
.phys-v {
  font: 14px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.phys-v.good { color: var(--good); }
.phys-v.warn { color: var(--warn); }
.phys-v.bad { color: var(--bad); }
.phys-load {
  margin-top: 8px;
  font: 10px/1.4 var(--mono);
  color: var(--text-dim);
}

/* per-member utilization bars */
.util-list { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.util-row { display: flex; align-items: center; gap: 6px; }
.util-label {
  flex: 0 0 26px;
  font: 9px/1 var(--mono);
  color: var(--text-faint);
  text-align: right;
}
.util-track {
  flex: 1;
  height: 5px;
  background: var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
}
.util-bar { height: 100%; border-radius: 3px; background: var(--accent); }
.util-bar.warn { background: var(--warn); }
.util-bar.bad { background: var(--bad); }
.util-val {
  flex: 0 0 30px;
  font: 9px/1 var(--mono);
  color: var(--text-dim);
  text-align: right;
}

/* ---------- goal-seek (pareto) card ---------- */
.pareto-status { font: 11px var(--mono); color: var(--text-dim); }
.pareto-svg-wrap { width: 100%; }
.pareto-svg { display: block; width: 100%; height: auto; }
.pareto-svg .ax { stroke: var(--line); stroke-width: 1; }
.pareto-svg .tgt { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.pareto-svg .pt { fill: none; stroke: var(--text-faint); stroke-width: 1; opacity: .8; }
.pareto-svg .pt.pareto { fill: var(--accent); stroke: var(--accent); opacity: 1; }
.pareto-svg .axl { fill: var(--text-faint); font: 8px var(--mono); }

.pareto-rows { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.pareto-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  font: 10.5px var(--mono);
  font-variant-numeric: tabular-nums;
}
.pareto-row:hover { background: #ffffff06; }
.pareto-row.sat { border-color: var(--good); }
.pr-params { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-num { color: var(--text); text-align: right; white-space: nowrap; }
.pr-apply {
  font: 10px var(--sans);
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.pr-apply:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- technique pills: 7 processes now, keep them on one row ---------- */
#techniques { min-width: 0; overflow-x: auto; scrollbar-width: none; }
#techniques::-webkit-scrollbar { display: none; }
.tech-btn { padding: 6px 11px; }

/* ---------- ribbon (top bar) ----------
   Replaces the two-row bar, which put ~25 tools on one line and needed 2.2k px
   to show them. Row 1 (48px): lockup, the five tool-set tabs, the technique
   strip. Row 2 (66px): the active tab's tools, grouped, with the controls every
   tab needs in a fixed strip on the right. Tools are icon over label so a tab's
   whole set fits at 1000px without wrapping; the full name is in each title.
   Dropdown menus hang below row 2, so nothing in the ribbon may clip overflow. */
:root { --topbar-h: 114px; }
#topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
#topbar .ribbon-head {
  flex: 0 0 48px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}
/* Tabs take the brand's active state, a solid Blue 500 fill — the same
   language as the right panel's tabs, at sentence case so the two rows of
   tabs on screen do not read as one strip. */
#topbar .ribbon-tabs { display: flex; gap: 2px; flex: 0 0 auto; }
#topbar .ribbon-tab {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font: 600 12.5px/1 var(--sans);
  letter-spacing: .01em;
  color: var(--text-dim);
}
#topbar .ribbon-tab:hover { color: var(--text); background: #ffffff0a; }
#topbar .ribbon-tab.active { color: var(--on-fill); background: var(--fill); }
#topbar #techniques { flex: 0 1 auto; margin: 0 0 0 auto; max-width: none; }

#topbar .ribbon-body {
  flex: 0 0 66px;
  display: flex;
  align-items: stretch;
  min-width: 0;
}
#topbar .ribbon-panels { flex: 1 1 auto; min-width: 0; display: flex; padding: 0 8px 0 14px; }
#topbar .ribbon-panel { display: flex; align-items: stretch; }
#topbar .ribbon-panel[hidden] { display: none; }
#topbar .ribbon-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 14px 0 4px;
  border-left: 1px solid var(--line);
  background: var(--panel-2);
}
#topbar .ribbon-strip #explode-wrap { align-self: center; padding: 0 10px; }

/* a group: its tools, a thin divider before it, a small caption under it */
#topbar .rgroup {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 10px;
  border-left: 1px solid var(--line-soft);
}
#topbar .ribbon-panel > .rgroup:first-child { border-left: 0; padding-left: 0; }
#topbar .ribbon-strip > .rgroup:first-of-type { border-left: 0; }
#topbar .rgroup-tools { display: flex; align-items: center; gap: 2px; }
#topbar .rgroup-cap {
  font: 9px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

/* a tool: icon over label */
#topbar .rtool {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 52px;
  height: 46px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font: 500 10.5px/1.1 var(--sans);
  white-space: nowrap;
}
#topbar .rtool svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#topbar .rtool:hover:not(:disabled) { color: var(--text); background: #ffffff08; border-color: var(--line); }
#topbar .rtool:disabled { opacity: .4; cursor: not-allowed; }
#topbar .rtool.active { color: var(--on-fill); background: var(--fill); border-color: var(--fill); font-weight: 600; }
#topbar .menu.open > .rtool { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }
/* the AI entry keeps the accent it had in the old bar */
#topbar #ai-btn.rtool { color: var(--accent); }
#topbar #ai-btn.rtool:hover { color: var(--text); border-color: var(--accent); }

/* a compact group: two rows of small tools, icon beside label (the Sketch
   tab's Edit tools, which would otherwise push the ribbon off the edge) */
#topbar .rgroup-tools.rgroup-grid { display: grid; grid-template-columns: repeat(4, auto); gap: 1px 2px; min-width: max-content; }
/* the grid group keeps its width: shrunk by the strip, its eight tools spilled
   over the next group (Sketch on) */
#topbar .rgroup:has(> .rgroup-grid) { flex: 0 0 auto; }
/* The Sketch tab holds 10 draw + 8 edit tools beside Sketch on and the shared
   strip; at full size they did not fit and the Edit tools were drawn over
   the next group. Draw is two rows of five; Edit is icons only (each keeps
   its name as tooltip and for screen readers); below 1500 px Draw goes
   icons-only too. */
#topbar .rgroup-tools.rgroup-grid5 { grid-template-columns: repeat(5, auto); }
#topbar .rgroup-icons .rtool { padding: 2px 4px; }
#topbar .rgroup-icons .rtool span,
#topbar .rgroup-grid .rtool span.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 1500px) {
  #topbar .rgroup-grid5 .rtool { padding: 2px 4px; }
  #topbar .rgroup-grid5 .rtool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
#topbar .rgroup-grid .rtool {
  flex-direction: row;
  justify-content: flex-start;
  gap: 5px;
  min-width: 0;
  height: 22px;
  padding: 2px 6px;
  font-size: 10.5px;
}
#topbar .rgroup-grid .rtool svg { width: 14px; height: 14px; stroke-width: 1.5; }

/* Narrow: same tools, tighter. Labels shrink before anything is hidden. */
@media (max-width: 1180px) {
  #topbar .ribbon-head { gap: 8px; }
  #topbar .ribbon-tab { padding: 7px 7px; font-size: 12px; }
  #topbar .tech-btn { padding: 6px 6px; font-size: 11.5px; }
  #topbar .rgroup { padding: 0 6px; }
  #topbar .rtool { min-width: 44px; padding: 4px 4px; font-size: 9.5px; }
  #topbar .ribbon-panels { padding-left: 10px; }
  #topbar .ribbon-strip { padding-right: 10px; }
}

/* Construct tools (construct-tools.js): axis and point rows under Planes, and
   any construction whose source is gone. */
.construct-glyph { flex: none; width: 14px; height: 10px; position: relative; opacity: 0.8; }
.construct-glyph.axis::before { content: ''; position: absolute; left: 0; right: 0; top: 4px; border-top: 2px dashed var(--accent); transform: rotate(-30deg); }
.construct-glyph.point::before { content: ''; position: absolute; left: 4px; top: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.plane-row.broken { border-color: var(--bad); }
.plane-row.broken .plane-name, .plane-row.broken .plane-id { color: var(--bad); }
.plane-row.broken .plane-swatch, .plane-row.broken .construct-glyph.point::before { background: var(--bad); }
.plane-row.broken .construct-glyph.axis::before { border-top-color: var(--bad); }
.plane-row .plane-id { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plane-row.broken.selected { background: transparent; border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }

/* Insert › Image: reference image rows under the planes */
.insert-images .plane-group-label { margin-top: 6px; }
.image-row.off .plane-name, .image-row.off .plane-id { opacity: .45; }
.image-row .image-eye { font-size: 11px; }

/* ---------- responsive ribbon ----------
   The ribbon row, the shared strip and the technique pill scroll sideways
   instead of drawing over one another (the Solid tab needs ~1210px; before
   this its Boolean/Pattern groups were painted under New design at <=1920).
   ribbon.js wraps each scroller in .hs-wrap with two arrow buttons that
   appear only while there is more to see that way; wheel and touch swipe
   scroll it too. Dropdowns inside a scroller are positioned fixed by
   ribbon.js, so the scroller's clipping never cuts them. */
.hs-wrap { position: relative; display: flex; min-width: 0; align-items: stretch; overflow: hidden; }
#topbar > .hs-wrap.hs-head { flex: 0 0 48px; border-bottom: 1px solid var(--line-soft); }
#topbar .hs-head > .ribbon-head { flex: 1 1 auto; border-bottom: 0; }
#topbar .hs-head > .hs-arrow { background: linear-gradient(90deg, var(--panel) 55%, transparent); }
#topbar .hs-head > .hs-arrow.r { background: linear-gradient(270deg, var(--panel) 55%, transparent); }
#topbar .ribbon-body > .hs-wrap:first-child { flex: 1 1 auto; }
#topbar .ribbon-body > .hs-wrap.hs-strip { flex: 0 1 auto; }
#topbar .ribbon-panels,
#topbar .ribbon-strip {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#topbar .ribbon-panels::-webkit-scrollbar,
#topbar .ribbon-strip::-webkit-scrollbar { display: none; }
#topbar .ribbon-panel, #topbar .ribbon-panel > .rgroup, #topbar .ribbon-strip > * { flex-shrink: 0; }
#topbar .ribbon-strip { flex: 1 1 auto; min-width: 0; }
.hs-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--text);
  font: 600 15px/1 var(--sans);
  cursor: pointer;
}
.hs-arrow.l { left: 0; background: linear-gradient(90deg, var(--panel-2) 55%, transparent); justify-content: flex-start; padding-left: 5px; }
.hs-arrow.r { right: 0; background: linear-gradient(270deg, var(--panel-2) 55%, transparent); justify-content: flex-end; padding-right: 5px; }
.hs-arrow:hover { color: var(--accent); }
.hs-arrow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hs-wrap.can-l > .hs-arrow.l, .hs-wrap.can-r > .hs-arrow.r { display: flex; }
#topbar .menu-list.hs-fixed { position: fixed; z-index: 60; max-height: calc(100vh - 16px); overflow-y: auto; }
/* the technique pill already scrolled, but centred: its first items were
   clipped off the left edge where no scroll could reach them */
#topbar #techniques { justify-content: flex-start; }
#topbar .ribbon-head > .hs-wrap.hs-tech { flex: 0 1 auto; margin-left: auto; }
#topbar .hs-tech #techniques { margin: 0; }
#topbar .hs-tech > .hs-arrow { border-radius: 999px; }

/* Below 1440 the shared strip goes icon-only (names stay as tooltips and for
   screen readers) so the active tab keeps the width. */
@media (max-width: 1439px) {
  #topbar .ribbon-strip .rtool { min-width: 34px; padding: 4px 5px; }
  #topbar .ribbon-strip .rtool > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #topbar .ribbon-strip .rtool svg { width: 19px; height: 19px; }
}
@media (max-width: 1439px) {
  #view-controls { max-width: calc(100% - 92px); overflow-x: auto; scrollbar-width: none; }
}
@media (max-width: 1180px) {
  #design-name { max-width: 150px; margin-left: 0; }
  #topbar .ribbon-strip { max-width: 46vw; }
}

/* ---------- narrow: side panels become drawers ----------
   At <=900px three columns left the viewport 0-340px wide (0 at 390px). The
   viewport now takes the whole width; Browser and the right panel slide over
   it from their own edge, opened by the two buttons ribbon.js adds to row 1
   (and by any ribbon tool that opens a right-panel tab). */
.drawer-toggles { display: none; }
.drawer-close { display: none; }
@media (max-width: 900px) {
  main { grid-template-columns: minmax(0, 1fr); position: relative; }
  main > #viewport { grid-column: 1; grid-row: 1; }
  #left, #copilot {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    z-index: 40;
    width: min(340px, 88vw);
    box-shadow: 0 0 32px #000a;
    transition: transform .22s ease;
    visibility: hidden;
  }
  #left { left: 0; transform: translateX(-102%); }
  #copilot { right: 0; transform: translateX(102%); }
  body.drawer-left #left, body.drawer-right #copilot { transform: none; visibility: visible; }
  .drawer-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 39; background: #0008; }
  body:not(.drawer-left):not(.drawer-right) .drawer-backdrop { display: none; }
  .drawer-toggles { display: flex; gap: 4px; flex: 0 0 auto; }
  .drawer-toggles button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; font: 600 12px/1 var(--sans); border-radius: 999px; }
  .drawer-toggles button[aria-expanded="true"] { color: var(--on-fill); background: var(--fill); border-color: var(--fill); }
  .drawer-close { display: flex; position: sticky; top: -12px; z-index: 5; margin: -4px -2px 8px auto; width: 32px; height: 32px; align-items: center; justify-content: center; padding: 0; font-size: 18px; line-height: 1; }
  #topbar .ribbon-head { overflow-x: auto; scrollbar-width: none; gap: 8px; padding: 0 8px; }
  #topbar .ribbon-tab { padding: 7px 9px; }
  #topbar .ribbon-head::-webkit-scrollbar { display: none; }
  #topbar .ribbon-head > * { flex-shrink: 0; }
  #topbar .ribbon-head > .hs-wrap.hs-tech { flex-shrink: 0; }
  #brand-logo, #brand .brand-rule { display: none; }
  #design-name { display: none; }
  #topbar .ribbon-panels { padding-left: 6px; }
  #topbar .ribbon-strip { max-width: 42vw; padding-right: 6px; }
  #view-controls { max-width: calc(100% - 72px); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .sk-confirm { flex-wrap: wrap; max-width: calc(100% - 16px); justify-content: center; }
  .sk-cbar { max-width: calc(100% - 16px); }
}
@media (prefers-reduced-motion: reduce) {
  #topbar .ribbon-panels, #topbar .ribbon-strip { scroll-behavior: auto; }
}
/* Sketcher overlay */
.sk-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  /* See-through: the part stays visible under the sketch (sketcher.js draws
     only a faint grid, and veils the view only when it is not square to it). */
  background: transparent;
  outline: none;
  /* The sketch owns every pointer: without this a touch or pen drag is taken
     by the browser as a scroll and cancelled after two moves. */
  touch-action: none;
}

/* Live dimension beside the cursor while a shape is being drawn. */
.sk-live {
  position: absolute;
  z-index: 21;
  display: none;
  padding: 3px 8px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.sk-live.show { display: block; }

/* Typed values: the live label becomes value boxes (sketcher.js renders the
   text; focus stays on the canvas, so the boxes are drawn, not inputs). */
.sk-live.typing.show {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  color: var(--text-dim);
}
.sk-tf-l { color: var(--text-dim); }
.sk-tf {
  min-width: 48px;
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--text);
  text-align: right;
}
.sk-tf em { font-style: normal; color: var(--text-faint); }
.sk-tf.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.sk-tf.on::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 12px;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--accent);
  animation: sk-caret 1s steps(1) infinite;
}
@keyframes sk-caret { 50% { opacity: 0; } }
.sk-tf-k { margin-left: 2px; font-size: 11px; color: var(--text-faint); }

.sk-confirm {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 21;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.sk-confirm.show { display: flex; }

.sk-confirm label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}

.sk-confirm .sk-mode,
.sk-confirm .sk-axis {
  padding: 4px 6px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.sk-confirm .sk-mode[hidden],
.sk-confirm .sk-axis[hidden] { display: none; }
.sk-confirm .sk-axis { max-width: 170px; }

.sk-confirm input[type='number'] {
  width: 64px;
  padding: 4px 6px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.sk-confirm button {
  padding: 5px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}
.sk-confirm button:hover { border-color: var(--accent); color: var(--accent); }
.sk-confirm .sk-cancel:hover { border-color: var(--bad); color: var(--bad); }

.sk-sep {
  width: 1px;
  height: 18px;
  background: var(--line-soft);
}

.sk-dims {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sk-dims:not(:empty)::after {
  content: '';
  width: 1px;
  height: 18px;
  background: var(--line-soft);
}
.sk-dims label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
}
.sk-dims input[type='number'] { width: 56px; }

/* Face mode (Sketch on face): the face name leads the bar, Revolve is hidden,
   Redraw is offered, and a refusal shows under the controls. */
.sk-face { font-weight: 600; color: var(--accent); white-space: nowrap; }
.sk-face:empty { display: none; }
.sk-confirm.sk-on-face { flex-wrap: wrap; max-width: calc(100% - 32px); }
.sk-confirm.sk-on-face .sk-rev { display: none; }
.sk-confirm:not(.sk-on-face) .sk-redraw { display: none; }
.sk-err { flex-basis: 100%; font-size: 12px; color: var(--bad); overflow-wrap: anywhere; }
.sk-err:empty { display: none; }

/* Constraints bar (finish-mode sketches): tools, rules, undo, status. */
.sk-cbar {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 32px);
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.sk-cbar.show { display: flex; }
.sk-cgroup { display: flex; gap: 2px; }
.sk-csep { width: 1px; height: 22px; background: var(--line-soft); }
.sk-cbar button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}
.sk-cbar button:hover { border-color: var(--line-strong); color: var(--text); }
.sk-cbar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sk-cbar .sk-tool.on { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.sk-rules button span, .sk-edits button span { display: none; }
/* Settings of the edit / text tool in use (fillet R, offset D, pattern count...). */
.sk-params { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text-dim); }
.sk-params[hidden], .sk-params:empty { display: none; }
.sk-params input, .sk-params select {
  width: 58px;
  padding: 2px 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}
.sk-params select { width: auto; font-family: var(--sans); }
.sk-params .sk-ptext { width: 110px; text-transform: uppercase; }
.sk-cbar .sk-papply { border-color: var(--line-strong); color: var(--text); }
.sk-cbar .sk-cundo, .sk-cbar .sk-credo { font-size: 14px; }
.sk-status { padding: 0 6px; font-family: var(--mono); white-space: nowrap; color: var(--text-dim); }
.sk-status.free { color: var(--accent); }
.sk-status.full { color: var(--text); font-weight: 600; }
.sk-status.bad { color: var(--bad); }
.sk-msg { flex-basis: 100%; color: var(--text-dim); overflow-wrap: anywhere; }
.sk-msg.bad { color: var(--bad); }
.sk-msg:empty { display: none; }

/* Typing a dimension's value, on the canvas where the label goes. */
.sk-dimedit {
  position: absolute;
  z-index: 22;
  width: 72px;
  padding: 3px 6px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

/* Two-point dimension: aligned / horizontal / vertical, under the value. */
.sk-dimkind {
  position: absolute;
  z-index: 22;
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}
.sk-dimkind button {
  display: flex;
  padding: 2px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
}
.sk-dimkind button:hover { border-color: var(--line-strong); color: var(--text); }
.sk-dimkind button.on { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.sk-dimkind button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Co-pilot chat panel */
.chat-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 8px; }
.chat-status-row { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); padding: 2px 0 6px; }
.chat-status { font: 11px var(--mono); color: var(--text-faint); }
.chat-new { white-space: nowrap; flex: none; align-self: flex-start; font: 11px var(--sans); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-dim); cursor: pointer; }
.chat-new:hover { border-color: var(--accent); color: var(--accent); }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; }
.chat-bubble { max-width: 85%; padding: 7px 10px; border-radius: var(--radius); font: 13px/1.45 var(--sans); white-space: pre-wrap; word-break: break-word; }
.chat-user { align-self: flex-end; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
.chat-assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line-soft); color: var(--text); }
.chat-error { align-self: flex-start; background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.chat-chip { align-self: flex-start; font: 11px var(--mono); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-soft); }
.chip-tool { color: var(--text-dim); background: var(--panel-2); }
.chip-action { color: var(--accent); border-color: var(--accent); background: transparent; }
.chip-error { color: var(--bad); border-color: var(--bad); }
.chip-note { color: var(--text-faint); font-style: italic; }
.chat-input-row { display: flex; gap: 6px; align-items: flex-end; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.chat-input { flex: 1; resize: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); font: 13px var(--sans); padding: 6px 8px; }
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send, .chat-abort { font: 12px var(--sans); padding: 6px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; }
.chat-send:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.chat-send:disabled { opacity: 0.5; cursor: default; }
.chat-abort { border-color: var(--bad); color: var(--bad); }
.chat-actions { display: flex; gap: 6px; align-self: flex-start; }
.chat-action-btn { font: 12px var(--sans); padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; }
.chat-action-btn.ok { border-color: var(--good, #35A877); color: var(--good, #35A877); }
.chat-action-btn.undo { border-color: var(--text-dim); color: var(--text-dim); }
.chat-action-btn:hover:not(:disabled) { filter: brightness(1.2); }
.chat-action-btn:disabled { opacity: 0.4; cursor: default; }
.chat-actions.used { opacity: 0.6; }
.chat-cards { display: flex; gap: 8px; align-self: stretch; overflow-x: auto; padding: 2px 0; }
.chat-card { flex: 1 1 0; min-width: 110px; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.chat-card-title { font: 600 12px var(--sans); color: var(--accent); }
.chat-card-line { font: 11px var(--mono); color: var(--text-dim); }
.chat-card-apply { margin-top: 6px; font: 11px var(--sans); padding: 4px 0; border-radius: 4px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
.chat-card-apply:hover:not(:disabled) { border-color: var(--good); color: var(--good); }
.chat-card-apply:disabled { opacity: 0.4; cursor: default; }

/* "cooking" indicator */
.chat-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px dashed var(--accent);
  background: var(--accent-dim);
  color: var(--text-dim);
  font: 12px var(--sans);
}
.think-dots { display: inline-flex; gap: 3px; align-items: center; }
.think-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: think-bounce 1.2s infinite ease-in-out;
}
.think-dots i:nth-child(2) { animation-delay: 0.15s; }
.think-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes think-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* floating pill over the viewport while the agent works */
#ai-working {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--accent);
  font: 12px var(--sans);
  cursor: pointer;
  box-shadow: 0 6px 18px #0008;
}
#ai-working[hidden] { display: none; }

/* ---- VarahiID account control + co-pilot sign-in gate (2026-10-27) ---- */
.acct { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 4px; font-size: 12px; }
.acct a { text-decoration: none; border-radius: var(--radius); white-space: nowrap; }
.acct-in { background: var(--fill); color: var(--on-fill); padding: 6px 14px; font-weight: 600; }
.acct-in:hover { background: var(--fill-hover); }
.acct-who { color: var(--text-dim); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-out { color: var(--accent); border: 1px solid var(--line); padding: 4px 10px; }
.acct-out:hover { border-color: var(--line-strong); color: var(--text); }
.chat-gate { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 6px 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); font-size: 12.5px; color: var(--text-dim); }
.chat-gate[hidden], .chat-input-row[hidden], .chat-starters[hidden] { display: none; }
.chat-gate-text { flex: 1; line-height: 1.4; }
.chat-gate-btn { background: var(--fill); color: var(--on-fill); padding: 6px 14px; border-radius: var(--radius);
  text-decoration: none; font-weight: 600; white-space: nowrap; }
.chat-gate-btn:hover { background: var(--fill-hover); }
/* Settings modal + standards tab */
.settings-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.settings-modal { width: min(520px, 92vw); max-height: 85vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--text); font: 13px var(--sans); }
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.settings-title { font-size: 15px; font-weight: 600; }
.settings-close { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }
.settings-close:hover { color: var(--text); }
.settings-section { border-top: 1px solid var(--line-soft); padding: 12px 0; }
.settings-section h3 { font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 0 0 8px; }
.settings-std-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.settings-std-name { flex: 1; }
.settings-std-meta { font: 11px var(--mono); color: var(--text-faint); }
.settings-del { font: 11px var(--sans); background: transparent; border: 1px solid var(--line); border-radius: var(--radius); color: var(--bad); padding: 2px 8px; cursor: pointer; }
.settings-del:hover { border-color: var(--bad); }
.settings-upload-row { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.settings-upload-row input[type="file"] { font: 12px var(--sans); color: var(--text-dim); }
.settings-dim { color: var(--text-faint); font-size: 12px; }
.settings-err { color: var(--bad); font-size: 12px; }
.settings-ai-line { display: flex; align-items: center; gap: 8px; }
.settings-mono { font: 12px var(--mono); }
.settings-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); display: inline-block; }
.settings-dot.ok { background: var(--good); }
.settings-modal a { color: var(--accent); }

/* Standards tab */
.standards-tab { display: flex; flex-direction: column; gap: 10px; padding: 6px 0; }
.standards-run { align-self: flex-start; font: 12px var(--sans); padding: 6px 14px; border-radius: var(--radius); border: 1px solid var(--accent); background: transparent; color: var(--accent); cursor: pointer; }
.standards-run:disabled { opacity: 0.5; cursor: default; }
.standards-pending { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 12px; }
.standards-spinner { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: std-spin 0.8s linear infinite; display: inline-block; }
@keyframes std-spin { to { transform: rotate(360deg); } }
.standards-results { display: flex; flex-direction: column; gap: 8px; }
.findings-note { font: 12px var(--sans); color: var(--text-dim); font-style: italic; }
.finding-card { border: 1px solid var(--line); border-left: 3px solid var(--text-dim); border-radius: var(--radius); background: var(--panel-2); padding: 8px 10px; }
.finding-fail { border-left-color: var(--bad); }
.finding-warn { border-left-color: var(--accent); }
.finding-info { border-left-color: var(--text-dim); }
.finding-top { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.finding-sev { font: 700 10px var(--mono); letter-spacing: 0.08em; }
.finding-fail .finding-sev { color: var(--bad); }
.finding-warn .finding-sev { color: var(--accent); }
.finding-info .finding-sev { color: var(--text-dim); }
.finding-rule { font: 600 12px var(--sans); color: var(--text); }
.finding-body { font: 12px/1.5 var(--sans); color: var(--text-dim); }
.finding-source { margin-top: 4px; font: 10px var(--mono); color: var(--text-faint); }
.settings-check { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; cursor: pointer; }
.settings-check input { accent-color: var(--fill); }
/* Varahi CAD — drawings viewer UI (consumed by another agent's DOM).
   Only class hooks here; no assumptions about their element tree.

   This surface is a deliberate light island: an engineering drawing is paper,
   so sheets, thumbnails and the controls sitting on them are white with ink
   text and stay that way on a dark app. Only the thumbnail caption sits on the
   APP's surface, and it uses the app tokens.

   --fg, --muted and --panel-hover were named here but never defined anywhere,
   so every var() using them always rendered its fallback. That is why the
   export buttons were dark-on-dark: background resolved to the real --panel
   (#142329) while the text stayed at its #111 fallback. Fixed with explicit
   paper values rather than by defining light tokens at :root, which would
   have inverted the dark app. */

.drawing-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drawing-thumb {
  width: 160px;
  border: 1px solid #C1C1C1;
  background: #fff;
  cursor: pointer;
  padding: 4px;
  box-sizing: border-box;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.drawing-thumb:hover {
  border-color: #007A94;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}
.drawing-thumb svg {
  display: block;
  width: 100%;
  height: auto;
}
/* The card is the click target for the viewer, so the per-sheet download sits
   on top of it and stops propagation. Revealed on hover or keyboard focus. */
.drawing-thumb {
  position: relative;
}
.drawing-thumb-dl {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  border: 1px solid #C1C1C1;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: #101418;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, border-color 0.12s ease;
}
.drawing-thumb:hover .drawing-thumb-dl,
.drawing-thumb-dl:focus-visible {
  opacity: 1;
}
.drawing-thumb-dl:hover {
  border-color: #007A94;
}
/* Touch has no hover — keep it permanently visible there. */
@media (hover: none) {
  .drawing-thumb-dl { opacity: 1; }
}

.drawing-actions {
  display: flex;
  gap: 6px;
}

.drawing-thumb .drawing-thumb-label {
  margin-top: 4px;
  font: 10px/1.3 var(--sans);
  color: var(--text-dim);          /* this one sits on the app, not on paper */
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawing-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0009;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vmin;
  box-sizing: border-box;
}
.drawing-viewer .drawing-sheet {
  width: 90%;
  max-width: 90vw;
  max-height: 90vh;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  overflow: auto;
}
.drawing-viewer .drawing-sheet svg {
  display: block;
  width: 100%;
  height: auto;
}
.drawing-viewer .close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #101418;
  font-size: 18px;
  line-height: 30px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}
.drawing-viewer .close:hover {
  background: #F4F6F7;
}

/* Export bar, top-right of the viewer and clear of the × button. */
.drawing-viewer-actions {
  position: absolute;
  top: 12px;
  right: 54px;
  display: flex;
  gap: 6px;
  z-index: 1;
}

.drawing-dl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid #C1C1C1;
  border-radius: 999px;
  background: #fff;
  color: #101418;
  font: 11px var(--sans);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.drawing-dl:hover {
  border-color: #007A94;          /* Varahi Blue 500 — this control is on paper */
  background: #F0F8FA;            /* Blue 050 */
}
/* Examples gallery (tab-examples) + chat prompt starters */

/* six tabs no longer fit on one line in a narrow panel */
#copilot-tabs { flex-wrap: wrap; row-gap: 4px; }

.ex-intro {
  font: 11px/1.5 var(--sans);
  color: var(--text-faint);
  margin-bottom: 10px;
}
.ex-grid { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }

.ex-card {
  border: 1px solid var(--line);
  border-left: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.ex-card:hover {
  border-color: var(--line);
  border-left-color: var(--accent);
  background: var(--panel);
}

.ex-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.ex-title { font: 600 13px var(--sans); color: var(--text); }
.ex-tag {
  flex: 0 0 auto;
  font: 10px var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ex-sub { font: 11px/1.45 var(--sans); color: var(--text-dim); margin-top: 3px; }

.ex-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.ex-chip {
  font: 10px var(--mono);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  white-space: nowrap;
}
.ex-chip.asm { color: var(--good); border-color: var(--good); }

.ex-note {
  font: italic 11px/1.45 var(--sans);
  color: var(--text-faint);
  margin-top: 7px;
}

.ex-load {
  margin-top: 9px;
  width: 100%;
  font: 11px var(--sans);
  padding: 5px 0;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.ex-card:hover .ex-load { border-color: var(--accent); color: var(--accent); }

/* ---------- chat prompt starters ---------- */
.chat-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 0 0 auto;
  padding: 6px 2px 0;
}
.chat-starter {
  font: 11px var(--sans);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-starter::before { content: "✦ "; color: var(--accent); }
.chat-starter:hover:not(:disabled) { border-color: var(--accent); border-style: solid; color: var(--text); }
.chat-starter:disabled { opacity: .4; cursor: default; }
/* Varahi CAD — lifetime (use-phase) charts.
   Class hooks only; charts.js builds the SVG, the DOM around it belongs to
   another agent. Series colours live in charts.js and are mirrored here purely
   so legends and swatches outside the SVG can match. Never use --accent/--good/
   --bad as a series colour: those stay reserved for cost and good/bad deltas. */

:root {
  --series-embodied: #bf8318;
  --series-use: #3f8ada;
  --series-maintenance: #c25fae;
  --series-eol: #2da872;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-variant-numeric: tabular-nums;
}

/* segments and markers lift slightly under the cursor; the tooltip is the
   <title> the browser renders natively, so no JS is needed on the bar */
.chart-seg {
  transition: opacity 0.12s ease;
  cursor: default;
}
.chart-stacked:hover .chart-seg { opacity: 0.55; }
.chart-stacked .chart-seg:hover { opacity: 1; }

.chart-crossover .chart-series { transition: opacity 0.12s ease; }
.chart-crossover .chart-hover { transition: opacity 0.1s ease; }

/* swatches for any legend rendered as DOM rather than SVG */
.series-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 6px;
}
.series-swatch.embodied { background: var(--series-embodied); }
.series-swatch.use { background: var(--series-use); }
.series-swatch.maintenance { background: var(--series-maintenance); }
.series-swatch.eol { background: var(--series-eol); }

/* the chart pair inside the Impact tab's Lifetime block */
.chart-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.chart-caption {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-dim);
}
.chart-caption b { color: var(--text); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .chart-seg,
  .chart-crossover .chart-series,
  .chart-crossover .chart-hover { transition: none; }
}

/* BOM: why the lifetime columns are blank on a shared duty cycle. */
.bom-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-faint);
}
/* Cost vs quantity block inside the Impact card (charts.js costQuantityChart). */
.costqty {
  margin: 14px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft, #18272D);
}
.costqty-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.costqty-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim, #66B4C4);
}
.costqty-sub {
  font-size: 10px;
  color: var(--text-faint, #7E959D);
}
/* The takeaway carries the decision, so it reads at body weight, not caption. */
.costqty-take {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text, #E8EEF0);
  margin-bottom: 10px;
}
.costqty-note {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.45;
  color: var(--text-faint, #7E959D);
}

/* Should-cost range, under the headline figure it qualifies. */
.cost-band {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: -2px 0 8px;
  font-size: 11px;
}
.cost-band-range {
  font-family: var(--mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim, #66B4C4);
}
.cost-band-label { color: var(--text-faint, #7E959D); }
/* ---------- sizes (left panel): editable numbers of an ops-built body ---------- */
#sizes:not([hidden]) { display: flex; flex-direction: column; gap: 8px; }
.sizes-note { font-size: 11px; color: var(--text-faint); }
.sizes-list { display: flex; flex-direction: column; gap: 4px; }
.size-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.size-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
}
.size-row input[type="number"] {
  width: 68px;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 5px;
}
.size-unit { width: 22px; font: 10px var(--mono); color: var(--text-faint); }
.sizes-foot { display: flex; align-items: flex-start; gap: 8px; }
.sizes-status { flex: 1; min-width: 0; font-size: 11px; color: var(--text-faint); overflow-wrap: anywhere; }
.sizes-status.busy { color: var(--accent); }
.sizes-status.ok { color: var(--good); }
.sizes-status.error { color: var(--bad); }
.sizes-undo { padding: 4px 8px; font-size: 11px; }
.sizes-undo:disabled { opacity: .4; cursor: default; }
.bodies-note { color: var(--text-faint); font-size: 11px; padding: 4px 2px; }
.size-row input[type="number"].bad { border-color: var(--bad); }

/* ---------- sizes narrowed to one Feature tree step ---------- */
.sizes-step { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--accent); }
.sizes-step-name { flex: 1; min-width: 0; font-weight: 600; }
.sizes-step-all { padding: 3px 8px; font-size: 11px; }

/* ---------- feature tree (left panel): the steps that built the selected part ---------- */
#left h2.collapsible { cursor: pointer; user-select: none; }
#left h2.collapsible::before { content: '▾ '; }
#left h2.collapsible.collapsed::before { content: '▸ '; }
#feature-tree:not([hidden]) { display: flex; flex-direction: column; gap: 2px; }
.ftree-part { font-size: 12px; font-weight: 600; color: var(--text); padding: 2px 6px 4px; }
.ftree-none { color: var(--text-faint); font-size: 11px; padding: 4px 6px; }
.ftree-step {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 4px 6px 4px 8px;
  border-left: 1px solid var(--line-soft);
  border-radius: 0 4px 4px 0;
  border-top: 1px solid transparent;
  border-right: 1px solid transparent;
  border-bottom: 1px solid transparent;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.ftree-step:hover { background: #ffffff08; color: var(--text); }
.ftree-step.selected { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }
.ftree-num { width: 16px; font: 10px var(--mono); color: var(--text-faint); text-align: right; }
.ftree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftree-del { border: 0; padding: 2px 5px; font-size: 11px; line-height: 1; color: var(--text-dim); background: transparent; }
.ftree-del:hover { color: var(--bad); background: transparent; }
.ftree-del.locked { opacity: .35; }
.ftree-del.locked:hover { color: var(--text-dim); }
.ftree-msg { font-size: 11px; padding: 4px 6px; overflow-wrap: anywhere; }
.ftree-msg.ok { color: var(--good); }
.ftree-msg.error { color: var(--bad); }

/* ---- history: tree rows, roll-back marker, timeline ---- */
.ftree-steps { position: relative; }
.ftree-steps.dragging, .tl-track.dragging { cursor: grabbing; }
.ftree-icon, .tl-icon { display: inline-flex; flex: none; width: 14px; height: 14px; color: var(--eyebrow); }
.ftree-icon svg, .tl-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ftree-sup { border: 0; padding: 2px 3px; line-height: 0; color: var(--text-faint); background: transparent; opacity: 0; }
.ftree-sup svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.ftree-step:hover .ftree-sup, .ftree-sup.on, .ftree-sup:focus-visible { opacity: 1; }
.ftree-sup:hover { color: var(--text); background: transparent; }
.ftree-hstep.suppressed .ftree-name { color: var(--text-faint); text-decoration: line-through; }
.ftree-hstep.suppressed .ftree-icon { color: var(--text-faint); }
.ftree-hstep.rolled { opacity: .45; }
.ftree-hstep.failed { border-left-color: var(--bad); }
.ftree-hstep.failed .ftree-name, .ftree-hstep.failed .ftree-icon { color: var(--bad); }
.ftree-hstep.editing { border-color: var(--accent); border-style: dashed; color: var(--text); }
.ftree-fail { margin-left: 12px; padding: 0 6px 4px 30px; border-left: 1px solid var(--bad); font-size: 11px; color: var(--bad); overflow-wrap: anywhere; }
.ftree-marker {
  display: flex; align-items: center; gap: 6px; margin: 2px 0 2px 12px; padding: 1px 6px;
  font: 10px var(--mono); color: var(--text-faint); cursor: ns-resize; user-select: none; touch-action: none;
}
.ftree-marker::after { content: ""; flex: 1; height: 2px; border-radius: 1px; background: var(--line-strong); }
.ftree-marker.rolled { color: var(--warn); }
.ftree-marker.rolled::after { background: var(--warn); }
.ftree-marker:hover::after { background: var(--accent); }
.ftree-marker-grip { letter-spacing: -2px; }
.ftree-drop, .tl-drop { position: absolute; pointer-events: none; background: var(--accent); border-radius: 1px; }
.ftree-drop { left: 12px; right: 0; height: 2px; }
.tl-drop { top: 4px; bottom: 4px; width: 2px; }

#viewport.has-timeline #viewport-hud { bottom: 50px; }
#timeline:not([hidden]) {
  position: absolute; z-index: 6; left: 12px; right: 296px; bottom: 10px; height: 34px;
  display: flex; align-items: center; gap: 8px; padding: 0 8px;
  background: #0c1014dd; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 16px #0006;
}
.tl-label { flex: none; font: 600 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--eyebrow); }
.tl-track { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; height: 100%; touch-action: none; }
.tl-chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 24px; max-width: 120px; padding: 0 8px;
  font: 11px var(--sans); color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; cursor: pointer;
}
.tl-chip:hover { color: var(--text); border-color: var(--line-strong); }
.tl-chip.selected { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }
.tl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-chip.suppressed { opacity: .5; }
.tl-chip.suppressed .tl-name { text-decoration: line-through; }
.tl-chip.rolled { opacity: .4; border-style: dashed; }
.tl-chip.failed { color: var(--bad); border-color: var(--bad); }
.tl-chip.failed .tl-icon { color: var(--bad); }
.tl-marker { flex: none; width: 10px; height: 26px; cursor: ew-resize; position: relative; touch-action: none; }
.tl-marker::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; border-radius: 1px; background: var(--line-strong); }
.tl-marker.rolled::before, .tl-marker:hover::before { background: var(--warn); }
.tl-marker::after { content: ""; position: absolute; left: 1px; top: -1px; border: 4px solid transparent; border-top-color: var(--line-strong); }
.tl-marker.rolled::after { border-top-color: var(--warn); }
@media (max-width: 760px) { #timeline:not([hidden]) { right: 12px; } }
/* ---------- hole: toolbar Hole button + its floating panel ---------- */
#tool-hole.active,
#tool-pushpull.active,
#tool-sketchface.active {
  color: var(--on-fill);
  background: var(--fill);
  border-color: var(--fill);
  font-weight: 600;
}
#hole-panel:not([hidden]),
#pushpull-panel:not([hidden]),
#sketchface-panel:not([hidden]) {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 26;
  width: 300px;
  max-width: calc(100% - 28px);
  max-height: calc(100% - 60px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px #000a;
}
.hole-head { display: flex; align-items: baseline; gap: 8px; }
.hole-title { font-weight: 600; color: var(--text); font-size: 13px; }
.hole-target {
  flex: 1;
  min-width: 0;
  font: 11px var(--mono);
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hole-x { padding: 2px 8px; font-size: 14px; line-height: 1; }
.hole-msg { font-size: 12px; color: var(--text-dim); }
.hole-form { display: flex; flex-direction: column; gap: 6px; }
.hole-row {
  display: grid;
  grid-template-columns: 1fr 88px 52px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.hole-row select { grid-column: 2 / 4; padding: 4px 6px; }
.hole-row input[type="number"] { width: 100%; padding: 4px 6px; text-align: right; }
.hole-row input[type="number"].bad, .hole-row select.bad { border-color: var(--bad); }
.hole-row.off { opacity: .45; }
.hole-hint { font: 10px var(--mono); color: var(--text-faint); white-space: nowrap; }
.hole-check { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); cursor: pointer; }
.hole-check input { accent-color: var(--accent); margin: 0; }
.hole-note { font-size: 11px; color: var(--warn); }
.hole-status { font-size: 11px; color: var(--text-faint); overflow-wrap: anywhere; }
.hole-status:empty { display: none; }
.hole-status.ok { color: var(--good); }
.hole-status.error { color: var(--bad); }
.hole-foot { display: flex; gap: 8px; }
.hole-drill { color: var(--on-fill); background: var(--fill); border-color: var(--fill); font-weight: 600; }
.hole-drill:hover { color: var(--on-fill); background: var(--fill-hover); border-color: var(--fill-hover); }
.hole-undo { margin-left: auto; }
.pp-sign, .pp-footprint { font-size: 11px; }

/* ---------- viewport right-click menu and its value prompt (ctxmenu.js) ---------- */
.ctx-menu {
  position: absolute;
  z-index: 40;
  min-width: 200px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px #000a;
  font-size: 12px;
}
.ctx-title {
  padding: 6px 8px 4px;
  font: 10px var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--eyebrow);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctx-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
}
.ctx-item:hover, .ctx-item:focus-visible, .ctx-item:focus {
  background: var(--panel-2);
  border-color: var(--accent);
  outline: none;
}
.ctx-label { flex: 1; }
.ctx-hint { font: 10px var(--mono); color: var(--text-faint); }
.ctx-ask { gap: 6px; padding: 8px 10px; }
.ctx-row { display: grid; grid-template-columns: 1fr 90px auto; align-items: center; gap: 6px; color: var(--text-dim); }
.ctx-row input, .ctx-row select { width: 100%; padding: 4px 6px; }
.ctx-row input { text-align: right; }
.ctx-msg { font-size: 11px; color: var(--bad); min-height: 0; }
.ctx-msg:empty { display: none; }
.ctx-foot { display: flex; justify-content: flex-end; gap: 6px; }
#sel-hud:not(:empty) { margin-left: 10px; color: var(--text); }

/* ---- drag handle (draghandle.js): push/pull a face, extrude a region ---- */
.dh { position: absolute; inset: 0; pointer-events: none; z-index: 18; }
.dh-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.dh-arrow { pointer-events: auto; cursor: grab; }
.dh.dragging .dh-arrow { cursor: grabbing; }
.dh-hit { stroke: transparent; stroke-width: 18px; stroke-linecap: round; }
.dh-shaft { stroke: var(--fill); stroke-width: 3px; stroke-linecap: round; }
.dh-head { fill: var(--fill); stroke: var(--text); stroke-width: 1px; }
.dh-base { fill: var(--bg); stroke: var(--fill); stroke-width: 2px; }
.dh-arrow:hover .dh-shaft, .dh.dragging .dh-shaft { stroke: var(--accent); }
.dh-arrow:hover .dh-head, .dh.dragging .dh-head { fill: var(--accent); }
.dh-live {
  position: absolute; display: none; white-space: nowrap;
  padding: 3px 8px; border-radius: 4px;
  background: var(--panel); border: 1px solid var(--fill); color: var(--text);
  font: 500 12px var(--mono);
}
.dh-live.show { display: block; }
.dh-live.error { border-color: var(--bad); color: var(--text); }
.dh-entry {
  position: absolute; display: flex; align-items: center; gap: 6px; pointer-events: auto;
  padding: 4px 8px; border-radius: 4px; background: var(--panel); border: 1px solid var(--accent);
  color: var(--text-dim); font: 12px var(--mono);
}
.dh-entry[hidden] { display: none; }
.dh-input {
  width: 72px; padding: 2px 4px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 3px; font: inherit;
}
.dh-input:focus { outline: none; border-color: var(--accent); }

/* finished sketches in the Feature tree */
.ftree-group { margin-top: 8px; color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.ftree-step.ftree-sketch .ftree-name { color: var(--eyebrow); }
.sk-confirm .sk-finish { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
.sk-confirm .sk-finish[hidden], .sk-confirm .sk-addshape[hidden] { display: none; }

/* ---------- Modify tool panel (toolpanel.js): Fillet / Chamfer / Shell / Mirror ----------
   Docked to the right edge of the viewport, under the view cube, so it never
   sits over the co-pilot (which is outside #viewport) or the part's centre. */
#tool-panel:not([hidden]) {
  position: absolute;
  top: 186px;
  right: 12px;
  z-index: 27;
  width: 272px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 200px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--fill);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px #000a;
}
.tp-head { display: flex; align-items: baseline; gap: 8px; }
.tp-title { font-weight: 600; color: var(--text); font-size: 13px; }
.tp-target { flex: 1; min-width: 0; font: 11px var(--mono); color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-x { margin-left: auto; padding: 2px 8px; font-size: 14px; line-height: 1; }
.tp-hint { font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.tp-form { display: flex; flex-direction: column; gap: 8px; }
.tp-row { display: grid; grid-template-columns: 92px 1fr 30px; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.tp-row.tp-edges, .tp-row.tp-face, .tp-row.tp-choice { grid-template-columns: 92px 1fr; }
.tp-row.tp-toggle { grid-template-columns: 1fr; }
.tp-row.tp-text { grid-template-columns: 92px 1fr; }
.tp-row.tp-edgesizes { grid-template-columns: 92px 1fr; align-items: start; }
.tp-edgesizes { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.tp-edgesize { display: grid; grid-template-columns: 48px 1fr 30px; align-items: center; gap: 6px; }
.tp-edgesize-n { font: 10px var(--mono); color: var(--text-faint); }
.tp-row[hidden] { display: none; }
.tp-row input[type="text"] { width: 100%; padding: 4px 6px; }
.tp-row input[type="number"] { width: 100%; padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums; }
.tp-row select { width: 100%; padding: 4px 6px; }
.tp-row .bad { border-color: var(--bad); }
.tp-unit { font: 10px var(--mono); color: var(--text-faint); }
.tp-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.tp-check input { accent-color: var(--fill); margin: 0; }
.tp-pick {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; text-align: left;
  font: 11px var(--mono); color: var(--text-dim);
  background: var(--panel-2); border: 1px dashed var(--line-strong);
}
.tp-pick-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--text-faint); flex: none; }
.tp-pick.filled { color: var(--text); border-style: solid; }
.tp-pick.filled .tp-pick-dot { background: var(--accent); border-color: var(--accent); }
.tp-pick.active { color: var(--on-fill); background: var(--fill); border: 1px solid var(--fill); }
.tp-pick.active .tp-pick-dot { background: var(--on-fill); border-color: var(--on-fill); }
.tp-pick.bad { border-color: var(--bad); }
.tp-pick:disabled { opacity: .45; cursor: not-allowed; }
.tp-msg { font-size: 11px; color: var(--text-faint); overflow-wrap: anywhere; line-height: 1.4; min-height: 15px; }
.tp-msg.ok { color: var(--good); }
.tp-msg.note { color: var(--text-dim); }
.tp-msg.error { color: var(--bad); }
.tp-foot { display: flex; gap: 8px; justify-content: flex-end; }
.tp-ok { min-width: 64px; color: var(--on-fill); background: var(--fill); border-color: var(--fill); font-weight: 600; }
.tp-ok:hover:not(:disabled) { background: var(--fill-hover); border-color: var(--fill-hover); }
.tp-ok:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Measure and Section (measure.js, section.js) ----------
   Measure docks where the Modify tool panel does (it closes that panel when it
   opens); Section sits bottom-left so it can stay on while other tools run. */
#measure-panel:not([hidden]), #section-panel:not([hidden]), #inspect-panel:not([hidden]) {
  position: absolute;
  z-index: 27;
  width: 260px;
  max-width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--fill);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px #000a;
}
#measure-panel:not([hidden]) { top: 186px; right: 12px; max-height: calc(100% - 200px); overflow-y: auto; }
/* Mass / Draft / Curvature (inspect.js) dock where Measure does; opening one closes the other. */
#inspect-panel:not([hidden]) { top: 186px; right: 12px; max-height: calc(100% - 200px); overflow-y: auto; }
#section-panel:not([hidden]) { left: 12px; bottom: 48px; }
.measure-result { display: flex; flex-direction: column; gap: 6px; }
.measure-kind { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--eyebrow); }
.measure-rows { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 12px; }
.measure-rows dt { color: var(--text-dim); }
.measure-rows dd { margin: 0; text-align: right; font: 12px var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.measure-rows dt:first-of-type, .measure-rows dd:first-of-type { font-weight: 600; }
.measure-rows dd:first-of-type { font-size: 14px; }
.measure-label {
  position: absolute;
  z-index: 26;
  transform: translate(-50%, -150%);
  padding: 2px 8px;
  font: 12px var(--mono);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  white-space: nowrap;
  pointer-events: none;
}
.measure-label[hidden] { display: none; }
.section-seg { display: flex; gap: 4px; }
.section-seg button { flex: 1; padding: 4px 0; font: 12px var(--mono); }
.section-seg button.active { color: var(--on-fill); background: var(--fill); border-color: var(--fill); }
.section-slider { width: 100%; accent-color: var(--fill); margin: 0; }
/* up to three cuts, each a row: on/off, name (click to edit), area, remove */
.section-cuts { display: flex; flex-direction: column; gap: 4px; }
.section-cut { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 6px;
  padding: 3px 6px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel-2); }
.section-cut.active { border-color: var(--accent); }
.section-cut input { accent-color: var(--fill); margin: 0; }
.section-cut-name { background: none; border: 0; padding: 2px 0; text-align: left; color: var(--text); font: 12px var(--mono); cursor: pointer; }
.section-cut-name:hover { color: var(--accent); }
.section-cut-area { font: 11px var(--mono); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.section-cut-x { background: none; border: 0; color: var(--text-dim); font-size: 14px; line-height: 1; padding: 0 2px; cursor: pointer; }
.section-cut-x:hover { color: var(--text); }
.section-add { align-self: flex-start; font-size: 12px; padding: 4px 10px; }
.section-editor { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.section-editor[hidden] { display: none; }
.section-editor-title { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--eyebrow); }
.section-cplane { flex: 1; min-width: 0; }

/* ---------- Analyse: Mass, Draft, Curvature (inspect.js) ---------- */
.inspect-body { display: flex; flex-direction: column; gap: 8px; }
.inspect-body select, .inspect-body input[type=number] { min-width: 0; }
.inspect-body .tp-row select { flex: 1; }
.inspect-rows dd { white-space: nowrap; }
.inspect-copy { align-self: flex-start; font-size: 12px; padding: 4px 12px; }
.inspect-legend { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; border-top: 1px solid var(--line-soft); }
.inspect-legend-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: 12px; color: var(--text); }
.inspect-legend-row:not(:has(.inspect-swatch)) { grid-template-columns: 1fr; color: var(--text-dim); }
.inspect-swatch { width: 12px; height: 12px; border-radius: 2px; border: 1px solid var(--line-strong); }
.inspect-legend-val { font: 12px var(--mono); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.inspect-ramp { height: 10px; border-radius: 2px; border: 1px solid var(--line-strong); }
.inspect-ramp-ticks { display: flex; justify-content: space-between; font: 11px var(--mono); color: var(--text-dim); }
.inspect-seg button { font: 12px var(--sans); }
/* ---------- start page (start-page.js) ----------
   The launch view. Console tokens only: the --bg ground, --panel cards, the
   Blue 500 fill on the one primary action (New design), Blue 300 for focus,
   hover and the eyebrows. No orange — that is spent in the Impact card. */
#start-page {
  position: fixed;
  inset: 0;
  z-index: 900;              /* over the workspace, under the settings dialog */
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
#start-page[hidden] { display: none; }

#start-page .sp-inner {
  box-sizing: border-box;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 32px 56px;
}

/* header: the same lockup as the ribbon — logotype at its 120px minimum, a
   hairline rule, then the product name — with "Start" beside the name */
#start-page .sp-head { margin-bottom: 28px; }
#start-page .sp-lockup { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#start-page .sp-logo { display: block; width: 120px; height: auto; flex: 0 0 auto; }
#start-page .sp-rule { width: 1px; height: 22px; background: var(--line); }
#start-page .sp-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  font: inherit;
}
#start-page .sp-mark {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.18em;
  color: var(--text);
}
#start-page .sp-kicker {
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--eyebrow);
}
#start-page .sp-lede {
  max-width: 62ch;
  margin: 18px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}
#start-page .sp-status { margin: 8px 0 0; min-height: 1.45em; font: 12px/1.45 var(--mono); color: var(--text-faint); }
#start-page .sp-status:empty { display: none; }

/* shared button reset: the app's quiet default button sets padding, a 1-line
   font and a centred row, none of which a card wants */
#start-page .sp-action,
#start-page .sp-card {
  box-sizing: border-box;
  display: flex;
  min-width: 0;
  margin: 0;
  text-align: left;
  font: inherit;
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .12s;
}
#start-page .sp-action:focus-visible,
#start-page .sp-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
#start-page .sp-action:disabled,
#start-page .sp-card:disabled { opacity: .5; cursor: progress; }

/* the two actions */
#start-page .sp-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}
#start-page .sp-action {
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  min-height: 104px;
  background: var(--panel);
  border: 1px solid var(--line);
}
#start-page .sp-action:hover:not(:disabled) { border-color: var(--accent); background: var(--panel); }
#start-page .sp-action-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 10px;
  box-sizing: content-box;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#start-page .sp-action-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#start-page .sp-action-name { font-size: 17px; font-weight: 600; line-height: 1.2; }
#start-page .sp-action-desc { font-size: 13px; line-height: 1.4; color: var(--text-dim); }

/* New design is the primary action: the site's solid Blue 500 CTA */
#start-page .sp-new { background: var(--fill); border-color: var(--fill); color: var(--on-fill); }
#start-page .sp-new:hover:not(:disabled) { background: var(--fill-hover); border-color: var(--fill-hover); }
#start-page .sp-new .sp-action-desc { color: var(--on-fill); opacity: .9; }
#start-page .sp-new .sp-action-icon { stroke: var(--on-fill); background: transparent; border-color: var(--on-fill); }
#start-page .sp-new:focus-visible { outline-color: var(--accent); }

/* samples */
#start-page .sp-samples-title {
  margin: 0 0 14px;
  font: 500 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--eyebrow);
}
#start-page .sp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
#start-page .sp-card {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
}
#start-page .sp-card:hover:not(:disabled) { border-color: var(--accent); background: var(--panel); transform: translateY(-1px); }

/* preview: a neutral placeholder — an inset well with a faint 10 mm grid and
   the cube — until the app can render real thumbnails */
#start-page .sp-preview {
  display: grid;
  place-items: center;
  height: 112px;
  background-color: var(--panel-2);
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: center;
  border-bottom: 1px solid var(--line);
}
#start-page .sp-cube {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 1.3;
  stroke-linejoin: round;
  transition: stroke .12s;
}
#start-page .sp-card:hover:not(:disabled) .sp-cube,
#start-page .sp-card:focus-visible .sp-cube { stroke: var(--accent); }

#start-page .sp-card-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; min-width: 0; }
#start-page .sp-card-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; color: var(--text); }
#start-page .sp-card-desc {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
}

@media (max-width: 1180px) {
  #start-page .sp-inner { padding: 32px 24px 44px; }
}
@media (max-width: 640px) {
  #start-page .sp-inner { padding: 24px 16px 36px; }
}
@media (prefers-reduced-motion: reduce) {
  #start-page .sp-action, #start-page .sp-card { transition: none; }
  #start-page .sp-card:hover:not(:disabled) { transform: none; }
}
#start-page .sp-lockup { display: flex; align-items: center; } #start-page .sp-acct { margin-left: auto; }

/* ---------- files (files.js): restore offer and recent designs ---------- */
#start-page .sp-restore {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 14px 18px;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
#start-page .sp-restore[hidden] { display: none; }
#start-page .sp-restore-text { display: flex; flex-direction: column; gap: 4px; flex: 1 1 260px; min-width: 0; }
#start-page .sp-restore-name { font-size: 14px; font-weight: 600; color: var(--text); }
#start-page .sp-restore-when { font-size: 12.5px; color: var(--text-dim); }
#start-page .sp-restore button { padding: 7px 16px; min-width: 88px; }
#start-page .sp-restore-yes { background: var(--fill); border-color: var(--fill); color: var(--on-fill); font-weight: 600; }
#start-page .sp-restore-yes:hover { background: var(--fill-hover); border-color: var(--fill-hover); }

#start-page .sp-recent { margin: 0 0 36px; }
#start-page .sp-recent[hidden] { display: none; }
#start-page .sp-recent-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
#start-page .sp-recent-row { display: flex; align-items: stretch; border-top: 1px solid var(--line-soft); background: var(--panel); }
#start-page .sp-recent-row:first-child { border-top: 0; }
#start-page .sp-recent-open {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 10px 14px; background: transparent; border: 0; border-radius: 0; text-align: left;
}
#start-page .sp-recent-open:hover { background: var(--panel-2); }
#start-page .sp-recent-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; font-weight: 600; color: var(--text); }
#start-page .sp-recent-meta { flex: 0 0 auto; font: 11.5px/1.4 var(--mono); color: var(--text-faint); }
#start-page .sp-recent-remove { flex: 0 0 auto; width: 40px; padding: 0; background: transparent; border: 0; border-left: 1px solid var(--line-soft); border-radius: 0; color: var(--text-faint); font-size: 16px; }
#start-page .sp-recent-remove:hover { color: var(--bad); background: var(--panel-2); }
/* Interface (interface.js, units.js): typed length boxes, command search,
   named views, materials library. Console tokens only (style.css :root). */

/* Length boxes are type=text so "1in" and "10+5" reach the parser; they keep
   the look of the number boxes they replaced. */
input[inputmode="decimal"] {
  font: 12px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
}
input[inputmode="decimal"]:hover { border-color: var(--line-strong); }
input[inputmode="decimal"]:focus { outline: none; border-color: var(--accent); }
.tp-row input[inputmode="decimal"], .hole-row input[inputmode="decimal"] { width: 100%; padding: 4px 6px; text-align: right; }
.hole-row input[inputmode="decimal"].bad, .tp-row input[inputmode="decimal"].bad { border-color: var(--bad); }
.size-row input[inputmode="decimal"] { width: 100%; padding: 4px 6px; text-align: right; }
.sk-confirm input[inputmode="decimal"], .sk-dims input[inputmode="decimal"], .sk-params input[inputmode="decimal"] { width: 64px; padding: 3px 6px; text-align: right; }
.sk-dimedit[inputmode="decimal"] { width: 72px; padding: 3px 6px; }

#view-controls #units-select { min-width: 58px; }
#view-controls #views-btn { min-width: 58px; }
#view-controls #views-btn[aria-expanded="true"] { background: var(--accent); color: var(--bg); }

/* ---------- command search ---------- */
.cmdp {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: #0B1418b3;
}
.cmdp[hidden] { display: none; }
.cmdp-box {
  width: 620px;
  max-width: 100%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-top: 2px solid var(--fill);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px #000c;
  overflow: hidden;
}
.cmdp-input {
  font: 15px var(--sans);
  color: var(--text);
  background: var(--panel-2);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 13px 16px;
  outline: none;
}
.cmdp-input::placeholder { color: var(--text-faint); }
.cmdp-list { overflow-y: auto; padding: 4px 0; }
.cmdp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.cmdp-row.on { background: var(--accent-dim); border-left-color: var(--accent); }
.cmdp-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.cmdp-label { color: var(--text); font-size: 13px; white-space: nowrap; }
.cmdp-group { color: var(--text-faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdp-row.off .cmdp-label { color: var(--text-faint); }
.cmdp-reason { font-size: 11px; color: var(--warn); white-space: nowrap; max-width: 46%; overflow: hidden; text-overflow: ellipsis; }
.cmdp-kbd {
  font: 10px var(--mono);
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}
.cmdp-empty { padding: 14px 16px; color: var(--text-dim); font-size: 12px; }
.cmdp-foot { padding: 6px 16px; font: 10px var(--mono); color: var(--text-faint); border-top: 1px solid var(--line-soft); }
@keyframes cmdp-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.cmdp-row.shake { animation: cmdp-shake .18s linear 2; }

/* ---------- named views ---------- */
.nv-panel:not([hidden]), .mat-panel:not([hidden]) {
  position: absolute;
  top: 60px;
  right: 12px;
  z-index: 28;
  width: 290px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 80px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--fill);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px #000a;
}
.nv-head, .mat-head { display: flex; align-items: baseline; gap: 8px; }
.nv-title, .mat-title { font-weight: 600; color: var(--text); font-size: 13px; }
.nv-x, .mat-x { margin-left: auto; padding: 2px 8px; font-size: 14px; line-height: 1; }
.nv-save { display: flex; gap: 6px; }
.nv-name, .nv-rename, .mat-search {
  flex: 1;
  min-width: 0;
  font: 12px var(--sans);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 8px;
}
.nv-name:focus, .nv-rename:focus, .mat-search:focus { outline: none; border-color: var(--accent); }
.nv-add { white-space: nowrap; padding: 5px 10px; background: var(--fill); color: var(--on-fill); border: 1px solid var(--fill); border-radius: 4px; cursor: pointer; font-size: 12px; }
.nv-add:hover { background: var(--fill-hover); }
.nv-note, .nv-empty, .mat-note { font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.nv-list { display: flex; flex-direction: column; gap: 2px; }
.nv-row { display: flex; align-items: center; gap: 2px; }
.nv-go {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  padding: 5px 8px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.nv-go:hover { border-color: var(--line-strong); background: var(--panel-2); }
.nv-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-tag, .mat-tag { font: 9px var(--mono); color: var(--eyebrow); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; white-space: nowrap; }
.nv-act { padding: 3px 7px; font-size: 12px; line-height: 1; color: var(--text-dim); background: transparent; border: 1px solid transparent; border-radius: 3px; cursor: pointer; }
.nv-act:hover { color: var(--text); border-color: var(--line-strong); }
.nv-del:hover { color: var(--bad); }

/* ---------- materials ---------- */
.mat-panel:not([hidden]) { width: 330px; }
.mat-pick { display: flex; gap: 4px; }
.mat-pick select { flex: 1; min-width: 0; }
#material-browse { padding: 4px 8px; font-size: 11px; color: var(--accent); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
#material-browse:hover { border-color: var(--accent); }
.mat-scope { display: flex; gap: 4px; }
.mat-scope-btn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 8px; font-size: 11px; color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.mat-scope-btn.on { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }
.mat-scope-btn:disabled { color: var(--text-faint); cursor: default; }
.mat-list { display: flex; flex-direction: column; gap: 10px; }
.mat-fam-head { display: flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--eyebrow); margin-bottom: 3px; }
.mat-swatch { width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--line-strong); }
.mat-count { margin-left: auto; font: 10px var(--mono); color: var(--text-faint); }
.mat-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  margin-top: 2px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  cursor: pointer;
}
.mat-row:hover { border-color: var(--line-strong); }
.mat-row.on { border-color: var(--accent); background: var(--accent-dim); }
.mat-row.off { opacity: .7; }
.mat-row:disabled { cursor: not-allowed; }
.mat-row-top { display: flex; align-items: center; gap: 6px; }
.mat-name { font-size: 12px; font-weight: 500; }
.mat-rec { color: var(--good); }
.mat-facts { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 3px; font: 10px var(--mono); color: var(--text-dim); }
.mat-fact em { font-style: normal; color: var(--text-faint); }
.mat-why { margin-top: 3px; font-size: 10px; color: var(--warn); }
.mat-empty { font-size: 12px; color: var(--text-dim); }
.mat-status { font-size: 11px; }
.mat-status.ok { color: var(--good); }
.mat-status.error { color: var(--bad); }
