:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #636368;
  --line: #d9d6d0;
  --accent: #0a6cdf;
  --accent-ink: #ffffff;
  --pal-w: 168px;
  --warn: #b26a00;
  --warn-bg: #fff4e0;
  --err: #c62828;
  --err-bg: #fdecea;
  --info-bg: #eef4fc;
  --btn: #ecebe7;
  --btn-on: #0a6cdf;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181a; --panel: #212226; --ink: #ececef; --muted: #9a9aa2; --line: #34353a;
    --accent: #4b9bff; --btn: #2d2e33; --btn-on: #2563c9;
    --warn: #ffb74d; --warn-bg: #3a2c12; --err: #ff6b6b; --err-bg: #3c1c1c; --info-bg: #1d2a3c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17181a; --panel: #212226; --ink: #ececef; --muted: #9a9aa2; --line: #34353a;
  --accent: #4b9bff; --btn: #2d2e33; --btn-on: #2563c9;
  --warn: #ffb74d; --warn-bg: #3a2c12; --err: #ff6b6b; --err-bg: #3c1c1c; --info-bg: #1d2a3c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
button {
  font: inherit; color: var(--ink); background: var(--btn);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.4; cursor: default; }
button.on { background: var(--btn-on); color: var(--accent-ink); border-color: var(--btn-on); }
h1 { font-size: 17px; margin: 0; letter-spacing: 0.02em; }
h2 { font-size: 12px; margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.top {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.viewsw { display: none; }
.hbtns { display: flex; gap: 6px; align-items: center; }
.hbtns button { height: 34px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; }
.hbtns button:not(:has(.hb-label:not(:empty))) { width: 34px; padding: 0; justify-content: center; }
.hbtns .hb-label:empty { display: none; }
#btn-more, .hmenu-back, .hbtns .hmenu-ex { display: none; }
.hmenu { display: contents; }
.hsep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
/* Header groups (wide screens): edit | views | panels | settings | Clear, shortcuts. The phone keeps Undo,
   Redo and Flow as icons and lists the rest under More in this same order. */
@media (min-width: 761px) and (min-height: 501px), (min-width: 761px) and (pointer: fine) {
  #btn-undo { order: 1; } #btn-redo { order: 2; } .hsep-edit { order: 3; }
  #btn-schem { order: 4; } #btn-split { order: 5; } #btn-device { order: 6; } .hsep-panels { order: 7; }
  #btn-bench { order: 8; } #btn-learn { order: 9; } .hsep-settings { order: 10; }
  #btn-flow { order: 11; } #btn-damage { order: 12; } .hsep-clear { order: 13; }
  #btn-clear { order: 14; } #btn-keys { order: 15; }
  .hsep-views { display: none; }
}
/* Two kinds of "on": a filled button is the view or panel that shows; a tinted button with an accent
   edge is a setting that is on (Flow, Burn-out, Volts, Autoscroll). */
button.tog.on, .schtools button.tog.on, .schtools button.tog.on:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--btn)); color: var(--ink); border-color: var(--accent);
}
.schtools button.tog.on { box-shadow: inset 0 0 0 1px var(--accent); }

.app {
  display: grid; height: calc(100% - 48px);
  grid-template-columns: var(--pal-w) minmax(0, 1fr) 360px;
  grid-template-areas: "palette stage side";
}
.palette { grid-area: palette; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
.palette button { flex: none; min-width: 0; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0; user-select: none; -webkit-user-select: none; font-size: 13px; }
.palette button svg.ico { width: 40px; height: 24px; overflow: visible; }
/* One fixed icon box and a one-line label, so every label of a row sits level. */
.palette button svg.ico, .palette button .ico-sm { flex: none; }
.palette button .tool-label { flex: none; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette button.on svg.ico .ico-cursor { fill: #fff; }
.ico-cursor { fill: var(--ink); stroke: none; }
.ico-wire { fill: none; stroke: #2b6fd0; stroke-width: 2.6; stroke-linecap: round; }
.ico-wire-end { fill: #8d939a; }
.ico-sm { width: 18px; height: 18px; flex: none; }
.ico-stroke { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pal-fixed { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 10px 0; }
.palette .pal-fixed .needs-sel { height: 36px; flex-direction: row; gap: 5px; }
.pal-find { flex: none; padding: 8px 10px; border-bottom: 1px solid var(--line); }
#pal-search { width: 100%; height: 32px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; min-width: 0; }
.pal-chips { display: none; }
.pal-groups { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 10px; }
.palette .pal-head {
  width: 100%; height: 30px; flex-direction: row; justify-content: flex-start; gap: 4px; padding: 0;
  background: none; border: 0; border-radius: 0; color: var(--muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
.chev { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.12s; }
.pal-group.closed .chev { transform: rotate(-90deg); }
.pal-items { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-bottom: 4px; }
.pal-item { display: grid; min-width: 0; }
.pal-group.closed .pal-items, .pal-item.miss, .pal-group.miss { display: none; }
.pal-none { display: none; padding: 8px 0; font-size: 13px; }
.pal-none.shown { display: block; }

.stage { grid-area: stage; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
#board.space-pan, #board.dragging-view { cursor: grab; }
.zoomctl { flex: none; display: flex; gap: 2px; padding: 0 6px; border-left: 1px solid var(--line); }
.zoomctl button { height: 32px; min-width: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 0; border-radius: 7px; }
.zoomctl button:hover { background: var(--btn); }
.zoomctl .hb-label { display: none; }
.zoomctl.board-zoom { display: none; border-left: 0; border-right: 1px solid var(--line); }
.app.schem-split .zoomctl.board-zoom { display: flex; }
#btn-zoom-pct { width: 58px; font-size: 13px; font-variant-numeric: tabular-nums; }
.app.device-mode .readbar, .app.device-mode #elec { display: none; }
#board { flex: 1; min-height: 0; width: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: var(--bg); }
#board.flash { animation: flash 0.35s; }
@keyframes flash { 0% { background: var(--err-bg); } 100% { background: var(--bg); } }
.readbar { height: 40px; flex: none; display: flex; align-items: center; border-top: 1px solid var(--line); background: var(--panel); }
#readout {
  flex: 1; min-width: 0; height: 100%; padding: 0 16px; display: flex; align-items: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px;
}

.side { grid-area: side; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); overflow-y: auto; }
.panel { padding: 12px 16px; border-bottom: 1px solid var(--line); flex: none; }
#project { flex: none; }
#project .proj-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#project .proj-row .pick-btn { grid-column: 1 / -1; padding: 0 8px 0 10px; }
#project .proj-row button { padding: 0; }
#inspector { height: 172px; overflow: hidden; }
#inspector .row + .row { margin-top: 6px; }
#elec { height: 150px; flex: none; overflow-y: auto; }
/* Inspector and Electrical: the selected part. Wide screens give each a fixed slot; the phone gives
   the pair one fixed slot, Electrical right under the inspector's rows so its values show without
   scrolling. */
.sel-group { display: contents; }
.app.device-mode .sel-group { display: none; }
.ekv { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 10px; font-size: 13px; align-items: baseline; }
.ekv.col2 { grid-template-columns: auto 1fr; }
.ek { color: var(--muted); white-space: nowrap; }
.ev { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ev.bad { color: var(--err); font-weight: 600; }
.meter { height: 6px; margin-top: 10px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); }
.meter.bad .meter-fill { background: var(--err); }
.elec-split { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.iv { flex: none; display: block; overflow: visible; }
.iv-axis { fill: none; stroke: var(--muted); stroke-width: 1; }
.iv-max { stroke: var(--err); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.iv-curve { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.iv-t { font-size: 9px; fill: var(--muted); }
.iv-op { fill: var(--accent); stroke: var(--panel); stroke-width: 1.5; }
table.pins { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 12px; }
table.pins th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 4px; border-bottom: 1px solid var(--line); }
table.pins td { padding: 2px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.pins .num { text-align: right; }
#warnings { flex: 0 0 132px; overflow-y: auto; }
#nets { flex: 1 0 140px; overflow-y: auto; border-bottom: 0; }
.muted { color: var(--muted); margin: 0; }
.insp-head { margin: 0 0 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; gap: 8px; align-items: center; }
.row button { height: 34px; padding: 0 14px; }
.row.bends button { flex: 1; padding: 0 6px; white-space: nowrap; min-width: 0; }
.row select, .row input { height: 34px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; min-width: 0; }
.row select, .row .pick-btn { flex: 1; }
.row input { width: 110px; }
.row input.bad { border-color: var(--err); }
.swatches { gap: 6px; }
.swatch { width: 34px; height: 34px; padding: 0 !important; background: var(--sw) !important; border: 2px solid var(--line); }
.swatch.on { outline: 2px solid var(--accent); outline-offset: 2px; }

.gpio-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.gpio-btn { height: 40px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.gpio-name { font-size: 11px; color: var(--muted); }
.gpio-mode { font-size: 12px; font-weight: 600; }
#firmware { flex: none; }
#firmware .row { margin-bottom: 6px; }
#firmware .fw-ctl { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin-bottom: 6px; }
#firmware .fw-ctl button { min-width: 0; padding: 0; }
.fw-stat { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: nowrap; }
#fw-time { width: 68px; text-align: right; margin-left: auto; }
#fw-speed { width: 52px; text-align: right; }
#fw-status { height: 16px; line-height: 16px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.gpio-btn.fw:disabled { opacity: 1; cursor: default; }
.gpio-btn.fw[data-mode="input"] { background: transparent; border-color: transparent; }
.gpio-btn[data-mode="pwm"] { background: #cdeccb; border-color: #4aa85a; color: #1b4a22; }
.gpio-btn[data-mode="pwm"] .gpio-name { color: #2d6a38; }
.gpio-btn[data-mode="high"] { background: #fde2a7; border-color: #e0a400; color: #5a3d00; }
.gpio-btn[data-mode="high"] .gpio-name { color: #7a5a10; }
.gpio-btn[data-mode="low"] { background: #cfe0f6; border-color: #5b8fd6; color: #12325c; }
.gpio-btn[data-mode="low"] .gpio-name { color: #2b4f80; }
/* Dark: the same hues, dimmed, so a driven pin does not glare. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gpio-btn[data-mode="pwm"] { background: #1f3d25; border-color: #3f9a55; color: #bfeac6; }
  :root:not([data-theme="light"]) .gpio-btn[data-mode="pwm"] .gpio-name { color: #8fcf9c; }
  :root:not([data-theme="light"]) .gpio-btn[data-mode="high"] { background: #43340f; border-color: #c99512; color: #ffe3a3; }
  :root:not([data-theme="light"]) .gpio-btn[data-mode="high"] .gpio-name { color: #e3c57a; }
  :root:not([data-theme="light"]) .gpio-btn[data-mode="low"] { background: #1c2e4a; border-color: #4f80c4; color: #cfe0f6; }
  :root:not([data-theme="light"]) .gpio-btn[data-mode="low"] .gpio-name { color: #9dbbe3; }
}
:root[data-theme="dark"] .gpio-btn[data-mode="pwm"] { background: #1f3d25; border-color: #3f9a55; color: #bfeac6; }
:root[data-theme="dark"] .gpio-btn[data-mode="pwm"] .gpio-name { color: #8fcf9c; }
:root[data-theme="dark"] .gpio-btn[data-mode="high"] { background: #43340f; border-color: #c99512; color: #ffe3a3; }
:root[data-theme="dark"] .gpio-btn[data-mode="high"] .gpio-name { color: #e3c57a; }
:root[data-theme="dark"] .gpio-btn[data-mode="low"] { background: #1c2e4a; border-color: #4f80c4; color: #cfe0f6; }
:root[data-theme="dark"] .gpio-btn[data-mode="low"] .gpio-name { color: #9dbbe3; }

.warn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.warn-list li { padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.warn-notes { margin-top: 12px; }
.warn-list li.error { background: var(--err-bg); border-left: 3px solid var(--err); }
.warn-list li.warn { background: var(--warn-bg); border-left: 3px solid var(--warn); }
.warn-list li.info { background: var(--info-bg); border-left: 3px solid var(--accent); }

table.nets { width: 100%; border-collapse: collapse; font-size: 12px; }
table.nets td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.nets td:first-child { font-weight: 600; white-space: nowrap; }
table.nets td.num { white-space: nowrap; text-align: right; }
table.nets tr.quiet { color: var(--muted); }

/* ---- board drawing (fixed physical colours) ---- */
.bb { stroke: #d6cfbf; stroke-width: 0.6; }
.bb-shadow { fill: rgba(40, 30, 10, 0.10); }
.bb-groove { stroke: #e2dccd; stroke-width: 0.8; }
.gap { stroke: #d5cebe; stroke-width: 0.3; }
.tp-rim { fill: #cfc8b9; }
.tp-hole { fill: #2e2c29; }
.tp-lip { fill: #6a655c; opacity: 0.55; }
.rail-plus { stroke: #d8343a; stroke-width: 0.9; }
.rail-minus { stroke: #2f62c4; stroke-width: 0.9; }
.rail-label { font-size: 7px; font-weight: 700; text-anchor: middle; }
.rail-plus-t { fill: #d8343a; }
.rail-minus-t { fill: #2f62c4; }
.col-label, .row-label { font-size: 3.4px; text-anchor: middle; fill: #a39a87; font-weight: 600; }
.mod-shadow { fill: rgba(0, 0, 0, 0.22); }
.mod-pcb { stroke: #0d0e10; stroke-width: 0.5; }
.mod-edge { fill: none; stroke: #3a4048; stroke-width: 0.4; }
.usb { stroke: #6f757c; stroke-width: 0.45; }
.usb-mouth { fill: #3c4046; }
.usb-seam { stroke: #9ba1a8; stroke-width: 0.4; }
.qfn-pin { fill: #c8ccd1; }
.chip { stroke: #111; stroke-width: 0.3; }
.chip-dot { fill: #55585d; }
.chip-label { font-size: 2.5px; fill: #c9ccd0; text-anchor: middle; font-weight: 600; letter-spacing: 0.05px; }
.chip-sub { font-size: 2.1px; fill: #8d9095; text-anchor: middle; }
.xtal { stroke: #7d838a; stroke-width: 0.35; }
.sw-body { fill: #d5d8dc; stroke: #8a9097; stroke-width: 0.35; }
.sw-nub { fill: #26282c; }
.ldo { fill: #2a2b2e; stroke: #111; stroke-width: 0.25; }
.pwr-led { fill: #ff4b3a; }
.smd-c { fill: #b7895a; }
.smd-r { fill: #1e1f22; stroke: #4d5157; stroke-width: 0.25; }
.antenna { fill: #e9e6df; stroke: #9f9a90; stroke-width: 0.3; }
.antenna-cap { fill: #c4c8cd; }
.silk { font-size: 2.6px; fill: #e8ebe8; text-anchor: middle; font-weight: 600; }
.pad { fill: #d6b45a; stroke: #8f7224; stroke-width: 0.35; }
.pad-pin { fill: #e9ecef; stroke: #8d939a; stroke-width: 0.3; }
.pin-label { font-size: 3.3px; fill: #f3f5f3; text-anchor: middle; font-weight: 700; }
.pl-v5, .pl-v3v3 { fill: #ff9b7a; }
.pl-gnd { fill: #b9c3cd; }
/* GPIO drive state on the header pads */
.pin-state { fill: none; stroke-width: 1.3; pointer-events: none; }
.ps-high { stroke: #ff5a36; fill: rgba(255, 90, 54, 0.35); }
.ps-low { stroke: #3d7bff; fill: rgba(61, 123, 255, 0.28); }
.ps-pwm { stroke: #39c46a; fill: rgba(57, 196, 106, 0.3); stroke-dasharray: 2 1.2; }
.pin-state.hot { animation: hot 0.9s ease-in-out infinite; }
@keyframes hot { 50% { stroke: #ff2020; stroke-width: 2.2; } }

/* highlights */
.hl { fill: rgba(24, 160, 255, 0.16); stroke: #18a0ff; stroke-width: 0.7; }
.hl-ring { fill: none; stroke: #18a0ff; stroke-width: 1.1; }
.hl-wire { fill: none; stroke: rgba(24, 160, 255, 0.45); stroke-width: 5; stroke-linecap: round; }
.halo-hover, .halo-sel { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
line.halo-hover, line.halo-sel { stroke-width: 11; }
rect.halo-hover, rect.halo-sel, circle.halo-hover, circle.halo-sel { stroke-width: 3; }
.halo-wire { stroke-width: 5.5; }
.halo-hover { stroke: rgba(24, 160, 255, 0.22); }
rect.halo-hover, circle.halo-hover { fill: rgba(24, 160, 255, 0.12); }
.halo-sel { stroke: rgba(24, 160, 255, 0.42); }
rect.halo-sel, circle.halo-sel { fill: rgba(24, 160, 255, 0.18); }

/* part leads */
.lead { stroke: #8f959c; stroke-width: 1.05; stroke-linecap: round; }
.lead-hi { stroke: #e7eaed; stroke-width: 0.35; stroke-linecap: round; pointer-events: none; }
.leg-end { fill: #6b7076; }
.leg-bend { fill: #d6dade; }
.shine { pointer-events: none; }
/* resistor */
.res-body { fill: #dcbd86; stroke: #9b7a45; stroke-width: 0.35; }
.res-body.res-mf { fill: #6f9fd0; stroke: #3f6a96; }
/* LED */
.led-body { stroke-width: 0.5; }
.led-anvil { fill: rgba(40, 40, 40, 0.45); }
.led-bond { fill: none; stroke: rgba(40, 40, 40, 0.5); stroke-width: 0.3; }
.anode-mark { font-size: 4.2px; font-weight: 700; fill: #6b5b4a; text-anchor: middle; }
.glow, .led-lit { pointer-events: none; }
.scorch { fill: rgba(60, 30, 10, 0.55); pointer-events: none; }
.puff { fill: rgba(120, 120, 120, 0.55); animation: puff 1.8s linear infinite; pointer-events: none; }
@keyframes puff { 0% { transform: translateY(0) scale(0.6); opacity: 0.8; } 100% { transform: translateY(-12px) scale(1.6); opacity: 0; } }
.stress { stroke: rgba(255, 40, 40, 0.55); stroke-width: 9; stroke-linecap: round; fill: none; pointer-events: none; animation: stress 0.9s ease-in-out infinite; }
@keyframes stress { 50% { stroke: rgba(255, 40, 40, 0.15); stroke-width: 12; } }
/* burn-out: charred body, soot, one-shot smoke */
.part.burnt { filter: grayscale(0.85) brightness(0.45) sepia(0.35); }
.soot { fill: rgba(25, 18, 12, 0.7); pointer-events: none; }
.pin-burnt { fill: rgba(25, 18, 12, 0.85); stroke: #6b2a10; stroke-width: 0.8; }
.burn-flash { fill: rgba(255, 190, 60, 0.85); pointer-events: none; transform-box: fill-box; transform-origin: center; animation: burn-flash 0.5s ease-out forwards; }
@keyframes burn-flash { 0% { transform: scale(0.4); opacity: 1; } 100% { transform: scale(2.4); opacity: 0; } }
.burn-puff { fill: rgba(95, 95, 95, 0.7); pointer-events: none; transform-box: fill-box; transform-origin: center; opacity: 0; animation: burn-puff 2.4s ease-out forwards; }
.burn-puff.p2 { animation-duration: 2.1s; }
.burn-puff.p3 { animation-duration: 1.8s; }
@keyframes burn-puff { 0% { transform: translateY(0) scale(0.5); opacity: 0.9; } 100% { transform: translateY(-26px) scale(2.6); opacity: 0; } }
.burnt-row { align-items: center; gap: 8px; }
.burnt-tag { color: var(--err); font-weight: 600; }
.warn-repair { margin-left: 8px; padding: 2px 10px; font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .burn-flash, .burn-puff { animation: none; opacity: 0; } }
/* diodes */
.dio-glass { fill: rgba(214, 112, 52, 0.82); stroke: #8a4419; stroke-width: 0.35; }
.dio-core { fill: rgba(70, 40, 20, 0.45); pointer-events: none; }
.dio-band { fill: #1b1b1b; }
.dio-epoxy { fill: #262626; stroke: #0d0d0d; stroke-width: 0.4; }
.dio-band-grey { fill: #b8bcc2; }
/* servo */
.sv-plug { fill: #1d1d1d; stroke: #000; stroke-width: 0.4; }
.sv-pin { fill: #c9a24a; }
.sv-wire { fill: none; stroke-width: 2.4; stroke-linecap: round; }
.sv-tab, .sv-case { fill: #2a63b8; stroke: #17407e; stroke-width: 0.5; }
.sv-tab { fill: #2559a6; }
.sv-case { fill-opacity: 0.96; }
.sv-dome { fill: #3a74c8; stroke: #17407e; stroke-width: 0.4; }
.sv-hole { fill: rgba(0, 0, 0, 0.45); }
.sv-label { font-size: 6px; font-weight: 700; fill: #e8eef8; text-anchor: middle; pointer-events: none; }
.sv-horn { fill: #f4f4f0; stroke: #a8a8a0; stroke-width: 0.5; }
.ws-pcb { fill: #1b1b1f; stroke: #000; stroke-width: 0.5; }
.ws-hdr { fill: #1d1d1d; stroke: #000; stroke-width: 0.4; }
.ws-pin { fill: #c9a24a; }
.ws-pkg { fill: #f1f0ea; stroke: #b9b7ad; stroke-width: 0.4; }
.ws-lens { fill: #fbfaf5; stroke: #d8d6cc; stroke-width: 0.3; }
.ws-die { fill: #8c8a80; }
.ws-label { font-size: 4.2px; font-weight: 700; fill: #d9d9de; text-anchor: middle; pointer-events: none; }
.ws-glow { filter: blur(2.2px); pointer-events: none; }
.ws-lit { pointer-events: none; }
.sv-screw { fill: #b9bec4; stroke: #6b7076; stroke-width: 0.4; }
/* capacitors */
.cap-disc { stroke: #8a4a14; stroke-width: 0.4; }
.cap-code { font-size: 2.9px; font-weight: 700; fill: #4a2508; text-anchor: middle; pointer-events: none; }
.cap-can { fill: #1f3463; stroke: #0f1c3a; stroke-width: 0.5; }
.cap-stripe { fill: #c9d3e6; }
.cap-top { stroke: #7d848c; stroke-width: 0.3; }
.cap-vent { stroke: #7e858d; stroke-width: 0.5; fill: none; }
.cap-minus { font-size: 4.4px; font-weight: 700; fill: #1f3463; text-anchor: middle; }
.cap-plus { font-size: 4.4px; font-weight: 700; fill: #6b5b4a; text-anchor: middle; }
/* tactile switch */
.btn-body { fill: #1d1e21; stroke: #08090a; stroke-width: 0.5; }
.btn-plate { stroke: #7d838a; stroke-width: 0.3; }
.btn-rivet { fill: #6f757c; stroke: #e3e6e9; stroke-width: 0.25; }
.btn-collar { fill: #2a2b2e; }
.btn-cap { stroke: #000; stroke-width: 0.5; }
.btn-cap.btn-down { stroke: #18a0ff; stroke-width: 0.8; }
.btn-shine { fill: rgba(255, 255, 255, 0.28); pointer-events: none; }
/* potentiometer */
.pot-body { fill: #24589e; stroke: #143766; stroke-width: 0.5; }
.pot-foot { fill: #1a4073; }
.pot-tick { stroke: #dfe7f2; stroke-width: 0.45; stroke-linecap: round; }
.pot-knob-rim { fill: #15181c; }
.pot-knob { fill: #2c3036; }
.pot-knurl { fill: none; stroke: #4a5059; stroke-width: 1; stroke-dasharray: 0.7 0.7; }
.pot-pointer { stroke: #f4f4f2; stroke-width: 1.3; stroke-linecap: round; }
.pot-mark { font-size: 3.2px; font-weight: 700; fill: #dfe7f2; text-anchor: middle; pointer-events: none; }
/* LDR */
.ldr-disc { fill: #f3ead2; stroke: #b19a63; stroke-width: 0.45; }
.ldr-face { fill: #ece2c2; }
.ldr-comb { stroke: #c7cbd0; stroke-width: 1.6; fill: none; }
.ldr-track { fill: none; stroke-width: 0.75; stroke-linejoin: round; }
/* NTC bead */
.ntc-bead { fill: #1d1f24; stroke: #000; stroke-width: 0.35; }
.ntc-tint { pointer-events: none; mix-blend-mode: screen; }
.ntc-mark { font-size: 2.2px; font-weight: 700; fill: #9aa1aa; text-anchor: middle; pointer-events: none; }
/* RGB LED */
.bo-pcb.oled-pcb { fill: #1f3f8a; stroke: #12285c; }
.bo-pcb.bme-pcb { fill: #5b2a86; }
.mod-pad { fill: #d9b25c; stroke: #8a6a26; stroke-width: 0.4; }
.mod-pin { fill: #8d939a; }
.mod-hole { fill: #0d0f12; stroke: #c7cbd1; stroke-width: 0.8; }
.mod-label { font-size: 2.6px; font-weight: 600; fill: #e8ecf2; text-anchor: middle; pointer-events: none; }
.mod-smd { fill: #2a2420; stroke: #c9c2b0; stroke-width: 0.3; }
.mpu-led { fill: #3fbf5a; stroke: #1d5e2b; stroke-width: 0.3; }
.mpu-axis { fill: none; stroke: #e8e4d8; stroke-width: 0.5; stroke-linecap: round; stroke-linejoin: round; }
.oled-glass { fill: #08090b; stroke: #2c3036; stroke-width: 0.5; }
.oled-aa { fill: #0b0c0f; }
.oled-flex { fill: #c8882a; }
.oled-screen { pointer-events: none; }
.oled-px { shape-rendering: crispEdges; }
.oled-glow { shape-rendering: crispEdges; }
.bme-lid { stroke: #7d838a; stroke-width: 0.3; }
.bme-vent { fill: #22252a; }
.bo-pcb.brk-blue { fill: #1d4f9a; stroke: #12305e; }
.bo-pcb.brk-black { fill: #24262a; stroke: #0d0e10; }
.bo-pcb.brk-green { fill: #1f6b3a; stroke: #124224; }
.bo-pcb.brk-purple { fill: #5b2a86; }
.bo-pcb.pir-pcb { fill: #1f6b3a; stroke: #124224; }
.pir-lens { fill: #f2f0ea; stroke: #c9c5b8; stroke-width: 0.5; }
.pir-facet { fill: none; stroke: #d6d2c6; stroke-width: 0.4; }
.pir-hole { fill: #0d0f12; stroke: #c7cbd1; stroke-width: 0.5; }
.pir-label { fill: #3a3f46; }
.pir-on { fill: none; stroke: #f0a020; stroke-width: 1.6; }
.bo-pcb.ky-pcb { fill: #1d4f9c; stroke: #10305f; }
.ky-label { fill: #e8ecf2; }
.ky-body { fill: #b9bcc0; stroke: #7d8187; stroke-width: 0.5; }
.ky-shaft { fill: #d7d9dc; stroke: #6c7076; stroke-width: 0.6; }
.ky-pointer { stroke: #2b2e33; stroke-width: 1.2; stroke-linecap: round; }
.ky-on { fill: none; stroke: #f0a020; stroke-width: 1.6; }
.bo-pcb.joy-pcb { fill: #1c1d21; stroke: #0b0c0e; }
.joy-label { fill: #e8ecf2; }
.joy-housing { fill: #3a3d42; stroke: #1f2125; stroke-width: 0.5; }
.joy-well { fill: #2a2c30; }
.joy-cap { fill: #4a4d53; stroke: #16171a; stroke-width: 0.8; }
.joy-cap.joy-down { stroke: #f0a020; stroke-width: 1.6; }
.kp-pad { fill: #e9e6df; stroke: #b9b4a8; stroke-width: 0.5; }
.kp-key { fill: #2f6fb3; }
.kp-key.kp-letter { fill: #c0392b; }
.kp-key.kp-held { fill: #13293f; }
.kp-keylabel { fill: #fff; font-size: 4px; text-anchor: middle; font-weight: 600; }
.kp-strand { stroke: #c9c5b8; stroke-width: 0.8; }
.kp-plug { fill: #24262a; }
.kp-label { fill: #3a3f46; }
.kp-grid { display: grid; grid-template-columns: repeat(4, minmax(44px, 1fr)); gap: 6px; max-width: 260px; }
.kp-grid button { min-height: 44px; font-variant-numeric: tabular-nums; }
@media (min-width: 761px) and (min-height: 501px), (min-width: 761px) and (pointer: fine) {
  .kp-grid { gap: 3px; max-width: 200px; }
  .kp-grid button { min-height: 0; height: 24px; padding: 0; }
}
/* TM1637 key matrix: a row label, then SG1-SG8. */
.tm-keys { display: grid; grid-template-columns: 28px repeat(8, minmax(0, 1fr)); gap: 4px; align-items: center; }
.tm-keys .sens-name { min-width: 0; }
.tm-keys button { min-height: 44px; padding: 0; font-variant-numeric: tabular-nums; }
@media (min-width: 761px) and (min-height: 501px), (min-width: 761px) and (pointer: fine) {
  .tm-keys { gap: 3px; }
  .tm-keys button { min-height: 0; height: 26px; }
}
.slide-body { stroke: #6e737a; stroke-width: 0.5; }
.slide-slot { fill: #1d1e21; }
.slide-act { fill: #2b2d31; stroke: #0e0f11; stroke-width: 0.4; }
.slide-mark { fill: #2a2d31; font-size: 3.2px; text-anchor: middle; font-weight: 600; }
.tilt-can { fill: #1f2023; stroke: #0c0d0f; stroke-width: 0.5; }
.tilt-cap { fill: #3a3c41; }
.tilt-cap.tilt-closed { fill: #3a3c41; stroke: #d9a521; stroke-width: 0.7; }
.tilt-ball { stroke: #6e737a; stroke-width: 0.3; }
.chip-leg { fill: #c9ccd0; }
.bh-window { fill: #b9d3e6; stroke: #6d8799; stroke-width: 0.2; }
.rtc-led { fill: #e04a3a; stroke: #6e1d15; stroke-width: 0.3; }
.rtc-cell { fill: none; stroke: rgba(255, 255, 255, 0.28); stroke-width: 0.6; stroke-dasharray: 2 1.4; }
.ky-count { min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.brk-chip { fill: #2b2c30; }
.bo-pcb.epd-pcb { fill: #1c1d21; stroke: #0b0c0e; }
.epd-frame { fill: #b9bcc0; stroke: #8c9096; stroke-width: 0.5; }
.epd-paper { fill: #e8e6df; }
.epd-pin { font-size: 2.2px; }
.epd-screen { pointer-events: none; }
.epd-px { fill: #23252a; shape-rendering: crispEdges; }
.rgb-body { fill: #eef0f2; fill-opacity: 0.8; stroke: #a9afb6; stroke-width: 0.5; }
.rgb-dome { fill: #f7f8f9; fill-opacity: 0.85; }
.rgb-die { stroke: rgba(40, 40, 40, 0.5); stroke-width: 0.2; }
.rgb-halo { mix-blend-mode: normal; }
/* TO-92 transistor */
.to92-body { fill: #202226; stroke: #08090a; stroke-width: 0.45; }
.to92-flat { stroke: #3a3d43; stroke-width: 0.7; }
.to92-type { font-size: 2.6px; font-weight: 700; fill: #b9bec4; text-anchor: middle; pointer-events: none; }
.to92-pin { font-size: 3px; font-weight: 700; fill: #e7eaed; text-anchor: middle; pointer-events: none; }
/* SOT-23 breakout */
.bo-pcb { fill: #5b2c8a; stroke: #3a1a5c; stroke-width: 0.45; }
.bo-trace { fill: none; stroke: #7a4aa8; stroke-width: 1.1; stroke-linejoin: round; }
.bo-pad { fill: #d9b45a; }
.bo-pin { fill: #2b2d31; }
.bo-silk { font-size: 3.2px; font-weight: 700; fill: #f2eefa; text-anchor: middle; pointer-events: none; }
.sot-body { fill: #1b1c1f; stroke: #000; stroke-width: 0.3; }
.sot-leg { fill: #c9ced4; }
.sot-mark { font-size: 2px; fill: #8e949b; text-anchor: middle; pointer-events: none; }
/* buzzer */
.bz-pcb { fill: #1e7a3c; }
.bz-can { fill: #18191c; stroke: #000; stroke-width: 0.5; }
.bz-top { fill: #222428; stroke: #34373c; stroke-width: 0.5; }
.bz-ring { fill: none; stroke: #33363b; stroke-width: 0.8; }
.bz-hole { fill: #050506; }
.bz-plus { font-size: 6px; font-weight: 700; fill: #e7eaed; text-anchor: middle; pointer-events: none; }
.bz-type { font-size: 2.8px; letter-spacing: 0.3px; fill: #6d727a; text-anchor: middle; pointer-events: none; }
.bz-wave { fill: none; stroke: rgba(255, 196, 40, 0.8); stroke-width: 1.2; pointer-events: none; animation: bz-wave 1.2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bz-wave { 0% { transform: scale(1); opacity: 0.9; } 100% { transform: scale(1.45); opacity: 0; } }
.stress-rect { fill: rgba(255, 40, 40, 0.18); stroke: rgba(255, 40, 40, 0.6); stroke-width: 2; pointer-events: none; animation: stress-rect 0.9s ease-in-out infinite; }
@keyframes stress-rect { 50% { stroke: rgba(255, 40, 40, 0.2); fill: rgba(255, 40, 40, 0.06); } }
.btn-pressed-ring { fill: none; stroke: #18a0ff; stroke-width: 1; stroke-dasharray: 2 1.4; pointer-events: none; }
/* wires */
.wire, .wire-edge, .wire-shadow, .wire-hi { fill: none; stroke-linecap: round; }
.wire-shadow { stroke: rgba(0, 0, 0, 0.2); stroke-width: 2.6; }
.wire-edge { stroke-width: 2.5; }
.wire { stroke-width: 1.75; }
.wire-hi { stroke: rgba(255, 255, 255, 0.38); stroke-width: 0.5; pointer-events: none; }
.wire, .wire-edge, .wire-shadow, .wire-hi, .hl-wire, .halo-wire { stroke-linejoin: round; }
/* flat (pre-cut) jumpers lie on the board: thinner, tight shadow */
.flat.wire-shadow { stroke: rgba(0, 0, 0, 0.16); stroke-width: 2.1; }
.flat.wire-edge { stroke-width: 2.1; }
.flat.wire { stroke-width: 1.45; }
.flat.wire-hi { stroke: rgba(255, 255, 255, 0.3); stroke-width: 0.4; }
.wire-pin { stroke: #b9bec4; stroke-width: 1.1; stroke-linecap: round; }
.wire-end { fill: #8d939a; stroke: #5b6167; stroke-width: 0.35; }
.sel.wire-shadow { stroke: rgba(24, 160, 255, 0.5); stroke-width: 4; }
.sel.lead { stroke: #4aa8ff; }
.sel.res-body, .sel.led-body, .sel.cap-disc, .sel.cap-can, .sel.btn-body, .sel.pot-body, .sel.ldr-disc, .sel.ntc-bead, .sel.rgb-body, .sel.to92-body, .sel.bo-pcb, .sel.bz-can, .sel.slide-body, .sel.tilt-can { stroke: #18a0ff; stroke-width: 0.9; }
.moving { opacity: 0.3; }
.handle { fill: rgba(24, 160, 255, 0.25); stroke: #18a0ff; stroke-width: 0.8; cursor: grab; }
/* bend points of the selected wire; "+" on each leg adds one */
.bend { fill: #fff; stroke: #18a0ff; stroke-width: 0.8; cursor: move; }
.bend.on { fill: #18a0ff; }
.bend-add { cursor: copy; }
.bend-add circle { fill: rgba(255, 255, 255, 0.85); stroke: #18a0ff; stroke-width: 0.5; }
.bend-add path { stroke: #18a0ff; stroke-width: 0.5; stroke-linecap: round; }
/* current flow */
.flow { fill: none; stroke: #ffe23a; stroke-width: 1.1; stroke-linecap: round; stroke-dasharray: 0.01 6; pointer-events: none; }
.flow.flow-u { stroke: rgba(30, 20, 0, 0.75); stroke-width: 1.9; }
.flow[data-on="0"], .flow:not([data-on]) { opacity: 0; }
/* ghost and snapping */
.ghost { opacity: 0.6; pointer-events: none; }
.ghost.bad { opacity: 0.75; }
.ghost.bad .lead, .ghost.bad .res-body, .ghost.bad .led-body, .ghost.bad .cap-disc, .ghost.bad .cap-can, .ghost.bad .btn-body,
.ghost.bad .pot-body, .ghost.bad .ldr-disc, .ghost.bad .ntc-bead, .ghost.bad .rgb-body, .ghost.bad .to92-body, .ghost.bad .bo-pcb, .ghost.bad .bz-can, .ghost.bad .slide-body, .ghost.bad .tilt-can { stroke: #e02020; stroke-width: 1; }
.snap { fill: none; stroke-width: 1; pointer-events: none; animation: snap 0.28s ease-out; transform-box: fill-box; transform-origin: center; }
.snap.ok { stroke: #20b35a; fill: rgba(32, 179, 90, 0.18); }
.snap.bad { stroke: #e02020; fill: rgba(224, 32, 32, 0.2); }
@keyframes snap { 0% { transform: scale(1.8); opacity: 0.2; } 100% { transform: scale(1); opacity: 1; } }
/* warnings */
.mark.error { fill: #e02020; }
.mark.warn { fill: #f0a000; }
.mark.info { fill: #18a0ff; }
.mark-text { font-size: 4.2px; font-weight: 700; fill: #fff; text-anchor: middle; pointer-events: none; }
.pin-ring { fill: none; stroke-width: 1; }
.pin-ring.error { stroke: #ff3030; }
.pin-ring.warn { stroke: #ffb000; }
.insp-note { font-size: 12px; margin-top: 6px; }
/* Desktop cursors: with Select, parts and wires can be dragged (a wire by its middle moves both
   ends); a placing tool aims at holes. */
#board { cursor: default; }
#board:not(.select-tool) { cursor: crosshair; }
#board.select-tool .part, #board.select-tool .wire-g { cursor: grab; }
#board.select-tool .part[data-pressed] { cursor: pointer; }
#board.dragging, #board.dragging * { cursor: grabbing !important; }

/* ---- Device view: the display, its buttons and the sensor sliders in place of the board ---- */
.device { display: none; }
.app.device-mode { grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "stage side"; }
.app.device-mode .palette, .app.device-mode #board, .app.device-mode #readout, .app.device-mode #inspector { display: none; }
.app.device-mode #code { left: 0; }
.app.device-mode .device { display: flex; flex: 1; min-height: 0; overflow-y: auto; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 24px; padding: 24px; background: var(--bg); }
.dev-top { display: flex; gap: 16px; align-items: stretch; }
.dev-case { flex: none; background: #1c1d21; border-radius: 18px; padding: 14px; }
#dev-screen { display: block; width: 400px; height: 400px; }
.dev-btns { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.dev-btn { width: 96px; height: 76px; font-size: 16px; font-weight: 600; letter-spacing: 0.04em; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.dev-sliders { width: 440px; display: flex; flex-direction: column; gap: 6px; }




/* Sensor slider (pot wiper, light, temperature): one full-width row; the whole track takes
   pointer and touch drags (touch-action: none), the value column is fixed. */
.sens-slider { align-items: center; }
.sens-slider .sens-name { min-width: 88px; }
.dev-sliders .sens-slider .sens-name { min-width: 100px; }
.sens-slider .sens-val { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.slider { position: relative; flex: 1; height: 36px; touch-action: none; cursor: pointer; user-select: none; -webkit-user-select: none; outline: none; }
.slider-rail { position: absolute; left: 10px; right: 10px; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; background: var(--line); }
.slider-fill { height: 100%; border-radius: 3px; background: var(--accent, #2563eb); }
.slider-thumb { position: absolute; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: #fff; border: 2px solid var(--accent, #2563eb); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); pointer-events: none; }
.slider-rail, .slider-thumb { box-sizing: border-box; }
.slider:focus-visible .slider-thumb { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35); }

/* ---- hover tip (tip.rs): desktop, above the hovered part ---- */
.tip { position: absolute; z-index: 5; transform: translate(-50%, calc(-100% - 6px)); pointer-events: none; white-space: nowrap;
  padding: 3px 8px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }
.tip.below { transform: translate(-50%, 6px); }

/* ---- schematic view (schem.rs): full size, or beside the board on wide screens ---- */
.views { flex: 1; min-height: 0; display: flex; }
.views > svg { flex: 1 1 0; min-width: 0; }
.app.device-mode .views { display: none; }
#schem { display: none; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: var(--bg); cursor: default;
  --s-ink: #1f2937; --s-muted: #6b7280; --s-faint: #a3a8b0; --s-wire: #0b6e4f; --s-pwr: #b91c1c; --s-paper: var(--panel); }
#schem.dragging { cursor: grabbing; }
.app.schem-full #schem, .app.schem-split #schem { display: block; }
.app.schem-full #board { display: none; }
.app.schem-split #schem { border-left: 1px solid var(--line); }
.app.schem-full { grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "stage side"; }
.app.schem-full .palette { display: none; }
/* No palette column: the code dock and the bench start at the left edge (they are placed from --pal-w). */
.app.schem-full { --pal-w: 0px; }
.wide-only { display: none !important; }
@media (min-width: 1280px) { .hbtns .wide-only { display: inline-flex !important; } }
.schtools { display: none; flex: none; gap: 2px; padding: 0 6px; border-left: 1px solid var(--line); }
.schtools.shown { display: flex; }
.schtools button { height: 32px; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 0; border-radius: 7px; font-size: 13px; }
.schtools button:hover:not(:disabled) { background: var(--btn); }
.schtools button.on, .schtools button.on:hover { background: var(--btn-on); color: var(--accent-ink); }
.s-draw path, .s-draw circle, .s-draw rect { fill: none; stroke: var(--s-ink); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.s-draw .fi { fill: var(--s-ink); }
.s-draw .fp { fill: var(--s-paper); }
.s-draw .s-wire { stroke: var(--s-wire); stroke-width: 1.3; }
.s-draw .s-dot { fill: var(--s-wire); stroke: none; }
.s-draw .s-nc { stroke: var(--s-faint); }
.s-draw .s-label path, .s-draw .s-label rect { fill: var(--s-paper); stroke: var(--s-wire); }
.s-draw .s-port path { stroke: var(--s-pwr); }
.s-draw .s-port.gnd path { stroke: var(--s-ink); }
#schem text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; dominant-baseline: central; fill: var(--s-ink); stroke: none; }
#schem .t-ref { font-size: 8px; font-weight: 600; }
#schem .t-val { font-size: 7px; fill: var(--s-muted); }
#schem .t-pin { font-size: 6px; fill: var(--s-muted); }
#schem .t-title { font-size: 8px; font-weight: 600; }
#schem .t-net { font-size: 7px; font-weight: 600; fill: var(--s-wire); }
#schem .s-port .t-net { fill: var(--s-pwr); }
.s-hl { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.28; }
.s-hl-end { fill: var(--accent); opacity: 0.35; }
.s-halo { fill: var(--accent); fill-opacity: 0.06; stroke: var(--accent); stroke-width: 1; stroke-opacity: 0.45; }
.s-halo.sel { fill-opacity: 0.1; stroke-opacity: 0.9; stroke-width: 1.4; }
#schem .s-volt { font-size: 6.5px; font-weight: 600; fill: var(--accent); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #schem { --s-ink: #d4d7dd; --s-muted: #9a9ea6; --s-faint: #5b6069; --s-wire: #4cc38a; --s-pwr: #ff7b72; }
}
:root[data-theme="dark"] #schem { --s-ink: #d4d7dd; --s-muted: #9a9ea6; --s-faint: #5b6069; --s-wire: #4cc38a; --s-pwr: #ff7b72; }
.lcd-tab { fill: #1d6b3a; stroke: #0f3f21; stroke-width: 0.4; }
.lcd-pcb { fill: #237a45; stroke: #12482a; stroke-width: 0.5; }
.lcd-pad { fill: #d9b25c; stroke: #8a6a26; stroke-width: 0.3; }
.lcd-bezel { fill: #111214; stroke: #000; stroke-width: 0.4; }
.lcd-glass { fill: #5f6b2c; }
.lcd-cell { fill: #000; opacity: 0.08; }
.lcd-bl { fill: #b9d43c; pointer-events: none; }
.lcd-ink { fill: #1b2410; pointer-events: none; }
.lcd-live { pointer-events: none; }
.lcd-pinlabel { fill: #e8ecf2; }
.tm-tab { fill: #1f4f8f; stroke: #10305a; stroke-width: 0.4; }
.tm-pcb { fill: #2160a8; stroke: #123a66; stroke-width: 0.5; }
.tm-face { fill: #141416; stroke: #000; stroke-width: 0.4; }
.tm-seg { fill: #2a1c1c; }
.tm-lit { fill: #ff3b30; }
.tm-glow { filter: drop-shadow(0 0 1.2px #ff3b30); }
.tm-live { pointer-events: none; }
.us-tab { fill: #1f4f8f; stroke: #10305a; stroke-width: 0.4; }
.us-pcb { fill: #2366b0; stroke: #123a66; stroke-width: 0.5; }
.us-can { fill: #c9ccd1; stroke: #7d828a; stroke-width: 0.6; }
.us-mesh { fill: #3a3d42; }
.us-weave { stroke: #6b7079; stroke-width: 0.25; }
.us-xtal { fill: #d8dade; stroke: #8a8f97; stroke-width: 0.4; }
.us-silk { fill: #e8eef7; font-size: 2.6px; text-anchor: middle; font-weight: 600; }
.us-live { pointer-events: none; }
.us-dist { fill: #fff; font-size: 5.2px; text-anchor: middle; font-weight: 700; paint-order: stroke; stroke: #123a66; stroke-width: 0.8px; }
.us-ring { fill: none; stroke: #9fd3ff; stroke-width: 0.6; opacity: 0; animation: us-ping 0.6s ease-out 1; }
.us-ring:nth-child(2) { animation-delay: 0.08s; }
.us-ring:nth-child(3) { animation-delay: 0.16s; }
@keyframes us-ping { 0% { opacity: 0.9; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .us-ring { animation: none; } }

/* DHT22 (white) / DHT11 (blue) housings with their vent grille; DS18B20 reading behind the TO-92. */
.dht-body { stroke-width: 0.5; }
.dht-body.dht-22 { fill: #eceef0; stroke: #9aa0a6; }
.dht-body.dht-11 { fill: #2a74c4; stroke: #164a85; }
.dht-slot { fill: #3b3f45; }
.dht-22 ~ .dht-silk { fill: #44494f; }
.dht-silk { fill: #e8eef7; font-size: 3px; text-anchor: middle; font-weight: 700; pointer-events: none; }
.dht-live, .ds-live { pointer-events: none; }
.dht-read, .ds-read { fill: #fff; font-size: 4.2px; text-anchor: middle; font-weight: 700; paint-order: stroke; stroke: #1b1e22; stroke-width: 0.7px; }
.sel.dht-body { stroke: #18a0ff; stroke-width: 0.9; }
.ghost.bad .dht-body { stroke: #e02020; stroke-width: 1; }

/* ---- keyboard shortcuts sheet (keys.rs): desktop, over the page ---- */
.keys-back { display: none; }
.keys-back.open { display: flex; position: fixed; inset: 0; z-index: 40; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.32); }
.keys { width: min(760px, calc(100% - 32px)); max-height: calc(100% - 64px); overflow-y: auto; padding: 16px 20px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); }
.keys-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.keys-head h2 { margin: 0; }
.keys-head button { height: 30px; padding: 0 12px; }
.keys-cols { columns: 2 320px; column-gap: 32px; }
.keys section { break-inside: avoid; margin-bottom: 12px; }
.keys h3 { margin: 0 0 4px; font-size: 13px; }
.keys dl { display: grid; grid-template-columns: 11em 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.keys dt { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink); }
.keys dd { margin: 0; color: var(--muted); }
/* Nothing selected: the inspector says so once; the Electrical slot stays blank, heading included. */
#elec:has(.elec-body:empty) h2 { visibility: hidden; }
.bo-pcb.relay-pcb { fill: #1d4f9c; stroke: #10305f; }
.relay-label { fill: #e8ecf2; }
.relay-cube { fill: #2a6fd6; stroke: #174a99; stroke-width: 0.6; }
.relay-print { fill: #e8ecf2; font-size: 3.2px; text-anchor: middle; dominant-baseline: middle; }
.relay-term { fill: #2f8f4e; stroke: #1b5a30; stroke-width: 0.5; }
.relay-screw { fill: #c9ccd1; stroke: #7d8187; stroke-width: 0.4; }
.relay-led { fill: #7a1d1d; }
.relay-led-on { fill: #ff3a2a; opacity: 0.85; }
.relay-arm { stroke: #f2f4f7; stroke-width: 1.1; stroke-linecap: round; fill: none; }
.relay-pivot { fill: #f2f4f7; }
.relay-cover { fill: #1d4f9c; }
.bo-pcb.l298-pcb { fill: #b3262b; stroke: #6e1418; }
.l298-label { fill: #f3e9e9; }
.l298-sink { fill: #1d1f23; stroke: #000; stroke-width: 0.5; }
.l298-fin { stroke: #4a4e55; stroke-width: 1.2; }
.l298-print { fill: #f3e9e9; font-size: 4px; text-anchor: middle; dominant-baseline: middle; }
.l298-reg { fill: #2b2d31; }
.motor-body { fill: #f2c230; stroke: #a37d0c; stroke-width: 0.6; }
.motor-hub { fill: #f4f4f1; stroke: #a9a9a2; stroke-width: 0.5; }
.motor-shaft { fill: #d8d8d2; stroke: #8f8f88; stroke-width: 0.4; }
.motor-spoke { fill: #3a3d42; }
.motor-lead { stroke: #c9ccd1; stroke-width: 0.9; }
.motor-label { fill: #3a3d42; }
.bo-pcb.stepper-pcb { fill: #2f7d4a; stroke: #1b4f2d; }
.stepper-label { fill: #eef5ef; }
.stepper-print { fill: #eef5ef; font-size: 3px; text-anchor: middle; dominant-baseline: middle; }
.stepper-ic { fill: #26282c; }
.stepper-ic-print { fill: #d6d8dc; font-size: 3px; text-anchor: middle; dominant-baseline: middle; }
.stepper-socket { fill: #f1efe6; stroke: #b9b5a4; stroke-width: 0.5; }
.stepper-cable { fill: none; stroke: #4b6fd1; stroke-width: 2.4; stroke-linecap: round; }
.stepper-can { fill: #c7cbd1; stroke: #7f858d; stroke-width: 0.7; }
.stepper-boss { fill: #d8dbe0; stroke: #8f949b; stroke-width: 0.5; }
.stepper-shaft { fill: #f1d36b; stroke: #a58a2c; stroke-width: 0.4; }
.stepper-pointer { fill: #d23b2c; }
.bo-pcb.matrix-pcb { fill: #b52a2a; stroke: #7a1717; }
.matrix-label { fill: #f6e7e7; }
.matrix-body { fill: #1b1b1d; stroke: #000; stroke-width: 0.5; }
.matrix-dot { fill: #3a2626; }
.matrix-on { fill: #ff3b2e; }
.bo-pcb.tft-pcb { fill: #1f4f9a; stroke: #12305f; }
.tft-label { fill: #e8eefa; }
.tft-bezel { fill: #121316; }
.tft-glass { fill: #08090b; }
.tft-pic { image-rendering: pixelated; }
.tft-dim { fill: #000; pointer-events: none; }
.ir-body { fill: #1b1c1f; stroke: #000; stroke-width: 0.4; }
.ir-lens { fill: #2b2d33; stroke: #0c0c0e; stroke-width: 0.3; }
.ir-on { fill: #ff3b3b; opacity: 0.55; pointer-events: none; }
.kp-grid.ir-grid { grid-template-columns: repeat(3, minmax(44px, 1fr)); }
.kp-grid.ir-grid #insp-ir-0 { grid-column: 2; }
.kp-grid.ir-grid #insp-ir-hold { grid-column: 3; }
.bo-pcb.hx-pcb { fill: #1f6b3a; stroke: #12401f; }
.hx-label { fill: #e8f5ea; }
.hx-chip { fill: #18191b; }
.hx-bar { fill: #b9bec5; stroke: #80868e; stroke-width: 0.4; }
.hx-gauge { fill: #e0c06a; stroke: #9c8540; stroke-width: 0.3; }
.hx-wire { fill: none; stroke-width: 0.9; stroke-linecap: round; }
.hx-load { fill: none; stroke: #c0392b; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }

/* ---- list picker (picker.rs): Examples and Firmware. Desktop: a panel under its button, placed by
   picker.rs (--pl/--pt/--pw/--ph); phone: a bottom sheet. ---- */
.pick-btn { display: flex; align-items: center; gap: 6px; height: 34px; min-width: 0; padding: 0 8px 0 10px; text-align: left; background: var(--bg); }
.pick-btn-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-chev { flex: none; width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pick-btn[aria-expanded="true"] { border-color: var(--accent); }
@media (hover: hover) { .pick-btn:hover { border-color: var(--muted); } }
.pick-back { display: none; position: fixed; inset: 0; z-index: 70; }
.pick-back.open { display: block; }
.pick-pop {
  display: none; position: fixed; z-index: 71; left: var(--pl); top: var(--pt); width: var(--pw); height: var(--ph);
  flex-direction: column; overflow: hidden; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}
.pick-pop.open { display: flex; }
.pick-title, .pick-foot { display: none; }
.pick-find { flex: none; height: 32px; margin: 8px; padding: 0 8px; min-width: 0; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.pick-find:focus { outline: none; border-color: var(--accent); }
.pick-list { flex: 1; min-height: 0; position: relative; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
.pick-head {
  position: sticky; top: 0; z-index: 1; padding: 8px 12px 4px; background: var(--panel);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.pick-row { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 8px; padding: 5px 12px; cursor: pointer; }
.pick-row.act { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.pick-ck { grid-row: 1 / span 2; align-self: center; width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.pick-row[aria-selected="true"] .pick-ck { visibility: visible; }
.pick-row[aria-selected="true"] .pick-t { font-weight: 600; }
.pick-t, .pick-d { grid-column: 2; }
.pick-d { font-size: 12px; color: var(--muted); }
.pick-row.miss, .pick-group.miss { display: none; }
.pick-none { display: none; padding: 12px; color: var(--muted); }
.pick-none.shown { display: block; }
/* Notice at the bottom of the page (project.rs `toast_view`): over the page, so nothing moves. */
.toast {
  position: fixed; left: 50%; bottom: 56px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 32px));
  padding: 8px 8px 8px 14px; font-size: 13px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}
.toast.error { border-color: var(--err); }
.toast { min-width: min(280px, calc(100vw - 32px)); }
.toast-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast button { height: 32px; padding: 0 12px; flex: none; }
.toast .toast-x { padding: 0; width: 32px; font-size: 18px; line-height: 1; }
@media (pointer: coarse) { .toast button { height: 44px; min-width: 44px; } }

/* Challenge panel: in-page confirm buttons keep their full labels on their own row. */
.learn-confirm { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 0 100%; }
.learn-confirm-q { flex: 1 0 100%; }
.learn-confirm button { flex: none; white-space: nowrap; }

/* Desktop: the firmware status line may take a second line instead of cutting its text. */
@media (min-width: 761px) and (min-height: 501px), (min-width: 761px) and (pointer: fine) {
  #fw-status { height: auto; min-height: 32px; white-space: normal; overflow: visible; text-overflow: clip; }
}
