.webio-tool {
  --webio-ink: #182321;
  --webio-muted: #687670;
  --webio-line: #c5d0cc;
  --webio-panel: #eef3f1;
  --webio-surface: #ffffff;
  --webio-scene: #10191b;
  --webio-accent: #087f75;
  --webio-danger: #9a3f34;
  background: var(--webio-surface);
  border: 1px solid #b9c8c2;
  border-radius: 6px;
  box-shadow: 0 18px 45px rgba(24, 46, 42, 0.12);
  color: var(--webio-ink);
  font-family: "Avenir Next", "IBM Plex Sans", sans-serif;
  margin: 0 auto;
  max-width: 1240px;
  min-width: 0;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.webio-tool *,
.webio-tool *::before,
.webio-tool *::after { box-sizing: border-box; }

.webio-tool button,
.webio-tool select,
.webio-tool input { font: inherit; }

.webio-tool button,
.webio-tool select { min-height: 40px; }

.webio-tool button {
  align-items: center;
  background: var(--webio-surface);
  border: 1px solid var(--webio-line);
  border-radius: 5px;
  color: var(--webio-ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 650;
  justify-content: center;
  padding: 8px 12px;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.webio-tool button:hover,
.webio-tool button:focus-visible,
.webio-tool select:focus-visible {
  border-color: var(--webio-accent);
  box-shadow: 0 0 0 2px rgba(8, 118, 110, 0.14);
  outline: none;
}

.webio-tool button:disabled,
.webio-tool select:disabled { cursor: default; opacity: 0.42; }
.webio-tool .webio-tool__primary { background: var(--webio-accent); border-color: var(--webio-accent); color: #fff; }
.webio-tool .webio-tool__danger { background: #f8e8e4; border-color: #d7a49d; color: #7f3026; }

.webio-tool__masthead {
  align-items: center;
  background: #162421;
  color: #f4faf7;
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 13px 16px;
}

.webio-tool__masthead div,
.webio-tool__masthead strong,
.webio-tool__masthead span { display: block; }
.webio-tool__masthead span { color: #8eb7af; font: 600 0.61rem "IBM Plex Mono", monospace; text-transform: uppercase; }
.webio-tool__masthead strong { font-size: 1rem; letter-spacing: 0; margin-top: 3px; }
.webio-tool__device-mark { border: 1px solid #55736d; border-radius: 4px; color: #c9ded9 !important; padding: 6px 8px; }

.webio-tool__connection {
  align-items: end;
  background: #f8faf9;
  border-bottom: 1px solid var(--webio-line);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.55fr) auto auto;
  min-width: 0;
  padding: 14px 16px;
  width: 100%;
}

.webio-tool__field {
  color: var(--webio-muted);
  display: grid;
  font-size: 0.63rem;
  font-weight: 650;
  gap: 4px;
  letter-spacing: 0;
  min-width: 0;
  text-transform: uppercase;
}

.webio-tool__field select,
.webio-tool__field input {
  background: var(--webio-surface);
  border: 1px solid var(--webio-line);
  border-radius: 5px;
  color: var(--webio-ink);
  min-width: 0;
  padding: 8px 10px;
  width: 100%;
}

.webio-tool__status {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--webio-line);
  display: flex;
  font-size: 0.72rem;
  gap: 9px;
  min-height: 44px;
  padding: 9px 16px;
}

.webio-tool__status-dot { background: #89938f; border-radius: 50%; flex: 0 0 9px; height: 9px; width: 9px; }
.webio-tool__status.is-connected .webio-tool__status-dot { background: var(--webio-accent); }
.webio-tool__status.is-busy .webio-tool__status-dot { animation: webio-pulse 900ms ease-in-out infinite alternate; background: #c27820; }
.webio-tool__status.is-error .webio-tool__status-dot { background: var(--webio-danger); }
.webio-tool__identity { color: var(--webio-muted); font-family: "IBM Plex Mono", monospace; margin-left: auto; text-align: right; }
.webio-tool__bus-scan { background: var(--webio-panel); border-bottom: 1px solid var(--webio-line); color: var(--webio-muted); display: block; font: 0.65rem/1.45 "IBM Plex Mono", monospace; padding: 8px 16px; white-space: pre-wrap; }
@keyframes webio-pulse { from { opacity: 0.38; } to { opacity: 1; } }

.webio-help__open { flex: 0 0 auto; min-height: 34px !important; padding: 6px 10px !important; border: 1px solid #55736d !important; background: transparent !important; color: #dce8e5 !important; font: 700 0.65rem "IBM Plex Mono", monospace !important; }
.webio-help__dialog { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: auto; border: 1px solid #8aa19b; border-radius: 7px; background: #fff; color: #182321; box-shadow: 0 24px 70px rgba(12, 31, 27, 0.28); }
.webio-help__dialog::backdrop { background: rgba(11, 24, 21, 0.72); }
.webio-help__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 20px; background: #162421; color: #f4faf7; }
.webio-help__head span { color: #8eb7af; font: 700 0.62rem "IBM Plex Mono", monospace; text-transform: uppercase; }
.webio-help__head h2 { margin: 3px 0 0; color: inherit; font-size: 1.12rem; }
.webio-help__close { width: 36px; height: 36px; min-height: 36px !important; padding: 0 !important; border: 1px solid #55736d !important; background: transparent !important; color: #fff !important; font-size: 1.3rem !important; }
.webio-help__diagram { display: block; width: calc(100% - 40px); height: auto; margin: 20px; border: 1px solid #d5ddda; background: #eef3f1; }
.webio-help__diagram text { fill: #50625d; font: 700 11px "IBM Plex Mono", monospace; }
.webio-help__box { fill: #fff; stroke: #718780; stroke-width: 2; }
.webio-help__box--bridge { fill: #dcefed; stroke: #087f75; }
.webio-help__box--device { fill: #fff8e8; stroke: #b67a1f; }
.webio-help__screen { fill: #182724; stroke: #718780; stroke-width: 2; }
.webio-help__line, .webio-help__chip, .webio-help__usb, .webio-help__sensor-line { fill: none; stroke: #40554f; stroke-width: 3; }
.webio-help__node { fill: #087f75; }
.webio-help__sensor { fill: #f4dfad; stroke: #b67a1f; stroke-width: 2; }
.webio-help__sensor-line { stroke: #8a5a13; stroke-linecap: round; stroke-linejoin: round; }
.webio-help__wire { fill: none; stroke-width: 3; }
.webio-help__wire--1 { stroke: #087f75; }.webio-help__wire--2 { stroke: #bd7416; }.webio-help__wire--3 { stroke: #3d4a47; }.webio-help__wire--4 { stroke: #a33d32; }
.webio-help__dialog > p { margin: 0; padding: 0 20px 16px; color: #50625d; font-size: 0.88rem; line-height: 1.55; }
.webio-help__notes { display: grid; grid-template-columns: 25px 1fr; gap: 8px 10px; margin: 0 20px 20px; padding: 14px; border: 1px solid #d5ddda; background: #f8faf9; }
.webio-help__notes span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #087f75; color: #fff; font: 700 0.68rem "IBM Plex Mono", monospace; }
.webio-help__notes p { margin: 2px 0 0; color: #50625d; font-size: 0.78rem; line-height: 1.45; }

.webio-tool__scenes { background: var(--webio-scene); display: grid; grid-template-columns: repeat(var(--webio-scene-count, 2), 1fr); min-height: 440px; }
.webio-tool__scene { min-height: 440px; min-width: 0; overflow: hidden; position: relative; }
.webio-tool__scene + .webio-tool__scene { border-left: 1px solid #344247; }
.webio-tool__canvas { display: block; height: 100%; inset: 0; position: absolute; width: 100%; }
.webio-tool__scene-label { color: #dce8e5; left: 16px; pointer-events: none; position: absolute; top: 15px; z-index: 2; }
.webio-tool__scene-label strong,
.webio-tool__scene-label span { display: block; }
.webio-tool__scene-label strong { font-size: 0.75rem; letter-spacing: 0; }
.webio-tool__scene-label span { color: #91a6a1; font: 0.67rem "IBM Plex Mono", monospace; margin-top: 3px; }
.webio-tool__angles { bottom: 14px; color: #dce8e5; display: flex; font: 0.67rem "IBM Plex Mono", monospace; gap: 12px; left: 16px; pointer-events: none; position: absolute; z-index: 2; }

.webio-tool__plot-wrap { background: var(--webio-scene); height: 360px; position: relative; }
.webio-tool__plot { display: block; height: 100%; width: 100%; }
.webio-tool__legend { color: #c9dad6; display: flex; flex-wrap: wrap; font: 0.66rem "IBM Plex Mono", monospace; gap: 12px; left: 17px; pointer-events: none; position: absolute; top: 15px; }
.webio-tool__legend span { align-items: center; display: inline-flex; gap: 5px; }
.webio-tool__legend i { border-radius: 50%; display: block; height: 7px; width: 7px; }

.webio-tool__telemetry { background: var(--webio-surface); border-bottom: 1px solid var(--webio-line); display: grid; grid-template-columns: repeat(var(--webio-reading-count, 4), minmax(72px, 1fr)); }
.webio-tool__reading { border-right: 1px solid var(--webio-line); min-width: 0; padding: 11px 12px; }
.webio-tool__reading:last-child { border-right: 0; }
.webio-tool__reading span,
.webio-tool__reading strong { display: block; }
.webio-tool__reading span { color: var(--webio-muted); font-size: 0.58rem; font-weight: 650; text-transform: uppercase; }
.webio-tool__reading strong { font: 700 0.78rem "IBM Plex Mono", monospace; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; }

.webio-tool__workspace { background: var(--webio-panel); display: grid; grid-template-columns: repeat(var(--webio-panel-count, 3), 1fr); }
.webio-tool__panel { border-right: 1px solid var(--webio-line); min-width: 0; padding: 16px; }
.webio-tool__panel:last-child { border-right: 0; }
.webio-tool__panel h3 { color: var(--webio-muted); font-size: 0.62rem; font-weight: 700; letter-spacing: 0; margin: 0 0 11px; text-transform: uppercase; }
.webio-tool__fields { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.webio-tool__actions { display: grid; gap: 7px; grid-template-columns: repeat(2, 1fr); margin-top: 10px; }
.webio-tool__result { background: var(--webio-surface); border: 1px solid #d5ddda; border-left: 3px solid #98aaa5; color: var(--webio-muted); display: block; font: 0.68rem/1.45 "IBM Plex Mono", monospace; margin: 9px 0 0; min-height: 58px; overflow-wrap: anywhere; padding: 9px 10px; white-space: pre-wrap; width: 100%; }
.webio-tool__file { display: none; }
.webio-tool__copy { color: var(--webio-muted); font-size: 0.72rem; line-height: 1.55; margin: 0; }

.webio-tool__pin-grid { background: var(--webio-panel); display: grid; gap: 1px; grid-template-columns: repeat(var(--webio-pin-columns, 4), minmax(0, 1fr)); }
.webio-tool__pin { background: var(--webio-surface); min-width: 0; padding: 13px; }
.webio-tool__pin header { align-items: center; display: flex; justify-content: space-between; margin-bottom: 9px; }
.webio-tool__pin header span { font: 700 0.72rem "IBM Plex Mono", monospace; }
.webio-tool__pin header b { color: var(--webio-muted); font: 700 0.62rem "IBM Plex Mono", monospace; }
.webio-tool__pin header b.is-high { color: var(--webio-accent); }
.webio-tool__pin button { margin-top: 9px; width: 100%; }
.webio-tool__toggle { align-items: center; color: var(--webio-muted); display: flex; font-size: 0.68rem; gap: 6px; margin-top: 9px; }
.webio-tool__toggle input { accent-color: var(--webio-accent); height: 16px; width: 16px; }

.webio-tool__pwm-grid { background: var(--webio-panel); display: grid; gap: 1px; grid-template-columns: repeat(var(--webio-pwm-columns, 4), minmax(0, 1fr)); }
.webio-tool__pwm-banks { background: var(--webio-panel); display: grid; gap: 1px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.webio-tool__pwm-bank { background: var(--webio-surface); min-width: 0; }
.webio-tool__pwm-bank > header { align-items: center; border-bottom: 1px solid var(--webio-line); display: flex; justify-content: space-between; padding: 8px 11px; }
.webio-tool__pwm-bank > header span { color: var(--webio-ink); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.webio-tool__pwm-bank > header b { color: var(--webio-muted); font: 0.6rem "IBM Plex Mono", monospace; }
.webio-tool__pwm-bank .webio-tool__pwm-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.webio-tool__pwm { background: var(--webio-surface); display: grid; gap: 7px; padding: 10px; }
.webio-tool__pwm span { display: flex; font: 700 0.7rem "IBM Plex Mono", monospace; justify-content: space-between; }
.webio-tool__pwm span strong { font: inherit; }
.webio-tool__pwm b { color: var(--webio-accent); }
.webio-tool__pwm input { accent-color: var(--webio-accent); min-width: 0; width: 100%; }
.webio-tool__pwm output { color: var(--webio-muted); font: 0.58rem "IBM Plex Mono", monospace; text-align: right; }
.webio-tool__actions--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.webio-tool--compact-gpio .webio-tool__pin { padding: 10px; }
.webio-tool--compact-gpio .webio-tool__pin header { margin-bottom: 6px; }
.webio-tool--compact-gpio .webio-tool__pin button { margin-top: 6px; padding-inline: 6px; }
.webio-tool--compact-gpio .webio-tool__toggle { margin-top: 6px; }
.webio-tool--port-cells .webio-tool__pin-grid { grid-template-columns: repeat(var(--webio-pin-columns), minmax(74px, 1fr)); max-width: 100%; min-width: 0; overflow-x: auto; width: 100%; }
.webio-tool--port-cells .webio-tool__pin { border-top: 4px solid #89938f; padding: 9px 6px 8px; }
.webio-tool--port-cells .webio-tool__pin.is-high { border-top-color: var(--webio-accent); background: #dff2ed; }
.webio-tool--port-cells .webio-tool__pin.is-output:not(.is-high) { background: #f7f9f8; }
.webio-tool__pin-actions { display: grid; gap: 5px; }
.webio-tool--port-cells .webio-tool__pin-actions { grid-template-columns: 1fr; }
.webio-tool__pin-actions button { font: 700 0.58rem "IBM Plex Mono", monospace; margin: 0; min-height: 30px; padding: 4px 2px; }
.webio-tool__pin-actions button[aria-pressed="true"] { border-color: var(--webio-accent); color: var(--webio-accent); background: #edf8f5; }
.webio-tool__editor-panel { display: grid; grid-template-rows: auto minmax(130px, 1fr) auto auto; }
.webio-tool__editor {
  background: #10191b;
  border: 1px solid #344247;
  border-radius: 5px;
  color: #dce8e5;
  font: 0.7rem/1.5 "IBM Plex Mono", monospace;
  min-height: 130px;
  padding: 10px;
  resize: vertical;
  tab-size: 2;
  width: 100%;
}
.webio-tool__editor:focus { border-color: var(--webio-accent); box-shadow: 0 0 0 2px rgba(8, 118, 110, 0.14); outline: none; }

@media (max-width: 900px) {
  .webio-tool__connection { grid-template-columns: 1fr 1fr; }
  .webio-tool__telemetry { grid-template-columns: repeat(4, 1fr); }
  .webio-tool__workspace { grid-template-columns: 1fr; }
  .webio-tool__panel { border-bottom: 1px solid var(--webio-line); border-right: 0; }
  .webio-tool__panel:last-child { border-bottom: 0; }
  .webio-tool--compact-gpio:not(.webio-tool--port-cells) .webio-tool__pin-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .webio-tool__pwm-banks { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .webio-tool { max-width: calc(100vw - 24px); }
  .webio-tool__connection,
  .webio-tool__scenes { grid-template-columns: 1fr; }
  .webio-tool__masthead { min-height: 62px; padding: 11px 13px; }
  .webio-tool__device-mark { display: none !important; }
  .webio-tool__scene { min-height: 330px; }
  .webio-tool__plot-wrap { height: 300px; }
  .webio-tool__scene + .webio-tool__scene { border-left: 0; border-top: 1px solid #344247; }
  .webio-tool__identity { display: none; }
  .webio-tool__telemetry { grid-template-columns: repeat(2, 1fr); }
  .webio-tool__reading { border-bottom: 1px solid var(--webio-line); }
  .webio-tool__reading:nth-child(2n) { border-right: 0; }
  .webio-tool__fields { grid-template-columns: 1fr; }
  .webio-tool__pin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .webio-tool--compact-gpio:not(.webio-tool--port-cells) .webio-tool__pin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .webio-tool__pwm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .webio-tool__pwm-bank .webio-tool__pwm-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .webio-tool__actions--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .webio-help__diagram { width: calc(100% - 24px); margin: 12px; }
  .webio-help__dialog > p { padding-inline: 14px; }
  .webio-help__notes { margin: 0 14px 14px; }
}
