/* ==========================================================
   WORKBENCH APP SHELL
   workbench.html is an app, not a document: one viewport, the
   staged model at the centre, a tool rail down one side and a
   parameter drawer that opens only when you want it.

   This file owns the shell and re-skins the shared .wb-*
   controls from workbench.css inside .wbapp. workbench.css is
   also loaded by index.html, so nothing here may leak out of
   the .wbapp scope.
   ========================================================== */
.wbapp {
  /* Set by JS from the selected model's authored color. */
  --acc: #38bdf8;
  --acc-soft: color-mix(in srgb, var(--acc) 16%, transparent);
  --acc-line: color-mix(in srgb, var(--acc) 34%, transparent);

  --bg: #0a0d13;
  --bg-lift: #121722;
  --glass: rgba(20, 26, 37, 0.72);
  --glass-hi: rgba(38, 48, 66, 0.6);
  --line: rgba(148, 172, 205, 0.14);
  --line-hi: rgba(148, 172, 205, 0.26);
  --ink: #eef4fb;
  --ink-dim: #9dabc0;
  --ink-mute: #8795aa;
  --warn: #fbbf24;
  --bad: #fb7185;

  --r-lg: 20px;
  --r-md: 13px;
  --r-sm: 9px;

  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: var(--font-ui);
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  /* workbench.css components read these names. */
  --font-product-serif: var(--font-display);
  --wb-font-mono: var(--font-mono);

  --bar: 54px;
  --rail: 92px;
  --dock: 68px;
  --drawer: 430px;

  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.wbapp * { box-sizing: border-box; }
.wbapp ::selection { background: var(--acc); color: #06121c; }

/* A single wash of the model's color behind everything ties the chrome
   to whatever is on the stage. */
.wbapp::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 55% at 22% 0%, color-mix(in srgb, var(--acc) 13%, transparent), transparent 68%),
    radial-gradient(60% 50% at 100% 100%, rgba(120, 88, 255, 0.1), transparent 70%);
  transition: background .5s ease;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: var(--bar) minmax(0, 1fr);
  height: 100dvh;
}

/* ---------- top bar ---------- */
.app__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 13, 19, 0.7);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.app__back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 9px;
  border-radius: 100px;
  color: var(--ink-dim);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .18s ease, color .18s ease;
}
.app__back:hover { background: var(--glass-hi); color: var(--ink); }
.app__brand {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.app__brand span { color: var(--acc); }

/* Segmented view switch — the whole page is either the tools or the maths. */
.seg {
  display: flex;
  gap: 2px;
  margin: 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(8, 11, 17, 0.6);
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 18px;
  border: 0;
  border-radius: 100px;
  background: transparent;
  color: var(--ink-dim);
  font: 500 0.8rem/1 var(--font-ui);
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.seg button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected='true'] {
  background: var(--acc);
  color: #06121c;
  font-weight: 600;
  box-shadow: 0 3px 14px -4px var(--acc);
}
.app__links { display: flex; align-items: center; gap: 4px; }
.app__links a {
  padding: 7px 12px;
  border-radius: 100px;
  color: var(--ink-dim);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .18s ease, color .18s ease;
}
.app__links a:hover { background: var(--glass-hi); color: var(--ink); }

/* ---------- body / views ---------- */
.app__body { position: relative; min-height: 0; }
.view { position: absolute; inset: 0; }
.view[hidden] { display: none; }

.view--tools {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) 0;
  transition: grid-template-columns .34s cubic-bezier(.32, .72, 0, 1);
}
.wbapp.is-drawer-open .view--tools { grid-template-columns: var(--rail) minmax(0, 1fr) var(--drawer); }

/* ---------- tool rail ---------- */
.rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: rgba(9, 12, 18, 0.5);
  scrollbar-width: thin;
}
.rail__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 172, 205, 0.09);
}
.rail__group:first-child {
  padding-top: 0;
  border-top: 0;
}
.rail__label {
  padding: 0 3px 2px;
  color: var(--ink-mute);
  font: 600 0.5rem/1.2 var(--font-ui);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}
.rail button {
  --tool-color: var(--acc);
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 11px 5px 9px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-mute);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.rail button svg {
  width: 23px; height: 23px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rail button strong {
  font: 600 0.7rem/1.3 var(--font-ui);
  letter-spacing: 0;
  text-align: center;
  overflow-wrap: anywhere;
}
.rail button small { display: none; }
.rail button:hover {
  background: var(--glass-hi);
  color: var(--ink);
}
.rail button[aria-selected='true'] {
  border-color: color-mix(in srgb, var(--tool-color) 45%, transparent);
  background: color-mix(in srgb, var(--tool-color) 15%, transparent);
  color: color-mix(in srgb, var(--tool-color) 82%, white);
}
.rail button[aria-selected='true']::before {
  content: '';
  position: absolute;
  left: -8px; top: 50%;
  width: 3px; height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--tool-color);
  box-shadow: 0 0 12px var(--tool-color);
  transform: translateY(-50%);
}
.rail button:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ---------- stage ---------- */
.stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
}
.stage__view { position: relative; min-height: 0; overflow: hidden; }
#wb-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#wb-canvas:active { cursor: grabbing; }

/* Overlays float over the render; none of them may eat a drag. */
.stage__view > *:not(canvas) { position: absolute; pointer-events: none; }
.stage__view button,
.stage__view .hud { pointer-events: auto; }

/* measured readout, top-left */
.hud {
  top: 14px; left: 14px;
  display: grid;
  gap: 1px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(8, 11, 17, 0.55);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}
.hud__row { display: flex; align-items: baseline; gap: 12px; }
.hud__row span {
  min-width: 62px;
  color: var(--ink-mute);
  font: 500 0.68rem/1.55 var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
}
.hud__row b {
  color: var(--ink);
  font: 500 0.72rem/1.6 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.hud__row.is-lead b { color: var(--acc); }

/* where this thing goes, top-centre */
.placard {
  top: 16px; left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--acc-line);
  border-radius: 100px;
  background: rgba(8, 11, 17, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink-dim);
  font: 500 0.68rem/1 var(--font-ui);
  white-space: nowrap;
}
.placard i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 9px var(--acc);
}

/* view controls, top-right */
.tools3d {
  top: 14px; right: 14px;
  display: flex;
  gap: 6px;
}
.tools3d__group {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(8, 11, 17, 0.55);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}
.icobtn {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 100px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.icobtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icobtn:hover { background: var(--glass-hi); color: var(--ink); }
.icobtn[aria-pressed='true'],
.icobtn.is-on { background: var(--acc); color: #06121c; }
.icobtn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.icobtn--text {
  width: auto;
  padding: 0 13px;
  font: 600 0.72rem/1 var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
}

/* hint, bottom-left */
.hint {
  bottom: 14px; left: 16px;
  color: var(--ink-mute);
  font: 500 0.68rem/1.3 var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
}

/* problems, bottom-centre */
.flag {
  bottom: 14px; left: 50%;
  max-width: min(560px, 70%);
  padding: 10px 16px;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  border-radius: var(--r-md);
  background: rgba(28, 12, 18, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #ffd9df;
  font-size: 0.76rem;
  line-height: 1.5;
  text-align: center;
}
.flag[hidden] { display: none; }
.flag.is-note {
  border-color: var(--line-hi);
  background: rgba(12, 16, 24, 0.82);
  color: var(--ink-dim);
}

/* ---------- dock ---------- */
.dock {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--dock);
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: rgba(10, 13, 19, 0.72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.dock__id { display: grid; gap: 3px; min-width: 0; }
.dock__id h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-mute);
  font: 500 0.68rem/1.2 var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
}
.dock__meta i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 8px var(--acc);
}
.dock__meta.is-custom i { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.wbapp.is-busy .dock__meta i { animation: wb-pulse .7s ease-in-out infinite; }
@keyframes wb-pulse { 50% { opacity: .2; } }
.dock__spacer { flex: 1 1 auto; }
.dock__actions { display: flex; align-items: center; gap: 8px; flex: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 100px;
  background: var(--acc);
  color: #06121c;
  font: 600 0.78rem/1 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -8px var(--acc); }
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn--ghost {
  border-color: var(--line-hi);
  background: transparent;
  color: var(--ink);
}
.btn--ghost:hover { background: var(--glass-hi); box-shadow: none; }
.btn:disabled { opacity: 0.32; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; }

/* ---------- parameter drawer ---------- */
.drawer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: var(--drawer);
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
}
.wbapp:not(.is-drawer-open) .drawer { visibility: hidden; }
.drawer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer__head h2 {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.drawer__body {
  padding: 4px 16px 28px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.drawer__section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.drawer__section:last-child { border-bottom: 0; }
.drawer__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
  color: var(--ink-mute);
  font: 600 0.72rem/1.25 var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
}
.drawer__label output { color: var(--acc); letter-spacing: 0.05em; }
.drawer__note { margin: 9px 0 0; color: var(--ink-dim); font-size: 0.78rem; line-height: 1.55; }
.drawer__owner {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--acc);
  font-size: 0.72rem;
  text-decoration: none;
}
.drawer__owner svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.drawer-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-dim);
  font: 600 0.72rem/1.25 var(--font-ui);
  cursor: pointer;
  list-style: none;
}
.drawer-details summary::-webkit-details-marker { display: none; }
.drawer-details summary svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s ease;
}
.drawer-details[open] summary { color: var(--ink); }
.drawer-details[open] summary svg { transform: rotate(180deg); }
.drawer__owner:hover { text-decoration: underline; }

/* floating open tab, when the drawer is shut */
.drawer-tab {
  position: absolute;
  top: 50%;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 12px 13px 15px;
  transform: translateY(-50%);
  border: 1px solid var(--acc-line);
  border-right: 0;
  border-radius: var(--r-md) 0 0 var(--r-md);
  background: rgba(14, 18, 27, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--ink);
  font: 600 0.7rem/1 var(--font-ui);
  cursor: pointer;
  writing-mode: vertical-rl;
  transition: background .2s ease, padding .2s ease;
}
.drawer-tab:hover { background: color-mix(in srgb, var(--acc) 22%, rgba(14, 18, 27, 0.78)); padding-right: 16px; }
.wbapp.is-drawer-open .drawer-tab { display: none; }
.drawer-tab svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shared workbench.css controls, re-skinned ---------- */
.wb-system-card {
  display: grid;
  gap: 5px;
  margin-bottom: 17px;
  padding: 13px 14px;
  border: 1px solid var(--acc-line);
  border-radius: var(--r-md);
  background: var(--acc-soft);
}
.wb-system-card__eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--acc);
  font: 600 0.64rem/1.2 var(--font-ui);
}
.wb-system-card__eyebrow i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 8px var(--acc);
}
.wb-system-card strong {
  color: var(--ink);
  font: 600 0.78rem/1.35 var(--font-ui);
}
.wb-system-card > span {
  color: var(--ink-dim);
  font: 400 0.7rem/1.5 var(--font-ui);
}
.wb-param-group + .wb-param-group {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid rgba(148, 172, 205, 0.09);
}
.wb-param-group__label {
  margin-bottom: 4px;
  color: var(--ink-mute);
  font: 600 0.66rem/1.2 var(--font-ui);
}

/* ---------- guided Gridfinity drawer planner ---------- */
.gf-planner {
  display: grid;
  gap: 16px;
}
.gf-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(8, 11, 17, 0.52);
}
.gf-steps button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 34px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-mute);
  font: 600 0.68rem/1 var(--font-ui);
  cursor: pointer;
}
.gf-steps button span {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font: 600 0.56rem/1 var(--font-mono);
}
.gf-steps button.is-active {
  background: var(--acc-soft);
  color: var(--acc);
}
.gf-planner__body {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.gf-planner__body > .btn {
  width: 100%;
  justify-content: center;
}
/* Two ways to say the same thing: measure a drawer, or name a grid. */
.gf-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 11, 17, 0.52);
}
.gf-mode button {
  display: grid;
  gap: 1px;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-mute);
  text-align: left;
  cursor: pointer;
}
.gf-mode button strong { font: 600 0.7rem/1.25 var(--font-ui); }
.gf-mode button small { font: 400 0.6rem/1.3 var(--font-ui); opacity: .78; }
.gf-mode button[aria-checked="true"] {
  background: var(--acc-soft);
  color: var(--acc);
}
.gf-planner__note {
  margin: 0;
  color: var(--ink-mute);
  font: 400 0.65rem/1.45 var(--font-ui);
}
.gf-planner__note.is-warn { color: var(--bad); }
.gf-fit-result {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 3px 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(8, 11, 17, 0.38);
}
.gf-fit-result > span {
  grid-row: 1 / 3;
  color: var(--ink-mute);
  font-size: 0.66rem;
}
.gf-fit-result strong {
  color: var(--ink);
  font: 600 0.78rem/1.3 var(--font-ui);
}
.gf-fit-result small {
  color: var(--ink-mute);
  font: 500 0.63rem/1.4 var(--font-ui);
}
.gf-step-heading {
  display: grid;
  gap: 3px;
}
.gf-step-heading strong {
  color: var(--ink);
  font: 600 0.82rem/1.35 var(--font-ui);
}
.gf-step-heading span {
  color: var(--ink-dim);
  font: 400 0.7rem/1.45 var(--font-ui);
}
.gf-map-shell {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.gf-map-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  color: var(--ink-mute);
  font: 500 0.62rem/1.3 var(--font-ui);
}
.gf-map-meta strong {
  color: var(--ink);
  font-size: 0.68rem;
}
.gf-map-meta span:nth-child(2) { margin-left: auto; }
/* The plate is drawn to scale, so the box has to keep the plate's own
   proportions or the 42 mm cells stop reading as squares. Capping the
   height with `max-height` would have done exactly that — it shortens
   the box without narrowing it — so the height limit is applied to the
   width instead and `aspect-ratio` is left free to do its job. */
.gf-map {
  --gf-map-h: 300px;
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, calc(var(--gf-map-h) * var(--gf-ar, 1)));
  margin-inline: auto;
  aspect-ratio: var(--gf-ar, 1);
  overflow: hidden;
  border: 2px solid #8b6f57;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.055), transparent 45%),
    #342a24;
  box-shadow: inset 0 0 0 5px rgba(0,0,0,.14);
  touch-action: none;
}
.gf-map__grid {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 5px;
  background: #7b8d98;
  box-shadow: 0 2px 10px rgba(0,0,0,.28);
}
.gf-map__cells,
.gf-map__bins {
  position: absolute;
  inset: 0;
}
.gf-map__cells { display: grid; }
.gf-map__cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(255,255,255,.2);
  border-bottom: 1px solid rgba(255,255,255,.2);
  background: rgba(15, 23, 32, .16);
  cursor: crosshair;
  touch-action: none;
}
.gf-map__cell:hover,
.gf-map__cell.is-drawing {
  background: color-mix(in srgb, var(--acc) 48%, rgba(255,255,255,.12));
}
/* The drag preview stays visible while it is illegal, colored rather
   than hidden, so the reason a bin did not appear is on screen before
   the pointer comes up instead of only in the status line after. */
.gf-map__cell.is-blocked {
  background: color-mix(in srgb, var(--bad) 52%, rgba(255,255,255,.1));
}
.gf-map__cell:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: -2px;
  z-index: 3;
}
.gf-map__bins { pointer-events: none; }
.gf-map.is-dragging .gf-map__cell { cursor: inherit; }
.gf-map.is-dragging .gf-map__cell:hover { background: rgba(15, 23, 32, .16); }
.gf-map__bin {
  position: absolute;
  display: grid;
  place-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 0;
  padding: 3px;
  border: 2px solid color-mix(in srgb, var(--bin-color) 65%, white);
  border-radius: 5px;
  background: color-mix(in srgb, var(--bin-color) 72%, #13202a);
  color: #071018;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.1), 0 2px 8px rgba(0,0,0,.22);
}
.gf-map__bin strong {
  font: 700 clamp(.55rem, 1.2vw, .72rem)/1 var(--font-mono);
}
.gf-map__bin span {
  font: 600 clamp(.45rem, 1vw, .58rem)/1 var(--font-mono);
}
.gf-map__bin.is-selected {
  outline: 2px solid white;
  outline-offset: 2px;
  z-index: 2;
}
.gf-map__bin:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
  z-index: 3;
}
.gf-map__bin.is-editable { cursor: grab; }
.gf-map__bin.is-moving {
  cursor: grabbing;
  z-index: 4;
  opacity: .82;
}
.gf-map__bin.is-invalid {
  border-color: var(--bad);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--bad) 70%, transparent), 0 2px 8px rgba(0,0,0,.22);
}
/* Corner grip. Sized in absolute px rather than a share of the bin so it
   stays grabbable on a 1×1 bin in a 20-wide grid. */
.gf-map__grip {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 0 0 4px 0;
  background:
    linear-gradient(135deg, transparent 46%, rgba(7,16,24,.85) 46%, rgba(7,16,24,.85) 58%, transparent 58%),
    linear-gradient(135deg, transparent 66%, rgba(7,16,24,.85) 66%, rgba(7,16,24,.85) 78%, transparent 78%);
  cursor: nwse-resize;
  touch-action: none;
}
.gf-map__grip:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
}
.gf-map-help {
  margin: 0;
  color: var(--ink-mute);
  font: 400 0.66rem/1.45 var(--font-ui);
}
.gf-planner__actions {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 8px;
}
.gf-planner__actions .btn {
  width: 100%;
  justify-content: center;
  padding-inline: 10px;
}
.gf-bin-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 142px;
  overflow-y: auto;
}
.gf-bin-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(8, 11, 17, .42);
  color: var(--ink-dim);
  text-align: left;
  cursor: pointer;
}
.gf-bin-card > i {
  width: 9px;
  height: 32px;
  flex: none;
  border-radius: 5px;
  background: var(--bin-color);
}
.gf-bin-card > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.gf-bin-card strong { color: var(--ink); font: 600 .69rem/1.2 var(--font-ui); }
.gf-bin-card small { color: var(--ink-mute); font: 500 .58rem/1.2 var(--font-mono); }
.gf-bin-card.is-selected {
  border-color: var(--bin-color);
  background: color-mix(in srgb, var(--bin-color) 12%, rgba(8, 11, 17, .42));
}
.gf-bin-editor {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  border-left: 3px solid var(--bin-color, var(--line));
  background: rgba(8, 11, 17, .38);
}
.gf-bin-editor__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 4px;
}
.gf-bin-editor__head strong { color: var(--ink); font: 600 .72rem/1.3 var(--font-ui); }
.gf-bin-editor__head small { margin-left: auto; color: var(--ink-mute); font: 500 .6rem/1.3 var(--font-mono); }
.gf-bin-editor > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  color: var(--ink-dim);
  font-size: .7rem;
}
.gf-mini-stepper {
  display: grid;
  grid-template-columns: 30px minmax(76px, auto) 30px;
  align-items: center;
  min-height: 30px;
  overflow: hidden;
  border: 1px solid var(--line-hi);
  border-radius: 8px;
}
.gf-mini-stepper button {
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.gf-mini-stepper button:hover { background: var(--acc-soft); }
.gf-mini-stepper button:disabled { opacity: .25; }
.gf-mini-stepper strong {
  color: var(--ink);
  font: 600 .66rem/1 var(--font-mono);
  text-align: center;
}
.gf-remove-bin {
  justify-self: start;
  margin-top: 5px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--bad);
  font: 500 .66rem/1 var(--font-ui);
  cursor: pointer;
}
.wbapp .wb-field {
  padding: 9px 0;
  border-bottom: 1px solid rgba(148, 172, 205, 0.09);
}
.wbapp .wb-field:last-child { border-bottom: 0; }
.wbapp .wb-field__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: none;
}
.wbapp .wb-field__top label { color: var(--ink-dim); font-weight: 500; line-height: 1.35; }
.wbapp .wb-field select {
  width: 152px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  background: rgba(8, 11, 17, 0.6);
  color: var(--ink);
  font: 500 0.74rem/1 var(--font-ui);
  cursor: pointer;
}
.wbapp .wb-field select:focus { outline: none; border-color: var(--acc); }
.wbapp .wb-stepper {
  width: 152px;
  height: 36px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  background: rgba(8, 11, 17, 0.6);
}
.wbapp .wb-stepper:focus-within { border-color: var(--acc); background: var(--acc-soft); }
.wbapp .wb-stepper__input {
  font: 600 0.8rem/1 var(--font-mono);
  color: var(--ink);
}
.wbapp .wb-stepper__unit { color: var(--ink-mute); font: 500 0.68rem/1 var(--font-mono); }
.wbapp .wb-stepper__button {
  width: 32px; height: 34px; flex-basis: 32px;
  color: var(--ink-dim);
  font-size: 15px;
}
.wbapp .wb-stepper__button:first-child { border-right: 1px solid rgba(148, 172, 205, 0.12); }
.wbapp .wb-stepper__button:last-child { border-left: 1px solid rgba(148, 172, 205, 0.12); }
.wbapp .wb-stepper__button:hover { background: var(--acc-soft); color: var(--ink); }

.wbapp .wb-toggle {
  min-height: 44px;
  border-bottom: 1px solid rgba(148, 172, 205, 0.09);
  color: var(--ink-dim);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.wbapp .wb-toggle:last-child { border-bottom: 0; }
.wbapp .wb-toggle:hover { color: var(--ink); }
.wbapp .wb-toggle input { width: 18px; height: 18px; accent-color: var(--acc); }

/* Color presets */
.wbapp .wb-color-palette { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; }
.wbapp .wb-color-swatch {
  border: 0;
  border-radius: 50%;
  background: var(--swatch-color);
  transition: transform .16s ease;
}
.wbapp .wb-color-swatch::after { content: none; }
.wbapp .wb-color-swatch:hover { transform: scale(1.12); }
.wbapp .wb-color-swatch[aria-checked='true'] {
  outline: 2px solid var(--swatch-color);
  outline-offset: 3px;
}
.wbapp .wb-color-actions { margin-top: 12px; }
.wbapp .wb-color-custom { color: var(--ink-dim); font-family: var(--font-ui); font-size: 0.72rem; font-weight: 500; }
.wbapp .wb-color-custom input { width: 34px; height: 26px; border-color: var(--line-hi); border-radius: var(--r-sm); }
.wbapp #wb-color-default { color: var(--acc); font-family: var(--font-ui); font-size: 0.72rem; font-weight: 500; }

/* cutouts + labels */
.wbapp .wb-cuts__head {
  padding-top: 0;
  border-top: 0;
  color: var(--ink-mute);
  font: 600 0.7rem/1.3 var(--font-ui);
  letter-spacing: 0.02em;
  text-transform: none;
}
.wbapp .wb-cut { border-bottom-color: rgba(148, 172, 205, 0.09); }
.wbapp .wb-cut__name { color: var(--ink); font-family: var(--font-ui); font-size: 0.76rem; font-weight: 500; }
.wbapp .wb-num,
.wbapp .wb-cut__fields input,
.wbapp .wb-labels input {
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  background: rgba(8, 11, 17, 0.6);
  color: var(--ink);
}
.wbapp .wb-num:focus,
.wbapp .wb-cut__fields input:focus,
.wbapp .wb-labels input:focus { outline: none; border-color: var(--acc); }
.wbapp .wb-cut__fields label,
.wbapp .wb-labels label { color: var(--ink-mute); }
.wbapp .wb-x { border-radius: var(--r-sm); border-color: var(--line-hi); color: var(--ink-mute); }
.wbapp .wb-add select,
.wbapp .wb-add button {
  height: 36px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  background: rgba(8, 11, 17, 0.6);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.75rem;
}
.wbapp .wb-add button { background: var(--acc-soft); color: var(--acc); font-weight: 600; }
.wbapp .wb-labels > strong { color: var(--ink); font-family: var(--font-ui); font-size: 0.7rem; letter-spacing: 0; text-transform: none; }
.wbapp .wb-labels__note { color: var(--ink-mute); font-size: 0.7rem; }

/* multi-piece plan */
.wbapp .wb-tiles { margin: 0; gap: 10px; }
.wbapp .wb-tiles__label {
  color: var(--ink-mute);
  font: 600 0.7rem/1.3 var(--font-ui);
  letter-spacing: 0.02em;
  text-transform: none;
}
.wbapp .wb-tile {
  border: 1px solid var(--line-hi);
  border-radius: 100px;
  background: rgba(8, 11, 17, 0.6);
  color: var(--ink-dim);
  font-family: var(--font-mono);
}
.wbapp .wb-tile:hover { border-color: var(--acc-line); color: var(--ink); }
.wbapp .wb-tile.is-on { border-color: var(--acc); background: var(--acc); color: #06121c; }

/* ---------- calculators view ---------- */
.view--calc { overflow-y: auto; overscroll-behavior: contain; }
.calcwrap { max-width: 1400px; margin: 0 auto; padding: 34px clamp(16px, 4vw, 44px) 90px; }
.calcwrap > header { max-width: 62ch; margin-bottom: 26px; }
.calcwrap > header h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.035em;
}
.calcwrap > header p { margin: 0; color: var(--ink-dim); font-size: 0.94rem; line-height: 1.65; }
.wbapp .wbp-calcs { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
.wbapp .wb-calc {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 22px;
  scroll-margin-top: 20px;
}
.wbapp .wb-calc > header h3 { font-family: var(--font-display); font-size: 1.14rem; }
.wbapp .wb-calc > header p { color: var(--ink-dim); }
.wbapp .wb-calc__grid label,
.wbapp .wb-calc__row label {
  color: var(--ink-mute);
  font: 500 0.75rem/1.3 var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
}
.wbapp .wb-calc select {
  height: 34px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  background: rgba(8, 11, 17, 0.6);
  color: var(--ink);
}
.wbapp .wb-out { border-top-color: var(--line); }
.wbapp .wb-out__row span { color: var(--ink-mute); }
.wbapp .wb-out__row b { color: var(--acc); }
.wbapp .wb-out__row.is-hero b { color: var(--warn); font-size: 1.1rem; }
.wbapp .wb-out__warn { color: var(--bad); }
.wbapp .wb-table th { color: var(--ink-mute); border-bottom-color: var(--line); }
.wbapp .wb-table td { color: var(--ink); border-bottom-color: rgba(148, 172, 205, 0.08); }
.wbapp .wb-table td:first-child { color: var(--ink-mute); }
.wbapp .wbp-note {
  border-left: 2px solid var(--warn);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: rgba(251, 191, 36, 0.06);
  padding: 14px 18px;
  margin: 26px 0 0;
  color: var(--ink-dim);
  font-size: 0.85rem;
  line-height: 1.6;
}
.wbapp .wbp-note strong { color: var(--warn); }
.wbapp .wbp-note a { color: var(--acc); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .wbapp { --drawer: 380px; --rail: 84px; } }

@media (max-width: 900px) {
  .wbapp { --rail: 0px; --bar: 50px; }
  .app__brand, .app__links a:not(#wb-account-link) { display: none; }
  .view--tools,
  .wbapp.is-drawer-open .view--tools {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  /* The rail becomes a swipeable strip under the bar. */
  .rail {
    flex-direction: row;
    gap: 6px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scroll-snap-type: inline proximity;
  }
  .rail__group {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 0 0 0 10px;
    border-top: 0;
    border-left: 1px solid rgba(148, 172, 205, 0.09);
  }
  .rail__group:first-child {
    padding-left: 0;
    border-left: 0;
  }
  .rail__label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    padding: 0 1px;
    font-size: 0.45rem;
  }
  .rail button {
    flex: 0 0 auto;
    grid-auto-flow: column;
    align-items: center;
    padding: 8px 14px 8px 11px;
    scroll-snap-align: start;
  }
  .rail button svg { width: 18px; height: 18px; }
  .rail button strong { font-size: 0.7rem; text-align: left; white-space: nowrap; }
  .rail button[aria-selected='true']::before { content: none; }

  /* The drawer becomes a bottom sheet — stopping above the dock, so the
     export buttons stay reachable while you are editing parameters. */
  .drawer {
    position: absolute;
    inset: auto 0 var(--dock) 0;
    z-index: 20;
    width: 100%;
    max-height: calc(100dvh - var(--bar) - var(--dock) - 64px);
    border-left: 0;
    border-top: 1px solid var(--acc-line);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    transform: translateY(calc(100% + var(--dock)));
    transition: transform .34s cubic-bezier(.32, .72, 0, 1);
  }
  .wbapp.is-drawer-open .drawer { transform: translateY(0); }
  .drawer-tab {
    top: auto;
    bottom: calc(var(--dock) + 14px);
    right: 14px;
    border-right: 1px solid var(--acc-line);
    border-radius: 100px;
    padding: 11px 16px;
    writing-mode: horizontal-tb;
  }
  .hud { padding: 9px 11px; }
  .hud__row span { min-width: 52px; font-size: 0.5rem; }
  .hud__row b { font-size: 0.65rem; }
  .placard { display: none; }
  /* The dock must stay exactly one --dock tall: the sheet above is
     positioned off that variable, and a wrapped dock would peek out. */
  .dock { gap: 10px; padding-inline: 12px; }
  .dock__id { min-width: 0; }
}

@media (max-width: 700px) {
  .app__bar { gap: 8px; padding: 0 8px; }
  .app__back { padding: 7px; }
  .app__back span { display: none; }
  .seg button { padding: 7px 14px; }
}

@media (max-width: 560px) {
  .hint { display: none; }
  .tools3d { top: 10px; right: 10px; }
  .tools3d__group:not(:last-child) { display: none; }
  .btn { padding: 0 14px; }
  .btn span { display: none; }
  .seg button { padding: 7px 11px; }
  .seg button span { display: none; }
  .calcwrap { padding: 22px 14px 70px; }
  .wbapp .wbp-calcs { grid-template-columns: minmax(0, 1fr); }
  .drawer__body { padding-inline: 12px; }
  .gf-map-meta span:last-child { display: none; }
  .gf-bin-list { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- board designer ---------- */
.view--board { display: block; }
.bd {
  --bd-palette: 248px;
  --bd-side: 300px;
  display: grid;
  grid-template-columns: var(--bd-palette) minmax(0, 1fr) var(--bd-side);
  grid-template-rows: minmax(0, 1fr) var(--dock);
  height: 100%;
  min-height: 0;
  background: rgba(8, 11, 17, 0.35);
}
.bd[hidden] { display: none; }

.bd-palette,
.bd-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: rgba(9, 12, 18, 0.72);
  border-right: 1px solid var(--line);
}
.bd-side { border-right: 0; border-left: 1px solid var(--line); }
.bd-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.bd-sheet__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.bd-sheet__head .icobtn { display: none; }

.bd-palette {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 18px;
  scrollbar-width: thin;
}
.bd-palette__label {
  margin: 16px 14px 8px;
  color: var(--ink-mute);
  font: 600 0.58rem/1.2 var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.bd-part {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: calc(100% - 16px);
  margin: 0 8px 4px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.bd-part:hover,
.bd-part:focus-visible {
  background: var(--glass-hi);
  border-color: var(--line-hi);
  outline: none;
}
.bd-part__chip {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--chip, var(--acc)) 18%, transparent);
  color: var(--chip, var(--acc));
  font-style: normal;
  font-size: 0.95rem;
}
.bd-part__copy { display: grid; gap: 2px; min-width: 0; }
.bd-part__copy strong {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.bd-part__copy small {
  color: var(--ink-mute);
  font-size: 0.66rem;
  line-height: 1.35;
}
.bd-legend {
  display: grid;
  gap: 6px;
  margin: 0 14px;
}
.bd-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 0.62rem;
}
.bd-legend__item i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.bd-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  background:
    radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--acc) 10%, transparent), transparent 70%),
    #0b1018;
}
.bd-surface {
  position: relative;
  overflow: hidden;
  min-height: 0;
  cursor: crosshair;
  touch-action: none;
}
.bd-surface__inner {
  position: absolute;
  transform-origin: 0 0;
  will-change: transform;
}
.bd-surface svg { display: block; overflow: visible; }
.bd-3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.bd-hud {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 3;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none;
}
.bd-hud span {
  display: flex;
  gap: 10px;
  color: var(--ink-mute);
  font: 500 0.62rem/1.35 var(--font-mono);
}
.bd-hud b { color: var(--ink); font-weight: 600; }
.bd-tools {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.bd-tools__sep {
  width: 1px;
  height: 18px;
  margin: 0 3px;
  background: var(--line);
}
.bd-stage .flag {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  transform: translateX(-50%);
  max-width: min(90%, 420px);
  margin: 0;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  border-radius: var(--r-sm);
  background: rgba(40, 12, 18, 0.86);
  color: #fecdd3;
  font-size: 0.72rem;
  text-align: center;
}

.bd-side__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 0 24px;
  scrollbar-width: thin;
}
.bd-side__body > section { padding: 14px 16px 4px; }
.bd-side__body h3 {
  margin: 0 0 10px;
  color: var(--ink-mute);
  font: 600 0.58rem/1.2 var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.bd-fields {
  display: grid;
  gap: 8px;
}
.bd-field {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  color: var(--ink-dim);
  font-size: 0.74rem;
}
.bd-field input {
  width: 76px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  background: rgba(8, 11, 17, 0.6);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}
.bd-field input:focus { outline: none; border-color: var(--acc); }
.bd-field small { color: var(--ink-mute); font-size: 0.62rem; min-width: 1.6em; }
.bd-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--ink-dim);
  font-size: 0.74rem;
  cursor: pointer;
}
.bd-check input { accent-color: var(--acc); }
.bd-selection__name {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 600;
}
.bd-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 12px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 0.66rem;
}
.bd-facts dd { margin: 0; color: var(--ink); }
.bd-danger { margin-top: 8px; color: var(--bad) !important; border-color: color-mix(in srgb, var(--bad) 35%, transparent) !important; }
.bd-bom {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.bd-bom li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-dim);
  font-size: 0.74rem;
}
.bd-bom b { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }

.bd-dock {
  grid-column: 1 / -1;
  z-index: 4;
}
.bd-dock .bd-sheet-btn { display: none; }
.bd-dock #bd-status[data-kind='bad'] { color: var(--bad); }
.bd-dock #bd-status[data-kind='ok'] { color: var(--acc); }

/* SVG board chrome */
.bd-board { fill: #1a2330; stroke: rgba(148, 172, 205, 0.28); stroke-width: 1.25; }
.bd-hole { fill: #0a0d13; }
.bd-rail { stroke-width: 3; stroke-linecap: round; opacity: 0.55; }
.bd-rail--plus { stroke: #fb7185; }
.bd-rail--minus { stroke: #60a5fa; }
.bd-wire { stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; fill: none; opacity: 0.95; }
.bd-wire.is-selected { stroke-width: 6; filter: drop-shadow(0 0 4px currentColor); }
.bd-anchor { fill: var(--acc); stroke: #06121c; stroke-width: 1.5; }
.bd-ghost { stroke: var(--acc); stroke-width: 3.5; stroke-dasharray: 5 4; fill: none; opacity: 0.7; }
.bd-ghost.is-bad { stroke: var(--bad); }
.bd-comp__body { fill: color-mix(in srgb, var(--part, #6ee7b7) 22%, #121722); stroke: var(--part, #6ee7b7); stroke-width: 1.4; }
.bd-comp__label {
  fill: var(--part, #6ee7b7);
  font: 600 9px var(--font-ui);
  text-anchor: middle;
  pointer-events: none;
}
.bd-comp__pin1 { fill: #fbbf24; stroke: #06121c; stroke-width: 1; }
.bd-comp__mount { fill: rgba(148, 172, 205, 0.08); stroke: rgba(148, 172, 205, 0.35); stroke-width: 1.2; stroke-dasharray: 3 2; }
.bd-comp__sel { fill: none; stroke: var(--acc); stroke-width: 1.6; stroke-dasharray: 4 3; }
.bd-collar { fill: none; stroke: rgba(148, 172, 205, 0.45); stroke-width: 1.2; }
.bd-screw { fill: #0a0d13; stroke: rgba(148, 172, 205, 0.5); stroke-width: 1; }
.bd-slot { stroke: rgba(148, 172, 205, 0.35); stroke-linecap: round; fill: none; }

@media (max-width: 1100px) {
  .bd { --bd-palette: 220px; --bd-side: 260px; }
}

@media (max-width: 900px) {
  .bd {
    --bd-palette: 0px;
    --bd-side: 0px;
    grid-template-columns: minmax(0, 1fr);
  }
  .bd-palette,
  .bd-side {
    position: absolute;
    z-index: 30;
    inset: 0 auto var(--dock) 0;
    width: min(320px, 88vw);
    border-right: 1px solid var(--acc-line);
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
    transform: translateX(-105%);
    transition: transform .34s cubic-bezier(.32, .72, 0, 1);
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.45);
  }
  .bd-side {
    inset: 0 0 var(--dock) auto;
    border-right: 0;
    border-left: 1px solid var(--acc-line);
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    transform: translateX(105%);
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45);
  }
  .bd[data-sheet='palette'] .bd-palette,
  .bd[data-sheet='side'] .bd-side { transform: translateX(0); }
  .bd-sheet__head .icobtn { display: inline-grid; }
  .bd-dock .bd-sheet-btn { display: inline-grid; }
  .bd-tools { top: 10px; right: 10px; }
  .bd-hud { left: 10px; top: 10px; padding: 8px 10px; }
}

@media (max-width: 560px) {
  .bd-dock .btn span { display: none; }
  .bd-dock .dock__id h1 { font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .view--tools, .drawer, .btn, .rail button, .seg button, .icobtn,
  .bd-palette, .bd-side { transition: none; }
  .wbapp.is-busy .dock__meta i { animation: none; }
}
