/* Instrument bench (crates/web/src/bench): multimeter, scope, logic analyzer.
   Desktop: a strip across the stage column, above the code dock, resizable by its top edge.
   Phone: a full-screen sheet. */
:root {
  --bench-h: 440px;
  --lcd-bg: #dfe5d5; --seg-on: #1c2614; --seg-off: rgba(28, 38, 20, 0.07);
  --run: #23803a; --stop: #c62828;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --lcd-bg: #121712; --seg-on: #a6ea86; --seg-off: rgba(166, 234, 134, 0.07); }
}
:root[data-theme="dark"] { --lcd-bg: #121712; --seg-on: #a6ea86; --seg-off: rgba(166, 234, 134, 0.07); }

#bench { display: none; }
#bench.open {
  display: flex; flex-direction: column;
  position: absolute; left: var(--pal-w); right: 360px; bottom: 0; height: var(--bench-h);
  background: var(--panel); border-top: 1px solid var(--line); z-index: 3;
}
/* Open, the bench sits above the code dock's bar; the dock folds to that bar (it keeps its state). */
.app:has(#code) #bench.open { bottom: var(--dock-bar); }
.app:has(#bench.open) #code.open { height: var(--dock-bar); }
.app:has(#bench.open) .stage, .app:has(#bench.open):has(#code) .stage { padding-bottom: var(--bench-h); }
.app:has(#bench.open):has(#code) .stage { padding-bottom: calc(var(--bench-h) + var(--dock-bar)); }
.app.device-mode #bench.open { left: 0; }
.bench-resize { position: absolute; top: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; touch-action: none; z-index: 1; }
.bench-bar { height: 40px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); }
.bench-tabs { display: flex; gap: 4px; }
.bench-tabs button { height: 30px; padding: 0 14px; }
.bench-close { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.bench-body { flex: 1; min-height: 0; display: flex; }
.meter-bench, .scope, .logic { flex: 1; min-width: 0; min-height: 0; }
#bench button { height: 30px; padding: 0 10px; }
#bench select { height: 30px; min-width: 0; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.ctl-row { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.ctl-name { width: 56px; flex: none; color: var(--muted); font-size: 13px; }
.runstop { width: 92px; color: #fff; font-weight: 600; background: var(--stop); border-color: var(--stop); }
.runstop.running { background: var(--run); border-color: var(--run); }
#bench .stp { display: inline-flex; align-items: center; }
#bench .stp button { width: 26px; padding: 0; }
.stp-val { min-width: 72px; text-align: center; white-space: nowrap; }

/* probes: a dot to drag onto the board, and the list of pins and nets */
.probe-pick { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.probe-pick select { flex: 1; }
#bench .probe-dot {
  width: 26px; height: 26px; padding: 0; flex: none; border-radius: 50%; border: 2px solid #fff;
  background: var(--pc); color: #fff; font-weight: 700; line-height: 1; box-shadow: 0 0 0 1px var(--line);
  touch-action: none; cursor: grab;
}
/* Armed (phone: the next tap on the board places it): a ring in the probe's colour, and the board strip outlined. */
#bench .probe-dot.armed { box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px var(--pc); }
body.phone .ph-stage.probing { box-shadow: inset 0 0 0 3px var(--accent, #1a73e8); }
.probe-mark { cursor: grab; }
.probe-mark .probe-body { fill: var(--pc); stroke: #fff; stroke-width: 0.8; }
.probe-mark .probe-tip { fill: #c9ccd1; stroke: #3a3a3e; stroke-width: 0.5; }
.probe-mark .probe-txt { font: 700 6px system-ui, sans-serif; fill: #fff; text-anchor: middle; pointer-events: none; }

/* meter */
.meter-bench { display: flex; gap: 16px; padding: 12px; }
.meter-face { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 14px; background: var(--lcd-bg); border-radius: 8px; color: var(--seg-on); }
.seg7 { height: min(110px, 60%); max-width: 70%; }
.seg7 path, .seg7 circle { fill: var(--seg-off); }
.seg7 .lit { fill: var(--seg-on); }
.meter-unit { width: 72px; font-size: 34px; font-weight: 600; }
.meter-beep { width: 34px; height: 34px; opacity: 0.12; visibility: hidden; }
.meter-beep.shown { visibility: visible; }
.meter-beep.on { opacity: 1; }
.meter-beep svg { width: 100%; height: 100%; }
.meter-ctl { width: 340px; flex: none; display: flex; flex-direction: column; gap: 8px; }
.seg-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }

/* scope */
.scope { display: flex; flex-direction: column; }
.sc-main { flex: 1; min-height: 0; display: flex; }
.sc-screen { flex: 1; min-width: 0; height: 100%; display: block; touch-action: none; }
.sc-screen.cursors { cursor: ew-resize; }
.sc-ctl, .la-ctl { width: 300px; flex: none; padding: 6px 12px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.sc-status { min-width: 56px; text-align: right; color: var(--muted); font-size: 13px; margin-left: auto; }
.sc-edge { width: 34px; padding: 0 !important; display: inline-flex; align-items: center; justify-content: center; }
.sc-table { flex: none; border-top: 1px solid var(--line); padding: 2px 12px 4px; overflow-x: auto; }
.sc-row {
  display: grid; align-items: center; gap: 4px; height: 34px; min-width: 680px;
  grid-template-columns: 44px minmax(88px, 1.4fr) 90px 90px minmax(62px, 1fr) minmax(62px, 1fr) minmax(48px, 0.8fr) minmax(52px, 0.8fr) minmax(52px, 0.8fr) minmax(56px, 1fr);
}
.sc-head { height: 22px; font-size: 12px; color: var(--muted); }
.sc-m { text-align: right; white-space: nowrap; }
.sc-row.off .sc-m { color: var(--muted); }
#bench .sc-ch { padding: 0; border-left: 4px solid var(--pc); }
#bench .sc-ch.on { background: var(--pc); border-color: var(--pc); color: #fff; }
.sc-head .sc-ch { display: block; }

/* logic analyzer: a list per lane, aligned with the canvas lanes */
.logic { display: flex; }
.la-lanes { width: 128px; flex: none; display: grid; grid-template-rows: repeat(9, minmax(0, 1fr)); align-items: center; padding: 0 6px 0 12px; }
#bench .la-lanes select { height: min(28px, 90%); width: 100%; }
.la-screen { flex: 1; min-width: 0; height: 100%; display: block; touch-action: none; cursor: grab; }
.la-ctl { width: 240px; }
.la-end { white-space: nowrap; }

