/* PanelPlanner — brand: navy primary, birch the only accent, slate neutrals, IBM Plex Sans (docs/brand/BRAND.md).
 * Brand values come from assets/tokens.css (--pp-*); this file maps them onto the app's own tokens. */

:root {
  --font: var(--pp-font);
  --font-num: var(--pp-font);
  --r-sm: var(--pp-radius-sm);
  --r-md: var(--pp-radius);
  --r-lg: var(--pp-radius-lg);
  --topbar: 52px;
  --left: 340px;
  --right: 310px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* Light is the default: slate-50 page, white surfaces, navy text and primary, birch accent. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--pp-slate-50);
  --stage: var(--pp-slate-100);
  --surface: var(--pp-white);
  --surface-2: var(--pp-slate-25);
  --surface-3: var(--pp-slate-100);
  --line: var(--pp-slate-150);
  --line-soft: var(--pp-slate-100);
  --text: var(--pp-navy);
  --text-2: var(--pp-slate-700);
  --muted: var(--pp-slate-500);
  --accent: var(--pp-navy);              /* primary actions, selection, focus */
  --accent-hover: #2a3446;
  --accent-ink: var(--pp-white);
  --accent-text: var(--pp-navy);
  --accent-soft: rgba(230, 207, 166, .38); /* birch tint for selected rows */
  --birch: var(--pp-birch);              /* secondary buttons */
  --birch-hover: #dcc293;
  --birch-ink: var(--pp-navy);
  --birch-text: var(--pp-birch-ink);
  --danger: var(--pp-danger);
  --danger-soft: rgba(179, 38, 30, .1);
  --ok: var(--pp-success);               /* cut / done */
  --focus: var(--pp-focus);
  --ruler: var(--pp-slate-25);
  --ruler-ink: var(--pp-slate-500);
  --ruler-line: var(--pp-slate-150);
  --ply: #e8d2a9;
  --ply-grain: #cfb284;
  --ply-edge: #b9996b;
  --cut: var(--pp-danger);
  --offcut: #5c4a2c;
  --band: rgba(19, 25, 35, .78);
  --sheet-shadow: rgba(30, 32, 36, .16);
  --part-ink: #1b1d17;
  --shadow-pop: 0 6px 20px rgba(20, 22, 26, .12), 0 0 0 1px rgba(20, 22, 26, .05);
}

/* Dark: the brand defines no dark theme, so this keeps navy-slate surfaces and makes birch the
   primary color (navy buttons would vanish here). Still no blue accents. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131923;
  --stage: #0e131b;
  --surface: #182030;
  --surface-2: #1e2738;
  --surface-3: #273145;
  --line: #2d3850;
  --line-soft: #232d40;
  --text: #e3e8f1;
  --text-2: #bac4d4;
  --muted: #8592a8;
  --accent: var(--pp-birch);
  --accent-hover: #eedcbd;
  --accent-ink: var(--pp-navy);
  --accent-text: var(--pp-birch);
  --accent-soft: rgba(230, 207, 166, .14);
  --birch: transparent;                  /* secondary: birch outline on dark */
  --birch-hover: rgba(230, 207, 166, .12);
  --birch-ink: var(--pp-birch);
  --birch-text: var(--pp-birch);
  --danger: #ef6a55;
  --danger-soft: rgba(239, 106, 85, .14);
  --ok: #3fae86;
  --focus: var(--pp-birch);
  --ruler: #151c28;
  --ruler-ink: #8592a8;
  --ruler-line: #283349;
  --ply: #d9bf92;
  --ply-grain: #bd9e6c;
  --ply-edge: #9d7f55;
  --cut: #ef6a55;
  --offcut: #5c4a2c;
  --band: rgba(20, 26, 38, .8);
  --sheet-shadow: rgba(0, 0, 0, .5);
  --part-ink: #1b1d17;
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
kbd {
  font: 600 11px var(--font-num);
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text-2);
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface-3); padding: 1px 4px; border-radius: 3px; }
.muted { color: var(--muted); font-weight: 500; }
.small { font-size: 12px; }
.spacer { flex: 1; }
.ico { flex: none; display: block; }
.i { display: inline-flex; }
[hidden] { display: none !important; }

/* ── Layout ─────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: var(--left) minmax(0, 1fr) var(--right);
  grid-template-rows: var(--topbar) minmax(0, 1fr);
  grid-template-areas: "top top top" "left stage right";
  height: 100vh;
}

/* ── Top bar ────────────────────────────────────────────── */

.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; padding-right: 14px; margin-right: 4px; border-right: 1px solid var(--line); height: 30px; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.bm-tile { fill: var(--accent); }
.bm-square { stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.bm-ticks { stroke: rgba(255, 255, 255, .7); stroke-width: 1.4; stroke-linecap: round; }
:root[data-theme="dark"] .bm-square { stroke: var(--accent-ink); }
:root[data-theme="dark"] .bm-ticks { stroke: rgba(11, 20, 34, .6); }
.brand-name { font: 800 17px var(--font); letter-spacing: -.02em; white-space: nowrap; }
.brand-tld { font-weight: 500; color: var(--muted); }
.project-switch { display: flex; align-items: center; gap: 2px; min-width: 0; }
.project-name {
  border: 1px solid transparent; background: transparent;
  padding: 5px 8px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 14.5px; width: 230px; min-width: 80px;
  text-overflow: ellipsis;
}
.project-name:hover { border-color: var(--line); }
.project-name:focus { border-color: var(--accent); background: var(--surface-2); outline: none; }
.save-state { color: var(--muted); font-size: 12px; margin-left: 6px; white-space: nowrap; }
.save-state.busy { color: var(--accent-text); }
.topbar-group { display: flex; gap: 2px; margin-left: 4px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn.small { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 32px; padding: 0; }
.btn .ico { opacity: .9; }

.pro-tag {
  font: 700 10px var(--font); font-style: normal;
  padding: 1px 5px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent-text);
  letter-spacing: .02em;
}

.plan-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 4px 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; font-size: 12.5px; color: var(--muted);
}
.plan-chip b { background: var(--accent); color: var(--accent-ink); padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.plan-chip.pro { color: var(--accent-text); padding-right: 11px; }
.plan-chip:hover { border-color: var(--accent); }

.seg { display: inline-flex; padding: 2px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  padding: 0 10px; height: 26px; border-radius: 4px; font-weight: 600; font-size: 12.5px;
}
.seg button[aria-checked="true"], .seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
:root[data-theme="light"] .seg button[aria-checked="true"], :root[data-theme="light"] .seg button.on { box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg.small button { height: 24px; padding: 0 9px; font-size: 12px; }
.seg.tiny button { height: 22px; padding: 0 8px; font-size: 11.5px; }

.only-narrow { display: none; }

/* ── Side panels ────────────────────────────────────────── */

.panel {
  background: var(--surface);
  min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
}
.panel.left { grid-area: left; border-right: 1px solid var(--line); }
.panel.right { grid-area: right; border-left: 1px solid var(--line); overflow-y: auto; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }

/* Composer */
.composer {
  margin: 0 12px 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 8px;
}
.composer-row { display: flex; align-items: center; gap: 6px; }
.composer input:not([type=checkbox]) {
  height: 32px; min-width: 0;
  padding: 0 9px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 500;
}
.composer input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer .grow { flex: 1; }
.composer .qty { width: 48px; text-align: center; font-family: var(--font-num); }
.composer .dim { position: relative; flex: 1; display: flex; min-width: 0; }
.composer .dim span {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 700; color: var(--muted); pointer-events: none;
}
.composer .dim input { width: 100%; padding-left: 24px; font-family: var(--font-num); font-size: 14px; }
.composer #cLRow .dim input { padding-left: 30px; }
.composer #cLRow .dim:nth-child(n+3) span { font-size: 10px; }
.times { color: var(--muted); font-weight: 600; }
.add-btn { height: 32px; padding: 0 12px; }
.composer-opts { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.composer-target { margin-left: auto; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.hint { color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); margin: 0; }

/* Parts list */
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px 6px; font-size: 12px; color: var(--muted); font-weight: 600;
}
.list-actions { display: flex; gap: 10px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--muted); }
.link-btn.danger:hover { color: var(--danger); }

.part-list { flex: 1; min-height: 80px; overflow-y: auto; padding: 0 8px 8px; }
.list-empty { padding: 28px 16px; text-align: center; color: var(--muted); line-height: 1.6; }
.list-group {
  font-size: 12px; font-weight: 700; color: var(--text-2);
  padding: 10px 6px 4px; position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.list-group span { font-weight: 500; color: var(--muted); margin-left: 4px; }

.part-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: var(--r-sm);
  border: 1px solid transparent;
  position: relative;
}
.part-row:hover { background: var(--surface-2); }
.part-row.sel { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.part-row.bad .pr-num { background: var(--danger); color: #fff; }
.part-row input {
  height: 26px; min-width: 0; border: 1px solid transparent; background: transparent;
  border-radius: 4px; padding: 0 5px;
}
.part-row input:hover { border-color: var(--line); background: var(--surface); }
.part-row input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.pr-name { flex: 1; font-weight: 600; text-overflow: ellipsis; }
.pr-dim { width: 54px; text-align: right; font-family: var(--font-num); font-size: 13.5px; }
.pr-shape { font-family: var(--font-num); color: var(--muted); font-size: 12.5px; }
.pr-num {
  flex: none; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 4px;
  display: grid; place-items: center;
  font: 700 11px var(--font-num); color: var(--muted); background: var(--surface-3);
}
.pr-num.grain { box-shadow: inset 0 -2px 0 var(--accent); }
.pr-actions { display: flex; gap: 0; opacity: 0; transition: opacity .12s; }
.part-row:hover .pr-actions, .part-row.sel .pr-actions, .part-row:focus-within .pr-actions { opacity: 1; }
@media (hover: none) { .pr-actions { opacity: 1; } }

.mini {
  width: 26px; height: 26px; display: inline-grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 4px;
}
.mini:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.mini.danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }

.swatch {
  flex: none; width: 14px; height: 14px; border-radius: 3px; background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); position: relative; cursor: pointer; overflow: hidden;
}
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.swatch.big { width: 28px; height: 28px; border-radius: 6px; }

/* Drawers */
.drawers { border-top: 1px solid var(--line); max-height: 52%; overflow-y: auto; flex: none; }
.drawer { border-bottom: 1px solid var(--line-soft); }
.drawer summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; font-weight: 600; font-size: 13px;
}
.drawer summary::-webkit-details-marker { display: none; }
.drawer summary::after { content: ""; width: 7px; height: 7px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(-45deg); margin-left: 6px; transition: transform .15s var(--ease); }
.drawer[open] summary::after { transform: rotate(45deg); }
.drawer summary:hover { background: var(--surface-2); }
.drawer summary .i { color: var(--muted); }
.drawer-meta { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.drawer-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.drawer-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.drawer-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.mat-card { padding: 10px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 8px; }
.mat-top { display: flex; gap: 6px; align-items: center; }
.mat-name { flex: 1; height: 28px; border: 1px solid transparent; background: transparent; border-radius: 4px; padding: 0 6px; font-weight: 600; }
.mat-name:hover { border-color: var(--line); }
.mat-name:focus { outline: none; border-color: var(--accent); background: var(--surface); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.field input, .field select, .insp-sec textarea, .copies-row input {
  height: 32px; width: 100%; min-width: 0;
  padding: 0 9px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 500;
}
.field input { font-family: var(--font-num); font-size: 14px; }
.field input:disabled { opacity: .5; }
.field input:focus, .field select:focus, .insp-sec textarea:focus, .copies-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-grid { display: grid; gap: 8px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.field-grid.four input { padding: 0 6px; font-size: 13px; }
.mat-card .field input { background: var(--surface); }

/* ── Stage ──────────────────────────────────────────────── */

.stage-col { grid-area: stage; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }

.sheetbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
  min-width: 0;
}
.sheet-tabs { display: flex; gap: 6px; overflow-x: auto; min-width: 0; scrollbar-width: thin; padding-bottom: 1px; }
.sheet-tab {
  position: relative; flex: none;
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 6px 2px 10px; border-radius: var(--r-md);
  border: 1px solid transparent; cursor: pointer; color: var(--muted);
  max-width: 240px; overflow: hidden;
}
.sheet-tab:hover { background: var(--surface-2); color: var(--text-2); }
.sheet-tab.active { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.st-num {
  width: 22px; height: 22px; border-radius: 5px; flex: none;
  display: grid; place-items: center; font: 700 12px var(--font-num);
  background: var(--surface-3); color: var(--text-2);
}
.sheet-tab.active .st-num { background: var(--accent); color: var(--accent-ink); }
.st-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.2; padding-right: 4px; }
.st-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-mat { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-count {
  flex: none; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: grid; place-items: center;
  font: 600 12px var(--font-num); color: var(--text-2); background: var(--surface-3);
}
.sheet-tab:not(.active) .st-count { background: transparent; border: 1px solid var(--line); }
.st-count.bad { color: #fff; background: var(--danger); border-color: var(--danger); }
.st-yield { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.st-yield::after { content: ""; position: absolute; inset: 0; width: var(--y); background: var(--ok); opacity: .7; }
.sheet-tab.active .st-yield::after { opacity: 1; }
.st-more { border: 0; background: transparent; color: var(--muted); width: 26px; height: 28px; margin-left: -4px; border-radius: 5px; display: grid; place-items: center; opacity: 0; flex: none; }
/* Only the active (or hovered) tab spends room on its menu button. */
.sheet-tab:not(.active) .st-more { display: none; }
.sheet-tab:hover .st-more, .sheet-tab.active .st-more { display: grid; opacity: 1; }
.sheet-tab:not(.active) { padding-right: 10px; }
.sheet-tab:not(.active):hover { padding-right: 6px; }
.st-more:hover { background: var(--surface-3); color: var(--text); }
.sheetbar-spacer { flex: 1; min-width: 8px; }

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#canvas { position: absolute; inset: 0; display: block; touch-action: none; outline: none; cursor: crosshair; }

.canvas-tools {
  position: absolute; top: 34px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  max-width: calc(100% - 50px); overflow-x: auto; scrollbar-width: none;
}
.tool {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 9px; border-radius: 5px;
  border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap;
}
.tool:hover { background: var(--surface-2); color: var(--text); }
.tool.on { color: var(--text); background: var(--surface-3); }
.tool.on .ico { color: var(--accent-text); }
.tool.locked { opacity: .75; }
.tool.locked::after { content: "Pro"; font: 700 9.5px var(--font); padding: 1px 4px; border-radius: 3px; background: var(--accent-soft); color: var(--accent-text); }
.tool.icon { width: 28px; padding: 0; justify-content: center; }
.zoom-read { font-family: var(--font-num); min-width: 50px; justify-content: center; }
.tool-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

.drag-readout {
  position: absolute; pointer-events: none; z-index: 5;
  padding: 3px 7px; border-radius: 4px;
  background: var(--text); color: var(--surface);
  font: 600 12px var(--font-num); white-space: pre;
}
.empty-hint {
  position: absolute; left: 50%; top: 56%; transform: translate(-50%, -50%);
  text-align: center; color: #5b4423; max-width: 340px; pointer-events: none;
}
.empty-hint p { margin: 4px 0; }
.empty-hint .eh-title { font-weight: 700; font-size: 16px; }
.empty-hint .link-btn { pointer-events: auto; color: #6b4a00; text-decoration: underline; }

.statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; height: 32px; flex: none;
  background: var(--surface); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.stats { display: flex; align-items: center; gap: 22px; white-space: nowrap; overflow: hidden; }
.stats b { color: var(--text); font: 700 13px var(--font-num); }
.stat { display: inline-flex; align-items: baseline; gap: 6px; }
.stat b { font-size: 17px; letter-spacing: -.01em; }
.stat > span { color: var(--muted); font-size: 12.5px; }
.bad-text { color: var(--danger); font-weight: 600; }
.warn-text { color: var(--danger); }

/* ── Inspector ──────────────────────────────────────────── */

#inspector { padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.insp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.insp-title {
  flex: 1; min-width: 0; height: 34px; padding: 0 8px; margin-left: -8px;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  border: 1px solid transparent; background: transparent; border-radius: var(--r-sm);
}
.swatch.big + .insp-title { margin-left: 0; }
.insp-title:hover { border-color: var(--line); }
.insp-title:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.insp-title.static { height: auto; padding: 0; margin: 0; border: 0; }
.sheet-glyph { color: var(--muted); }
.insp-actions { display: flex; gap: 6px; }
.insp-actions .btn:not(.icon-only) { flex: 1; }
.insp-actions.wrap { flex-wrap: wrap; }
.insp-sec { padding: 14px 0 6px; border-top: 1px solid var(--line-soft); margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.insp-actions + .insp-sec { margin-top: 14px; }
.insp-sec h3 { margin: 4px 0 -2px; font-size: 13px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.insp-sec h3 .muted { font-size: 12px; font-weight: 500; }
.insp-sec p { margin: 0; }
.insp-sec textarea { height: auto; padding: 7px 9px; resize: vertical; line-height: 1.4; }

.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.switch {
  appearance: none; flex: none; width: 32px; height: 18px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line); position: relative; cursor: pointer; margin: 0;
  transition: background .15s;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .15s var(--ease), background .15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(14px); background: var(--accent-ink); }
.switch:disabled { opacity: .45; }

.band-widget { width: 100%; max-width: 240px; align-self: center; overflow: visible; }
.bw-part { opacity: .85; }
.bw-edge { cursor: pointer; }
.bw-hit { stroke: transparent; stroke-width: 18; }
.bw-line { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 3 3; transition: stroke .12s; }
.bw-edge:hover .bw-line { stroke: var(--text); }
.bw-edge.on .bw-line { stroke: var(--accent); stroke-width: 5; stroke-dasharray: none; }
.bw-edge text { fill: var(--muted); font: 700 11px var(--font-num); text-anchor: middle; dominant-baseline: middle; }
.bw-edge.on text { fill: var(--accent-text); }
.bw-edge:focus { outline: none; }
.bw-edge:focus-visible .bw-line { stroke: var(--focus); }

.copies-row { display: flex; gap: 6px; }
.copies-row input { width: 64px; text-align: center; font-family: var(--font-num); }

.multi-stack { display: flex; }
.multi-stack span { width: 22px; height: 22px; border-radius: 5px; background: var(--c); border: 2px solid var(--surface); margin-left: -8px; }
.multi-stack span:first-child { margin-left: 0; }
.color-row { display: flex; gap: 6px; flex-wrap: wrap; }
.color-dot { width: 22px; height: 22px; border-radius: 5px; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.color-dot:hover { transform: scale(1.1); }

.yield { display: flex; flex-direction: column; gap: 6px; }
.yield-num { display: flex; align-items: baseline; gap: 8px; }
.yield-num b { font: 700 30px/1 var(--font-num); letter-spacing: -.01em; }
.yield-num span { color: var(--muted); font-size: 12.5px; }
.yield-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.yield-bar span { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width .3s var(--ease); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv dd { margin: 0; text-align: right; font: 600 13.5px var(--font-num); }
.pro-link { border: 0; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); font: 700 11px var(--font); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; border-top: 1px dashed var(--line); }
.total-row b { font: 700 20px var(--font-num); }

.offcut-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.offcut-list li { display: flex; justify-content: space-between; padding: 6px 8px; border-radius: var(--r-sm); background: var(--surface-2); font-family: var(--font-num); }

.promo { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 14px; margin-top: 16px; }
.promo h3 { color: var(--accent-text); display: flex; align-items: center; gap: 6px; margin-top: 0; }
.promo ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.65; }

/* ── Menu, toasts ───────────────────────────────────────── */

.menu {
  position: fixed; z-index: 60; min-width: 220px; max-height: 70vh; overflow-y: auto;
  padding: 5px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 9px; border: 0; border-radius: 5px; background: transparent; text-align: left; font-size: 13px;
}
.menu-item:hover:not(:disabled), .menu-item:focus { background: var(--surface-2); outline: none; }
.menu-item.danger { color: var(--danger); }
.mi-icon { width: 16px; color: var(--muted); display: flex; }
.menu-item.danger .mi-icon { color: var(--danger); }
.mi-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.menu-sep { height: 1px; background: var(--line-soft); margin: 4px 2px; }
.menu-heading { padding: 6px 9px 3px; font-size: 11.5px; color: var(--muted); font-weight: 600; }

.toasts { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  padding: 9px 10px 9px 14px; border-radius: var(--r-md);
  background: var(--text); color: var(--surface); font-weight: 500; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: min(560px, 92vw);
  animation: toast-in .22s var(--ease);
}
.toast.warn { border-left: 3px solid var(--accent); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.toast-action { border: 0; background: transparent; color: var(--accent); font-weight: 700; padding: 3px 6px; border-radius: 4px; white-space: nowrap; }
:root[data-theme="light"] .toast-action { color: #9cc3f7; }
:root[data-theme="dark"] .toast-action { color: #1d4f8f; }
.toast-action:hover { background: rgba(255,255,255,.1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Modals ─────────────────────────────────────────────── */

.modal-root { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; padding: 16px; }
.modal-root.open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 10, 12, .55); backdrop-filter: blur(2px); animation: fade .15s; }
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); animation: pop .18s var(--ease);
}
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 20px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px 14px 20px; border-top: 1px solid var(--line-soft); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }

.import-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }
.drop { position: relative; }
.drop textarea {
  width: 100%; min-height: 230px; resize: vertical;
  padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.drop textarea:focus { outline: none; border-color: var(--accent); }
.drop-hint { position: absolute; right: 10px; bottom: 10px; font-size: 11.5px; color: var(--muted); pointer-events: none; }
.drop.over textarea { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.import-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 10px; }
.file-btn { cursor: pointer; }
.import-right { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line-soft); border-radius: var(--r-md); overflow: hidden; }
.preview-head { padding: 9px 12px; font-size: 13px; background: var(--surface-2); border-bottom: 1px solid var(--line-soft); }
.preview { overflow: auto; max-height: 290px; }
.preview table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.preview th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 10px; position: sticky; top: 0; background: var(--surface); }
.preview td { padding: 5px 10px; border-top: 1px solid var(--line-soft); font-family: var(--font-num); white-space: nowrap; }
.preview td:first-child { font-family: var(--font); font-weight: 600; white-space: normal; }
.errs { margin: 8px 12px; padding-left: 16px; color: var(--danger); font-size: 12px; }

.proj-list { display: flex; flex-direction: column; gap: 6px; }
.proj-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--line-soft); background: var(--surface-2); }
.proj-row.current { border-color: var(--accent); }
.proj-main { flex: 1; min-width: 0; }
.proj-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.feature-callout { padding: 12px 14px; border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.feature-callout p { margin-top: 3px; color: var(--text-2); }
.modal.upgrade { width: min(720px, 100%); }
.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.plan { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); }
.plan.pro { border-color: var(--accent); background: linear-gradient(var(--accent-soft), transparent 70%); }
.plan-name { font-weight: 700; }
.plan-price { font: 700 24px/1.2 var(--font-num); font-variant-numeric: tabular-nums slashed-zero; white-space: nowrap; }
.plan-price span { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.plan .small { line-height: 1.35; }
.compare { width: 100%; border-collapse: collapse; font-size: 13px; }
.compare th { font-weight: 600; color: var(--muted); padding: 0 4px 6px; text-align: center; }
.compare th:first-child { text-align: left; }
.compare td { padding: 7px 4px; border-top: 1px solid var(--line-soft); }
.compare td:nth-child(n+2), .compare th:nth-child(n+2) { width: 82px; text-align: center; }
button.plan { font: inherit; color: inherit; background: var(--surface); text-align: left; cursor: pointer; transition: border-color .12s, background .12s; }
button.plan:not(:disabled):hover { border-color: var(--accent); }
button.plan:disabled { cursor: default; }
button.plan:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.plan .small { margin-bottom: auto; }
.plan .small a { color: var(--text); text-decoration: underline; }
.plan-cta { margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--accent-text); }
.plan.pro .plan-cta { color: var(--text); }
.license-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); }
.license-status.on { border-color: var(--accent); background: var(--accent-soft); }
.license-status.off { border-color: var(--danger); }
.license-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.license-form .field > span { font-size: 13px; }
.license-row { display: flex; gap: 8px; }
.license-row input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-family: var(--font-num); font-size: 14px; border-radius: var(--r-sm); }
.license-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.license-err { color: var(--danger) !important; }
@media (max-width: 640px) { .plans { grid-template-columns: 1fr 1fr; } }
.compare .yes { color: var(--ok); display: inline-flex; }
.compare .no { color: var(--muted); }

.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys td { padding: 6px 4px; border-top: 1px solid var(--line-soft); }
.keys td:first-child { white-space: nowrap; width: 150px; }

.soon { display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.soon-art { width: 200px; color: var(--accent-text); }

.scrim { position: fixed; inset: var(--topbar) 0 0 0; background: rgba(0,0,0,.35); z-index: 30; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 1280px) {
  :root { --left: 316px; --right: 280px; }
  .hide-sm { display: none; }
  .project-name { width: 170px; }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: var(--left) minmax(0, 1fr); grid-template-areas: "top top" "left stage"; }
  .panel.right {
    position: fixed; top: var(--topbar); right: 0; bottom: 0; width: min(320px, 90vw); z-index: 40;
    transform: translateX(100%); transition: transform .22s var(--ease); box-shadow: var(--shadow-pop);
  }
  .app.show-right .panel.right { transform: none; }
  #toggleRightBtn { display: inline-grid; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "stage"; }
  .panel.left {
    position: fixed; top: var(--topbar); left: 0; bottom: 0; width: min(340px, 92vw); z-index: 40;
    transform: translateX(-100%); transition: transform .22s var(--ease); box-shadow: var(--shadow-pop);
  }
  .app.show-left .panel.left { transform: none; }
  #toggleLeftBtn { display: inline-grid; }
  .brand { border: 0; padding: 0; }
  .brand-name, .save-state, #importBtn, #view3dBtn, .plan-chip span { display: none; }
  .project-name { width: 120px; }
  .topbar { gap: 4px; padding: 0 8px; }
  .import-grid { grid-template-columns: 1fr; }
  .canvas-tools .tool span:not(.i) { display: none; }
  .tool.locked::after { display: none; }
  #optimizeBtn { padding: 0 9px; }
}
@media (max-width: 520px) {
  #unitsSeg, .topbar-group { display: none; }
  .stats span:nth-child(n+3) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Print ──────────────────────────────────────────────── */

.print-root { display: none; }

@media print {
  /* Margins live on the page boxes, not @page, so they hold even with the dialog set to "None". */
  @page { size: letter portrait; margin: 0; }
  html, body { height: auto; overflow: visible; background: #fff !important; color: #000 !important; }
  .app, .toasts, .menu, .modal-root, .scrim { display: none !important; }
  .print-root { display: block !important; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: #000; }

  .pr-page {
    break-after: page; position: relative; box-sizing: border-box;
    min-height: 10.95in; padding: .6in .65in .75in;
    -webkit-box-decoration-break: clone; box-decoration-break: clone;   /* repeat margins on overflow pages */
  }
  .pr-page:last-child { break-after: auto; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .pr-head h1 { margin: 0; font-size: 20px; font-weight: 700; }
  .pr-of { font-weight: 500; color: #555; font-size: 15px; }
  .pr-shop { font-size: 11px; font-weight: 700; color: #333; margin-bottom: 2px; }
  .pr-sub { font-size: 11.5px; color: #333; margin-top: 2px; }
  .pr-kpis { display: flex; gap: 16px; text-align: right; }
  .pr-kpis div { display: flex; flex-direction: column; }
  .pr-kpis b { font-size: 17px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
  .pr-kpis span { font-size: 10px; color: #555; }
  .print-root h2 { font-size: 13px; margin: 14px 0 6px; }
  .pr-diagram { border: 1px solid #bbb; padding: 6px; margin-bottom: 10px; }
  .pr-table { width: 100%; border-collapse: collapse; font-size: 11px; }
  .pr-table th, .pr-table td { border: 1px solid #555; padding: 4px 6px; text-align: left; vertical-align: top; }
  .pr-table th { background: #e8e8e8 !important; font-weight: 700; font-size: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-table .r { text-align: right; }
  .pr-table .c { text-align: center; width: 34px; }
  .pr-table tr { break-inside: avoid; }
  .pr-notes { font-size: 10px; color: #444; }
  .pr-box { display: inline-block; width: 11px; height: 11px; border: 1.5px solid #000; border-radius: 2px; }
  .pr-note { font-size: 10.5px; color: #333; margin: 8px 0 0; }
  .pr-stage { font-size: 11px; font-weight: 600; margin: 8px 0 4px; }
  .pr-cuts { columns: 2; font-size: 10.5px; margin: 0; padding-left: 22px; }
  .pr-cuts li { break-inside: avoid; margin-bottom: 2px; }
  .pr-cuts span { color: #555; }
  .pr-foot { position: absolute; bottom: .4in; right: .65in; font-size: 9.5px; color: #777; }

  .print-root.labels .lbl-page {
    break-after: page; display: grid;
    grid-template-columns: repeat(3, 2.625in); grid-auto-rows: 1in; column-gap: .125in;
    box-sizing: border-box; padding: .5in .1875in 0;   /* Avery 5160 sheet margins */
  }
  .lbl { padding: .08in .14in; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
  .lbl-name { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lbl-dim { font-size: 14px; font-weight: 700; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
  .lbl-meta { font-size: 8.5px; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media print { .print-root.labels { margin: 0; } }

.note { font-size: 12.5px; color: var(--text-2); padding: 8px 10px; border-radius: var(--r-sm); background: var(--accent-soft); border-left: 3px solid var(--accent); }

/* Cutlist drag-to-reorder */
.pr-num[data-drag] { cursor: grab; touch-action: none; }
.pr-num[data-drag]:hover { background: var(--accent); color: var(--accent-ink); }
.part-list.dragging, .part-list.dragging * { cursor: grabbing !important; user-select: none; }
.part-row.drag-src { opacity: .35; }
.drop-line { position: absolute; left: 8px; right: 8px; height: 2px; border-radius: 2px; background: var(--accent); pointer-events: none; z-index: 3; box-shadow: 0 0 0 2px var(--accent-soft); }
.drag-ghost {
  position: fixed; z-index: 90; pointer-events: none;
  padding: 5px 10px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--accent); box-shadow: var(--shadow-pop);
  font-weight: 600; font-size: 12.5px; white-space: nowrap;
}
.part-list { position: relative; }

/* ── 3D assembly view ───────────────────────────────────── */

.view-seg button { display: inline-flex; align-items: center; gap: 5px; }
.view-seg .pro-tag { margin-left: 2px; }
.asmbar, .stage3d { display: none; }
body.mode-3d .stage-col > .sheetbar:not(.asmbar), body.mode-3d #stage { display: none; }
body.mode-3d .asmbar { display: flex; }
body.mode-3d .stage3d { display: block; }

.asmbar { gap: 10px; min-height: 65px; }
.asm-glyph { color: var(--muted); display: flex; }
.asm-name {
  width: 150px; height: 32px; padding: 0 8px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; font-weight: 700; font-size: 14.5px;
}
.asm-name:hover { border-color: var(--line); }
.asm-name:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.asm-dims { display: flex; align-items: center; gap: 4px; }
.asm-dims .dim { position: relative; display: flex; }
.asm-dims .dim span { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 700; color: var(--muted); pointer-events: none; }
.asm-dims input {
  width: 84px; height: 32px; padding: 0 8px 0 24px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); font-family: var(--font-num); font-size: 14px;
}
.asm-dims input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.stage3d {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, var(--surface-2), var(--stage) 70%);
}
.three-host { position: absolute; inset: 0; }
.three-host canvas { display: block; cursor: grab; touch-action: none; }
.tip3d {
  position: absolute; z-index: 4; pointer-events: none;
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 9px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); font-size: 12.5px;
}
.tip3d span { color: var(--muted); font-family: var(--font-num); }
.status3d { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.hint3d { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 12px; color: var(--muted); pointer-events: none; white-space: nowrap; }

.view3d-tools { display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }
.explode-row { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.explode-row input[type=range] { flex: 1; accent-color: var(--accent); }
.view3d-tools .seg { display: flex; }
.view3d-tools .seg button { flex: 1; }

.role-group { gap: 4px; }
.role-row {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto 112px; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
}
.role-row:hover { background: var(--surface-2); }
.role-row.sel { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.rr-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-dims { font: 500 12px var(--font-num); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-row select { height: 28px; width: 100%; padding: 0 4px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; }
.fit { display: flex; }
.fit.ok { color: var(--ok); }
.fit.warn { color: var(--accent-text); }

@media (max-width: 820px) {
  .asm-name { width: 90px; }
  .asm-dims input { width: 64px; }
  .asmbar [data-action="asm-auto"], .hint3d, .view-seg .i { display: none; }
}
.warn-line { display: flex; gap: 6px; align-items: flex-start; } .warn-line .ico { margin-top: 2px; flex: none; }

/* Locked parts */
.pr-num.locked { position: relative; background: var(--text-2); color: var(--surface); }
.pr-lock {
  position: absolute; right: -5px; top: -5px; width: 13px; height: 13px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 0 0 1.5px var(--surface);
}
.pr-lock .ico { stroke-width: 2.6; }
.lock-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.lock-note { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; }
.lock-note .ico { flex: none; margin-top: 2px; }
.field input:disabled, .field select:disabled { opacity: .55; cursor: not-allowed; }

/* 3D: cabinets and room */
.cab-tabs { display: flex; gap: 4px; overflow-x: auto; min-width: 110px; scrollbar-width: none; flex: 0 1 auto; }
.asmbar .asm-dims, .asmbar > .btn, .asmbar > .icon-btn { flex: none; }
.cab-chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 10px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
  max-width: 180px;
}
.cab-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-chip em { font: 600 11.5px var(--font-num); font-style: normal; min-width: 20px; height: 18px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; border: 1px solid var(--line); }
.cab-chip:hover { background: var(--surface-2); color: var(--text-2); }
.cab-chip.on { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.cab-chip.on .ico { color: var(--accent-text); }
.cab-chip.on em { background: var(--surface-3); border-color: transparent; }
.asmbar .asm-dims { margin-left: 6px; }
.pos-grid { margin-top: 12px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.field-grid.three input { padding: 0 7px; }
.room-sec .switch-row b { color: var(--text); }
.wall-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hint3d kbd { font-size: 10.5px; }
@media (max-width: 1280px) { .cab-chip span { max-width: 90px; } }

/* 3D: part moving and joinery */
.tools3d { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; gap: 8px; align-items: center; }
.move-mode { display: inline-flex; align-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.18); background: var(--surface); }
.move-mode.dim { opacity: .55; }
.move-mode .mm-label { padding: 0 8px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.joint-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) 118px; align-items: center; gap: 8px; padding: 4px 0; }
.joint-row select { height: 28px; width: 100%; padding: 0 4px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; }
.jt-type { font-family: var(--font); font-weight: 600; color: var(--accent-text); }
.danger-note { background: var(--danger-soft); border-left-color: var(--danger); }
.danger-line { color: var(--danger); }
.reset-all { margin-top: 10px; font-size: 12.5px; }
.part3d-sec h3 .muted { font-weight: 500; }
.sel-sum { color: var(--text-2); padding-left: 12px; border-left: 1px solid var(--line); }
.sel-sum b { color: var(--accent-text); }
.tool.cut-nums { font: 700 14px var(--font-num); }
.tool.cut-nums.on { color: var(--accent-text); }
.tool.cut-nums.locked::after { display: none; }
@media print {
  .pr-joint { font-size: 10px; color: #222; margin-top: 2px; }
}

/* 3D: measure tool */
.tool3d-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font-weight: 600; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.tool3d-btn:hover { color: var(--text); }
.tool3d-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.measure-labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.m3d-label {
  position: absolute; transform: translate(-50%, -130%);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 3px 8px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 10px rgba(0,0,0,.3);
  font: 600 12px var(--font-num); white-space: nowrap;
}
.m3d-label b { font-size: 14px; }
.m3d-label span { font-size: 11px; opacity: .8; }
.m3d-label.preview { background: var(--surface); color: var(--text); border: 1px solid var(--accent); }
.m3d-x {
  position: absolute; top: -7px; right: -7px; width: 16px; height: 16px; border-radius: 50%;
  border: 0; padding: 0; line-height: 16px; font-size: 12px; pointer-events: auto;
  background: var(--text); color: var(--surface); opacity: 0; transition: opacity .12s;
}
.m3d-label:hover .m3d-x, .m3d-x:focus { opacity: 1; }
.measure-labels .m3d-label { pointer-events: auto; }

/* ── Help ──────────────────────────────────────────────── */

.help-fab {
  position: fixed; right: 18px; bottom: 46px; z-index: 50;
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font-weight: 700; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
.help-fab:hover, .help-fab.on { color: var(--text); border-color: var(--accent); }
.help-panel {
  position: fixed; right: 18px; bottom: 92px; z-index: 55;
  width: min(400px, calc(100vw - 32px)); height: min(560px, calc(100vh - 160px));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); animation: pop .18s var(--ease);
}
.help-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 16px; }
.help-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.help-form { padding: 0 12px 10px; border-bottom: 1px solid var(--line-soft); }
.help-form input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); font-weight: 500;
}
.help-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.help-results { flex: 1; overflow-y: auto; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.help-results > p { margin: 0; }
.help-sec { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.help-sec h4 { margin: 0 0 4px; font-size: 13.5px; }
.help-sec p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.help-sec mark { background: var(--accent-soft); color: var(--text); border-radius: 2px; padding: 0 1px; }
.help-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.help-topic { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.help-topic:hover { border-color: var(--accent); color: var(--text); }
.help-back { align-self: flex-start; font-size: 12.5px; }
@media (max-width: 820px) {
  .help-panel { right: 8px; left: 8px; width: auto; bottom: 88px; }
  .help-fab span { display: none; } .help-fab { padding: 0 11px; }
}
@media print { .help-fab, .help-panel { display: none !important; } }


/* ── PanelPlanner: simpler chrome ───────────────────────── */

body { letter-spacing: -.003em; }
.topbar { gap: 10px; padding: 0 14px; }
.project-name { font-weight: 700; }

/* Plan / 3D: the main switch, styled as navigation, not a toggle */
.view-seg { background: transparent; border: 0; gap: 2px; padding: 0; margin-left: 6px; }
.view-seg button { height: 34px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--muted); }
.view-seg button:hover { color: var(--text); background: var(--surface-2); }
.view-seg button[aria-checked="true"] { background: var(--text); color: var(--surface); box-shadow: none; }
:root[data-theme="light"] .view-seg button[aria-checked="true"] { box-shadow: none; }
.view-seg .pro-tag { margin-left: 6px; }

.btn { border-radius: var(--r-sm); font-size: 13.5px; }
.btn.primary { box-shadow: 0 1px 0 rgba(0,0,0,.08); }
#printBtn { background: var(--surface); }

/* The details panel only appears when there's something selected */
body.no-inspector .app { grid-template-columns: var(--left) minmax(0, 1fr) 0; }
body.no-inspector .panel.right { display: none; }
.panel.right .insp-head .icon-btn { margin-left: auto; }

/* Cutlist: calmer, larger rows */
.panel-head { padding: 16px 16px 10px; }
.panel-head h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.composer { margin: 0 14px 12px; padding: 12px; background: var(--surface-2); border-color: var(--line-soft); border-radius: var(--r-md); }
.composer input:not([type=checkbox]) { height: 36px; background: var(--surface); }
.add-btn { height: 36px; }
.composer-more { align-self: flex-start; font-size: 12.5px; color: var(--muted); }
.composer-more:hover { color: var(--accent-text); }
.part-row { padding: 6px 8px; border-radius: var(--r-sm); }
.part-row input { height: 30px; }
.pr-name { font-size: 14px; }
.pr-dim { font-size: 14px; }
.pr-num { border-radius: 6px; min-width: 22px; height: 22px; font-size: 11.5px; }
.part-row.sel { background: var(--accent-soft); border-color: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.list-head { padding: 6px 16px 8px; }

/* Sheet tabs: quieter until active */
.sheetbar { padding: 8px 14px; }
.sheet-tab.active { background: var(--surface); border-color: var(--line); box-shadow: 0 1px 2px rgba(23, 32, 27, .06); }
.sheet-tab.active .st-num { background: var(--accent); color: var(--accent-ink); }
.st-yield::after { background: var(--accent); }

/* Canvas toolbar: one View menu and zoom */
.canvas-tools { top: 16px; border-radius: 999px; padding: 3px 6px; box-shadow: 0 4px 14px rgba(23, 32, 27, .1); }
.tool { border-radius: 999px; }
.stage { background: var(--stage); }

/* Status bar: the numbers that matter, readable at a glance */
.statusbar { height: 44px; padding: 0 18px; }
.yield-bar span { background: var(--accent); }

/* Project settings window */
.settings-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; }
.settings-grid h3 { margin: 0 0 10px; font-size: 14px; font-weight: 800; }
.settings-col { display: flex; flex-direction: column; gap: 10px; }
.settings-col .mat-card { background: var(--surface-2); }
@media (max-width: 760px) { .settings-grid { grid-template-columns: 1fr; } }

.help-fab { bottom: 56px; }
.help-panel { bottom: 100px; }
.empty-hint { color: #3a3020; }
.empty-hint .link-btn { color: var(--accent-text); }
@media (max-width: 1100px) { body.no-inspector .app { grid-template-columns: var(--left) minmax(0, 1fr); } }
@media (max-width: 820px) {
  body.no-inspector .app { grid-template-columns: minmax(0, 1fr); }
  .brand-name { display: none; }
  .stat > span { display: none; }
  .stats { gap: 12px; }
}

/* Part rows: name on top, size underneath, so neither gets cut off */
.part-row { align-items: center; gap: 8px; }
.pr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.pr-main .pr-name { width: 100%; height: 26px; font-weight: 700; }
.pr-dims { display: flex; align-items: center; gap: 2px; color: var(--muted); }
.pr-dims .pr-dim { width: 72px; height: 24px; text-align: left; font-size: 13px; color: var(--text-2); }
.pr-dims .times { font-size: 12px; }
.list-head { align-items: center; }
#listMenuBtn { width: 28px; height: 28px; }

@media (max-width: 560px) {
  .topbar { gap: 4px; padding: 0 6px; }
  .brand, #projectsBtn, .save-state { display: none; }
  .project-name { width: 96px; min-width: 60px; padding: 5px 6px; }
  .view-seg { margin-left: 0; }
  .view-seg button { padding: 0 11px; height: 32px; }
  .view-seg .pro-tag { display: none; }
  #printBtn { width: 34px; padding: 0; }
  .icon-btn { width: 30px; }
  .sheetbar { padding: 6px 8px; gap: 6px; }
  #optimizeBtn { padding: 0 10px; }
  .hide-xs { display: none; }
}

/* ── PanelPlanner: richer, structured chrome ───────────── */

/* Top bar: project | Plan/3D | actions */
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 16px; padding: 0 14px; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-right { justify-content: flex-end; gap: 8px; }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; }
.crumb { border: 0; background: none; padding: 5px 6px; border-radius: var(--r-sm); color: var(--muted); font-weight: 600; font-size: 14px; }
.crumb:hover { color: var(--text); background: var(--surface-2); }
.crumb-sep { color: var(--line); font-size: 18px; font-weight: 300; margin: 0 1px; }
.crumbs .project-name { width: 240px; font-size: 14.5px; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-left: 4px; }
.save-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .75; }
.save-state.busy::before { background: #c08a12; }
.btn-group { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.btn-group .icon-btn { border-radius: 0; width: 34px; height: 32px; }
.btn-group .icon-btn + .icon-btn { border-left: 1px solid var(--line); }

.view-seg { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; margin: 0; }
.view-seg button { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 16px; border-radius: 999px; }
.view-seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(23, 32, 27, .14), 0 0 0 1px var(--line); }
.view-seg button[aria-checked="true"] .ico { color: var(--accent-text); }

/* Cutlist header and add-part card */
.panel-head { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 16px 12px; }
.head-meta { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.composer { gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(23, 32, 27, .05); }
.cgrid { display: flex; align-items: flex-end; gap: 8px; }
.cgrid.four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cfield { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.cfield.qty { flex: 0 0 64px; }
.cfield > span { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.cfield input { width: 100%; }
.cgrid .times { padding-bottom: 9px; color: var(--muted); }
.composer input:not([type=checkbox]) { background: var(--surface-2); border-color: var(--line-soft); font-size: 14px; }
.composer input:focus { background: var(--surface); }
.composer-foot { display: flex; align-items: center; gap: 8px; padding-top: 2px; }
.composer-foot .composer-target { margin-left: auto; max-width: 110px; font-size: 12px; }
.composer-foot .add-btn { padding: 0 14px; }
.composer-more { font-size: 12.5px; color: var(--muted); }
.composer-opts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px; border-radius: var(--r-sm); background: var(--surface-2); }

/* Tabs above the list */
.list-head { padding: 4px 12px 0 16px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.tabs { display: flex; gap: 18px; }
.tabs button { position: relative; border: 0; background: none; padding: 10px 0 11px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.tabs button em { font-style: normal; font-weight: 600; font-size: 11.5px; margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }

/* Part rows with to-scale thumbnails */
.part-list { padding: 2px 8px 12px; }
.part-row { gap: 10px; padding: 6px 8px; }
.pr-thumb { flex: none; display: grid; place-items: center; width: 46px; height: 36px; border-radius: 8px; background: color-mix(in srgb, var(--ply) 40%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ply-edge) 30%, transparent); cursor: grab; touch-action: none; }
.pr-thumb text { font: 700 10px var(--font); fill: var(--part-ink); }
.pr-thumb:hover { border-color: var(--accent); }
.part-row.bad .pr-thumb { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.pr-flags { display: inline-flex; gap: 4px; margin-left: 6px; color: var(--muted); }
.pr-flags i { display: inline-flex; }
.list-group { padding: 12px 8px 6px; font-size: 12px; }

/* Sheet tabs with layout miniatures */
.sheet-tab { height: 52px; padding: 0 8px 0 6px; gap: 10px; }
.st-mini { position: relative; flex: none; display: grid; place-items: center; width: 62px; height: 40px; border-radius: 7px; background: var(--surface-2); }
.st-mini svg { display: block; }
.st-mini b { position: absolute; left: -4px; top: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; display: grid; place-items: center; font: 700 10.5px var(--font); background: var(--surface-3); color: var(--text-2); box-shadow: 0 0 0 2px var(--surface); }
.sheet-tab.active .st-mini b { background: var(--accent); color: var(--accent-ink); }
.st-mini.bad { box-shadow: inset 0 0 0 1.5px var(--danger); }
.mini-ply { fill: var(--ply); stroke: var(--ply-edge); stroke-width: .6; }
.st-mat em { font-style: normal; color: var(--danger); font-weight: 600; }
.sheet-tab:not(.active) { padding-right: 12px; }

/* Canvas dock */
.canvas-dock {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(23, 32, 27, .12);
}
.dock-btn {
  position: relative; display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 6px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; font-size: 13px;
}
.dock-btn:hover { background: var(--surface-2); color: var(--text); }
.dock-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.dock-btn.locked { opacity: .5; }
.dock-num { font-size: 15px; }
.dock-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.zoom-read { min-width: 54px; font-variant-numeric: tabular-nums slashed-zero; color: var(--text-2); }
.dock-btn[data-tip]:hover::after, .dock-btn[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--surface);
  font: 600 11.5px var(--font); white-space: nowrap; pointer-events: none;
}
.empty-hint { top: 48%; }

/* Color grid */
.color-pop { position: fixed; z-index: 70; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); }
.cg-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.cg-grid { display: flex; flex-direction: column; gap: 4px; }
.cg-row { display: flex; gap: 4px; }
.cg-sw { width: 24px; height: 24px; border-radius: 6px; border: 0; padding: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .08s; }
.cg-sw:hover { transform: scale(1.15); }
.cg-sw.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.cg-sw:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.swatch.big { border: 0; padding: 0; cursor: pointer; }
button.swatch.big:hover { box-shadow: inset 0 0 0 1px rgba(0,0,0,.2), 0 0 0 3px var(--accent-soft); }
.color-btn { justify-content: flex-start; gap: 8px; }
.color-btn .swatch { width: 16px; height: 16px; }

@media (max-width: 1280px) { .crumbs .project-name { width: 170px; } }
@media (max-width: 1100px) { .brand-name { display: none; } .brand { padding-right: 6px; } }
@media (max-width: 820px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
  .crumb, .crumb-sep, .save-state { display: none; }
  .view-seg button { padding: 0 11px; }
  .canvas-dock { bottom: 10px; }
}
@media (max-width: 560px) {
  .view-seg .ico { display: none; }
  .crumbs .project-name { width: 96px; }
  .dock-sep, .dock-btn[data-toggle="showOffcuts"] { display: none; }
}

.pr-dims .pr-dim { width: auto; min-width: 3ch; padding: 0 3px; }
.pr-dims .pr-dim:focus { min-width: 9ch; }

.composer-foot .composer-more { white-space: nowrap; }
@media (max-width: 560px) {
  .btn-group { display: none; }
  .help-fab { bottom: 70px; right: 10px; }
}

/* ── PanelPlanner: plain tool chrome ───────────────────── */
/* Square-ish corners, real borders, toolbars attached to edges, no floating pills or soft glows. */

body { font-size: 13px; letter-spacing: 0; font-weight: 400; }
.muted { font-weight: 400; }
.btn, .seg button, .tabs button, .crumb, .tool, .menu-item { font-weight: 500; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.panel-head h2 { font-size: 15px; font-weight: 700; letter-spacing: 0; }
.insp-title { font-size: 15px; font-weight: 600; letter-spacing: 0; }
.modal-head h2 { font-size: 16px; letter-spacing: 0; }
.project-name, .crumbs .project-name { font-weight: 600; font-size: 13.5px; }
.crumb { font-size: 13px; }
.btn { font-size: 13px; height: 30px; }
.btn.primary { box-shadow: none; }

/* Top bar: Plan/3D as a plain segmented control */
.view-seg { border-radius: var(--r-sm); padding: 2px; background: var(--surface-2); }
.view-seg button { height: 26px; padding: 0 14px; border-radius: 4px; font-size: 13px; font-weight: 500; }
.view-seg button[aria-checked="true"] { box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.view-seg button[aria-checked="true"] .ico { color: inherit; }
.save-state::before { width: 6px; height: 6px; }

/* Cutlist */
.panel-head { padding: 14px 14px 10px; }
.head-meta { font-weight: 400; font-size: 12px; font-variant-numeric: tabular-nums slashed-zero; }
.composer { margin: 0 14px 12px; padding: 12px; border-radius: var(--r-md); box-shadow: none; background: var(--surface-2); border-color: var(--line-soft); }
.composer input:not([type=checkbox]) { height: 32px; background: var(--surface); border-color: var(--line); font-size: 13.5px; }
.cfield > span { font-weight: 500; font-size: 11.5px; letter-spacing: 0; }
.add-btn { height: 32px; }
.tabs button { font-weight: 500; font-size: 13px; }
.tabs button.on { font-weight: 600; }
.tabs button em { border-radius: 4px; font-weight: 500; padding: 0 5px; background: transparent; color: var(--muted); }
.tabs button.on::after { border-radius: 0; }
.pr-main .pr-name { font-weight: 600; font-size: 13.5px; }
.pr-thumb { border-radius: 4px; }
.part-row { border-radius: var(--r-sm); }
.part-row.sel { box-shadow: none; border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* Cut progress */
.cut-progress { height: 3px; margin: -4px 14px 10px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.cut-progress span { display: block; height: 100%; background: var(--accent); transition: width .25s var(--ease); }

/* Cut checkbox on each part row */
.pr-cut {
  flex: none; width: 18px; height: 18px; padding: 0; margin-right: -2px;
  display: grid; place-items: center;
  border: 1.5px solid color-mix(in srgb, var(--muted) 70%, transparent); border-radius: 4px;
  background: var(--surface); color: transparent;
}
.pr-cut:hover { border-color: var(--accent); color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pr-cut[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pr-cut .ico { stroke-width: 3; }
.part-row.cut .pr-thumb, .part-row.cut .pr-dims { opacity: .45; }
.part-row.cut .pr-name { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.part-row.cut .pr-name:focus { text-decoration: none; color: var(--text); }
.cut-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cut-btn.on:hover:not(:disabled) { background: var(--accent-hover); }

/* Sheet tabs: flat, with a bottom rule for the active one */
.sheetbar { padding: 6px 12px; }
.sheet-tab { height: 48px; border-radius: var(--r-sm); }
.sheet-tab.active { box-shadow: none; background: var(--surface-2); }
.st-name { font-weight: 600; font-size: 13px; }
.st-mat { display: flex; gap: 8px; font-variant-numeric: tabular-nums slashed-zero; }
.st-mat > span { color: var(--muted); }
.st-mini { border-radius: 3px; }
.st-mini b { border-radius: 3px; font-family: var(--font); font-weight: 600; }

/* Canvas toolbar: a flat strip pinned to the bottom-left, not a floating pill */
.canvas-dock {
  left: 12px; bottom: 12px; transform: none;
  padding: 2px; gap: 0; border-radius: var(--r-sm); box-shadow: none;
}
.dock-btn { min-width: 30px; height: 30px; border-radius: 4px; font-weight: 600; }
.dock-btn.on { background: var(--surface-3); color: var(--text); }
.dock-btn[data-tip]:hover::after, .dock-btn[data-tip]:focus-visible::after { border-radius: 4px; font-weight: 500; }
.dock-sep { margin: 0 3px; }

/* Status bar: ordinary text, numbers aligned */
.statusbar { height: 34px; padding: 0 14px; }
.stats { gap: 18px; font-variant-numeric: tabular-nums slashed-zero; }
.stat b { font-size: 13px; font-weight: 600; letter-spacing: 0; }
.stat > span { font-size: 12px; }

/* Menus, popovers, modals: tighter, flatter */
.menu { padding: 4px; border-radius: var(--r-md); }
.menu-item { padding: 6px 8px; border-radius: 4px; }
.modal { border-radius: var(--r-lg); }
.toast { border-radius: var(--r-sm); box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.color-pop { border-radius: var(--r-md); }
.cg-sw { border-radius: 3px; width: 22px; height: 22px; }
.cg-sw:hover { transform: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--muted); }
.cg-title { font-weight: 500; }

/* Help: lives in the top bar now; the panel drops down from it */
.help-panel { top: calc(var(--topbar) + 6px); bottom: auto; right: 12px; border-radius: var(--r-md); animation: none; }
#helpFab.on { background: var(--surface-3); color: var(--text); }
.help-sec { border-radius: var(--r-sm); }
.help-topic { border-radius: 4px; font-weight: 500; }
.help-form input { border-radius: var(--r-sm); height: 34px; }

/* 3D overlays: flat */
.move-mode, .tool3d-btn { box-shadow: none; }
.stage3d { background: var(--stage); }
.cab-chip { border-radius: var(--r-sm); }
.cab-chip em { border-radius: 4px; }
.m3d-label { border-radius: 4px; box-shadow: none; }

@media (max-width: 820px) {
  .help-panel { top: calc(var(--topbar) + 6px); bottom: auto; left: 8px; right: 8px; }
}
@media (max-width: 560px) {
  #helpFab { display: none; }
}
@media print { .pr-box.on::after { content: "✓"; display: block; font-size: 11px; line-height: 10px; text-align: center; font-weight: 700; } }
:root[data-theme="dark"] .pr-thumb { background: var(--surface-3); border-color: var(--line); }
:root[data-theme="dark"] .pr-thumb text { fill: var(--text); }
/* Flags (grain, banding, lock) sit in a fixed column at the row's right edge, whatever the name or size. */
.pr-dims .pr-flags { margin-left: auto; padding-left: 8px; justify-content: flex-end; }
/* Draggable canvas toolbar */
.canvas-dock { user-select: none; -webkit-user-select: none; }
.canvas-dock.moved { bottom: auto; }
.canvas-dock.dragging { cursor: grabbing; box-shadow: var(--shadow-pop); }
.dock-grip { display: grid; place-items: center; width: 16px; height: 30px; color: var(--muted); cursor: grab; touch-action: none; }
.dock-grip:hover { color: var(--text); }
.canvas-dock.dragging .dock-grip { cursor: grabbing; }
#toggleRightBtn[aria-pressed="true"] { color: var(--text); }
@media (min-width: 1101px) { #toggleRightBtn[aria-pressed="true"] { background: var(--surface-2); } }

/* ── Cut mode: sheet + checklist, for the shop floor ───── */

.cut-panel { display: none; }
body.mode-cut .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "stage"; }
body.mode-cut .panel.left, body.mode-cut .panel.right, body.mode-cut .scrim { display: none !important; }
body.mode-cut #toggleLeftBtn, body.mode-cut #toggleRightBtn,
body.mode-cut #addSheetBtn, body.mode-cut #optimizeSplit, body.mode-cut .st-more,
body.mode-cut .statusbar, body.mode-cut .dock-grip, body.mode-cut .dock-sep,
body.mode-cut .canvas-dock [data-toggle] { display: none !important; }
body.mode-cut .stage-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "bar bar" "canvas list";
}
body.mode-cut .stage-col > .sheetbar:not(.asmbar) { grid-area: bar; }
body.mode-cut #stage { grid-area: canvas; }
body.mode-cut .cut-panel {
  grid-area: list; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto;
}
body.mode-cut .canvas-dock { left: 12px; bottom: 12px; top: auto !important; }

.cp-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 16px 16px 10px; }
.cp-title { min-width: 0; }
.cp-title h2 { margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-title span { font-size: 12.5px; color: var(--muted); }
.cp-count { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums slashed-zero; }
.cp-count b { font-size: 22px; color: var(--text); font-weight: 700; }
.cp-bar { height: 6px; margin: 0 16px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.cp-bar span { display: block; height: 100%; background: var(--accent); transition: width .25s var(--ease); }
.cp-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 16px 10px; font-size: 12px; color: var(--muted); }
.cp-list { display: flex; flex-direction: column; padding: 0 8px 12px; }
.cp-empty { color: var(--muted); padding: 20px 8px; margin: 0; }
.cp-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px;
  padding: 8px 10px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent;
  text-align: left; border-radius: 0; -webkit-tap-highlight-color: transparent;
}
.cp-row:hover { background: var(--surface-2); }
.cp-box {
  flex: none; width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
  border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent); color: transparent; background: var(--surface);
}
.cp-box .ico { stroke-width: 3; }
.cp-row.done .cp-box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cp-num {
  flex: none; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 5px; display: grid; place-items: center;
  font-weight: 700; font-size: 12.5px; color: var(--text);
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); box-shadow: inset 0 0 0 1.5px var(--c);
}
.cp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cp-main b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-dims { font-size: 17px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums slashed-zero; }
.cp-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cp-row.done .cp-main, .cp-row.done .cp-num, .cp-row.done .cp-meta { opacity: .45; }
.cp-row.done .cp-main b { text-decoration: line-through; }
.cp-row.flash { background: var(--accent-soft); }
.cp-done { margin: 4px 16px 20px; padding: 14px; border-radius: var(--r-md); background: var(--accent-soft); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.cp-done p { margin: 0; }

@media (max-width: 820px) {
  body.mode-cut .stage-col {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 0.85fr) minmax(0, 1.15fr);
    grid-template-areas: "bar" "canvas" "list";
  }
  body.mode-cut .cut-panel { border-left: 0; border-top: 1px solid var(--line); }
  .cp-head { padding: 12px 14px 8px; }
  .cp-bar { margin: 0 14px; }
  .cp-sub { padding: 6px 14px 6px; }
}
@media (max-width: 820px) {
  body.mode-cut .stage-col { grid-template-rows: auto minmax(0, 0.62fr) minmax(0, 1.38fr); }
  body.mode-cut .canvas-dock { display: none; }
}

/* Row dimensions: numbers, ×, and flag icons share one optical line */
.pr-dims .pr-dim { padding: 0 4px; }
.pr-dims .pr-dim:focus { min-width: 7ch; }
.pr-dims .times { margin: 0 1px; transform: translateY(-1px); }
.pr-dims .pr-flags { align-self: center; transform: translateY(-1px); }

/* Plan / Cut / 3D: the active view is a filled primary segment */
.view-seg button[aria-checked="true"],
:root[data-theme="light"] .view-seg button[aria-checked="true"] {
  background: var(--accent); color: var(--accent-ink, #fff); box-shadow: none;
}
.view-seg button[aria-checked="true"]:hover { background: var(--accent-hover, var(--accent)); color: var(--accent-ink, #fff); }
.view-seg button[aria-checked="true"] .ico { color: inherit; }
@supports (field-sizing: content) {
  .pr-dims .pr-dim { field-sizing: content; width: auto !important; min-width: 2ch; }
}

/* Grain/banding/lock flags sit on the same line as the row's action buttons */
.part-row > .pr-flags {
  flex: none; margin: 0; min-width: 52px; height: 28px; transform: none;
  display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px;
}
.part-row.cut > .pr-flags { opacity: .45; }

/* Size fields never shrink below their number in narrow panels */
.pr-dims .pr-dim { flex: none; }

/* Cutlist can be hidden on wide screens (top-left toggle), remembered */
@media (min-width: 821px) {
  body.no-cutlist { --left: 0px; }
  body.no-cutlist .panel.left { display: none; }
}
#toggleLeftBtn[aria-pressed="true"] { color: var(--text); }
@media (min-width: 821px) { #toggleLeftBtn[aria-pressed="true"] { background: var(--surface-2); } }

/* The cut checkbox means nothing while building in 3D */
body.mode-3d .pr-cut { display: none; }

/* 3D: home button and the axis a part is sliding along */
.tool3d-btn.icon-only { padding: 0; width: 32px; justify-content: center; }
.tip3d span { display: block; }

/* 3D details: the selected part comes first, then its cabinet */
.part3d-sec { gap: 8px; }
.part3d-head { display: flex; align-items: center; gap: 8px; }
.part3d-head .swatch { width: 14px; height: 14px; flex: none; }
.part3d-head .insp-title { flex: 1; min-width: 0; margin: 0; }
.part3d-sub { margin: -4px 0 2px; }
.part3d-sec h4, .cab-pos-h { margin: 6px 0 -2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.insp-divider { height: 1px; background: var(--line); margin: 16px 0 14px; }

/* Cabinet bar: room for fractions like 54 1/16 */
.asm-dims-label { font-size: 12px; color: var(--muted); margin-right: 4px; white-space: nowrap; }
.asm-dims input { width: 104px; }
@media (max-width: 1280px) { .asm-dims-label { display: none; } }
.part3d-sec:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
@media (max-width: 820px) { .asm-dims input { width: 80px; } }


/* ── Brand base (docs/brand/BRAND.md) ─────────────────────── */
body { font-family: var(--font); background: var(--bg); color: var(--text); }
:focus-visible { outline-color: var(--focus); }

/* Logo: light mark on light, dark mark on dark. Lockup: mark = 1.5 × cap height, gap = 0.42em. */
.brand { gap: calc(16px * .42); }
.brand-mark { width: auto; height: calc(16px * .698 * 1.5); }
.brand-mark.mark-dark { display: none; }
:root[data-theme="dark"] .brand-mark.mark-light { display: none; }
:root[data-theme="dark"] .brand-mark.mark-dark { display: block; }
.brand-name { font-family: var(--pp-font); font-weight: 700; font-size: 16px; letter-spacing: var(--pp-tracking-tight); color: var(--text); }

/* Buttons: primary navy (birch in dark), secondary birch with navy text. Radius 8. */
.btn, .tool3d-btn, input, select, textarea { border-radius: var(--pp-radius); }
.btn { font-weight: 600; background: var(--birch); color: var(--birch-ink); border-color: var(--birch); }
.btn:hover:not(:disabled) { background: var(--birch-hover); border-color: var(--birch-hover); }
:root[data-theme="dark"] .btn:not(.primary):not(.ghost) { border-color: rgba(230, 207, 166, .45); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn.danger { background: var(--surface); color: var(--text-2); border-color: var(--line); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.link-btn, .empty-hint .link-btn { color: var(--birch-text); }

/* Selected rows: birch tint with a navy edge */
.part-row.sel { border-color: color-mix(in srgb, var(--birch-text) 45%, transparent); }

/* Cut / done uses the success color */
.pr-cut[aria-checked="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.pr-cut:hover { border-color: var(--ok); color: color-mix(in srgb, var(--ok) 45%, transparent); }
.cut-progress span { background: var(--ok); }

/* Numbers: aligned figures and a slashed zero in every size, quantity and table */
input, select, table, .pr-dims, .rr-dims, .kv, .head-meta, .zoom-read, .statusbar, .tab-meta,
.tip3d, .measure-labels, .cp-dims, .cp-head, .cut-panel, .print-doc, .pp-num {
  font-variant-numeric: tabular-nums slashed-zero;
}
.cut-btn.on, .cp-row.done .cp-box { background: var(--ok); border-color: var(--ok); color: #fff; }
.cut-btn.on:hover:not(:disabled) { background: color-mix(in srgb, var(--ok) 85%, #000); }
.cp-bar span { background: var(--ok); }

/* 3D: back from a part to its cabinet */
.back-link {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 8px 0 4px; margin: -4px 0 2px -4px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.back-link:hover { background: var(--surface-2); color: var(--text); }
.insp-title-static { font-size: 15px; font-weight: 600; }

/* Optimize: main button plus a caret that picks the method */
.split-btn { display: inline-flex; flex: none; }
.split-btn > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-btn > .split-caret { width: 30px; padding: 0; justify-content: center; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid color-mix(in srgb, var(--accent-ink) 25%, transparent); }
.mi-label { display: flex; flex-direction: column; }
.mi-note { font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.35; margin-top: 2px; max-width: 250px; white-space: normal; }
.menu-item:has(.mi-note) { align-items: flex-start; height: auto; padding-top: 7px; padding-bottom: 7px; }
.mi-stats { font-size: 12px; font-weight: 600; color: var(--birch-text); margin-top: 3px; font-variant-numeric: tabular-nums slashed-zero; }
.menu-item:has(.mi-stats) { align-items: flex-start; height: auto; padding-top: 7px; padding-bottom: 7px; }

/* ── Accounts (account.js) ─────────────────────────────────── */
.code-input { font-family: var(--font-num); font-size: 24px; letter-spacing: .35em; text-align: center; height: 48px; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; }
.acct-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.acct-row > span:first-child { color: var(--muted); font-weight: 600; }
.acct-row > span:last-child { text-align: right; }
