/* kerfmaster shell — dock-first Workbench (A+C ruling). Dark is default; both
   themes ruled one-click (2026-08-19). Typography deliberate, not accreted. */
:root {
  --bg: #14171b; --panel: #1c2127; --edge: #2a313a; --ink: #dbe2ea;
  --dim: #8b97a5; --accent: #35b6ff; --good: #3ecf6f; --warn: #f2c037;
  --bad: #f25757; --pend: #5a6672; --canvas: #0f1216;
  --base-layer: #6b7684; --healed-line: #3ecf6f; --healed-arc: #35b6ff;
  /* canvas signal colors, DELIBERATELY separate from the interface accent
     (Jordan 2026-09-04: recoloring selection must not restyle the app) */
  --sel: #35b6ff; --toolpath: #35b6ff;
}
[data-theme="light"] {
  --bg: #f2f4f6; --panel: #ffffff; --edge: #d6dce2; --ink: #1d2530;
  --dim: #5d6a78; --canvas: #fbfcfd; --base-layer: #9aa5b1; --pend: #b7c0c9;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink); overflow: hidden;
  font: 14px/1.45 "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}
#topbar {
  display: flex; align-items: center; gap: 14px; height: 46px;
  padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--edge);
}
#brand { font-weight: 700; letter-spacing: .06em; color: var(--accent);
  cursor: pointer; }
#brand:hover, #jobname:hover { text-decoration: underline; }
#jobname { color: var(--dim); cursor: pointer; white-space: nowrap;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
#jobname:hover { color: var(--ink); }
#tabs { display: flex; gap: 2px; flex: 1; justify-content: center; }
.tab {
  display: flex; align-items: center; gap: 7px; padding: 5px 13px;
  border-radius: 7px 7px 0 0; cursor: pointer; color: var(--dim);
  border: 1px solid transparent; user-select: none;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); background: var(--bg);
  border-color: var(--edge); border-bottom-color: var(--bg); }
.dot { width: 15px; height: 15px; border-radius: 50%; font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #0d1013; font-weight: 700; background: var(--pend); }
.dot.done { background: var(--good); } .dot.flagged { background: var(--warn); }
.dot.blocked { background: var(--bad); }
#topright { display: flex; gap: 8px; }
.chip { background: var(--bg); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }

#workbench { display: flex; height: calc(100% - 46px); }

/* Panels & workspaces (brick 11) — the A+C ruling: docked Workbench is the
   ground state; a panel tears off into a floating window, snap-back is one
   click, and a panel can never be lost (floats clamp on-screen; Reset docks
   everything). Plain DOM + pointer events — identical on Web/Mac/PC shells. */
.panel { background: var(--panel); display: flex; flex-direction: column;
  flex-shrink: 0; }
.panel.dockleft { order: -1; border-right: 1px solid var(--edge); }
.panel.dockright { order: 1; border-left: 1px solid var(--edge); }
.panel[data-panel="tools"] { width: 56px; }
.panel[data-panel="checks"] { width: 300px; }
.panel[data-panel="healqc"] { width: 236px; }
.panel[data-panel="dims"] { width: 250px; }
.panel.floating { position: fixed; z-index: 40; border: 1px solid var(--edge);
  border-radius: 10px; box-shadow: 0 12px 36px rgba(0, 0, 0, .45);
  overflow: hidden; resize: both; min-width: 56px; min-height: 100px;
  width: 300px; }
.pgrip { display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  border-bottom: 1px solid var(--edge); cursor: grab; user-select: none;
  color: var(--dim); font-weight: 600; letter-spacing: .04em;
  touch-action: none; }
.pgrip:active { cursor: grabbing; }
.gdots { font-size: 10px; letter-spacing: -1px; }
.ptitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12.5px; }
.panel[data-panel="tools"]:not(.collapsed) .ptitle { display: none; }
/* With the title hidden the dots stretch, so the narrow grip keeps a real
   drag target beside its two buttons. */
.panel[data-panel="tools"]:not(.collapsed) .gdots { flex: 1; }
.pbtns { display: flex; gap: 2px; }
.pbtn { background: none; border: 0; color: var(--dim); cursor: pointer;
  padding: 0 3px; font-size: 12px; line-height: 1.3; }
.pbtn:hover { color: var(--ink); }
.pbody { flex: 1; min-height: 0; }
/* Double-click the header: a float minimizes to its title bar and back. */
.panel.floating.fmin { height: auto !important; min-height: 0; resize: none; }
.panel.floating.fmin .pbody { display: none; }
.panel.collapsed { width: 26px !important; }
.panel.collapsed .pbody, .panel.collapsed .pbtns,
.panel.collapsed .gdots { display: none; }
.panel.collapsed .pgrip { flex-direction: column; border-bottom: 0;
  height: 100%; cursor: pointer; padding: 10px 4px; }
.panel.collapsed .ptitle { writing-mode: vertical-rl; flex: 0 1 auto;
  display: block; }
#workbench.hintleft::after, #workbench.hintright::after {
  content: ""; position: fixed; top: 46px; bottom: 0; width: 6px;
  background: var(--accent); z-index: 50; opacity: .8; }
#workbench.hintleft::after { left: 0; }
#workbench.hintright::after { right: 0; }
#wsmenu { position: fixed; top: 50px; right: 14px; z-index: 60; width: 258px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
  padding: 10px 14px 12px; box-shadow: 0 12px 36px rgba(0, 0, 0, .45); }
.wsrow { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.wsrow .wsname { flex: 1; cursor: pointer; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.wsrow .wsname:hover { color: var(--accent); }

#toolbar { display: flex; flex-direction: column; gap: 4px; padding: 8px 6px;
  overflow-y: auto; }
.tool { width: 40px; height: 40px; border-radius: 8px; border: 1px solid transparent;
  background: none; color: var(--dim); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center; position: relative; }
.tool:hover { color: var(--ink); border-color: var(--edge); }
.tool.on { color: var(--accent); border-color: var(--accent); background: var(--bg); }
.tool .key { position: absolute; right: 3px; bottom: 1px; font-size: 8px; color: var(--dim); }

#canvaswrap { flex: 1; position: relative; background: var(--canvas); }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#zoomui { position: absolute; left: 12px; bottom: 10px; display: flex;
  align-items: center; gap: 10px; background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--edge); border-radius: 8px; padding: 5px 10px; }
#zoompreset { background: var(--bg); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 5px; padding: 2px 4px; }
#zoomreadout { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
#scalebar { display: flex; align-items: center; gap: 6px; }
#scalebarline { display: inline-block; height: 0; border-bottom: 2px solid var(--ink);
  border-left: 2px solid var(--ink); border-right: 2px solid var(--ink);
  padding: 3px 0 0; }
#scalebarlabel { color: var(--dim); font-size: 12px; }

#drawerbody { padding: 12px 14px; overflow-y: auto; }
.kv { display: flex; justify-content: space-between; padding: 3px 0; gap: 10px; }
.kv .k { color: var(--dim); } .kv .v { font-variant-numeric: tabular-nums; text-align: right; }
.banner { margin: 10px 0; padding: 8px 12px; border-radius: 7px; font-weight: 700;
  text-align: center; color: #0d1013; }
.banner.pass { background: var(--good); } .banner.flag { background: var(--warn); }
.banner.block { background: var(--bad); }
.drawernote { color: var(--dim); font-style: italic; margin-top: 8px; }
.layerrow { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.swatch { width: 14px; height: 3px; border-radius: 2px; }
h4.sect { margin: 12px 0 4px; color: var(--dim); font-size: 12px;
  text-transform: uppercase; letter-spacing: .08em; }

#jobshome { position: absolute; inset: 0; background: var(--bg); overflow-y: auto; }
#homeinner { max-width: 860px; margin: 40px auto; padding: 0 20px; }
#jobshome h1 { color: var(--accent); letter-spacing: .06em; }
#jobshome .sub { color: var(--dim); margin-bottom: 18px; }
#dropzone { border: 2px dashed var(--edge); border-radius: 12px; padding: 26px;
  text-align: center; color: var(--dim); margin-bottom: 24px; }
#dropzone.over { border-color: var(--accent); color: var(--ink); }
#browsebtn { margin: 10px 0; background: var(--accent); color: #0d1013;
  border: 0; border-radius: 7px; padding: 8px 18px; font-weight: 700; cursor: pointer; }
.unitfield { background: var(--bg); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 5px; padding: 2px 7px; width: 90px; text-align: center; }
.hint { font-size: 12px; margin-top: 8px; }
.jobcard { display: flex; align-items: center; gap: 14px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 10px; padding: 12px 16px;
  margin-bottom: 10px; cursor: pointer; }
.jobcard:hover { border-color: var(--accent); }
.jobcard .jname { font-weight: 600; flex: 1; }
.jobcard .jdate { color: var(--dim); font-size: 12px; }
.ministrip { display: flex; gap: 4px; }
.ministrip .dot { width: 11px; height: 11px; font-size: 0; }

/* Filing: customer folders + search (jobs-home-filing, 2026-09-02) */
#jobsearch { display: block; width: 100%; box-sizing: border-box;
  margin: 18px 0 10px; padding: 9px 14px; background: var(--panel);
  color: var(--ink); border: 1px solid var(--edge); border-radius: 8px;
  font: inherit; }
#jobsearch:focus { outline: none; border-color: var(--accent); }
.custhead { display: flex; align-items: center; gap: 8px;
  padding: 10px 6px 6px; cursor: pointer; user-select: none;
  font-weight: 600; }
.custhead .chev { color: var(--dim); width: 14px; }
.custhead .ccount { color: var(--dim); font-size: 12px; font-weight: 400; }
.custhead:hover .cname { color: var(--accent); }
.jobcard .jref { color: var(--dim); font-size: 12px;
  border: 1px solid var(--edge); border-radius: 6px; padding: 1px 7px;
  white-space: nowrap; }
.filebtn { background: none; color: var(--dim); border: 1px solid var(--edge);
  border-radius: 6px; padding: 2px 9px; font-size: 12px; cursor: pointer; }
.filebtn:hover { color: var(--accent); border-color: var(--accent); }
.fileform { display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: -4px 0 10px; padding: 9px 14px; background: var(--panel);
  border: 1px dashed var(--edge); border-radius: 10px; font-size: 12.5px; }
.fileform label { display: flex; gap: 6px; align-items: center;
  color: var(--dim); }
.fileform input, .fileform select { background: var(--bg); color: var(--ink);
  border: 1px solid var(--edge); border-radius: 5px; padding: 3px 8px;
  font: inherit; font-size: 12.5px; }
.fileform .fsave { background: var(--accent); color: var(--bg); border: 0;
  border-radius: 6px; padding: 4px 14px; font-weight: 700; cursor: pointer; }

/* Part review (brick 2) */
.findrow { margin: 6px 0; padding: 6px 9px; border-radius: 6px; font-size: 12.5px;
  cursor: pointer; border-left: 4px solid; background: var(--bg); }
.findrow.red { border-color: var(--bad); }
.findrow.yellow { border-color: var(--warn); }
.findrow:hover { outline: 1px solid var(--edge); }
/* A row that navigates says so: pointer + accent ring + a "go" glyph. Rows
   with no geometry to go to stay flat — honestly not navigable. */
.findrow.nav { cursor: pointer; }
.findrow.nav::after { content: " ⌖"; color: var(--accent); font-weight: 700; }
.findrow.nav:hover { outline: 1px solid var(--accent); }
.ovrow { display: flex; align-items: center; gap: 7px; padding: 3px 0;
  color: var(--dim); flex-wrap: wrap; }
.ovrow a { color: var(--accent); }
.src { color: var(--dim); font-size: 11px; font-style: italic; }
.btn { background: var(--accent); color: #0d1013; border: 0; border-radius: 7px;
  padding: 6px 14px; font-weight: 700; cursor: pointer; margin-top: 6px; }
.btn.small { padding: 2px 9px; font-weight: 600; margin: 0; }
#drawerbody select { background: var(--bg); color: var(--ink);
  border: 1px solid var(--edge); border-radius: 5px; padding: 2px 5px;
  max-width: 190px; }

/* first-run tour + help + bug report (brick 13, sitting ruling 9).
   The tour dims the screen through a spotlight hole but NEVER blocks it:
   the container passes pointer events, only the card takes them — so a
   "try it now" step works live under the tour. Plain DOM, three lenses. */
#tour { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
#tourhole { position: fixed; border-radius: 10px; border: 2px solid var(--accent);
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .55); transition: all .22s; }
#tourhole.nohole { border-color: transparent; }
#tourcard { position: fixed; width: 340px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 12px; padding: 14px 16px 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .5); pointer-events: auto; }
#tourcard h4 { margin: 0 0 6px; color: var(--accent); }
#tourbody { font-size: 13px; }
#tourbody .dot { vertical-align: middle; }
#tourbtns { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
#tourstep { flex: 1; text-align: center; color: var(--dim); font-size: 12px;
  font-variant-numeric: tabular-nums; }
#tourskipall { display: block; margin: 8px auto 0; font-size: 11.5px; }
#helpmenu { position: fixed; top: 50px; right: 14px; z-index: 60; width: 258px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
  padding: 10px 14px 12px; box-shadow: 0 12px 36px rgba(0, 0, 0, .45); }
/* Onboarding wizard — the shop-setup modal (same [hidden] guard as the
   bug modal: display:flex outranks the UA's [hidden]). */
#wizmodal { position: fixed; inset: 0; z-index: 84;
  background: rgba(0, 0, 0, .45); display: flex; align-items: center;
  justify-content: center; }
#wizmodal[hidden] { display: none; }
#wizcard { width: 400px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }
#wizcard h4 { margin: 0 0 4px; color: var(--accent); }
.wizq { font-weight: 700; margin: 10px 0 4px; }
.wizopt { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0;
  font-size: 12.5px; cursor: pointer; }
.wizopt input { margin-top: 2px; }

#bugmodal { position: fixed; inset: 0; z-index: 85;
  background: rgba(0, 0, 0, .45); display: flex; align-items: center;
  justify-content: center; }
/* display:flex outranks the UA's [hidden]{display:none} — without this
   line the INVISIBLE modal covers the screen and eats every click
   (caught live by verify_tour phase 5). */
#bugmodal[hidden] { display: none; }
#bugcard { width: 360px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }
#bugcard h4 { margin: 0 0 4px; }
#bugtext { width: 100%; margin-top: 8px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--edge); border-radius: 6px; padding: 6px 8px;
  font: inherit; resize: vertical; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--edge); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; opacity: 0; transition: opacity .25s;
  pointer-events: none; }
#toast.show { opacity: 1; }

/* cut plan (brick 4): the ordered sequence list */
.seqrow { margin: 3px 0; padding: 4px 7px; border-radius: 6px;
  font-size: 12.5px; cursor: pointer; color: var(--dim);
  display: flex; align-items: center; gap: 7px; }
.seqrow:hover { outline: 1px solid var(--edge); }
.seqrow.selected { color: var(--ink); outline: 1px solid var(--accent); }
.seqnum { min-width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--dim); display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 11px;
  font-variant-numeric: tabular-nums; }
.seqnum.red { border-color: var(--bad); color: var(--bad); }
.seqnum.yellow { border-color: var(--warn); color: var(--warn); }

/* nest layout-array one-clicks: active spread shows as pressed */
.btn.on { outline: 2px solid var(--accent); outline-offset: 1px;
  filter: brightness(1.15); }

/* sketch (brick 10): typed-number primitive rows */
.primrow { display: flex; align-items: center; gap: 4px; padding: 3px 0;
  flex-wrap: wrap; }
.primtype { color: var(--dim); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; min-width: 42px; }
.unitfield.mini { width: 62px; padding: 2px 4px; font-size: 11.5px; }
.btnrow { display: flex; gap: 6px; margin: 8px 0 4px; }
#sketchbtn { background: var(--accent); color: #0d1013; border: 0;
  border-radius: 6px; padding: 3px 12px; font-weight: 700; cursor: pointer; }
#sketchname { width: 120px; }

/* post (brick 5): program preview + the audit's own words */
.ncpre { background: var(--bg); border: 1px solid var(--edge);
  border-radius: 6px; padding: 8px 10px; font-size: 11px; line-height: 1.5;
  overflow-x: auto; white-space: pre; max-height: 260px; overflow-y: auto;
  font-variant-numeric: tabular-nums; }
.ncanom { margin: 4px 0; padding: 4px 8px; border-left: 3px solid var(--dim);
  color: var(--dim); font-size: 11.5px; background: var(--bg);
  border-radius: 4px; }
a.btn.small { text-decoration: none; display: inline-block;
  color: #0d1013; } /* .ovrow a's accent would paint accent-on-accent */

/* Heal/QC manual edit panel (brick F) */
#healqcbody .hqrow { display: flex; gap: 6px; align-items: center;
  margin: 4px 8px; }
#healqcbody .hqbtn { flex: 1; text-align: left; }
#dimsbody { padding: 10px 12px; overflow-y: auto; font-size: 12.5px; }
#dimsbody .hqrow { display: flex; gap: 6px; align-items: center;
  padding: 2px 0; }
#dimsbody .hqbtn { text-align: left; }
/* pressed lens keeps the shared .btn.on look (outline + brightness) —
   never accent text on the accent fill, which made the label invisible */
#healqcbody input.unitfield { width: 62px; flex-shrink: 0; }
#healqcbody .hqedit { font-size: 11.5px; margin: 3px 8px; display: flex;
  gap: 6px; align-items: baseline; justify-content: space-between; }
#healqcbody .hqnote { font-size: 11px; color: var(--dim); margin: 8px; }
#healqcbody .hqnote2 { font-size: 10.5px; color: var(--dim); }
#healqcbody .hqnote2.skip { color: var(--warn); }

/* Colours & legend modal (Jordan 2026-09-04) — same [hidden] guard as the
   bug modal: display:flex outranks the UA's [hidden]. */
#colmodal { position: fixed; inset: 0; z-index: 85;
  background: rgba(0, 0, 0, .45); display: flex; align-items: center;
  justify-content: center; }
#colmodal[hidden] { display: none; }
#colcard { width: 430px; max-height: 82vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--edge);
  border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }
#colcard h4 { margin: 0 0 4px; }
.colrow { display: flex; align-items: center; gap: 10px; padding: 5px 0;
  border-bottom: 1px solid var(--edge); }
.colrow:last-child { border-bottom: 0; }
.colrow input[type="color"] { width: 34px; height: 24px; padding: 0;
  border: 1px solid var(--edge); border-radius: 5px; background: none;
  cursor: pointer; flex: none; }
.colrow .colname { font-weight: 600; white-space: nowrap; }
.colrow .colmeans { color: var(--dim); font-size: 12px; flex: 1; }
.colrow .colreset1 { color: var(--accent); font-size: 12px; cursor: pointer;
  flex: none; visibility: hidden; }
.colrow.changed .colreset1 { visibility: visible; }

/* Units confirmation modal (Jordan, 2026-09-04): autodetected units with
   a one-click flip; the BIG RED warning only on the extremes. Same
   [hidden] guard as every modal (display:flex outranks the UA rule). */
#unitsmodal { position: fixed; inset: 0; z-index: 86;
  background: rgba(0, 0, 0, .45); display: flex; align-items: center;
  justify-content: center; }
#unitsmodal[hidden] { display: none; }
#unitscard { width: 380px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }
#unitscard h4 { margin: 0 0 4px; color: var(--accent); }
.unitsred { background: color-mix(in srgb, var(--bad) 18%, var(--panel));
  border: 1px solid var(--bad); color: var(--bad); font-weight: 700;
  border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.unitstoggle { display: flex; gap: 8px; margin: 8px 0; }
.unitstoggle .btn { flex: 1; }
.unitstoggle .btn.on { color: var(--accent); border-color: var(--accent);
  background: var(--bg); font-weight: 700; }

/* Processing indicator (Jordan, 2026-09-04): an upload used to show
   nothing until the job appeared after a reload. */
#busy { position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, .35); display: flex; align-items: center;
  justify-content: center; }
#busy[hidden] { display: none; }
#busycard { display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--edge);
  border-radius: 10px; padding: 12px 16px; font-size: 13px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }
.spin { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--edge); border-top-color: var(--accent);
  animation: kmspin .8s linear infinite; }
@keyframes kmspin { to { transform: rotate(360deg); } }

/* Tool palettes (Jordan, 2026-09-04): a slight white glow in dark mode,
   a slight drop shadow in light. Floating panels keep their lift shadow
   and add the theme's cue. */
.panel { box-shadow: 0 0 10px rgba(255, 255, 255, .07); }
.panel.floating { box-shadow: 0 0 12px rgba(255, 255, 255, .10),
  0 12px 36px rgba(0, 0, 0, .45); }
[data-theme="light"] .panel { box-shadow: 0 2px 8px rgba(0, 0, 0, .14); }
[data-theme="light"] .panel.floating { box-shadow: 0 2px 8px rgba(0, 0, 0, .14),
  0 12px 36px rgba(0, 0, 0, .30); }
