/*
 * Colors follow IoT Platform and MQTT Client: two styles (Standard, FILKOM) x two modes
 * (light, dark), selected by <html data-ui="standard|filkom" data-theme="light|dark">
 * (set by theme.js). Everything below uses these variables; the board, parts and console keep
 * their own realistic colors.
 */

/* ---------- Standard, light (IoT Platform palette) ---------- */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e4e7ec;
  --text: #1d2433;
  --muted: #667085;
  --accent: #2a78d6;
  --accent-line: var(--accent);
  --accent-soft: rgba(42, 120, 214, 0.1);
  --accent-text: #ffffff;
  --btn-bg: var(--accent);
  --btn-fg: #ffffff;
  --btn-hover: #1f63b5;
  --code-bg: #fbfcfd;
  --console-bg: #0f1419;
  --console-text: #d6dde4;
  --ok: #1a7f37;
  --warn: #9a6700;
  --err: #cf222e;
  --led-off: #5b1a1a;
  --led-on: #ff3b30;
  --wire-gnd: #24292f;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --heading-weight: 600;
  --heading: var(--text);
  --pane-border: var(--border);
  --pane-shadow: none;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* top bar (names as in IoT Platform static/css/app.css) */
  --ui-bar-bg: var(--panel);
  --ui-bar-fg: var(--text);
  --ui-bar-muted: var(--muted);
  --ui-bar-line: var(--border);
  --ui-bar-line-w: 1px;
  --ui-bar-ctl-border: var(--border);
  --ui-bar-ctl-bg: var(--panel);
  --ui-bar-switch-bg: #f8f9fb;
  --ui-active-bg: var(--accent-soft);
  --ui-active-fg: var(--accent);
  --ui-bar-ok: var(--ok);
  --ui-bar-err: var(--err);
  --ui-logo-bg: #2a78d6;
  --ui-logo-fg: #ffffff;
  color-scheme: light;
}

/* ---------- Standard, dark ---------- */
html[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #171a20;
  --border: #2a2f38;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --btn-hover: #5b9dec;
  --code-bg: #121418;
  --console-bg: #0a0c10;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --wire-gnd: #9198a1;
  --ui-bar-switch-bg: #1d2128;
  color-scheme: dark;
}

/* ---------- FILKOM, light (FILKOM Apps: slate #232E40 bar, orange #FB9337, Roboto) ---------- */
html[data-ui="filkom"] {
  --fk-header: #232e40;
  --fk-title-bar: #2d3a50;
  --fk-orange: #fb9337;

  --bg: #d8dce3;
  --panel: #ffffff;
  --border: #d3d8e0;
  --text: #2b3445;
  --muted: #5f6b80;
  --accent: #b85d0f;           /* orange for text on white (contrast ~4.6:1) */
  --accent-line: var(--fk-orange);
  --accent-soft: rgba(251, 147, 55, 0.16);
  --btn-bg: var(--fk-orange);  /* the Run button sits on the slate bar */
  --btn-fg: var(--fk-header);
  --btn-hover: #ffa75a;
  --code-bg: #f7f8fa;
  --font: Roboto, "Helvetica Neue", Arial, sans-serif;
  --heading-weight: 500;
  --heading: #32415a;
  --pane-border: transparent;
  --pane-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);

  --ui-bar-bg: var(--fk-header);
  --ui-bar-fg: #ffffff;
  --ui-bar-muted: rgba(255, 255, 255, 0.72);
  --ui-bar-line: var(--fk-title-bar);
  --ui-bar-line-w: 6px;
  --ui-bar-ctl-border: rgba(255, 255, 255, 0.2);
  --ui-bar-ctl-bg: rgba(255, 255, 255, 0.06);
  --ui-bar-switch-bg: rgba(255, 255, 255, 0.06);
  --ui-active-bg: rgba(251, 147, 55, 0.18);
  --ui-active-fg: var(--fk-orange);
  --ui-bar-ok: #4ade80;
  --ui-bar-err: #ff8a80;
  --ui-logo-bg: var(--fk-orange);
  --ui-logo-fg: var(--fk-header);
}

/* ---------- FILKOM, dark ---------- */
html[data-ui="filkom"][data-theme="dark"] {
  --fk-header: #1a2230;

  --bg: #141b26;
  --panel: #1f2938;
  --border: #314057;
  --text: #dbe1ea;
  --muted: #a3adbf;
  --accent: var(--fk-orange);
  --code-bg: #18202d;
  --console-bg: #0f141c;
  --heading: #e3e8f0;
  --pane-border: var(--border);
  --pane-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  --ui-bar-switch-bg: rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
  display: flex;
  flex-direction: column;
}
button, select, input, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-fg); }
button.primary:hover:not(:disabled) { background: var(--btn-hover); border-color: var(--btn-hover); }
select, input {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 6px;
  padding: 4px 8px;
}
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 16px;
  color: var(--ui-bar-fg);
  background: var(--ui-bar-bg);
  border-bottom: var(--ui-bar-line-w) solid var(--ui-bar-line);
}
.topbar button:not(.primary), .topbar select {
  color: var(--ui-bar-fg);
  background: var(--ui-bar-ctl-bg);
  border-color: var(--ui-bar-ctl-border);
}
.topbar button:not(.primary):hover:not(:disabled) { border-color: var(--ui-active-fg); }
.topbar select option { color: var(--text); background: var(--panel); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ui-logo { flex: none; display: block; }
.ui-logo-bg { fill: var(--ui-logo-bg); }
.ui-logo-fg { stroke: var(--ui-logo-fg); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; }
html[data-ui="filkom"] .brand-name { text-transform: uppercase; letter-spacing: 0.1em; font-size: 15px; }
.brand-sub {
  font-size: 10px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ui-bar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.topbar .field { color: var(--ui-bar-muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status { margin-left: auto; color: var(--ui-bar-muted); }
.status.ok { color: var(--ui-bar-ok); }
.status.err { color: var(--ui-bar-err); }

/* style and color-mode switches (theme.js), shaped like IoT Platform's */
.ui-switches { display: flex; align-items: center; gap: 6px; }
.ui-switches[hidden] { display: none; }
.switch {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid var(--ui-bar-ctl-border);
  background: var(--ui-bar-switch-bg);
}
.topbar .switch button {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ui-bar-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}
.topbar .switch button:hover { color: var(--ui-bar-fg); }
.topbar .switch button.active { color: var(--ui-active-fg); background: var(--ui-active-bg); }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  /* editor | splitter | board + serial; --editor-width is set by dragging the splitter (layout.js).
     The right column is 1fr: a total below 1fr would leave part of the free width empty. */
  grid-template-columns: minmax(320px, var(--editor-width, 1.625fr)) 10px minmax(300px, 1fr);
  /* board | serial monitor | what is left when both are folded */
  grid-template-rows: minmax(0, 1fr) minmax(200px, 0.75fr) 0;
  gap: 0;
  padding: 10px;
}
.layout.io-folded { grid-template-rows: minmax(0, 1fr) auto 0; }
.layout.board-folded { grid-template-rows: auto minmax(0, 1fr) 0; }
.layout.board-folded.io-folded { grid-template-rows: auto auto minmax(0, 1fr); }
.layout > .editor-pane { grid-column: 1; grid-row: 1 / -1; }
.layout > .splitter { grid-column: 2; grid-row: 1 / -1; }
.layout > .board-pane { grid-column: 3; grid-row: 1; }
.layout > .io-pane { grid-column: 3; grid-row: 2; margin-top: 10px; }
.board-pane.folded > :not(.pane-title) { display: none; }
.board-pane.folded > .pane-title { border-bottom: 0; }
.splitter { cursor: col-resize; position: relative; touch-action: none; border-radius: 4px; }
.splitter::after { content: ''; position: absolute; top: 50%; left: 3px; width: 4px; height: 40px; margin-top: -20px; border-radius: 2px; background: var(--border); }
.splitter:hover::after, .splitter:focus-visible::after, .splitter.dragging::after { background: var(--accent, #2f81f7); height: 64px; margin-top: -32px; }
.splitter:focus-visible { outline: none; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing .monaco { pointer-events: none; }
/* fold buttons of the parts list and the serial monitor */
.fold { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; padding: 2px 4px; display: inline-flex; align-items: center; gap: 4px; }
.fold-icon { display: inline-block; transition: transform 0.15s; }
.fold[aria-expanded='false'] .fold-icon { transform: rotate(-90deg); }
.fold.unread::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent, #2f81f7); }
.io-pane.folded .tab-body { display: none; }
.io-pane.folded .tabs { border-bottom: 0; }
.pane {
  background: var(--panel);
  border: 1px solid var(--pane-border);
  box-shadow: var(--pane-shadow);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.editor-pane { grid-row: 1 / span 2; }
.board-pane { overflow: auto; }
.pane-title {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: var(--heading-weight);
  color: var(--heading);
  display: flex;
  gap: 8px;
  align-items: center;
}

.monaco { flex: 1; min-height: 0; }
.editor { flex: 1; display: flex; min-height: 0; background: var(--code-bg); }
.gutter, #code {
  font: 13px/20px var(--mono);
  margin: 0;
  padding: 8px 0;
  tab-size: 2;
}
.gutter {
  width: 48px;
  text-align: right;
  padding-right: 8px;
  color: var(--muted);
  overflow: hidden;
  user-select: none;
  border-right: 1px solid var(--border);
}
.gutter .err { color: var(--err); font-weight: 700; }
#code {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  padding-left: 10px;
  background: transparent;
  white-space: pre;
  overflow: auto;
}
.log-box { border-top: 1px solid var(--border); max-height: 40%; overflow: auto; }
.log-box summary { padding: 6px 12px; cursor: pointer; color: var(--muted); }
#log { margin: 0; padding: 6px 12px 12px; font: 12px/1.5 var(--mono); white-space: pre-wrap; }
#log .err { color: var(--err); cursor: pointer; }
#log .warn { color: var(--warn); }

.chip { font-size: 12px; font-weight: 400; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.busy { color: var(--warn); border-color: var(--warn); }
.chip.err { color: var(--err); border-color: var(--err); }

.board-pane > * { flex: none; } /* the pane scrolls as a whole; children keep their height */
.board { padding: 10px 8px 6px; overflow-x: auto; }
.pinmap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  font: 11px/1 var(--mono);
  min-width: 360px;
}
.pm-col { display: grid; gap: 2px; padding: 8px 0; }
.pm-row { display: flex; align-items: center; gap: 6px; height: 17px; }
.pm-row.left { justify-content: flex-end; }
.pm-use { color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pm-row.left .pm-use { text-align: right; }
.pm-pin {
  flex: none;
  width: 50px;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  cursor: default;
  position: relative;
}
.pm-pin.power { opacity: 0.6; }
.pm-pin.power.used-power { opacity: 1; color: var(--text); }
.pm-use.power { color: var(--muted); }
.pm-pin.input-only { border-style: dashed; }
.pm-pin.used { color: var(--text); border-color: var(--accent); font-weight: 700; }
.pm-pin.problem { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.pm-pin.high { background: rgba(255, 196, 0, var(--level, 1)); color: #1f2328; }
.esp32 {
  background: #1d3b53;
  color: #e6f0f8;
  border-radius: 6px;
  margin: 0 6px;
  padding: 10px 8px;
  font-family: var(--mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  width: 118px;
}
.esp32-name { font-weight: 700; font-size: 12px; }
.chip-body { background: #9aa7b1; color: #1d2a33; border-radius: 3px; padding: 14px 4px; width: 100%; font-weight: 700; }
.mac { opacity: 0.8; line-height: 1.3; }
.usb { margin-top: auto; background: #b7c0c7; color: #333; border-radius: 3px; padding: 3px 10px; font-weight: 700; }
.led {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--led-off);
  vertical-align: middle;
  border: 1px solid #0006;
}
.led { background: color-mix(in srgb, var(--led-color, #ff3b30) 28%, #111); }
.led.on { background: var(--led-color, var(--led-on)); box-shadow: 0 0 10px 3px color-mix(in srgb, var(--led-color, #ff3b30) 65%, transparent); }
.led.blue.on { background: #2f81f7; box-shadow: 0 0 10px 3px #2f81f7aa; }

.parts-head { display: flex; align-items: center; gap: 6px; padding: 4px 12px 8px; font-weight: 600; flex-wrap: wrap; }
.parts-head > span:first-child { margin-right: auto; }
.parts-head select { max-width: 220px; }
.parts { display: grid; gap: 8px; padding: 0 12px 12px; }
.part {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  display: grid;
  gap: 6px;
}
.part.has-warning { border-color: var(--warn); }
.part.has-error { border-color: var(--err); }
.part-pins { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.pin-select { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.pin-select select { font-size: 12px; max-width: 230px; }
.pin-select.power select { max-width: 110px; }
.part-issues { margin: 0; padding-left: 18px; font-size: 12px; }
.part-issues .error { color: var(--err); }
.part-issues .warning { color: var(--warn); }
.part-issues .info { color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.rgb-led { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #888; background: #000; display: inline-block; }
.relay-state { font-family: var(--mono); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
.relay-state.on { color: var(--ok); border-color: var(--ok); }
.led.lamp.on { background: #ffd54a; box-shadow: 0 0 10px 3px #ffd54aaa; }
.part-head { display: flex; align-items: center; gap: 8px; }
.part-name { font-weight: 600; margin-right: auto; }
.part-remove { border: 0; padding: 0 6px; color: var(--muted); background: transparent; }
.part-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.part-body label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.part-body input[type="range"] { width: 140px; }
.value { font-family: var(--mono); min-width: 52px; }
.press {
  user-select: none;
  touch-action: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  background: #444c56;
  border: 3px solid #22272e;
}
.press.down { background: #22272e; }
.servo-dial { width: 48px; height: 48px; border: 2px solid var(--border); border-radius: 50%; position: relative; }
.servo-arm {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 4px;
  height: 22px;
  margin-left: -2px;
  background: var(--accent);
  transform-origin: bottom center;
  border-radius: 2px;
  transition: transform 0.2s;
}

.part-body.sliders { display: grid; grid-template-columns: 1fr; gap: 4px; }
.part-body.sliders label { justify-content: space-between; }
.neopixels { position: relative; display: inline-flex; gap: 4px; flex-wrap: wrap; }
.neopixels.ring { width: 96px; height: 96px; display: inline-block; }
.neopixels.ring .px { position: absolute; transform: translate(-50%, -50%); }
.neopixels .px { width: 12px; height: 12px; border-radius: 50%; background: #2a2a2a; border: 1px solid #555; display: inline-block; }
.rotor { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #8b949e; position: relative; display: inline-block;
  background: conic-gradient(#8b949e 0 25%, transparent 0 50%, #8b949e 0 75%, transparent 0); }
.rotor.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.joy-pad { width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, #3b434c, #22272e); position: relative; touch-action: none; cursor: grab; border: 2px solid #555; }
.joy-knob { position: absolute; width: 30px; height: 30px; border-radius: 50%; background: #111; border: 3px solid #6e7681; transform: translate(-50%, -50%); pointer-events: none; }
.press.small { width: 28px; height: 28px; }
.keypad { display: grid; grid-template-columns: repeat(4, 34px); gap: 4px; }
.keypad button { padding: 6px 0; font-family: var(--mono); font-weight: 700; user-select: none; touch-action: none; }
.keypad button:nth-child(4n) { background: #c33; color: #fff; border-color: #911; }
.keypad button.down { filter: brightness(0.6); transform: translateY(1px); }
.i2c-pins { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
canvas.lcd { border-radius: 4px; border: 6px solid #1a6a2f; max-width: 100%; }
canvas.oled {
  width: 256px;
  max-width: 100%;
  image-rendering: pixelated;
  border: 6px solid #10161c;
  border-radius: 4px;
  background: #000;
}

.editor-tabs { padding: 0 6px; gap: 0; }
.editor-tabs .tab { font-weight: var(--heading-weight); padding: 6px 12px; }
.part.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }

/* wiring diagram */
.diagram { flex: 1; min-height: 0; position: relative; overflow: hidden; background:
  radial-gradient(circle, var(--border) 1px, transparent 1px) 0 0 / 20px 20px, var(--code-bg); }
.diagram-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.diagram-svg.panning { cursor: grabbing; }
.diagram-toolbar { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 4px; align-items: center; pointer-events: none; }
.diagram-toolbar button { pointer-events: auto; padding: 2px 10px; }
.diagram-toolbar button:disabled { opacity: 0.45; cursor: default; }
.diagram-hint { margin-left: 8px; color: var(--muted); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-select { font-weight: 600; }
.diagram-tip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; z-index: 5;
  background: var(--text); color: var(--bg); font-size: 12px; padding: 3px 8px; border-radius: 4px; white-space: nowrap;
}
.diagram text { font-family: system-ui, sans-serif; fill: var(--text); }
.board-pcb { fill: #1d3b53; stroke: #0e2537; stroke-width: 2; }
.board-title { font-weight: 700; font-size: 13px; fill: #e6f0f8 !important; }
.board-module { fill: #9aa7b1; }
.board-module-text, .board-usb-text { font-size: 9px; font-weight: 700; fill: #1d2a33 !important; }
.board-usb { fill: #b7c0c7; }
.board-small { font-size: 9px; fill: #b9cbd8 !important; }
.board-led { fill: #123; stroke: #2f81f7; }
.board-led.on { fill: #2f81f7; filter: drop-shadow(0 0 5px #2f81f7); }
.board-pin-label { font: 10px var(--mono) !important; fill: #cfe0ec !important; }
.board-pin-label.power { fill: #7f97a8 !important; }
.board-pin { fill: #c9a227; stroke: #6b5512; stroke-width: 1.5; cursor: crosshair; }
.board-pin.power { fill: #6b7780; stroke: #3b444a; cursor: default; }
.board-pin.used { stroke: #fff; stroke-width: 2; }
.board-pin.high { fill: #ffd400; filter: drop-shadow(0 0 4px #ffd400); }
.board-pin.can-drop { fill: #3fb950; stroke: #1a7f37; }
.board-pin.cannot-drop { fill: #f85149; stroke: #8e1519; opacity: 0.6; }
.board-pin.hover { r: 9; }
.part-node { cursor: move; }
.part-box { fill: var(--panel); stroke: var(--border); stroke-width: 1.5; filter: drop-shadow(0 1px 2px #0003); }
.part-node:hover .part-box { stroke: var(--accent); }
.part-title { font-size: 12px; font-weight: 600; }
.part-sub, .d-reading { font-size: 11px; fill: var(--muted) !important; }
.part-pin-label { font: 10px var(--mono) !important; fill: var(--muted) !important; }
.part-pin { fill: var(--accent); stroke: var(--panel); stroke-width: 2; cursor: crosshair; }
.part-pin.fixed { fill: var(--muted); cursor: default; }
.wire { fill: none; stroke-width: 3; stroke-linecap: round; opacity: 0.9; pointer-events: none; }
.wire.dragging { stroke: var(--accent); stroke-dasharray: 6 5; }
.wire.power { stroke-width: 2; opacity: 0.75; }
.wire.ortho { stroke-width: 2.5; stroke-linejoin: round; }
.wire.ortho.power { stroke-width: 2; }
.diagram-select { pointer-events: auto; font-size: 12px; padding: 2px 6px; margin-left: 6px; }
.board-pin.power.gnd { fill: #6b7780; stroke: #c9d1d9; cursor: crosshair; }
.board-pin.power.vcc { fill: #e5534b; stroke: #ffd8d3; cursor: crosshair; }
.part-pin.gnd { fill: var(--wire-gnd); }
.part-pin.vcc { fill: #e5534b; }
.part-pin.open { fill: var(--panel); stroke: var(--muted); stroke-width: 2; stroke-dasharray: 2 2; }
/* turn / delete buttons of a part or the board, shown on hover; a selected wire's delete button stays */
.part-handle { visibility: hidden; cursor: pointer; }
.part-node:hover .part-handle, .board-node:hover .part-handle, .part-handle.shown { visibility: visible; }
.diagram-press.part-handle circle { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.part-handle-icon { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.diagram-press.part-handle.delete circle { stroke: var(--err); }
.part-handle.delete .part-handle-icon { stroke: var(--err); stroke-width: 2; }
/* wires can be pointed at and selected */
.wire-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.wire.hover { opacity: 1; stroke-width: 4; }
.wire.selected { opacity: 1; stroke-width: 4.5; filter: drop-shadow(0 0 3px var(--accent)); }
.part-node.unpowered .part-box { stroke: var(--warn); stroke-dasharray: 5 4; }
.part-node.unpowered .d-led, .part-node.unpowered .d-rgb, .part-node.unpowered .d-relay { opacity: 0.35; }
.part-nopower { font-size: 10px; font-weight: 700; fill: var(--warn) !important; }
.diagram-check { pointer-events: auto; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 12px; color: var(--muted); }
.diagram-trash {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  padding: 10px 22px; border: 2px dashed var(--err); border-radius: 8px; color: var(--err);
  background: color-mix(in srgb, var(--panel) 85%, transparent); font-size: 13px; font-weight: 600;
}
.diagram-trash.hover { background: var(--err); color: #fff; }
.d-led { fill: color-mix(in srgb, var(--led-color, #ff3b30) 28%, #111); stroke: #0008; }
.d-led.on { fill: var(--led-color, #ff3b30); filter: drop-shadow(0 0 6px var(--led-color, #ff3b30)); }
.d-px { fill: #2a2a2a; stroke: #555; stroke-width: 1; }
.d-motor { fill: #6e7681; stroke: #444c56; stroke-width: 2; }
.d-rotor { transform-box: fill-box; transform-origin: center; }
.d-rotor.spin { animation: spin 1s linear infinite; }
.d-rotor-spoke { stroke: #e6edf3; stroke-width: 3; stroke-linecap: round; }
.d-switch { fill: #444c56; stroke: #22272e; }
.d-switch-knob { fill: #c9d1d9; }
.d-switch-knob.on { fill: #3fb950; }
.d-ir_obstacle { fill: #222; stroke: #6e7681; }
.d-ir_obstacle.on { fill: #ffd54a; filter: drop-shadow(0 0 5px #ffd54a); }
.d-flame { fill: #222; stroke: #6e7681; }
.d-flame.on { fill: #ff7b00; filter: drop-shadow(0 0 6px #ff7b00); }
.d-joy { fill: #111; stroke: #8b949e; stroke-width: 2; }
.d-arrow { font-size: 18px; cursor: pointer; fill: var(--accent) !important; }
.d-key rect { fill: #2d333b; stroke: #6e7681; }
.d-key.down rect { fill: #0d1117; }
.d-key-text { font: 700 10px var(--mono) !important; fill: #e6edf3 !important; pointer-events: none; }
.d-rgb { fill: #111; stroke: #888; stroke-width: 2; }
.d-relay { fill: #1f4e8c; stroke: #0b2747; }
.d-relay.on { fill: #1a7f37; }
.d-relay-text { font: 700 10px var(--mono) !important; fill: #fff !important; }
.d-buzzer { fill: #222; stroke: #555; stroke-width: 3; }
.d-servo { fill: #1f4e8c; }
.d-servo-arm, .d-knob-mark { stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.d-knob { fill: #2d333b; stroke: #6e7681; stroke-width: 2; }
.d-pir { fill: #e8e8e8; stroke: #999; cursor: pointer; }
.d-pir.on { fill: #ffd54a; filter: drop-shadow(0 0 5px #ffd54a); }
.diagram-press { fill: #444c56; stroke: #22272e; stroke-width: 3; cursor: pointer; }
.diagram-press.down { fill: #22272e; }
canvas.d-lcd, canvas.d-oled { width: 100%; height: auto; display: block; image-rendering: pixelated; border-radius: 3px; }

/* realistic look of the diagram (web/part-art.js): real component colours in both themes */
.board.real .board-pin { fill: #d9a93f; stroke: #a07a22; stroke-width: 1.5; }
.board.real .board-pin.power { fill: #b8964a; stroke: #7a6430; }
.board.real .board-pin.power.vcc { fill: #d9a93f; stroke: #e5534b; stroke-width: 2.5; }
.board.real .board-pin.power.gnd { fill: #d9a93f; stroke: #9aa3ab; stroke-width: 2.5; }
.board.real .board-pin.used { stroke: #fff; stroke-width: 2; }
.board.real .board-pin.high { fill: #ffd400; }
.board.real .board-pin.can-drop { fill: #3fb950; stroke: #1a7f37; }
.board.real .board-pin.cannot-drop { fill: #f85149; stroke: #8e1519; }
.board-pad-hole { fill: #3a3326; pointer-events: none; }
.board.real .board-pin-label { font: 8px var(--mono) !important; fill: #eef0f2 !important; }
.board.real .board-pin-label.power { fill: #b9c0c8 !important; }
.diagram .art-silk { font: 6px var(--mono); fill: #eef0f2; }
.diagram .art-engrave { font-family: var(--mono); fill: #6b7079; }
.diagram .art-chip-text { font: 6px var(--mono); fill: #9aa0a8; }
.board-led.real { fill: #e4e0d0; stroke: none; }
.board-led.real.rgb { fill: #d8d4c4; }
.board-led.real.on { fill: var(--led-color, #3d8bff); filter: drop-shadow(0 0 5px var(--led-color, #3d8bff)) drop-shadow(0 0 2px var(--led-color, #3d8bff)); }
.board-flash.real { fill: #fffbe8; stroke: #e6d58c; }
.board-flash.real.on { fill: #fff; filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 4px #ffe9a0); }
.board-cap { fill: #26282c; }
.board-button.real { fill: #26282c; stroke: #55585e; stroke-width: 1; }
.board-button.real.down { fill: #000; r: 4px; }
.part-node.real .part-box { fill: transparent; stroke: transparent; filter: none; }
.part-node.real:hover .part-box { stroke: var(--accent); stroke-dasharray: 4 4; }
.part-node.real.unpowered .part-box { stroke: var(--warn); stroke-dasharray: 5 4; }
.part-node.real .part-pin { r: 4.5px; fill: #c9ccd1; stroke: #6e7681; stroke-width: 1.5; }
.part-node.real .part-pin.vcc { stroke: #e5534b; stroke-width: 2.5; }
.part-node.real .part-pin.gnd { stroke: var(--wire-gnd); stroke-width: 2.5; }
.part-node.real .part-pin.open { fill: var(--panel); stroke: var(--muted); stroke-dasharray: 2 2; }
.part-node.real .part-pin-label { font: 9px var(--mono) !important; }
.d-led.real { fill: color-mix(in srgb, var(--led-color, #ff3b30) 45%, #e9e4dc); fill-opacity: 0.92; stroke: none; }
.d-led.real.on { fill: var(--led-color, #ff3b30); filter: drop-shadow(0 0 8px var(--led-color, #ff3b30)) drop-shadow(0 0 3px var(--led-color, #ff3b30)); }
.d-led-rim { fill: color-mix(in srgb, var(--led-color, #ff3b30) 80%, #000); }
.diagram-press.d-btn-cap { fill: #d83c31; stroke: #b02e25; stroke-width: 2; }
.diagram-press.d-btn-cap.down { fill: #a92a21; r: 11.5px; }
.d-knob-mark.real { stroke: #5a5f66; stroke-width: 2.5; }
.d-servo-arm.real { stroke: #f7f7f5; stroke-width: 7; }
.diagram .art-engrave-s { font: 7px var(--mono); fill: #6b7079; }
.diagram .art-dark { font: 8px var(--mono); fill: #4a515c; }
.art-led { fill: color-mix(in srgb, var(--c, #2ea043) 30%, #1b1b1f); }
.art-led.on { fill: var(--c, #2ea043); filter: drop-shadow(0 0 4px var(--c, #2ea043)); }
.art-led.art-blink.on { animation: art-blink 1s steps(1) infinite; }
@keyframes art-blink { 50% { fill: color-mix(in srgb, var(--c, #2ea043) 30%, #1b1b1f); filter: none; } }
.diagram-press.art-hit { fill: transparent; stroke: none; }
.d-sound { opacity: 0; }
.d-sound.on { animation: art-pulse 0.5s ease-in-out infinite alternate; }
.d-flow.on { stroke: #39c5cf; animation: art-pulse 1s ease-in-out infinite alternate; }
@keyframes art-pulse { from { opacity: 0.3; } to { opacity: 1; } }
.d-shaft { stroke: #8f949b; stroke-width: 2.5; stroke-linecap: round; }
.d-px.real { fill: #3a3a3a; stroke: none; }
.d-rgb.real { fill: #d9d4df; stroke: none; }
.d-joy.real { fill: #36363b; stroke: #4a4a50; stroke-width: 4; stroke-dasharray: 3 4; }
.d-pir.real { fill: #f4f4f2; stroke: #d8d8d4; stroke-width: 1.5; }
.d-pir.real.on { fill: #ffe7a8; filter: drop-shadow(0 0 6px #fb9337); }
.d-key.real rect { fill: #ecebe6; stroke: none; }
.d-key.real.letter rect { fill: #c7372d; }
.d-key.real.down rect { fill: #9a9890; }
.d-key.real.letter.down rect { fill: #8e231c; }
.d-key.real text { stroke: none; font: 700 9px var(--mono) !important; fill: #1d232b !important; }
.d-key.real.letter text { fill: #fff !important; }
.part-node.selected .part-box, .part-node.real.selected .part-box, .part-node.real.selected:hover .part-box { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: none; }
/* drawing a wire from a board pin: the part terminals that can take it (after the realistic rules, so they win) */
.part-pin.can-drop, .part-node.real .part-pin.can-drop { fill: #3fb950; stroke: #1a7f37; stroke-dasharray: none; }
.part-pin.cannot-drop, .part-node.real .part-pin.cannot-drop { fill: #f85149; stroke: #8e1519; stroke-dasharray: none; opacity: 0.6; }
.part-pin.hover { r: 8px; }

.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 6px; }
.tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--accent-line); }
.tab-action { margin-left: auto; border: 0; background: transparent; color: var(--muted); }
.tab-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.console {
  flex: 1;
  margin: 0;
  padding: 8px 10px;
  overflow: auto;
  background: var(--console-bg);
  color: var(--console-text);
  font: 12.5px/1.45 var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
}
.console .sys { color: #8b949e; }
.console .warn { color: #d29922; }
.console .err { color: #f85149; }
.net div { border-bottom: 1px solid #ffffff10; padding: 1px 0; }
.net .k { display: inline-block; min-width: 86px; color: #8b949e; }
.net .mqtt-out .k, .net .http-out .k { color: #58a6ff; }
.net .mqtt-in .k, .net .http-in .k { color: #3fb950; }
.net .mqtt-error .k, .net .http-error .k { color: #f85149; }
.serial-form { display: flex; border-top: 1px solid var(--border); }
.serial-form input { flex: 1; border: 0; border-radius: 0; padding: 6px 10px; font-family: var(--mono); }

dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); max-width: 560px; width: calc(100% - 32px); }
dialog::backdrop { background: #0008; }
.settings-form { display: grid; gap: 10px; }
.settings-form h2 { margin: 0; font-size: 18px; }
.settings-form p { margin: 0; color: var(--muted); }
.settings-form textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; border: 1px solid var(--border); border-radius: 6px; background: var(--code-bg); padding: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  .layout, .layout.io-folded, .layout.board-folded, .layout.board-folded.io-folded { grid-template-columns: 1fr; grid-template-rows: 55vh auto auto; overflow: auto; gap: 10px; }
  .layout > .editor-pane, .layout > .board-pane, .layout > .io-pane { grid-column: 1; grid-row: auto; margin-top: 0; }
  .layout > .io-pane:not(.folded) { min-height: 45vh; }
  .layout > .splitter { display: none; }
  .status { margin-left: 0; width: 100%; }
}

/* board selector and the hardware on the ESP32-C3 OLED board (app.js renderBoardBox, diagram.js) */
#board-select { font-size: 12px; font-weight: 400; padding: 1px 4px; max-width: 150px; }
.esp32.c3 { width: 132px; }
.oled-wrap { background: #10161c; padding: 4px; border-radius: 3px; }
canvas.board-oled { display: block; width: 108px; image-rendering: pixelated; background: #000; }
.board-button { fill: #444c56; stroke: #22272e; stroke-width: 3; cursor: pointer; }
.board-button.down { fill: #22272e; }
.press.board-button { vertical-align: middle; }

/* ESP32-CAM board: live view, last picture, camera source, flash LED (app.js renderBoardBox, diagram.js) */
.camera-wrap { background: #10161c; padding: 3px; border-radius: 3px; width: 100%; }
.camera-preview { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; }
.camera-info { font-size: 10px; opacity: 0.85; }
.led.white { --led-color: #ffffff; }
.led.red { --led-color: #ff3b30; }
.board-lens { fill: #1b1f24; stroke: #6e7681; stroke-width: 2; }
.board-lens-glass { fill: #2f4f6f; }
.board-flash { fill: #3a3f45; stroke: #c9d1d9; }
.board-flash.on { fill: #ffffff; filter: drop-shadow(0 0 8px #ffffff); }

/* welcome page (web/welcome.html) and the signed-in user in the top bar */
body.welcome-page { overflow: auto; }
.welcome { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.welcome-card {
  max-width: 560px; background: var(--panel); border: 1px solid var(--pane-border); box-shadow: var(--pane-shadow);
  border-radius: 10px; padding: 28px;
}
.welcome-card h1 { margin: 0 0 10px; font-size: 22px; color: var(--heading); font-weight: var(--heading-weight); }
.welcome-card p { margin: 0 0 14px; color: var(--muted); line-height: 1.5; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
a.button {
  display: inline-block; padding: 7px 14px; border-radius: 6px; text-decoration: none; font-weight: 600;
  border: 1px solid var(--border); color: var(--text); background: var(--panel);
}
a.button:hover { border-color: var(--accent-line); }
a.button.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-fg); }
a.button.primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.welcome-note { font-size: 13px; }
.welcome-msg { padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border); color: var(--text) !important; }
.welcome-msg.error { border-color: var(--err); }
.welcome-msg.info { border-color: var(--accent-line); }

.user-menu { position: relative; }
.user-menu summary {
  list-style: none; cursor: pointer; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--ui-bar-ctl-border); background: var(--ui-bar-ctl-bg); color: var(--ui-bar-fg);
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu form {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 6px; min-width: 220px;
  padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  box-shadow: 0 6px 18px #0003;
}
.user-menu .user-name { font-size: 12px; color: var(--muted); }
.user-menu form button { text-align: left; }

/* device picker and projects dialogs (app.js) */
dialog.wide-dialog { max-width: 720px; }
.pick-list { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.pick-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
}
.pick-row.current { border-color: var(--accent-line); }
.pick-row .pick-name { font-weight: 600; }
.pick-row .pick-meta { grid-column: 1; font-size: 12px; color: var(--muted); }
.pick-row .pick-actions { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; }
.pick-empty { color: var(--muted); padding: 8px 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 4px; vertical-align: middle; }
.dot.on { background: var(--ok); }
.dialog-actions.left { justify-content: flex-start; align-items: center; }
.project-name input { flex: 1; min-width: 220px; }
.camera-wrap { position: relative; }
.camera-live { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; }
.camera-live.hidden { display: none; }
.camera-preview.corner { position: absolute; right: 6px; bottom: 6px; width: 34%; border: 1px solid #e6f0f8; }
.camera-preview.corner:not([src]) { display: none; }
.camera-source { font-size: 10px; max-width: 100%; color: #e6f0f8; background: #2a4a63; border: 1px solid #4a6a83; border-radius: 3px; }

/* TM1637 7-segment display (parts.js drawSevenSegment), 4-channel relay, RGB board LED */
canvas.seg7 { border-radius: 4px; border: 4px solid #1d2a38; max-width: 100%; }
canvas.d-seg7 { width: 100%; height: auto; display: block; border-radius: 3px; }
.relay-state + .relay-state { margin-left: 4px; }
.led.rgb { --led-color: #ffffff; }

/* SPI parts: TFT displays, SD card file list, bus label (parts.js) */
canvas.tft { display: block; max-width: 100%; width: 192px; image-rendering: pixelated; border: 4px solid #1d2a38; border-radius: 4px; }
canvas.d-tft { width: 100%; height: auto; display: block; image-rendering: pixelated; border-radius: 3px; }
.sd-files { display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); font-size: 11px; margin-bottom: 4px; }
.spi-bus { font-size: 11px; align-self: center; }

/* ---------- Schematic tab (schematic.js): an academic drawing on paper ----------
 * Symbols dark red on cream, wires green, power red, references blue (IEEE / IEC style).
 * Light mode is paper-white in both styles; dark mode turns the sheet dark. Only the
 * selection follows the app's accent (Standard blue / FILKOM orange). */
:root {
  --sch-paper: #ffffff; --sch-grid: #d9dde3; --sch-frame: #8a8f98; --sch-body: #8a1f11; --sch-fill: #fff9e0;
  --sch-wire: #0b7a3b; --sch-power: #b3261e; --sch-gnd: #1d2433; --sch-text: #1d2433; --sch-ref: #0b3d91;
  --sch-label-fill: #e8f0fe; --sch-nc: #1f4fd1; --sch-high: #d93025; --sch-muted: #5b6474; --sch-desk: #e9ecf0;
}
html[data-theme="dark"] {
  --sch-paper: #0f1419; --sch-grid: #222b35; --sch-frame: #5b6572; --sch-body: #f0a58f; --sch-fill: #2a1f16;
  --sch-wire: #4ade80; --sch-power: #ff7b72; --sch-gnd: #d6dde4; --sch-text: #e6edf3; --sch-ref: #79b8ff;
  --sch-label-fill: #132a4a; --sch-nc: #79b8ff; --sch-high: #ff7b72; --sch-muted: #9aa4b2; --sch-desk: #0a0d11;
}
/* sheet chosen in the Schematic toolbar: light or dark whatever the app's mode, and black and white */
.schematic.sch-sheet-light {
  --sch-paper: #ffffff; --sch-grid: #d9dde3; --sch-frame: #8a8f98; --sch-body: #8a1f11; --sch-fill: #fff9e0;
  --sch-wire: #0b7a3b; --sch-power: #b3261e; --sch-gnd: #1d2433; --sch-text: #1d2433; --sch-ref: #0b3d91;
  --sch-label-fill: #e8f0fe; --sch-nc: #1f4fd1; --sch-high: #d93025; --sch-muted: #5b6474;
}
.schematic.sch-sheet-dark {
  --sch-paper: #0f1419; --sch-grid: #222b35; --sch-frame: #5b6572; --sch-body: #f0a58f; --sch-fill: #2a1f16;
  --sch-wire: #4ade80; --sch-power: #ff7b72; --sch-gnd: #d6dde4; --sch-text: #e6edf3; --sch-ref: #79b8ff;
  --sch-label-fill: #132a4a; --sch-nc: #79b8ff; --sch-high: #ff7b72; --sch-muted: #9aa4b2;
}
.schematic.sch-bw {
  --sch-paper: #ffffff; --sch-grid: #dcdcdc; --sch-frame: #000000; --sch-body: #000000; --sch-fill: #ffffff;
  --sch-wire: #000000; --sch-power: #000000; --sch-gnd: #000000; --sch-text: #000000; --sch-ref: #000000;
  --sch-label-fill: #ffffff; --sch-nc: #000000; --sch-high: #000000; --sch-muted: #444444;
}
html[data-theme="dark"] .schematic.sch-bw:not(.sch-sheet-light), .schematic.sch-bw.sch-sheet-dark {
  --sch-paper: #000000; --sch-grid: #2a2a2a; --sch-frame: #ffffff; --sch-body: #ffffff; --sch-fill: #000000;
  --sch-wire: #ffffff; --sch-power: #ffffff; --sch-gnd: #ffffff; --sch-text: #ffffff; --sch-ref: #ffffff;
  --sch-label-fill: #000000; --sch-nc: #ffffff; --sch-high: #ffffff; --sch-muted: #bbbbbb;
}
/* black and white: a HIGH wire is told apart by its width only */
.sch-bw .sch-wire.high { stroke-width: 3.2; }
.sch-bw .sch-tag rect { fill: var(--sch-body); }
.sch-bw .sch-tag-text { fill: var(--sch-paper); }
.schematic { flex: 1; min-height: 0; position: relative; overflow: hidden; background: var(--sch-desk); }
.sch-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.sch-svg.panning { cursor: grabbing; }
.sch-svg text { font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sch-paper { fill: var(--sch-paper); }
.sch-dot { fill: var(--sch-grid); }
.sch-frame { fill: none; stroke: var(--sch-frame); stroke-width: 1.2; }
.sch-title-box { fill: var(--sch-paper); }
.sch-title { font-size: 11px; font-weight: 700; fill: var(--sch-text); }
.sch-name { font-size: 10px; fill: var(--sch-text); }
.sch-note { font-size: 9px; fill: var(--sch-muted); }
.sch-body { fill: var(--sch-fill); stroke: var(--sch-body); stroke-width: 1.6; }
.sch-pin { stroke: var(--sch-body); stroke-width: 1.4; fill: none; }
.sch-lead { stroke: var(--sch-body); stroke-width: 1.4; fill: none; }
.sch-glyph { fill: none; stroke: var(--sch-body); stroke-width: 1.6; }
.sch-glyph.thin { stroke-width: 1.1; }
.sch-glyph.dashed { stroke-width: 1.2; stroke-dasharray: 4 3; }
.sch-glyph.filled { fill: var(--sch-body); stroke: none; }
.sch-glyph-text { font-size: 10px; fill: var(--sch-body); }
.sch-glyph-text.big { font-size: 13px; font-weight: 700; }
.sch-diode { fill: var(--sch-fill); }
.sch-glow { fill: transparent; stroke: none; opacity: 0; }
.sch-glow.on { opacity: 0.2; }
.sch-pin-name { font-size: 10px; fill: var(--sch-text); }
.sch-pin-num { font-size: 8px; fill: var(--sch-body); }
.sch-ref { font-size: 11px; font-weight: 700; fill: var(--sch-ref); }
.sch-value { font-size: 10px; fill: var(--sch-ref); }
.sch-reading { font-size: 9px; fill: var(--sch-muted); }
.sch-nopower { font-size: 9px; font-weight: 700; fill: var(--warn); }
.sch-builtin { fill: none; stroke: var(--sch-body); stroke-width: 1; stroke-dasharray: 3 2; }
.sch-wire { fill: none; stroke: var(--sch-wire); stroke-width: 1.6; }
.sch-wire-in { fill: none; stroke: var(--sch-wire); stroke-width: 1.6; }
.sch-junction { fill: var(--sch-wire); }
.sch-power { fill: none; stroke: var(--sch-power); stroke-width: 1.6; }
.sch-power-text { font-size: 10px; font-weight: 700; fill: var(--sch-power); }
.sch-gnd { fill: none; stroke: var(--sch-gnd); stroke-width: 1.6; }
.sch-label { fill: var(--sch-label-fill); stroke: var(--sch-ref); stroke-width: 1; }
.sch-label-text { font-size: 10px; font-weight: 700; fill: var(--sch-ref); }
.sch-nc { stroke: var(--sch-nc); stroke-width: 1.6; fill: none; }
.sch-hit { fill: transparent; stroke: none; }
.sch-part { cursor: move; }
.sch-part.unpowered > g { opacity: 0.4; }
.sch-part.dragging .sch-halo { stroke: var(--accent); }
.sch-halo { fill: none; stroke: transparent; stroke-width: 2; stroke-dasharray: 6 4; }
.sch-part.selected .sch-halo { stroke: var(--accent); }
.sch-part:hover .sch-halo { stroke: var(--border); }
.sch-part.selected:hover .sch-halo { stroke: var(--accent); }
.sch-press { cursor: pointer; }
/* pin ends: drag from one to draw a wire (part pin → board pin, or board pin → part pin) */
.sch-end { cursor: crosshair; }
.sch-end:hover { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.sch-wire-draft { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.sch-wire-draft.no { stroke: var(--err); }
.sch-drop { stroke-width: 1.6; fill-opacity: 0.25; cursor: crosshair; }
.sch-drop.ok { fill: var(--ok); stroke: var(--ok); }
.sch-drop.no { fill: var(--err); stroke: var(--err); fill-opacity: 0.12; stroke-opacity: 0.6; }
.sch-drop.hover { fill-opacity: 0.6; stroke-width: 2.4; }
.diagram-tip.bad { background: var(--err); color: #ffffff; }
/* turn / duplicate / remove buttons above a symbol (and turn on the board), shown on hover or selection */
.sch-handles { opacity: 0; pointer-events: none; transition: opacity 0.12s; }
.sch-part:hover .sch-handles, .sch-part.selected .sch-handles, .sch-board:hover .sch-handles, .sch-handles.shown { opacity: 1; pointer-events: auto; }
.sch-handle { cursor: pointer; }
.sch-handle circle { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.sch-handle.delete circle { stroke: var(--err); }
.sch-handle:hover circle { fill: var(--accent-soft); }
.sch-handle-icon { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linecap: round; pointer-events: none; }
.sch-handle.delete .sch-handle-icon { stroke: var(--err); }
/* wires, net labels and power symbols of parts: click to select, then ✕ / Delete disconnects */
.sch-wire-hit { fill: none; stroke: transparent; stroke-width: 10; }
.sch-conn { cursor: pointer; }
.sch-conn:hover .sch-wire, .sch-conn:hover .sch-pickable { stroke-width: 2.6; }
.sch-conn.selected .sch-wire, .sch-conn.selected .sch-pickable { stroke: var(--accent) !important; stroke-width: 2.8; stroke-dasharray: none; }
.sch-conn.selected .sch-label { fill: var(--accent-soft); }
.sch-issue path { stroke: none; }
.sch-issue.warning path { fill: var(--warn); }
.sch-issue.error path { fill: var(--err); }
.sch-issue-text { font-size: 10px; font-weight: 700; fill: #ffffff; pointer-events: none; }
/* live state (Live levels; off: .sch-nolive) */
.sch-tag rect { fill: var(--sch-wire); }
.sch-tag.high rect { fill: var(--sch-high); }
.sch-tag.analog rect { fill: var(--sch-ref); width: 26px; transform: translateX(-4px); }
.sch-tag-text { font-size: 8px; font-weight: 700; fill: #ffffff; }
.sch-wire.high { stroke: var(--sch-high); stroke-width: 2.2; }
.sch-wire.pwm { stroke: var(--sch-high); stroke-width: 2.2; stroke-dasharray: 5 3; }
.sch-nolive .sch-wire.high, .sch-nolive .sch-wire.pwm { stroke: var(--sch-wire); stroke-width: 1.6; stroke-dasharray: none; }
.sch-nolive .sch-tag { display: none; }
.sch-sound { stroke: var(--sch-high); opacity: 0; }
.sch-sound.on { opacity: 1; }
.sch-blade.on, .sch-coil.on { stroke: var(--sch-high); }
.sch-coil.on { fill: var(--sch-high); fill-opacity: 0.35; }
.sch-pir.on, .sch-active.on { fill: var(--sch-high); fill-opacity: 0.25; }
.sch-active { stroke: transparent; fill: transparent; }
.sch-key.down { fill: var(--sch-high); }
/* reference designator in the parts list, and the card of the selected part */
.part-ref { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--accent); }
.part.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.part.selected.has-error { border-color: var(--err); }

/* a white PCB (Nucleo) in the realistic look: dark silkscreen and pin names */
.board.real.light-pcb .art-silk { fill: #2b2f36; }
.board.real.light-pcb .board-pin-label { fill: #2b2f36 !important; }
.board.real.light-pcb .board-pin-label.power { fill: #6b5a2e !important; }
