/* Drag wiring, part pages and code runner */
.wb-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.wb-hint-inline { color: var(--ink-3); font-size: 11.5px; }
.wb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
.wb-palette { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); padding: 8px; overflow-x: auto; }
.wb-group { display: flex; align-items: center; gap: 5px; flex: 0 1 auto; flex-wrap: wrap; max-width: 100%; }
.wb-group + .wb-group { margin-top: 0; }
.wb-group h4 { font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); margin: 0 4px 0 0; white-space: nowrap; }
.wb-pal-btn { width: auto; min-width: 120px; display: flex; align-items: center; gap: 6px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); padding: 5px 6px; cursor: grab; font: inherit; touch-action: none; }
.wb-pal-btn:hover { border-color: var(--accent); }
.wb-pal-btn.dragging { opacity: .55; outline: 2px solid var(--accent); outline-offset: 1px; }
.wb-pal-btn svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.wb-pal-btn span { display: flex; flex-direction: column; min-width: 0; }
.wb-pal-btn b { font-size: 10.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-pal-btn small { font-family: var(--mono); font-size: 9px; color: var(--ink-3); }
.wb-main { min-width: 0; }
.wb-canvas-wrap { border: 1px solid var(--line); border-radius: 12px; background: var(--paper-3); overflow: auto; }
.wb-canvas { position: relative; width: 900px; height: 640px; background-image: radial-gradient(circle, var(--line) 1px, transparent 1px); background-size: 20px 20px; }
.wb-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wb-wire { fill: none; stroke-width: 3; stroke-linecap: round; opacity: .82; pointer-events: stroke; cursor: pointer; }
.wb-wire:hover { stroke-width: 5; opacity: 1; }
.wb-wire-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.wb-wire.w-pwr { stroke: var(--k-pwr); }
.wb-wire.w-gnd { stroke: var(--k-gnd); stroke-width: 4; }
.wb-wire.w-ctl { stroke: var(--k-ctl); }
.wb-wire.w-dig { stroke: var(--k-dig); }
.wb-wire.w-ana { stroke: var(--k-ana); }
.wb-wire.w-i2c { stroke: var(--k-com); }
.wb-wire.w-pass { stroke: var(--ink-2); }
.wb-nodes { position: absolute; inset: 0; }
.wb-node { position: absolute; width: 210px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: 0 6px 18px rgba(30,24,14,.12); user-select: none; touch-action: none; }
.wb-node-head { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 9px 9px 0 0; background: var(--ink); color: var(--paper); cursor: grab; }
.wb-node-head:active { cursor: grabbing; }
.wb-node-head svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: var(--paper); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.wb-node-head b { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-del { margin-left: auto; border: 0; background: transparent; color: var(--paper); font-size: 17px; line-height: 1; cursor: pointer; opacity: .7; }
.wb-del:hover { opacity: 1; color: #ffb4a8; }
.wb-node-body { padding: 6px; display: grid; gap: 3px; }
.wb-port { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper-2); color: var(--ink-2); font-family: var(--mono); font-size: 10px; padding: 3px 6px; cursor: pointer; }
.wb-port:hover { border-color: var(--accent); }
.wb-port i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); flex: 0 0 auto; }
.wb-port.pwr i { background: var(--k-pwr); }
.wb-port.gnd i { background: var(--k-gnd); }
.wb-port.ctl i { background: var(--k-ctl); }
.wb-port.dig i { background: var(--k-dig); }
.wb-port.ana i { background: var(--k-ana); }
.wb-port.i2c i { background: var(--k-com); }
.wb-port.pass i { background: var(--ink-2); }
.wb-port.sel { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--accent-soft); color: var(--accent); }
.wb-hint { color: var(--ink-3); font-size: 11.5px; margin-top: 7px; }
.wb-side { border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); padding: 14px; position: sticky; top: 76px; }
.wb-side h3 { font-family: var(--serif); font-size: 22px; margin: 2px 0 8px; }
.wb-side h4 { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 14px 0 6px; }
.wb-status { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; margin-bottom: 8px; }
.wb-status b { font-size: 12.5px; }
.wb-status span { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.wb-status.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: color-mix(in srgb, var(--ok) 10%, var(--paper)); color: var(--ok); }
.wb-status.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--paper)); color: var(--warn); }
.wb-status.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); color: var(--bad); }
.wb-check { display: grid; grid-template-columns: 15px 1fr; gap: 6px; font-size: 11.5px; line-height: 1.45; padding: 4px 0; border-bottom: 1px solid var(--line); }
.wb-check i { font-style: normal; font-weight: 700; text-align: center; }
.wb-check.ok i { color: var(--ok); }
.wb-check.warn i { color: var(--warn); }
.wb-check.bad { color: var(--bad); }
.wb-check.bad i { color: var(--bad); }
.wb-net { display: grid; grid-template-columns: 48px 1fr auto; gap: 6px; font-size: 11px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.wb-net b { color: var(--ink-3); font-weight: 600; }
.wb-net span { font-family: var(--mono); }
.wb-net small { color: var(--ink-3); }
.wb-wire-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 9.5px; color: var(--ink-2); }
.wb-wire-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-wire-row button { margin-left: auto; border: 0; background: transparent; color: var(--bad); font-size: 14px; line-height: 1; cursor: pointer; }
.wb-log { margin-top: 10px; font-family: var(--mono); font-size: 10px; color: var(--ink-3); max-height: 110px; overflow: auto; }
.wb-log-line { padding: 2px 0; border-bottom: 1px dashed var(--line); }
.wb-log-line.ok { color: var(--ok); }
.wb-log-line.warn { color: var(--warn); }
.wb-log-line.bad { color: var(--bad); }
.wb-muted { color: var(--ink-3); font-size: 11.5px; }
/* Part page */
.part-title { font-family: var(--serif); font-size: clamp(30px, 5vw, 50px); letter-spacing: -.03em; margin: 4px 0 2px; }
.part-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.part-related-title { font-family: var(--serif); font-size: 24px; margin: 26px 0 12px; }
.part[href] { text-decoration: none; }
/* Code runner */
.code-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; align-items: start; }
.code-pane { border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); overflow: hidden; }
.code-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 10px; border-bottom: 1px solid var(--line); }
.code-toolbar select { padding: 6px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; font-size: 11.5px; }
.code-editor { width: 100%; min-height: 430px; resize: vertical; border: 0; background: #0d1518; color: #d6e6df; font-family: var(--mono); font-size: 12px; line-height: 1.6; padding: 14px; outline: none; tab-size: 2; }
.code-side { border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); padding: 14px; position: sticky; top: 76px; }
.code-side h3 { font-family: var(--serif); font-size: 22px; margin: 2px 0 8px; }
.code-status { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 8px; }
.code-status.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: color-mix(in srgb, var(--ok) 10%, var(--paper)); color: var(--ok); }
.code-status.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--paper)); color: var(--warn); }
.code-status.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); color: var(--bad); }
.code-checks { display: grid; gap: 5px; margin: 8px 0 12px; }
.code-check { display: grid; grid-template-columns: 15px 1fr; gap: 6px; font-size: 11.5px; line-height: 1.4; }
.code-check i { font-style: normal; font-weight: 700; text-align: center; }
.code-check.ok i { color: var(--ok); }
.code-check.warn i { color: var(--warn); }
.code-check.bad { color: var(--bad); }
.code-state { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 10px 0; }
.code-state > div { border: 1px solid var(--line); border-radius: 7px; padding: 7px 8px; background: var(--paper); }
.code-state span { display: block; color: var(--ink-3); font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; }
.code-state b { font-family: var(--mono); font-size: 13px; }
.code-ledbar { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 5px; }
.code-ledbar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .2s ease; }
.code-toolbar label { display: flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: 10px; }
.code-serial { background: #0d1518; color: #b8d8cc; border-radius: 7px; padding: 8px; min-height: 92px; max-height: 180px; overflow: auto; font-family: var(--mono); font-size: 10.5px; white-space: pre-wrap; }
.code-help { color: var(--ink-3); font-size: 11px; margin: 10px 0 0; line-height: 1.5; }
@media (max-width: 1180px) {
  .wb-layout { grid-template-columns: 1fr; }
  .wb-main { grid-column: auto; }
  .wb-side { position: static; grid-column: auto; }
  .code-layout { grid-template-columns: 1fr; }
  .code-side { position: static; }
}
@media (max-width: 680px) {
  .wb-toolbar { gap: 6px; }
  .wb-hint-inline { width: 100%; }
  .wb-palette { display: block; padding: 6px; max-height: 300px; overflow: auto; }
  .wb-group { display: flex; margin: 0 0 7px; }
  .wb-group h4 { flex: 0 0 100%; margin: 0 0 4px; }
  .wb-pal-btn { flex: 1 1 46%; min-width: 0; }
  .wb-node { width: 190px; }
  .wb-canvas { width: 820px; height: 620px; }
  .wb-side { padding: 12px; }
  .part-actions { margin: 12px 0; }
  .code-editor { min-height: 320px; font-size: 11px; }
}
