/* ------ design tokens ------ */
:root {
  --bg-0:        #0c0f13;
  --bg-1:        #11151b;
  --bg-2:        #161b22;
  --bg-3:        #1d242e;
  --border:      #232b36;
  --border-soft: #1a2129;
  --fg-0:        #e6e9ef;
  --fg-1:        #b6bdc8;
  --fg-2:        #7e8896;
  --fg-3:        #4d5663;

  --accent:      #f0b94a;        /* highlight amber */
  --accent-soft: #f0b94a40;
  --good:        #6ee7b7;

  /* PCB layer colors. Designed for readability against #0c0f13. */
  --layer-cu-bot:   #d94d4d;     /* C1 - red */
  --layer-cu-top:   #4f8df0;     /* C2 - blue */
  --layer-silk-top: #e5e9ef;     /* S2 - near-white */
  --layer-silk-bot: #9aa3b0;     /* S1 - cool grey */
  --layer-i1:       #d4a35c;     /* I1 - warm tan */
  --layer-i2:       #4ed4b3;     /* I2 - cyan-green */
  --layer-outline:  #f5d272;     /* O - warm yellow */
  --pad-fill:       #e9e6dc;     /* unselected pad */
  --net:            #ffd54a;     /* highlighted electrical net */
  --drill:          #0c0f13;     /* drill = background */
  --substrate:      #1a2030;     /* dark board substrate; used for text halo */

  --shadow-1: 0 1px 0 #ffffff05 inset, 0 1px 2px #00000040;
  --shadow-2: 0 6px 24px #00000080;

  --font-ui:   ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  /* Column flex so the topbar can size itself. It used to be pinned at 46px
     with the layout below hard-coded to calc(100vh - 46px); adding a button
     made the actions wrap onto a second row that was then clipped away. */
  display: flex; flex-direction: column;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }

code { font-family: var(--font-mono); font-size: 0.92em; background: var(--bg-2); padding: 1px 5px; border-radius: 3px; }

/* ------ topbar ------ */
.topbar {
  flex: 0 0 auto;
  min-height: 46px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 18px; height: 18px;
  background:
    radial-gradient(circle at 30% 30%, var(--accent) 0 3px, transparent 4px),
    linear-gradient(135deg, var(--layer-cu-top) 0 50%, var(--layer-cu-bot) 50% 100%);
  border-radius: 4px;
  box-shadow: var(--shadow-1);
}
.brand-name { font-weight: 600; letter-spacing: 0.2px; }
.brand-sub  { color: var(--fg-2); font-weight: 400; font-family: var(--font-mono); font-size: 12px; }

.topbar-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 6px 0;
}

.file-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #1a1408;
  padding: 6px 12px;
  border-radius: 5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: filter 120ms;
}
.file-btn:hover { filter: brightness(1.08); }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn.ghost {
  background: transparent;
  color: var(--fg-1);
  border: 1px solid var(--border);
  font-weight: 500;
}
.file-btn.ghost:hover { background: var(--bg-2); color: var(--fg-0); }

.seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px;
  gap: 1px;
}
.seg-btn {
  background: transparent;
  border: none;
  color: var(--fg-1);
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 100ms;
  position: relative;
}
.seg-btn:hover { color: var(--fg-0); background: var(--bg-3); }
.seg-btn.active { background: var(--bg-3); color: var(--accent); }
.seg-btn.layer-off { color: var(--fg-3); }
.seg-btn.layer-off .swatch { opacity: 0.15; }
.seg-btn.disabled { opacity: 0.35; pointer-events: none; }
.seg-btn .swatch {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px; vertical-align: -1px;
  background: currentColor;
  opacity: 0.85;
}

.icon-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg-1);
  width: 30px; height: 30px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 100ms;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-soft); }
.icon-btn.ghost { background: transparent; }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ------ main layout ------ */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  flex: 1 1 auto;
  min-height: 0;
  transition: grid-template-columns 180ms ease;
}
.layout.bom-hidden { grid-template-columns: 0 1fr; }
.layout.bom-hidden .bom { overflow: hidden; opacity: 0; pointer-events: none; }

/* ------ BOM panel ------ */
.bom {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
  transition: opacity 100ms;
}

.bom-tools {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 8px;
}
#search {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 10px;
  color: var(--fg-0);
  width: 100%;
  outline: none;
  transition: border-color 100ms;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--fg-3); }

.bom-stats {
  font-family: var(--font-mono);
  color: var(--fg-2);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.bom-stats .progress {
  flex: 0 0 70px;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.bom-stats .progress > i {
  display: block; height: 100%;
  background: var(--good);
  width: 0%;
  transition: width 200ms;
}

.bom-scroll { flex: 1 1 auto; overflow: auto; min-height: 0; }

.bom-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}
.bom-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-1);
  text-align: left;
  font-weight: 500;
  color: var(--fg-2);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  user-select: none;
  cursor: pointer;
}
.bom-table thead th:hover { color: var(--fg-0); }
.bom-table thead th.col-mark { cursor: default; width: 26px; padding-right: 0; }
.bom-table .sort-arrow { color: var(--accent); margin-left: 3px; }

.bom-table tbody tr {
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 80ms;
}
.bom-table tbody tr:hover    { background: var(--bg-2); }
.bom-table tbody tr.selected { background: var(--accent-soft); color: var(--fg-0); }
.bom-table tbody tr.selected td { color: var(--fg-0); }
.bom-table tbody tr.placed   { opacity: 0.45; }
.bom-table tbody tr.placed.selected { opacity: 1; }

.bom-table tbody tr:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.bom-table tbody tr:focus { background: var(--accent-soft); }

@keyframes row-flash {
  0%   { background: var(--accent); color: #1a1408; }
  100% { background: var(--accent-soft); color: var(--fg-0); }
}
.bom-table tbody tr.flash { animation: row-flash 0.7s ease-out; }

.bom-table td {
  padding: 5px 10px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}
.bom-table td.col-mark { padding-right: 0; }
.bom-table td.col-ref { font-weight: 600; color: var(--accent); }
.bom-table tbody tr.placed td.col-ref { color: var(--good); }
.bom-table td.col-side { color: var(--fg-2); font-size: 11px; }
.bom-table td .empty { color: var(--fg-3); }

.bom-table input[type="checkbox"] {
  appearance: none;
  width: 14px; height: 14px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  border-radius: 3px;
  cursor: pointer;
  display: inline-grid; place-items: center;
  margin: 0; padding: 0;
  vertical-align: middle;
  transition: all 100ms;
}
.bom-table input[type="checkbox"]:hover  { border-color: var(--accent); }
.bom-table input[type="checkbox"]:checked {
  background: var(--good);
  border-color: var(--good);
}
.bom-table input[type="checkbox"]:checked::after {
  content: '';
  width: 4px; height: 8px;
  border: solid #0c0f13;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* ------ board pane ------ */
.board-pane {
  position: relative;
  min-width: 0; min-height: 0;
  background:
    radial-gradient(ellipse at top, #1a232f 0%, #0c0f13 60%);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.board-empty {
  flex: 1;
  display: grid; place-items: center;
  padding: 32px;
}
.board-empty.dismissed { display: none; }
.board-empty .hint {
  position: relative;
  max-width: 480px;
  color: var(--fg-1);
  border: 1px dashed var(--border);
  background: var(--bg-1);
  padding: 22px 26px;
  border-radius: 8px;
  text-align: left;
}
.board-empty h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: 0.2px;
  padding-right: 24px;
}
.board-empty p { margin: 0 0 14px; }
.board-empty ul { margin: 0; padding-left: 18px; }
.board-empty li { margin: 5px 0; color: var(--fg-1); }
.board-empty li strong { color: var(--accent); font-weight: 500; }
.board-empty .dismiss {
  position: absolute;
  top: 8px; right: 8px;
  width: 24px; height: 24px;
  border: none;
  background: transparent;
  color: var(--fg-2);
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  display: grid; place-items: center;
  line-height: 1;
  transition: all 100ms;
}
.board-empty .dismiss:hover { background: var(--bg-3); color: var(--accent); }

/* Re-showable help overlay (triggered by the ? button). Sits absolutely over
   the board pane so the user can summon it without leaving their place. */
.help-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, 0.55);
  display: grid; place-items: center;
  padding: 32px;
  z-index: 20;
  backdrop-filter: blur(2px);
}
.help-overlay[hidden] { display: none; }
.help-card {
  position: relative;
  max-width: 460px;
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px 18px;
  box-shadow: var(--shadow-2);
  color: var(--fg-1);
}
.help-card h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; color: var(--fg-0); padding-right: 24px; }
.help-card h3 { margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--fg-2);
                text-transform: uppercase; letter-spacing: 0.5px; }
.help-card ul { margin: 0; padding-left: 18px; }
.help-card li { margin: 4px 0; color: var(--fg-1); }
.help-card kbd {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 6px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--fg-0);
}
.help-card .dismiss {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border: none;
  background: transparent;
  color: var(--fg-2);
  border-radius: 4px;
  font-size: 18px;
  cursor: pointer;
  display: grid; place-items: center;
  line-height: 1;
}
.help-card .dismiss:hover { background: var(--bg-3); color: var(--accent); }

/* Drag-and-drop overlay: subtle full-page hint that fires while the user
   is dragging a file from the OS over the window. */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.65);
  z-index: 100;
  display: grid; place-items: center;
  pointer-events: none;   /* let the drop event hit the window beneath */
  backdrop-filter: blur(2px);
}
.drop-overlay[hidden] { display: none; }
.drop-card {
  border: 2px dashed var(--accent);
  background: var(--bg-1);
  color: var(--fg-0);
  padding: 28px 40px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
}
.drop-card code {
  background: var(--bg-2); color: var(--accent);
  padding: 2px 7px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 14px;
}

.board-stage {
  flex: 1 1 auto;
  position: relative;
  min-width: 0; min-height: 0;
  overflow: hidden;
}
.board-stage svg {
  display: block;
  width: 100%; height: 100%;
  cursor: grab;
}
.board-stage svg.dragging { cursor: grabbing; }
.board-stage svg:focus { outline: none; }

.board-label {
  position: absolute;
  top: 10px; left: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--fg-3);
  pointer-events: none;
  z-index: 2;
}

.status {
  position: absolute;
  bottom: 8px; right: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  pointer-events: none;
  text-align: right;
  white-space: pre;
  z-index: 2;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------ SVG render classes ------ */
.layer-O    { color: var(--layer-outline); }
.layer-C2   { color: var(--layer-cu-top); }
.layer-S2   { color: var(--layer-silk-top); }
.layer-C1   { color: var(--layer-cu-bot); }
.layer-S1   { color: var(--layer-silk-bot); }
.layer-I1   { color: var(--layer-i1); }
.layer-I2   { color: var(--layer-i2); }

.lay-stroke   { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.lay-fill     { fill: currentColor; stroke: none; pointer-events: none; }
/* Zones are filled and outlined — the outline width is what rounds their
   corners in Sprint, so without it the copper stops short of the real edge. */
.lay-fill-zone { stroke: currentColor; stroke-linejoin: round; }

/* Automatic ground plane. Dimmer than the tracks on the same layer so routing
   still reads on top of it. */
.pour         { fill: currentColor; opacity: .30; pointer-events: none; }
/* Shapes inside a pour mask: black punches a hole in the plane. Stroke and
   fill both paint, so a stroke-width of 2*groundDist offsets the outline. */
/* Every .pour-clear element sets its own stroke-width explicitly. Leaving it
   unset would inherit SVG's default of 1 *user unit* — 1 mm in board space —
   and silently fatten every keep-out by half a millimetre on each side. */
.pour-clear   { fill: #000; stroke: #000; stroke-linecap: round; stroke-linejoin: round; }
.pour-clear-open { fill: none; }
/* White inside a mask = keep the plane. Used for thermal-pad spokes, which
   bridge the keep-out ring the pad just punched. */
.pour-keep    { fill: none; stroke: #fff; stroke-linecap: butt; }
.pour-clear-text {
  font-family: var(--font-mono); font-weight: 600;
  text-anchor: middle; dominant-baseline: middle; paint-order: stroke fill;
}
.pad          { fill: var(--pad-fill); pointer-events: none; }
/* Elongated pads are drawn as a stroked segment with round caps — that is
   literally how Sprint exports them (stroke of aperture 2*out along the pad
   axis), so the stadium shape comes out exact. */
.pad.pad-oblong { fill: none; stroke: var(--pad-fill); stroke-linecap: round; }
.pad-drill    { fill: var(--drill); pointer-events: none; }
/* Bare mounting holes (outer diameter == drill) carry Sprint's cross marker. */
.drill-cross  { fill: none; stroke: var(--pad-fill); opacity: .75; pointer-events: none; }

/* SMD pads sit on one copper side, so they take the layer's colour
   (currentColor is set per layer-group). Add a subtle outline so adjacent
   pads are easier to tell apart. */
.smd-pad      { fill: currentColor; pointer-events: none; }
/* Text drawn with Sprint's stroke font: the glyph polylines stored in the
   file. `.glyph-run` groups one text object's characters. */
.glyph-run    { fill: none; pointer-events: none; }
.glyph        { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
/* Substrate-coloured underlay that keeps a refdes readable over vias and
   tracks — the stroke equivalent of paint-order on a <text>. */
.glyph-halo   { fill: none; stroke: var(--substrate); stroke-linecap: round; stroke-linejoin: round; }
.net-hl .glyph, .pick-hl .glyph { stroke: currentColor; }
.net-hl .glyph-halo, .pick-hl .glyph-halo { display: none; }

.silk-text    {
  fill: currentColor;
  font-family: var(--font-mono);
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke fill;
  pointer-events: none;
  user-select: none;
}
/* Refdes labels (e.g. "C13", "R44") get a dark substrate-colored halo so
   they stay readable when they cross vias, traces, or other silk graphics. */
.silk-text.component-label {
  stroke: var(--substrate);
  stroke-width: 0.18;
  stroke-linejoin: round;
  paint-order: stroke fill;
}

/* Toggleable visibility for vias / THT drill holes.
   When `hide-vias` is on the pads-group:
     - standalone THT pads (vias, mounting holes) disappear entirely
     - component THT pads keep their copper ring, but the inner drill circle
       is hidden so silk-screen labels passing over them remain readable. */
.pads-group.hide-vias .via-wrap  { display: none; }
.pads-group.hide-vias .pad-drill { display: none; }

/* Explanatory row shown when the BOM has nothing to list. */
.bom-empty td {
  padding: 18px 14px;
  color: var(--fg-2);
  font-size: 12px;
  line-height: 1.55;
  text-align: left;
  white-space: normal;
}
.bom-empty td em     { color: var(--fg-1); font-style: normal; font-weight: 600; }
.bom-empty td strong { color: var(--fg-1); }
.bom-empty:hover     { background: none; }

/* Measurement overlay. non-scaling-stroke keeps it the same weight at any
   zoom, which a board-space stroke width would not. */
.measure-line {
  fill: none; stroke: var(--accent); stroke-width: 1.5;
  stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; pointer-events: none;
}
.measure-end {
  fill: var(--accent); stroke: var(--bg-0); stroke-width: 1;
  vector-effect: non-scaling-stroke; pointer-events: none;
}

/* Net panel */
.net-builder { margin-top: 10px; padding: 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2); }
.net-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 220px; overflow: auto; }
.net-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 5px; cursor: pointer; font-size: 12px;
}
.net-list li:hover { background: var(--bg-3); }
.net-list li.on { background: var(--accent-soft); }
.net-list li span { flex: 1; color: var(--fg-0); }
.net-list li em { font-style: normal; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.net-list li.none { color: var(--fg-3); cursor: default; }
.net-list li.none:hover { background: none; }

/* Board-info modal */
.help-card.wide { max-width: 620px; }
.info-stats { display: grid; grid-template-columns: 1fr; gap: 2px; margin-bottom: 4px; }
.info-stats > div { display: flex; gap: 10px; font-size: 12px; padding: 3px 0; border-bottom: 1px solid var(--border-soft); }
.info-stats dt { flex: 0 0 120px; margin: 0; color: var(--fg-2); }
.info-stats dd { margin: 0; color: var(--fg-0); }
.info-note { font-size: 11px; color: var(--fg-2); line-height: 1.5; margin: 4px 0 8px; }
.info-note.warn { color: var(--accent); }
.drill-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.drill-table th { text-align: right; color: var(--fg-2); font-weight: 500; padding: 3px 8px; border-bottom: 1px solid var(--border); }
.drill-table td { text-align: right; padding: 3px 8px; border-bottom: 1px solid var(--border-soft); }
.drill-table tr.sum td { color: var(--fg-0); font-weight: 600; border-top: 1px solid var(--border); border-bottom: none; }

/* Part-builder pick highlight: the objects chosen for the part being defined. */
.pick-hl { pointer-events: none; }
.pick-hl .lay-stroke,
.pick-hl .lay-fill,
.pick-hl .smd-pad,
.pick-hl .silk-text        { color: var(--good); opacity: 1; }
.pick-hl .pad              { fill: var(--good); }
.pick-hl .pad.pad-oblong   { fill: none; stroke: var(--good); }
.pick-hl .pad-drill        { fill: var(--drill); }
.pick-hl .hit-box          { display: none; }

/* Part builder panel (BOM sidebar, part mode only) */
.part-builder {
  margin-top: 10px; padding: 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-2);
}
.pb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pb-head strong { font-size: 12px; color: var(--fg-0); }
.pb-count { font-size: 11px; color: var(--good); font-variant-numeric: tabular-nums; }
.pb-hint  { margin: 6px 0 8px; font-size: 11px; line-height: 1.45; color: var(--fg-2); }
.pb-fields { display: grid; gap: 6px; }
.pb-fields input {
  width: 100%; padding: 5px 8px; font: inherit; font-size: 12px;
  color: var(--fg-0); background: var(--bg-1);
  border: 1px solid var(--border); border-radius: 6px;
}
.pb-fields input:focus { outline: none; border-color: var(--accent); }
.pb-actions { display: flex; gap: 6px; margin-top: 8px; }
.pb-btn {
  flex: 1; padding: 5px 8px; font: inherit; font-size: 12px; cursor: pointer;
  color: var(--fg-1); background: var(--bg-3);
  border: 1px solid var(--border); border-radius: 6px;
}
.pb-btn:hover:not(:disabled) { color: var(--fg-0); border-color: var(--fg-3); }
.pb-btn.primary:not(:disabled) { color: #17202b; background: var(--accent); border-color: var(--accent); }
.pb-btn:disabled { opacity: .45; cursor: default; }

/* Delete control on user-defined BOM rows */
.row-del {
  margin-left: 4px; padding: 0 4px; line-height: 1;
  font: inherit; font-size: 13px; cursor: pointer;
  color: var(--fg-3); background: none; border: none;
}
.row-del:hover { color: var(--layer-cu-bot); }

/* Net highlight: copies of the net's members drawn over the board in one
   colour. Copies, not restyled originals, so it is independent of the layer
   each member happens to live on. */
.net-hl { pointer-events: none; }
.net-hl .lay-stroke,
.net-hl .lay-fill,
.net-hl .smd-pad          { color: var(--net); opacity: 1; }
.net-hl .pad              { fill: var(--net); }
.net-hl .pad.pad-oblong   { fill: none; stroke: var(--net); }
.net-hl .pad-drill        { fill: var(--drill); }
.net-hl .drill-cross      { stroke: var(--net); }
.net-hl .hit-box          { display: none; }

/* Layer visibility — toggled by class on the layer group */
.layer-group.hidden { display: none; }
.layer-group.mode-hidden { display: none; }     /* hidden because of mode */

/* X-Ray mode: dim the "far" side of the board so the near side reads first */
.board-stage[data-mode="xray"] .layer-C1,
.board-stage[data-mode="xray"] .layer-S1 {
  opacity: 0.55;
}

/* highlight overlay */
.hl-halo {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 0.15;
  pointer-events: none;
  animation: halo-pulse 1.6s ease-in-out infinite;
}
@keyframes halo-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.member-hl {
  filter: drop-shadow(0 0 0.5px var(--accent)) drop-shadow(0 0 1.2px var(--accent));
}

/* Hit-boxes are transparent overlays for click-pickup */
.hit-box {
  fill: transparent;
  cursor: pointer;
  pointer-events: all;
}

/* ------ scrollbar polish ------ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 5px;
  border: 2px solid var(--bg-1);
}
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ------ responsive ------ */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: minmax(180px, 35vh) 1fr; }
  .bom { border-right: none; border-bottom: 1px solid var(--border); }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 10px; }
  .topbar-actions { width: 100%; }
}
