/* IoT Circuit Studio — styles */
/* Colour-coded calculations in the Properties sidebar, using theme palettes. */
#inspector .ohms-card {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary-text);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
#inspector .ohms-card p { margin: 8px 0; }
#inspector .ohms-title, #inspector .ohms-voltage { color: var(--primary-text); }
#inspector .ohms-title { font-size: 13px; }
#inspector .ohms-formula {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--accent-text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
#inspector .ohms-current { color: var(--ok-fg); }
#inspector .ohms-resistance, #inspector .ohms-power { color: var(--warn-text); }
#inspector .ohms-note { color: var(--muted); font-size: 11px; }
#power-summary .power-card { border-left: 4px solid var(--primary-text); padding: 10px; background: var(--surface-2); border-radius: 6px; overflow-wrap: anywhere; }
#power-summary .ohms-title { color: var(--primary-text); }
#power-summary .ohms-note { color: var(--muted); font-size: 11px; }
#power-summary .table { font-size: 11px; }
#power-summary details { margin-top: 12px; }
:root {
  color-scheme: light;
  --draw-filter: none;
  /* colours that differ in the dark theme (set again in both dark blocks at the end) */
  --btn-primary: var(--primary-2);
  --btn-primary-hover: var(--primary);
  --btn-accent: #0f766e; /* white text: 5.5:1 (the lighter --accent is for fills and borders) */
  --btn-accent-hover: #115e59;
  --accent-text: #0f766e;
  --warn-text: #b45309;
  --primary-text: var(--primary); /* the brand blue used as text: tabs, logo, numbers */
  --sim-tab-fg: #047857;
  --tip-fg: #57534e;
  --k-blue-fg: #1d4ed8;
  --k-black-fg: #111827;
  --k-purple-fg: #6d28d9;
  --ic-fg: #fff; /* the tick / cross inside the coloured check circles */
  --bb-table: #fdfaf3; /* the surface the breadboard and board sit on (Breadboard and Simulate tabs) */
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --surface-4: #e2e8f0;
  --ok-bg: #dcfce7;
  --ok-bg-2: #ecfdf5;
  --ok-bg-3: #f0fdf4;
  --ok-bg-5: #a7f3d0;
  --warn-bg: #fffbeb;
  --warn-bg-2: #fef3c7;
  --warn-bg-3: #fde68a;
  --err-bg: #fef2f2;
  --err-bg-2: #fee2e2;
  --info-bg: #eff6ff;
  --info-bg-2: #dbeafe;
  --info-bg-3: #eef2ff;
  --info-bg-4: #e0e7ff;
  --text-2: #334155;
  --text-3: #475569;
  --muted-2: #94a3b8;
  --ok-fg: #166534;
  --ok-fg-2: #065f46;
  --ok-fg-3: #15803d;
  --warn-fg: #92400e;
  --warn-fg-2: #b45309;
  --warn-fg-3: #78350f;
  --err-fg: #991b1b;
  --err-fg-2: #b91c1c;
  --err-fg-3: #7f1d1d;
  --info-fg: #3730a3;
  --info-fg-2: #1e3a8a;
  --info-fg-3: #1e40af;
  --sky-bg: #f0f9ff;
  --sky-bg-2: #e0f2fe;
  --purple-bg: #ede9fe;
  --teal-bg: #f0fdfa;
  --orange-bg: #ffedd5;
  --cream-bg: #fffdf7;
  --sky-border: #bae6fd;
  --teal-border: #99f6e4;
  --border-strong: #cbd5e1;
  --border-strong-2: #94a3b8;
  --ok-border: #86efac;
  --ok-border-2: #bbf7d0;
  --warn-border-2: #fde68a;
  --err-border: #fecaca;
  --glass-60: rgba(255, 255, 255, 0.6);
  --glass-95: rgba(255, 255, 255, 0.95);
  --glass-90: rgba(255, 255, 255, 0.9);
  --bg: #eef2f7;
  --panel: #ffffff;
  --border: #dbe3ee;
  --text: #0f172a;
  --muted: #5d6c82; /* 4.75:1 on the page background (WCAG AA) */
  --primary: #1e40af;
  --primary-2: #2563eb;
  --accent: #0d9488;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  --topbar: 58px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
button { font: inherit; color: inherit; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 8px; color: var(--text-2); text-transform: none; }
p { line-height: 1.45; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
}
code { font-family: var(--mono); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.board-pin-warning { background: var(--warn-bg); color: var(--warn-fg); border-left: 3px solid var(--warn); padding: 10px; margin: 12px 0; border-radius: 6px; }
.board-pin-warning p { margin: 6px 0 0; }
.board-setup { margin: 12px 0; padding: 10px; border: 1px solid var(--border); border-radius: 6px; }
.board-setup summary { cursor: pointer; font-weight: 600; }
.power-component { margin: 8px 0; }
.power-component > summary { cursor: pointer; padding: 6px 0; overflow-wrap: anywhere; }
.power-component > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.power-component-total { display: block; margin: 4px 0 0 18px; color: var(--muted); font-size: 12px; }
.warn-text { color: var(--warn-text); font-weight: 600; }
.cs-wire-legend { display: inline-flex; gap: 8px; align-items: center; margin-left: auto; font-size: 11px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.cs-wire-legend span { display: inline-flex; align-items: center; gap: 3px; }
.cs-wire-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cs-wire-legend .signal { background: #2563eb; }.cs-wire-legend .ground { background: #334155; }.cs-wire-legend .threev3 { background: #dc2626; }.cs-wire-legend .fivev { background: #ea580c; }
.theme-picker { height: 30px; width: 190px; max-width: 190px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: #b8c4d6; }
.btn:focus-visible, .icon-btn:focus-visible, .part-card:focus-visible, .chip:focus-visible, .tabs button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 1px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--btn-primary); border-color: var(--btn-primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--btn-primary-hover); }
.btn.accent { background: var(--btn-accent); border-color: var(--btn-accent); color: #fff; }
.btn.accent:hover { background: var(--btn-accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--err-bg); border-color: var(--err-border); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(15, 23, 42, 0.06); }
.btn.small { padding: 5px 9px; font-size: 12.5px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.icon-btn:hover:not(:disabled) { background: rgba(15, 23, 42, 0.07); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: .1px; color: var(--primary-text); white-space: nowrap; }
.brand svg { filter: drop-shadow(0 2px 5px rgba(45, 212, 191, .22)); flex: 0 0 auto; }
.project-name { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 120px; max-width: 420px; }
.project-name input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  background: var(--surface-2);
}
.project-name input:hover { border-color: var(--border); }
.project-name input:focus { outline: none; border-color: var(--primary-2); background: var(--surface); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.save-state { font-size: 11.5px; font-weight: 600; white-space: nowrap; padding: 2px 8px; border-radius: 99px; }
.save-state.ok { color: var(--ok); background: var(--ok-bg); }
.save-state.warn { color: var(--warn-fg); background: var(--warn-bg-2); }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 6px;
  min-width: 260px;
  z-index: 50;
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.menu button:hover { background: var(--surface-3); }
.menu button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.schematic { -webkit-touch-callout: none; } /* a long press opens our menu, not the iPad's */
.menu.ctx-menu { position: fixed; right: auto; top: 0; min-width: 210px; z-index: 200; }
.ctx-menu button { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 6px 10px; }
.ctx-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ctx-menu button:disabled { opacity: 0.45; cursor: default; background: none; }
.ctx-menu button:focus { background: var(--surface-3); }
.ctx-menu button.danger:not(:disabled) { color: var(--danger); }
.ctx-menu kbd { color: var(--muted); white-space: nowrap; }
.ctx-menu .menu-label { text-transform: none; letter-spacing: 0; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-bar { display: none; }

/* ---------- App layout ---------- */
.app {
  --palette-w: 236px;
  --side-w: 350px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, var(--palette-w)) minmax(0, 1fr) minmax(0, var(--side-w));
  height: calc(100vh - var(--topbar));
  height: calc(100dvh - var(--topbar));
  transition: grid-template-columns 0.18s ease;
}
.palette, .side { background: var(--panel); overflow-y: auto; }
.palette { grid-column: 1; border-right: 1px solid var(--border); padding: 14px; }
.side { grid-column: 3; border-left: 1px solid var(--border); }

/* Collapse tabs: reclaim canvas width on a smaller desktop window without dropping to the mobile drawers. */
.panel-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 6;
  box-shadow: var(--shadow);
  transition: left 0.18s ease, right 0.18s ease, background 0.15s, color 0.15s;
}
.panel-toggle:hover { background: var(--surface-2); color: var(--text); }
#palette-toggle { left: calc(var(--palette-w) - 11px); }
#side-toggle { right: calc(var(--side-w) - 11px); }
html.pnl-palette-collapsed .app { --palette-w: 30px; }
html.pnl-side-collapsed .app { --side-w: 30px; }
@media (min-width: 1101px) {
  html.pnl-palette-collapsed .palette { padding: 0; overflow: hidden; }
  html.pnl-side-collapsed .side { overflow: hidden; }
  html.pnl-palette-collapsed .palette > * { display: none; }
  html.pnl-side-collapsed .side > * { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .app, .panel-toggle { transition: none; }
}
/* The Parts palette and the Properties & circuit check panel only apply to the schematic you're editing, so both
   (and their collapse tabs and mobile drawer buttons) only appear on the Schematic tab — every other tab gets the
   canvas width instead. */
body.hide-palette .palette, body.hide-palette #palette-toggle, body.hide-palette #btn-show-palette { display: none; }
body.hide-side .side, body.hide-side #side-toggle, body.hide-side #btn-show-side { display: none; }
@media (min-width: 1101px) {
  body.hide-palette .app { --palette-w: 0px; }
  body.hide-side .app { --side-w: 0px; }
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.close-drawer { display: none; }
.panel-head.mobile-only { display: none; }
#board-select {
  width: 100%;
  max-width: 240px;
  min-width: 0;
  min-height: 32px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  margin-bottom: 16px;
  background: var(--surface-2);
}
.part-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  margin-bottom: 2px;
}
.part-search:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.part-card[hidden], .palette-group[hidden] { display: none; }
.palette h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 6px; }
.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.part-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  cursor: grab;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.part-card:hover { border-color: var(--primary-2); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15); }
.part-card:active { transform: scale(0.97); cursor: grabbing; }
.part-icon { display: flex; width: 56px; height: 36px; align-items: center; justify-content: center; }
.part-icon svg { max-width: 100%; max-height: 100%; }
.part-name { font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.2; }
.howto { margin-top: 18px; padding: 10px 12px; background: var(--sky-bg); border: 1px solid var(--sky-border); border-radius: 10px; font-size: 12.5px; }
.howto h3 { margin: 0 0 6px; color: #075985; text-transform: none; letter-spacing: 0; font-size: 13px; }
.howto ol { margin: 0 0 6px; padding-left: 18px; }
.howto li { margin: 2px 0; }
.howto p { margin: 6px 0 0; }

/* colour keys */
.k { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; margin: 1px 2px; }
.k.blue { background: var(--info-bg-2); color: var(--k-blue-fg); }
.k.red { background: var(--err-bg-2); color: var(--err-fg-2); }
.k.black { background: var(--surface-4); color: var(--k-black-fg); }
.k.purple { background: var(--purple-bg); color: var(--k-purple-fg); }
.k.green { background: var(--ok-bg); color: var(--ok-fg-3); }
.k.amber { background: var(--warn-bg-2); color: var(--warn-fg-2); }

/* ---------- Center ---------- */
.center { grid-column: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 10px 0; background: var(--bg); } /* wraps rather than hiding tabs off-screen */
.tabs button {
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  padding: 9px 14px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
}
.tabs button:hover { background: var(--glass-60); }
.tabs button.active { background: var(--surface); border-color: var(--border); color: var(--primary-text); }
.view { display: none; flex: 1; min-height: 0; flex-direction: column; background: var(--surface); border-top: 1px solid var(--border); margin-top: -1px; }
.view.active { display: flex; }
.banner { padding: 8px 14px; font-size: 13px; background: var(--surface-2); border-bottom: 1px solid var(--border); line-height: 1.45; }
.banner .tag {
  display: inline-block;
  font-weight: 800;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 6px;
  background: var(--info-bg-4);
  color: var(--info-fg);
}
.schematic-banner { background: var(--info-bg-3); }
.wire-howto { display: inline-flex; align-items: center; gap: 7px 12px; flex-wrap: wrap; }
.wire-howto b { white-space: nowrap; }
.ring-best { color: #16a34a; }
.ring-ok { color: #2563eb; }
.ring-avoid { color: #b45309; }
.ring-used { color: #dc2626; }
:root[data-theme="high-contrast"] .ring-best { color: #00ff80; }
:root[data-theme="high-contrast"] .ring-ok { color: #00ffff; }
:root[data-theme="high-contrast"] .ring-avoid { color: #ffff00; }
:root[data-theme="high-contrast"] .ring-used { color: #ff5555; }
:root[data-theme="high-contrast"] .schematic-banner { background: #000 !important; color: #fff !important; border-bottom: 2px solid #fff !important; }
:root[data-theme="high-contrast"] .schematic-banner .tag { background: #ffff00 !important; color: #000 !important; border: 2px solid #ffff00; }
:root[data-theme="high-contrast"] .wire-howto > span { border-left: 2px solid #fff; padding-left: 9px; }
:root[data-theme="high-contrast"] .wire-howto > span:first-child { border-left: 0; padding-left: 0; }
:root[data-theme="high-contrast"] .wire-howto kbd { background: #000; color: #fff; border: 1px solid #fff; }
.breadboard-banner { background: var(--warn-bg); }
.breadboard-banner .tag { background: var(--warn-bg-3); color: var(--warn-fg-3); }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.zoom { font-size: 12px; font-weight: 600; min-width: 42px; text-align: center; color: var(--muted); }
.wiring-hint { margin-left: auto; font-size: 12.5px; font-weight: 600; color: #0369a1; background: var(--sky-bg-2); padding: 4px 10px; border-radius: 99px; }
.canvas-wrap { flex: 1; position: relative; min-height: 0; }
.schematic { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; background: #fbfdff; display: block; }
.schematic.panning { cursor: grabbing; }
.schematic.pan-ready { cursor: grab; }
.schematic .note { cursor: move; }
.schematic .comp { cursor: move; }
.schematic .wire, .schematic .wire-label { cursor: pointer; }
.schematic .pin { cursor: crosshair; }
.schematic .pin:hover { fill: rgba(14, 165, 233, 0.3); stroke: #0ea5e9; stroke-width: 1.5; }
.schematic .pin-dot { fill: #fff; stroke: #64748b; stroke-width: 1.2; pointer-events: none; }
.schematic .pin-dot.on { fill: var(--muted); }
.schematic .pin-lead { cursor: pointer; }
.schematic .wire:hover polyline:last-child { stroke-width: 3; }

/* ---------- Breadboard ---------- */
.bb-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; }
.bb-canvas-wrap { position: relative; min-width: 0; min-height: 0; display: flex; }
.bb-canvas { flex: 1; overflow: auto; padding: 12px; background: var(--bb-table); }
.bb-canvas svg { width: 100%; height: auto; display: block; max-width: none; }
.bb-canvas.panning, .bb-canvas.panning * { cursor: grabbing !important; }
.bb-zoom { position: absolute; right: 14px; bottom: 14px; display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--glass-95); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12); }
.bb-canvas .bb-wire, .bb-canvas .bb-part { transition: opacity 0.15s; }
.bb-canvas.focusing .bb-wire:not(.hl), .bb-canvas.focusing .bb-part:not(.hl) { opacity: 0.18; }
.bb-steps { border-left: 1px solid var(--border); overflow-y: auto; padding: 12px 14px; font-size: 13px; }
.bb-steps h3 { margin-top: 0; }
.bb-steps ol { padding-left: 22px; margin: 0; }
.bb-steps li { padding: 6px 6px; border-radius: 6px; line-height: 1.4; cursor: default; }
.bb-steps li[data-jumper], .bb-steps li[data-comp] { cursor: pointer; }
.bb-steps li:hover { background: var(--warn-bg-2); }
.bb-steps li.done { color: var(--muted); text-decoration: line-through; }
.note { margin-top: 12px; font-size: 12px; color: var(--warn-fg-3); background: var(--warn-bg); border: 1px solid var(--warn-border-2); padding: 8px 10px; border-radius: 8px; line-height: 1.45; }

/* Breadboard editing */
.bb-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--cream-bg); flex-wrap: wrap; min-height: 42px; font-size: 12.5px; }
.bb-tip { color: var(--tip-fg); flex: 1; }
.bb-sel { font-weight: 700; flex: 1; }
.bb-sel .muted { font-weight: 400; }
.bb-swatches { display: inline-flex; gap: 4px; }
.bb-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px #94a3b8; cursor: pointer; padding: 0; }
.bb-swatch:not(.auto-swatch) { background: var(--swatch-color) !important; }
.bb-swatch.on { box-shadow: 0 0 0 2px #0ea5e9; }
.auto-swatch { background: repeating-conic-gradient(#dc2626 0deg 90deg, #2563eb 90deg 180deg, #16a34a 180deg 270deg, #eab308 270deg 360deg) !important; }
.wire-bend { cursor: grab; }
.wire-bend:active { cursor: grabbing; }
.wire-mid { cursor: copy; }
.wire-mid:hover { fill-opacity: 0.9; }
.wire-end { cursor: grab; }
.wire-end:hover { stroke-width: 2.5; }
.wire-end:active { cursor: grabbing; }
svg.bb-editable .bb-part { cursor: grab; }
svg.bb-editable .bb-part.dragging { cursor: grabbing; opacity: 0.85; }
svg.bb-editable .bb-part.sel { filter: drop-shadow(0 0 3px #0ea5e9) drop-shadow(0 0 1px #0ea5e9); }
svg.bb-editable .bb-wire { cursor: pointer; }
svg.bb-editable .bb-wire.sel path:last-of-type { stroke-width: 4; }
svg.bb-editable .bb-wire.sel { filter: drop-shadow(0 0 2px #0ea5e9); }
.bb-handle { fill: transparent; stroke: transparent; cursor: move; }
svg.bb-editable .bb-handle:hover { fill: rgba(14, 165, 233, 0.25); stroke: #0ea5e9; stroke-width: 1.5; }
.bb-ghost { fill: rgba(14, 165, 233, 0.3); stroke: #0ea5e9; stroke-width: 2; pointer-events: none; }
.bb-ghost.bad { fill: rgba(220, 38, 38, 0.25); stroke: #dc2626; }

/* ---------- Tables ---------- */
.doc { padding: 14px 18px; overflow: auto; flex: 1; }
.doc-actions { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; background: var(--surface-3); padding: 8px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); border-bottom: 2px solid var(--border); }
.table td { padding: 8px 10px; border-bottom: 1px solid #edf2f7; vertical-align: top; }
.table tbody tr:hover { background: var(--surface-2); }
#wiring-table tr[data-wire] { cursor: pointer; }
.swatch { display: inline-block; width: 18px; height: 11px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, 0.2); box-shadow: 0 0 0 1px var(--border-strong); } /* the outline keeps a black wire visible on the dark theme */

/* ---------- Code ---------- */
.code-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.code-libs { font-size: 12.5px; color: var(--text, var(--text)); }
.lib { display: inline-block; background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; margin: 2px; color: var(--text-2); }
/* Editor: a transparent textarea over the highlighted <pre>. Both must share exact metrics. */
.code-editor { flex: 1; display: flex; min-height: 0; background: #0f172a; position: relative; overflow: hidden; }
.code-gutter {
  flex: none;
  width: 46px;
  padding: 14px 0;
  background: #0b1222;
  color: #8494ab; /* the code editor is dark in both themes */
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 20px;
  text-align: right;
  user-select: none;
  will-change: transform;
}
.code-gutter div { padding-right: 10px; }
.code-gutter .err { background: #7f1d1d; color: #fecaca; }
.code-gutter .warn { background: #78350f; color: #fde68a; }
.code-area { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.code,
.code-input {
  margin: 0;
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 20px;
  tab-size: 2;
  white-space: pre;
  letter-spacing: 0;
  word-spacing: 0;
}
.code { position: absolute; top: 0; left: 0; min-width: 100%; color: #e2e8f0; background: transparent; pointer-events: none; will-change: transform; }
.code code { font-size: inherit; font-family: inherit; }
.code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  overflow: auto;
  background: transparent;
  color: transparent;
  caret-color: #f8fafc;
  -webkit-text-fill-color: transparent;
}
.code-input::selection { background: rgba(96, 165, 250, 0.35); -webkit-text-fill-color: transparent; }
.code-input:focus { box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.35); }
.code-state .pill { font-size: 11.5px; }
.code-notice { padding: 8px 14px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-border-2); font-size: 13px; color: var(--warn-fg-3); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.code-notice[hidden] { display: none; }
.code-foot { border-top: 1px solid var(--border); max-height: 45%; overflow-y: auto; padding: 8px 14px; background: var(--surface); }
.code-foot .code-libs { margin-bottom: 6px; }
.code-lint h4 { margin: 4px 0 6px; font-size: 13px; }
.lint { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; padding: 5px 8px; border-radius: 7px; margin-bottom: 4px; background: var(--info-bg); color: var(--info-fg-2); }
.lint.error { background: var(--err-bg); color: var(--err-fg); }
.lint.warning { background: var(--warn-bg); color: var(--warn-fg); }
.lint .sev { font-size: 10.5px; font-weight: 800; text-transform: uppercase; background: none; color: inherit; padding: 0; }
.lint code { background: rgba(0, 0, 0, 0.06); padding: 0 4px; border-radius: 4px; }
.lint-line { border: 0; background: rgba(0, 0, 0, 0.07); border-radius: 5px; padding: 1px 6px; font-size: 11.5px; cursor: pointer; font-family: var(--mono); }
.lint-ok { font-size: 12.5px; color: var(--ok-fg); background: var(--ok-bg-3); padding: 6px 9px; border-radius: 7px; }
.c-com { color: #86efac; }
.c-str { color: #fcd34d; }
.c-pre { color: #f0abfc; }
.c-num { color: #fdba74; }
.c-kw { color: #7dd3fc; font-weight: 600; }

/* ---------- Side panel ---------- */
.panel { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stats div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px; text-align: center; }
.stats b { display: block; font-size: 20px; color: var(--primary-text); }
.stats span { font-size: 11.5px; color: var(--muted); }
.empty-cta { background: var(--teal-bg); border: 1px solid var(--teal-border); border-radius: 10px; padding: 10px 12px; }
.empty-cta p { margin: 0 0 8px; }
.insp-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.insp-head h2 { margin: 0; }
.insp-head .part-icon { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; width: 60px; height: 42px; }
.desc { font-size: 13px; color: var(--text-2); margin: 6px 0 10px; }
.field { display: block; margin: 8px 0; }
.field span { display: block; font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 4px; }
.field input, .field select, .pin-select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
}
.field input:focus, .field select:focus, .pin-select:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.pin-list { list-style: none; margin: 0; padding: 0; }
.pin-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.pin-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.pin-name { font-weight: 600; }
.pin-conn { text-align: right; font-size: 12.5px; color: var(--info-fg-2); font-weight: 600; }
.pin-select { font-size: 12.5px; padding: 5px 7px; }
.chips { margin-top: 5px; font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--ok-border);
  background: var(--ok-bg-3);
  color: var(--ok-fg-3);
  border-radius: 99px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.chip:hover { background: var(--ok-bg); }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 8px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.legend { margin: 6px 0; }
.insp-issues { margin-top: 10px; font-size: 12.5px; background: var(--err-bg); color: var(--err-fg); border-radius: 8px; padding: 6px 10px; }

/* Circuit check */
#check-panel h2 { display: flex; align-items: center; gap: 8px; }
.compare-btn { margin-top: 10px; width: 100%; }
.teacher-box { margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); }
.teacher-box h3 { margin: 0 0 6px; font-size: 14px; }
.teacher-box label { display: block; line-height: 1.45; }
.hints-note { font-size: 12.5px; background: var(--info-bg-2); color: var(--info-fg); padding: 8px 10px; border-radius: 8px; margin: 0 0 10px; }
.compare-score { display: flex; align-items: center; gap: 12px; margin: 6px 0 12px; }
.compare-score meter { flex: 1; height: 14px; }
.compare-score b { font-size: 22px; }
.compare-list { padding-left: 18px; }
.compare-list li { margin-bottom: 6px; }
.count { display: inline-flex; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 800; }
.count.ok { background: var(--ok-bg); color: var(--ok-fg-3); }
.count.warn { background: var(--warn-bg-2); color: var(--warn-fg-2); }
.count.err { background: var(--err-bg-2); color: var(--err-fg-2); }
.check-summary { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; font-size: 12px; }
.check-summary li { display: flex; align-items: center; gap: 6px; }
.check-summary .ic { display: inline-flex; width: 17px; height: 17px; border-radius: 50%; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: var(--ic-fg); flex: none; }
.check-summary .ok .ic { background: var(--ok); }
.check-summary .idle .ic { background: var(--muted); }
.check-summary .idle { color: var(--muted); }
.count.idle { background: var(--surface-2); color: var(--muted); }
.check-summary .warn .ic { background: var(--warn); }
.check-summary .err .ic { background: var(--danger); }
.issue { border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: 9px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; background: var(--surface); transition: box-shadow 0.15s; }
.issue:hover { box-shadow: var(--shadow); }
.issue.error { border-left-color: var(--danger); }
.issue.warning { border-left-color: var(--warn); }
.issue.focused { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35); }
.issue-head { display: flex; gap: 8px; align-items: baseline; }
.issue h4 { margin: 0; font-size: 13.5px; line-height: 1.35; }
.sev { flex: none; font-size: 10.5px; font-weight: 800; text-transform: uppercase; padding: 1px 6px; border-radius: 5px; background: var(--info-bg-2); color: #1d4ed8; }
.issue.error .sev { background: var(--err-bg-2); color: var(--err-fg-2); }
.issue.warning .sev { background: var(--warn-bg-2); color: var(--warn-fg-2); }
.issue p { margin: 6px 0 0; font-size: 12.5px; color: var(--text-2); }
.issue .fix { color: var(--text); }
.issue-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.all-good { text-align: center; background: var(--ok-bg-3); border: 1px solid var(--ok-border-2); border-radius: 10px; padding: 16px; font-size: 13px; line-height: 1.5; }
.all-good .big { font-size: 30px; }

/* ---------- Tooltip, toast, modal, tour ---------- */
.tooltip {
  position: fixed;
  z-index: 60;
  max-width: 290px;
  background: #0f172a;
  color: #f1f5f9;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.tooltip .muted { color: var(--muted-2); }
.tooltip div { margin-top: 3px; }
.tip-hint { color: #7dd3fc; font-size: 11.5px; }
.tip-rate { font-weight: 600; }
.tip-rate.best, .tip-rate.shared { color: #86efac; }
.tip-rate.ok { color: #bef264; }
.tip-rate.avoid { color: #fcd34d; }
.tip-rate.used { color: #fca5a5; }
.tip-rate.bad { color: #cbd5e1; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 20px);
  background: rgba(15, 23, 42, 0.68);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  max-width: min(560px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}
/* a message sits at the bottom, clear of the toolbar and tabs, and a click on it closes it */
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
.toast.ok { background: rgba(20, 83, 45, 0.72); }
.toast.warn { background: rgba(124, 45, 18, 0.72); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 14px; padding: 20px 22px; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3); }
.modal h2 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.share-link input { width: 100%; box-sizing: border-box; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: inherit; }
.proj-list { list-style: none; padding: 0; margin: 0; }
.proj-list li { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 6px; }
.proj-open { flex: 1; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; border-radius: 9px; }
.proj-open:hover { background: var(--surface-2); }
.proj-open .muted { font-size: 12px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; font-size: 13px; }
.help-grid h3 { margin-top: 10px; }
.help-grid ol { padding-left: 18px; }

.tour {
  position: fixed;
  left: 252px;
  bottom: 18px;
  width: 370px;
  max-width: calc(100vw - 32px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 2px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.20);
  backdrop-filter: blur(12px);
  padding: 12px 16px 14px;
  z-index: 70;
}
.tour[hidden] { display: none; }
.tour-top { display: flex; justify-content: space-between; align-items: center; }
.tour-count { font-size: 11.5px; font-weight: 700; color: var(--accent-text); text-transform: uppercase; letter-spacing: 0.04em; }
.tour-progress { height: 4px; background: var(--surface-4); border-radius: 4px; margin: 6px 0 10px; overflow: hidden; }
.tour-progress span { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }
.tour h3 { font-size: 16px; margin: 0 0 6px; color: var(--text); }
.tour-body { font-size: 13.5px; line-height: 1.5; }
.tour-status { margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--warn-fg); background: var(--warn-bg); padding: 5px 9px; border-radius: 7px; }
.tour-status.ok { color: var(--ok-fg); background: var(--ok-bg); }
.tour-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.tour-hl { outline: 3px solid var(--accent) !important; outline-offset: 2px; animation: pulse 1.4s ease-in-out infinite; border-radius: 8px; }
.cs-welcome { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: min(410px, calc(100% - 36px)); padding: 26px 28px; border: 1px solid var(--border-strong); border-radius: 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 18px 48px rgba(0, 0, 0, .22); backdrop-filter: blur(12px); text-align: center; z-index: 4; }
.cs-welcome[hidden] { display: none; }
.cs-welcome-kicker { color: var(--accent-text); font-weight: 800; font-size: 11px; letter-spacing: .1em; }
.cs-welcome h2 { margin: 7px 0 6px; font-size: 21px; }
.cs-welcome p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.cs-welcome-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.cs-welcome-board-label { display: block; margin: 14px 0 6px; text-align: left; font-weight: 600; }
#cs-welcome-board-select { width: 100%; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.cs-example-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.cs-example-list button { min-height: 46px; text-align: left; }
@keyframes pulse {
  0%, 100% { outline-color: rgba(13, 148, 136, 1); }
  50% { outline-color: rgba(13, 148, 136, 0.3); }
}

/* ---------- Simulation ---------- */
.tabs .sim-tab { color: var(--sim-tab-fg); }
.tabs .sim-tab.active { color: var(--sim-tab-fg); }
body.sim-running .tabs .sim-tab::after { content: ' ●'; color: #16a34a; animation: pulse-dot 1s infinite; }
@keyframes pulse-dot { 50% { opacity: 0.2; } }
.sim-banner { background: var(--ok-bg-2); }
.sim-banner .tag { background: var(--ok-bg-5); color: var(--ok-fg-2); }
.sim-clock { font-family: var(--mono); font-weight: 700; font-size: 13px; color: var(--ok-fg-2); background: var(--ok-bg-2); padding: 3px 9px; border-radius: 6px; }
.sim-live-hint { font-size: 12px; color: var(--muted); margin-left: auto; }
.sim-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
.sim-parts { overflow-y: auto; padding: 12px 16px; background: var(--surface-2); }
.sim-parts h3 { margin: 6px 0 10px; }
.sim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.sim-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.sim-card header { display: flex; gap: 8px; align-items: center; }
.sim-card header .part-icon { width: 44px; height: 30px; }
.sim-status { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg-2); color: var(--warn-fg); }
.pill.err { background: var(--err-bg-2); color: var(--err-fg); }
.sim-controls { display: flex; flex-direction: column; gap: 6px; }
.sim-ctl span { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); }
.sim-ctl input[type=range] { width: 100%; accent-color: #059669; }
.sim-hold { justify-content: center; user-select: none; -webkit-user-select: none; touch-action: none; }
.sim-keys { display: grid; gap: 4px; margin-top: 4px; }
.sim-keys .sim-key { justify-content: center; padding: 6px 4px; min-width: 0; font-weight: 600; user-select: none; -webkit-user-select: none; }
.sim-keys.grid .sim-key { font-family: ui-monospace, Menlo, Consolas, monospace; }
.btn.sim-key.down { background: #059669; color: #fff; border-color: #059669; transform: translateY(1px); }
.btn.sim-hold.down, .btn.sim-hold.down:hover { background: #059669; color: #fff; border-color: #059669; transform: translateY(1px); }
.sim-toggle { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.sim-out { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 40px; justify-content: center; }
.sim-reading { font-size: 12.5px; color: var(--text-2); text-align: center; }
.sim-reading.warn { color: var(--warn-fg-2); font-weight: 600; }
.sim-led { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border-strong-2); transition: background 0.08s, box-shadow 0.08s; }
.sim-led.burned { background: #57534e; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; border-color: #292524; }
.sim-buzzer { font-size: 30px; opacity: 0.35; filter: grayscale(1); }
.sim-buzzer.on { opacity: 1; filter: none; animation: shake 0.12s infinite; }
@keyframes shake { 50% { transform: rotate(8deg) scale(1.08); } }
.sim-relay { font-weight: 700; font-size: 13px; padding: 8px 12px; border-radius: 8px; background: var(--surface-3); color: var(--text-3); border: 2px solid var(--border-strong); }
.sim-relay.on { background: var(--ok-bg); color: var(--ok-fg); border-color: #16a34a; }
.sim-servo { width: 120px; }
.sim-strip { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; background: #0f172a; padding: 6px; border-radius: 6px; }
.sim-px { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.sim-oled { width: 100%; max-width: 256px; border-radius: 4px; border: 3px solid #0f172a; }
.sim-lcd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: #84cc16; color: #1a2e05; padding: 8px 10px; border-radius: 4px; border: 4px solid #1e3a8a; letter-spacing: 1px; line-height: 1.35; }
.sim-lcd.off { background: #3f6212; color: transparent; }
.sim-meter { width: 100%; height: 10px; background: var(--surface-4); border-radius: 99px; overflow: hidden; }
.sim-meter-bar { height: 100%; background: linear-gradient(90deg, #34d399, #059669); }
.sim-side { border-left: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; }
.sim-panel { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.sim-panel h3 { margin: 0 0 8px; }
.sim-panel-head { display: flex; justify-content: space-between; align-items: center; }
.sim-serial { background: #0f172a; color: #a7f3d0; font-family: var(--mono); font-size: 12px; height: 230px; overflow: auto; margin: 0; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; }
.sim-event { font-size: 12.5px; padding: 6px 9px; border-radius: 7px; margin-bottom: 6px; line-height: 1.4; }
.sim-event.error { background: var(--err-bg); color: var(--err-fg); }
.sim-event.warn { background: var(--warn-bg); color: var(--warn-fg); }
.sim-event.info { background: var(--info-bg); color: var(--info-fg-3); }
.sim-pins td, .sim-pins th { padding: 4px 6px; font-size: 12px; }
.lvl { font-weight: 800; font-size: 11px; padding: 1px 6px; border-radius: 5px; }
.lvl.high { background: var(--orange-bg); color: #c2410c; }
.lvl.low { background: var(--surface-4); color: var(--text-2); }
.lvl.float { background: var(--warn-bg-2); color: var(--warn-fg); }
.lvl.data { background: var(--info-bg-4); color: var(--info-fg); }

/* ---------- Wokwi-style simulator ---------- */
@media (min-width: 1101px) {
  body.sim-wide .app { grid-template-columns: 0 minmax(0, 1fr) 0; }
  body.sim-wide .palette, body.sim-wide .side { visibility: hidden; overflow: hidden; border: 0; padding: 0; }
}
.wk-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.wk-play {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: #16a34a; color: #fff; font-size: 17px; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.45); transition: transform 0.1s, background 0.15s;
}
.wk-play:hover { background: #15803d; transform: scale(1.05); }
.wk-play.running { background: #0f172a; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35); }
.wk-status { font-size: 13px; font-weight: 600; color: var(--ok-fg-2); }
.wk-status.stale { color: var(--warn-fg-2); }
.wk-status.bad { color: var(--err-fg-2); }
.wk-spacer { flex: 1; }
.wk-mode { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 12.5px; }
.wk-mode label { padding: 5px 10px; cursor: pointer; display: flex; gap: 5px; align-items: center; background: var(--surface); }
.wk-mode label:has(input:checked) { background: var(--ok-bg-2); color: var(--ok-fg-2); font-weight: 700; }
.wk-mode label.disabled { opacity: 0.45; cursor: not-allowed; }
.wk-mode input { accent-color: #059669; margin: 0; }
.wk-layout { flex: 1; display: grid; grid-template-columns: minmax(300px, 40%) minmax(0, 1fr); min-height: 0; }
.wk-code { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid #1e293b; background: #0f172a; }
.wk-pane-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: #1e293b; color: #cbd5e1; font-size: 12.5px; }
.wk-file { font-family: var(--mono); color: #f8fafc; background: #0f172a; padding: 3px 10px; border-radius: 6px 6px 0 0; }
.wk-code .muted { color: var(--muted-2); }
.wk-code-error { padding: 7px 12px; background: #7f1d1d; color: #fee2e2; font-size: 12.5px; line-height: 1.4; }
.wk-code-error[hidden] { display: none; }
.wk-code-error .lint-line { background: rgba(255, 255, 255, 0.18); color: #fff; }
.code-gutter .run { background: #14532d; color: #bbf7d0; }
.wk-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.wk-diagram-wrap { flex: 1; position: relative; min-height: 0; background: var(--bb-table); overflow: hidden; }
.wk-diagram { position: absolute; inset: 0; overflow: auto; padding: 10px; }
.wk-diagram svg { width: 100%; height: auto; display: block; min-width: 520px; max-width: none; }
.wk-diagram.panning, .wk-diagram.panning * { cursor: grabbing !important; }
.wk-diagram-wrap .bb-zoom { z-index: 3; }
.wk-hint { position: absolute; left: 10px; bottom: 8px; font-size: 11.5px; color: var(--text-3); background: var(--glass-90); padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border); pointer-events: none; }
.wk-hit { cursor: pointer; }
.wk-hit:hover { stroke: #0ea5e9; stroke-width: 2; stroke-dasharray: 4 3; }
.wk-hit.hold { cursor: grab; }
.wk-hit.hold.down { fill: rgba(34, 197, 94, 0.15); }
.wk-waves.on { animation: wk-pulse 0.25s infinite alternate; }
@keyframes wk-pulse { from { opacity: 0.35; } to { opacity: 1; } }
.wk-popover { position: fixed; width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22); padding: 10px 12px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.wk-popover[hidden] { display: none; }
/* pointer from the popover to its part (the popover sits above the part, or below when there's no room) */
.wk-popover::after { content: ''; position: absolute; left: var(--arrow-x, 50%); bottom: -7px; width: 12px; height: 12px; margin-left: -6px; background: var(--surface); border: 1px solid var(--border); border-top: 0; border-left: 0; transform: rotate(45deg); }
.wk-popover.below::after { bottom: auto; top: -7px; transform: rotate(225deg); }
.wk-pop-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.wk-pop-head .icon-btn { margin-left: auto; width: 26px; height: 26px; font-size: 14px; }
.wk-halt { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); background: var(--err-bg); border: 1px solid var(--err-border); color: var(--err-fg-3); border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.45; box-shadow: 0 10px 24px rgba(127, 29, 29, 0.15); z-index: 4; }
.wk-halt[hidden] { display: none; }
.wk-halt-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.wk-bottom { height: 36%; min-height: 170px; display: flex; flex-direction: column; border-top: 1px solid var(--border); background: var(--surface); }
.wk-tabs { display: flex; gap: 2px; padding: 4px 8px 0; background: var(--surface-3); border-bottom: 1px solid var(--border); min-width: 0; }
.wk-tabs button { white-space: nowrap; }
.wk-tabs button { border: 0; background: transparent; padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-3); border-radius: 8px 8px 0 0; cursor: pointer; }
.wk-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 -1px 0 var(--border) inset; }
.wk-panel { display: none; flex: 1; min-height: 0; overflow: auto; padding: 8px 10px; }
.wk-panel.active { display: flex; flex-direction: column; }
.wk-panel .sim-serial { flex: 1; height: auto; min-height: 60px; border-radius: 8px 8px 0 0; }
.wk-panel .sim-parts { padding: 0; background: transparent; overflow: visible; }
.sim-serial .partial { opacity: 0.85; }
.wk-serial-in { display: flex; gap: 6px; padding-top: 6px; }
.wk-serial-in input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-family: var(--mono); font-size: 12.5px; }
.wk-serial-in input:focus { outline: none; border-color: #059669; box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); }

/* ---------- Examples menu: lessons ---------- */
.menu { max-height: min(78vh, 640px); overflow-y: auto; }
.menu-label { padding: 6px 10px 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

/* ---------- Simulate: Dashboard (MQTT) ---------- */
.dash { padding: 10px 12px; }
.dash-empty { max-width: 560px; line-height: 1.5; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.dash-status { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.dash-mode { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 12.5px; }
.dash-mode label { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; cursor: pointer; }
.dash-mode label + label { border-left: 1px solid var(--border); }
.dash-mode label:has(input:checked) { background: var(--ok-bg-2); color: var(--ok-fg-2); font-weight: 700; }
.dash-btns-right { display: inline-flex; gap: 6px; }
.dash-login { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.dash-login input { margin-left: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.dash-status.ok { color: var(--ok-fg); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.dash-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; min-width: 0; color: var(--primary-2); }
.dash-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-val { font-size: 22px; font-weight: 700; color: var(--text); margin: 2px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dash-spark { width: 100%; height: 24px; display: block; }
.dash-btns { display: flex; gap: 4px; margin-top: 6px; }
.dash-log { margin-top: 10px; }
.dash-log summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.dash-log pre { font-family: var(--mono); font-size: 12px; max-height: 160px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin: 6px 0 0; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 10px 0; }
.iot-fields .row { display: flex; gap: 6px; }
.iot-format { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px 8px; margin: 8px 0; }
.iot-format legend { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 0 4px; }
.iot-format label { display: block; font-size: 13px; margin: 4px 0; line-height: 1.4; }
.iot-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.iot-row .grow { flex: 1; min-width: 180px; }
.iot-row .port { width: 90px; }
.iot-row .port input { width: 100%; }
.iot-row .tls { margin: 0 0 14px; }
.iot-broker .field[hidden] { display: none; }
.iot-fields .row input { flex: 1; min-width: 0; }

/* ---------- Simulate: Serial Plotter ---------- */
.plotter { display: flex; flex-direction: column; height: 100%; min-height: 220px; padding: 8px 12px; gap: 6px; }
.plot-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.plot-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; }
.plot-key { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.plot-key b { font-variant-numeric: tabular-nums; }
.plot-sw { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.plot-btns { display: flex; gap: 6px; }
.plot-canvas { flex: 1; width: 100%; min-height: 170px; border: 1px solid var(--border); border-radius: 8px; }

/* ---------- Simulate: Multimeter ---------- */
.meter { padding: 10px 12px; }
.meter-body { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.meter-face { background: #f5b800; border-radius: 16px; padding: 12px; width: 230px; box-shadow: inset 0 0 0 3px #1f2937; flex: none; }
.meter-lcd { background: #b7c9a8; color: #111827; border-radius: 6px; border: 3px solid #1f2937; height: 64px; display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; padding: 8px 12px; font-family: var(--mono); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25); }
.meter-lcd #meter-big { font-size: 34px; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.meter-lcd #meter-unit { font-size: 16px; font-weight: 700; }
.meter-modes { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.meter-mode { display: flex; align-items: center; gap: 6px; background: #1f2937; color: #f9fafb; border-radius: 8px; padding: 5px 8px; font-size: 13px; cursor: pointer; }
.meter-mode b { min-width: 26px; color: #fcd34d; }
.meter-mode.on { outline: 2px solid #fff; }
.meter-mode input { accent-color: #f5b800; }
.meter-probes { flex: 1; min-width: 220px; max-width: 460px; }
.meter-probes select { width: 100%; }
.meter-probes .field .probe, .probe { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin: 0 3px 0 0; border: 1px solid var(--border-strong-2); }
.probe.red { background: #dc2626; }
.probe.black { background: #111827; }
.meter-note { min-height: 1.4em; font-weight: 600; color: var(--text-2); }

/* ---------- Simulate: fault finding ---------- */
.fault-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-border-2); color: var(--warn-fg); font-size: 13px; }
.fault-bar[hidden] { display: none; }
.fault-bar.solved { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }
.fault-bar.gave-up { background: var(--info-bg); border-color: var(--border); color: var(--info-fg); }
.fault-bar .muted { color: inherit; opacity: 0.8; }
.fault-form { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.fault-form select { max-width: 220px; }
.fault-meta { font-variant-numeric: tabular-nums; opacity: 0.85; }
.fault-msg { flex-basis: 100%; font-weight: 600; }
.fault-msg:empty { display: none; }
.fault-actions { display: inline-flex; gap: 6px; }

/* ---------- Send to board (Web Serial) ---------- */
.ws-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.ws-baud { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.ws-out { font-family: var(--mono); font-size: 12.5px; background: #0b1220; color: #d1fae5; border-radius: 8px; padding: 10px; height: 220px; overflow: auto; white-space: pre-wrap; margin: 0 0 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .app { --palette-w: 210px; --side-w: 310px; }
  .tour { left: 226px; }
  .bb-layout { grid-template-columns: minmax(0, 1fr) 270px; }
}
@media (max-width: 1080px) {
  .brand span { display: none; }
  .top-actions .btn { padding: 7px 9px; }
}
/* Tablets (1024 px) and phones: the parts list and the properties panel become drawers, so the canvas gets the width */
@media (max-width: 1100px) {
  :root { --topbar: auto; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .topbar, .mobile-bar { flex-shrink: 0; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .project-name { order: 2; flex-basis: 100%; max-width: none; }
  .top-actions { order: 3; flex-basis: 100%; flex-wrap: wrap; margin-left: 0; padding-bottom: 2px; }
  .menu { position: fixed; left: 12px; right: 12px; top: auto; min-width: 0; }
  .mobile-bar { display: flex; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .mobile-bar .btn { flex: 1; justify-content: center; }
  .app { display: flex; flex: 1; flex-direction: column; height: auto; min-height: 0; }
  .panel-toggle { display: none; }
  .center { flex: 1; height: auto; min-height: 0; }
  .palette, .side {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(340px, 88vw);
    z-index: 75;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
    transition: transform 0.25s ease;
  }
  .palette { left: 0; transform: translateX(-105%); }
  .side { right: 0; transform: translateX(105%); }
  body.show-palette .palette, body.show-side .side { transform: none; }
  body.show-palette::after, body.show-side::after { content: ''; position: fixed; inset: 0; z-index: 74; background: rgba(0, 0, 0, 0.35); }
  .close-drawer { display: inline-flex; }
  .panel-head.mobile-only { display: flex; padding: 12px 16px 0; }
  .bb-layout { display: block; overflow: auto; }
  .sim-layout { display: block; overflow: auto; }
  /* Simulate: the running circuit first, then the Serial Monitor, then the code — one page that scrolls */
  .wk-layout { display: flex; flex-direction: column; overflow: visible; }
  .wk-right { order: -1; min-height: 0; flex: none; }
  .wk-diagram-wrap { flex: none; height: min(60vh, 520px); min-height: 280px; }
  .wk-bottom { height: auto; min-height: 260px; }
  .wk-code { min-height: 320px; border-right: 0; flex: none; }
  #view-simulate { overflow: auto; }
  .wk-mode { order: 5; }
  .sim-side { border-left: 0; border-top: 1px solid var(--border); }
  .sim-live-hint { display: none; }
  .wk-tabs { flex-wrap: wrap; }
  .wk-tabs button { padding: 6px 9px; }
  .bb-steps { border-left: 0; border-top: 1px solid var(--border); }
  .bb-canvas { overflow-x: auto; }
  .tour { left: 16px; right: 16px; width: auto; bottom: 12px; }
  .help-grid { grid-template-columns: 1fr; }
  .banner { font-size: 12.5px; }
}
@media (max-width: 520px) {
  .tabs button { padding: 8px 10px; font-size: 13px; }
  .toolbar .sep { display: none; }
  .top-actions .sep { display: none; }
  .check-summary { grid-template-columns: 1fr; }
}

/* Parts palette */
.palette-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.part-name { overflow-wrap: anywhere; }
.supply-line { margin: -4px 0 10px; font-size: 12.5px; color: var(--muted); }
.supply-line b { color: var(--text); font-weight: 600; }
details.more { margin: -4px 0 10px; font-size: 13px; }
details.more summary { cursor: pointer; color: var(--primary); }
details.more p { margin: 6px 0 0; line-height: 1.5; }

/* ---------- Code tab: libraries ---------- */
.libs-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.libs-head h4 { margin: 0; }
.libs-head .muted { font-size: 12.5px; line-height: 1.45; }
.libs-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.lib-card { border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.lib-card.dep { background: var(--surface-2); }
.lib-name { font-size: 13.5px; }
.lib-why { line-height: 1.4; }
.lib-inc code { font-size: 11.5px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.lib-note { color: var(--warn-fg); background: var(--warn-bg); border-radius: 6px; padding: 3px 7px; }
.lib-actions { display: flex; gap: 6px; margin-top: 2px; }
.lib-actions a.btn { text-decoration: none; }
.lib-core { margin-top: 8px; font-size: 12.5px; color: var(--text-3); }
.lib-core code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.lib-link { color: var(--accent-text); }

/* ---------- Wokwi-style editor tabs + Library Manager ---------- */
.lm-hidden { display: none !important; }
.lm-tabhost { display: flex; align-items: center; background: #1e293b; padding: 0 8px; }
.lm-tabs { display: flex; gap: 2px; }
.lm-tabs button { background: transparent; border: 0; color: var(--muted-2); font: 600 12.5px ui-monospace, Menlo, Consolas, monospace; padding: 8px 12px; border-bottom: 2px solid transparent; cursor: pointer; }
.lm-tabs button:hover { color: #e2e8f0; }
.lm-tabs button.active { color: #fff; border-bottom-color: #22c55e; background: #0f172a; }
.wk-pane-head .lm-tabs button { padding: 6px 10px; }
.lm-panel { flex: 1; min-height: 0; overflow: auto; background: var(--surface); }
.lm-txt { display: flex; flex-direction: column; background: #0f172a; }
.lm-txt[hidden], .lm-manager[hidden] { display: none; }
.lm-textarea { flex: 1; min-height: 200px; width: 100%; border: 0; resize: none; background: #0f172a; color: #e2e8f0; font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace; padding: 12px 14px; outline: none; }
.lm-txt-note { font-size: 12px; padding: 8px 14px; background: #111827; color: var(--muted-2); }
.lm-txt-note code { color: #e2e8f0; }
.lm-manager { padding: 12px 14px; font-size: 13px; }
.lm-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.lm-head b { font-size: 15px; }
.lm-spacer { flex: 1; }
.lm-search { border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 12px; background: var(--surface-2); }
.lm-q { width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13px; }
.lm-results { max-height: 320px; overflow: auto; margin-top: 6px; }
.lm-row, .lm-res { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--surface-3); }
.lm-res.custom { background: var(--warn-bg); border-radius: 8px; }
.lm-main { flex: 1; min-width: 0; }
.lm-name { font-weight: 700; color: var(--text); text-decoration: none; }
a.lm-name:hover { text-decoration: underline; }
.lm-ver { font: 11.5px ui-monospace, Menlo, monospace; color: var(--muted); margin-left: 4px; }
.lm-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lm-why { color: var(--text-2); }
.lm-tag { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-3); white-space: nowrap; }
.lm-tag.sim { background: var(--ok-bg); color: var(--ok-fg); }
.lm-tag.warn { background: var(--warn-bg-2); color: var(--warn-fg); }
.lm-tag.ok { background: var(--info-bg-4); color: var(--info-fg); }
.lm-lock { font-size: 14px; opacity: 0.6; }
.lm-installed { color: #16a34a; font-weight: 700; font-size: 12px; white-space: nowrap; }
.lm-empty { padding: 10px 4px; }
.lm-foot { font-size: 11.5px; margin-top: 12px; line-height: 1.6; }
.libs-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.libs-summary .lib { background: var(--info-bg-3); color: var(--info-fg); border-radius: 99px; padding: 1px 8px; font-size: 11.5px; }
.libs-summary .lib.mine { background: var(--ok-bg); color: var(--ok-fg); }
.libs-summary .libs-btns { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; }
.libs-how { font-size: 12px; margin: 4px 0 6px; }
.lm-links { font-size: 12px; padding: 8px 14px; background: #111827; color: #cbd5e1; border-top: 1px solid #1e293b; line-height: 1.8; }
.lm-links a { color: #7dd3fc; text-decoration: none; white-space: nowrap; }
.lm-links a:hover { text-decoration: underline; }
.lm-links:empty { display: none; }

/* ---------- parts palette: category dropdowns ---------- */
.pal-tools { display: flex; justify-content: flex-end; margin: 4px 0 2px; }
.palette-group { border: 1px solid var(--border); border-radius: 10px; margin: 6px 0; background: var(--surface); overflow: hidden; }
.palette-group > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); user-select: none; }
.palette-group > summary::-webkit-details-marker { display: none; }
.palette-group > summary::before { content: '▸'; font-size: 11px; color: var(--muted); transition: transform 0.15s; }
.palette-group[open] > summary::before { transform: rotate(90deg); }
.palette-group > summary:hover { background: var(--surface-2); }
.palette-group > summary:focus-visible { outline: 2px solid var(--primary-2); outline-offset: -2px; }
.pal-cat { flex: 1; }
.pal-count { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-3); border-radius: 99px; padding: 1px 8px; text-transform: none; letter-spacing: 0; }
.palette-group[open] > .palette-grid { padding: 0 8px 8px; }

/* ---------- Oscilloscope (Simulate tab) ---------- */
.scope { display: flex; gap: 10px; flex: 1; min-height: 0; }
.scope-screen { flex: 1 1 60%; min-width: 0; min-height: 170px; border-radius: 8px; border: 6px solid #1f2937; background: #05140d; box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6); }
.scope-screen canvas { display: block; width: 100%; height: 100%; }
.scope-side { flex: 0 1 330px; min-width: 220px; display: flex; flex-direction: column; gap: 8px; overflow: auto; font-size: 12px; }
.scope-chs { display: flex; flex-direction: column; gap: 4px; }
.scope-ch { display: flex; align-items: center; gap: 6px; }
.scope-ch span { flex: 0 0 38px; font-weight: 700; color: #111; background: var(--ch); border-radius: 4px; text-align: center; padding: 1px 0; font-size: 11px; }
.scope-ch select, .scope-knobs select { flex: 1; min-width: 0; font-size: 12px; padding: 2px 4px; }
.scope-knobs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; align-items: end; }
.scope-knobs label { display: flex; flex-direction: column; gap: 2px; color: var(--muted, var(--muted)); }
.scope-meas table { width: 100%; border-collapse: collapse; font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: #05140d; border-radius: 6px; }
.scope-meas th { color: #86efac; font-weight: 600; text-align: left; padding: 3px 4px; }
.scope-meas td { padding: 2px 4px; white-space: nowrap; }
@media (max-width: 760px) { .scope { flex-direction: column; } .scope-side { flex-basis: auto; } }

/* Raspberry Pi: set-up commands in the Packages tab */
.lm-setup { background: #0f172a; color: #e2e8f0; padding: 8px 10px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; overflow-x: auto; }

/* Code language picker (under the board list) */
.lang-label { margin: 10px 0 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.lang-label[hidden] { display: none; }
.lang-pick { display: grid; grid-template-columns: 1fr; margin-bottom: 4px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 12.5px; background: var(--surface); }
.lang-pick[hidden] { display: none; }
.lang-pick label { display: flex; gap: 6px; align-items: center; justify-content: flex-start; padding: 5px 10px; cursor: pointer; white-space: nowrap; min-width: 0; }
.lang-pick label + label { border-top: 1px solid var(--border); }
.lang-pick label:has(input:checked) { background: var(--ok-bg-2); color: var(--ok-fg-2); font-weight: 700; }
.lang-pick label.disabled { opacity: 0.45; cursor: not-allowed; }
.lang-pick input { margin: 0; }
.lang-note { margin: 6px 0 0; }

/* Accessibility: a visible keyboard focus ring everywhere, and no motion for people who ask for none */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--primary-2);
  outline-offset: 2px;
}
.code-input:focus-visible, .part-search:focus-visible, .project-name input:focus-visible { outline: none; } /* these draw their own ring */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Keyboard editing of the schematic: the pin picker and its focus ring */
#schematic:focus-visible { outline: 3px solid var(--primary-2); outline-offset: -3px; }
.kb-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 48px));
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 12px 48px rgba(15, 23, 42, 0.35);
}
.kb-dialog[open] { display: flex; flex-direction: column; gap: 8px; }
.kb-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.kb-dialog h2 { margin: 0; font-size: 16px; }
.kb-dialog p { margin: 0; }
.kb-filter { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }
.kb-filter:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }
.kb-list { list-style: none; margin: 0; padding: 0; overflow: auto; min-height: 60px; border: 1px solid var(--border); border-radius: 8px; }
.kb-list li { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid #eef2f7; }
.kb-list li:last-child { border-bottom: 0; }
.kb-list li.on { background: var(--info-bg-2); }
.kb-list li:hover:not(.on) { background: var(--surface-3); }
.kb-list .kb-h { font-size: 12px; color: var(--muted); }
.kb-list li.kb-remove .kb-l { color: var(--danger); }
.kb-list li.kb-none { cursor: default; color: var(--muted); }
.kb-actions { display: flex; justify-content: flex-end; }

/* the schematic drawing and the palette icons are line art in fixed dark strokes: in the dark theme they are inverted */
#schematic, .part-icon svg { filter: var(--draw-filter); }

/* ---------- Dark theme ----------
   Chosen from the system setting, or with the sun/moon button (remembered in this browser). Pictures of real parts and
   boards (breadboard, simulator) keep their own colours on a dark mat (see the end of this file); the schematic drawing is inverted. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --draw-filter: invert(0.92) hue-rotate(180deg);
  --bg: #0a1120;
  --panel: #111b2e;
  --primary: #3b6fe0;
  --primary-2: #4f8bf5;
  --accent: #14b8a6;
  --danger: #f87171;
  --warn: #f59e0b;
  --ok: #34d399;
  --info: #60a5fa;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  --surface: #111b2e;
  --surface-2: #152238;
  --surface-3: #1a2942;
  --surface-4: #233553;
  --ok-bg: #0f2f25;
  --ok-bg-2: #0f2f25;
  --ok-bg-3: #0d2a21;
  --ok-bg-5: #115e3a;
  --warn-bg: #332608;
  --warn-bg-2: #3d2e0a;
  --warn-bg-3: #5b4310;
  --err-bg: #3a1518;
  --err-bg-2: #451a1d;
  --info-bg: #12274a;
  --info-bg-2: #16305a;
  --info-bg-3: #172a55;
  --info-bg-4: #1d2f66;
  --text-2: #cbd5e1;
  --text-3: #b6c2d4;
  --muted-2: #7d8ba1;
  --ok-fg: #86efac;
  --ok-fg-2: #6ee7b7;
  --ok-fg-3: #4ade80;
  --warn-fg: #fcd34d;
  --warn-fg-2: #fbbf24;
  --warn-fg-3: #fde68a;
  --err-fg: #fca5a5;
  --err-fg-2: #f87171;
  --err-fg-3: #fecaca;
  --info-fg: #93c5fd;
  --info-fg-2: #a5b4fc;
  --info-fg-3: #93c5fd;
  --sky-bg: #0c2a3f;
  --sky-bg-2: #0f3550;
  --purple-bg: #2a1f52;
  --teal-bg: #0b2f2e;
  --orange-bg: #442a10;
  --cream-bg: #152238;
  --sky-border: #1f5a80;
  --teal-border: #1b6660;
  --border-strong: #3a4f75;
  --border-strong-2: #4a6088;
  --ok-border: #1f7a4a;
  --ok-border-2: #1f7a4a;
  --warn-border-2: #8a6a17;
  --err-border: #8b2c33;
  --glass-60: rgba(255, 255, 255, 0.08);
  --glass-95: rgba(17, 27, 46, 0.95);
  --glass-90: rgba(17, 27, 46, 0.9);
  --text: #e6edf7;
  --muted: #94a3b8;
  --muted-2: #94a3b8;
  --btn-primary: #2563eb; /* white text: 5.2:1 */
  --btn-primary-hover: #1d4ed8;
  --btn-accent: #0f766e; /* white text: 5.5:1 */
  --btn-accent-hover: #115e59;
  --primary-text: #8fb4ff;
  --sim-tab-fg: #34d399;
  --tip-fg: #b6c2d4;
  --k-blue-fg: #93c5fd;
  --k-black-fg: #e2e8f0;
  --k-purple-fg: #c4b5fd;
  --ic-fg: #0b1220;
  --bb-table: #263041; /* a dark work mat: the parts keep their real colours on it */
  --accent-text: #2dd4bf;
  --warn-text: #f59e0b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --draw-filter: invert(0.92) hue-rotate(180deg);
  --bg: #0a1120;
  --panel: #111b2e;
  --primary: #3b6fe0;
  --primary-2: #4f8bf5;
  --accent: #14b8a6;
  --danger: #f87171;
  --warn: #f59e0b;
  --ok: #34d399;
  --info: #60a5fa;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  --surface: #111b2e;
  --surface-2: #152238;
  --surface-3: #1a2942;
  --surface-4: #233553;
  --ok-bg: #0f2f25;
  --ok-bg-2: #0f2f25;
  --ok-bg-3: #0d2a21;
  --ok-bg-5: #115e3a;
  --warn-bg: #332608;
  --warn-bg-2: #3d2e0a;
  --warn-bg-3: #5b4310;
  --err-bg: #3a1518;
  --err-bg-2: #451a1d;
  --info-bg: #12274a;
  --info-bg-2: #16305a;
  --info-bg-3: #172a55;
  --info-bg-4: #1d2f66;
  --text-2: #cbd5e1;
  --text-3: #b6c2d4;
  --muted-2: #7d8ba1;
  --ok-fg: #86efac;
  --ok-fg-2: #6ee7b7;
  --ok-fg-3: #4ade80;
  --warn-fg: #fcd34d;
  --warn-fg-2: #fbbf24;
  --warn-fg-3: #fde68a;
  --err-fg: #fca5a5;
  --err-fg-2: #f87171;
  --err-fg-3: #fecaca;
  --info-fg: #93c5fd;
  --info-fg-2: #a5b4fc;
  --info-fg-3: #93c5fd;
  --sky-bg: #0c2a3f;
  --sky-bg-2: #0f3550;
  --purple-bg: #2a1f52;
  --teal-bg: #0b2f2e;
  --orange-bg: #442a10;
  --cream-bg: #152238;
  --sky-border: #1f5a80;
  --teal-border: #1b6660;
  --border-strong: #3a4f75;
  --border-strong-2: #4a6088;
  --ok-border: #1f7a4a;
  --ok-border-2: #1f7a4a;
  --warn-border-2: #8a6a17;
  --err-border: #8b2c33;
  --glass-60: rgba(255, 255, 255, 0.08);
  --glass-95: rgba(17, 27, 46, 0.95);
  --glass-90: rgba(17, 27, 46, 0.9);
  --text: #e6edf7;
  --muted: #94a3b8;
  --muted-2: #94a3b8;
  --btn-primary: #2563eb; /* white text: 5.2:1 */
  --btn-primary-hover: #1d4ed8;
  --btn-accent: #0f766e; /* white text: 5.5:1 */
  --btn-accent-hover: #115e59;
  --primary-text: #8fb4ff;
  --sim-tab-fg: #34d399;
  --tip-fg: #b6c2d4;
  --k-blue-fg: #93c5fd;
  --k-black-fg: #e2e8f0;
  --k-purple-fg: #c4b5fd;
  --ic-fg: #0b1220;
  --bb-table: #263041; /* a dark work mat: the parts keep their real colours on it */
  --accent-text: #2dd4bf;
  --warn-text: #f59e0b;
}
:root[data-theme="high-contrast"] { color-scheme: dark; --bg: #000; --panel: #000; --surface: #000; --surface-2: #0d0d0d; --surface-3: #1f1f1f; --surface-4: #303030; --text: #fff; --text-2: #fff; --text-3: #fff; --muted: #f0f0f0; --border: #fff; --border-strong: #fff; --primary: #ffff00; --primary-2: #ffff00; --accent: #00ffff; --danger: #ff6b6b; --warn: #ffff00; --ok: #00ff80; --draw-filter: none; }
:root[data-theme="high-contrast"] .cs-wire-legend { color: #fff; }
/* Do not filter the whole SVG here: a filter would alter a student-selected wire or component colour.
   Labels and interaction handles are inverted independently, leaving wires, LED lenses, and button caps exact. */
:root[data-theme="high-contrast"] #schematic .labels,
:root[data-theme="high-contrast"] #schematic .handles,
:root[data-theme="high-contrast"] .part-icon svg { filter: invert(1); }
/* Preserve each component's fill (for example, LED and button colours), while making its electrical symbol visible on black. */
:root[data-theme="high-contrast"] #schematic .comps [stroke] { stroke: #fff !important; }
:root[data-theme="high-contrast-light"] { color-scheme: light; --bg: #fff; --panel: #fff; --surface: #fff; --surface-2: #f2f2f2; --surface-3: #e5e5e5; --surface-4: #d6d6d6; --text: #000; --text-2: #000; --text-3: #111; --muted: #222; --border: #000; --border-strong: #000; --primary: #000080; --primary-2: #000080; --accent: #005a5a; --danger: #a00000; --warn: #6b4f00; --ok: #006400; --draw-filter: none; }
:root[data-theme="high-contrast-light"] {
  --btn-primary: #000080; --btn-primary-hover: #000050; --btn-accent: #005a5a; --btn-accent-hover: #003e3e;
  --accent-text: #005a5a; --warn-text: #6b4f00; --primary-text: #000080; --sim-tab-fg: #006400;
  --tip-fg: #000; --k-blue-fg: #000080; --k-black-fg: #000; --k-purple-fg: #4b0082; --ic-fg: #fff; --bb-table: #fff;
  --ok-bg: #fff; --ok-bg-2: #fff; --ok-bg-3: #fff; --ok-bg-5: #fff; --warn-bg: #fff; --warn-bg-2: #fff; --warn-bg-3: #fff;
  --err-bg: #fff; --err-bg-2: #fff; --info-bg: #fff; --info-bg-2: #fff; --info-bg-3: #fff; --info-bg-4: #fff;
  --text-2: #000; --text-3: #000; --muted-2: #222; --ok-fg: #006400; --ok-fg-2: #006400; --ok-fg-3: #006400;
  --warn-fg: #6b4f00; --warn-fg-2: #6b4f00; --warn-fg-3: #6b4f00; --err-fg: #a00000; --err-fg-2: #a00000; --err-fg-3: #800000;
  --info-fg: #000080; --info-fg-2: #000080; --info-fg-3: #000080; --sky-bg: #fff; --sky-bg-2: #fff; --purple-bg: #fff; --teal-bg: #fff; --orange-bg: #fff; --cream-bg: #fff;
  --sky-border: #000; --teal-border: #000; --border-strong-2: #000; --ok-border: #006400; --ok-border-2: #006400; --warn-border-2: #6b4f00; --err-border: #a00000;
  --glass-60: #fff; --glass-95: #fff; --glass-90: #fff; --shadow: none; --circuit-wire-signal: #000080; --circuit-wire-ground: #222; --circuit-wire-3v3: #a00000; --circuit-wire-5v: #6b4f00;
}
:root[data-theme="high-contrast-light"] .cs-wire-legend { color: #000; }
:root[data-theme="high-contrast-light"] .cs-wire-legend .signal { background: #000080; }
:root[data-theme="high-contrast-light"] .cs-wire-legend .ground { background: #222; }
:root[data-theme="high-contrast-light"] .cs-wire-legend .threev3 { background: #a00000; }
:root[data-theme="high-contrast-light"] .cs-wire-legend .fivev { background: #6b4f00; }
:root[data-theme="high-contrast-light"] .cs-legend { color: #000 !important; }
:root[data-theme="high-contrast-light"] .cs-legend .sig { background: #000080 !important; }
:root[data-theme="high-contrast-light"] .cs-legend .gnd { background: #222 !important; }
:root[data-theme="high-contrast-light"] .cs-legend .v33 { background: #a00000 !important; }
:root[data-theme="high-contrast-light"] .cs-legend .v5 { background: #6b4f00 !important; }
:root[data-theme="high-contrast-light"] .ring-best { color: #006400; }
:root[data-theme="high-contrast-light"] .ring-ok { color: #000080; }
:root[data-theme="high-contrast-light"] .ring-avoid { color: #6b4f00; }
:root[data-theme="high-contrast-light"] .ring-used { color: #a00000; }
:root[data-theme="high-contrast-light"] .banner .tag { background: #fff; color: #000080; border: 1px solid #000080; }
:root[data-theme="high-contrast-light"] .toast { background: #000; color: #fff; border: 2px solid #000; backdrop-filter: none; }
:root[data-theme="high-contrast-light"] .toast.ok { background: #006400; color: #fff; }
:root[data-theme="high-contrast-light"] .toast.warn { background: #6b4f00; color: #fff; }
:root[data-theme="high-contrast-light"] .tooltip { background: #fff; color: #000; border: 2px solid #000; box-shadow: none; }
:root[data-theme="high-contrast-light"] .tip-rate.best, :root[data-theme="high-contrast-light"] .tip-rate.shared { color: #006400; }
:root[data-theme="high-contrast-light"] .tip-rate.ok { color: #000080; }
:root[data-theme="high-contrast-light"] .tip-rate.avoid { color: #6b4f00; }
:root[data-theme="high-contrast-light"] .tip-rate.used { color: #a00000; }
:root[data-theme="high-contrast-light"] .tip-rate.bad, :root[data-theme="high-contrast-light"] .tip-hint { color: #000; }
:root[data-theme="high-contrast-light"] .modal-backdrop, :root[data-theme="high-contrast-light"] .kb-dialog::backdrop { background: rgb(0 0 0 / 55%); }
:root[data-theme="high-contrast-light"] .schematic .bg { fill: #fff; }
:root[data-theme="high-contrast-light"] .schematic-banner .tag { background: #000080; color: #fff; }
:root[data-theme="high-contrast-light"] #schematic .labels,
:root[data-theme="high-contrast-light"] #schematic .handles,
:root[data-theme="high-contrast-light"] .part-icon svg { filter: none; }
:root[data-theme="high-contrast-light"] .schematic-banner { background: #fff !important; color: #000 !important; border-bottom: 2px solid #000 !important; }
:root[data-theme="high-contrast-light"] .schematic-banner .tag { background: #000080 !important; color: #fff !important; border: 2px solid #000080; }
:root[data-theme="high-contrast-light"] .wire-howto > span { border-left: 2px solid #000; padding-left: 9px; }
:root[data-theme="high-contrast-light"] .wire-howto > span:first-child { border-left: 0; padding-left: 0; }
:root[data-theme="high-contrast-light"] .wire-howto kbd { background: #fff; color: #000; border: 1px solid #000; }

/* Breadboard and Simulate tabs in the dark theme: a dark mat under the real-coloured parts. Only the page changes —
   exported pictures (PNG, SVG, PDF) are drawn on the light table, for printing. The Simulate tab outlines only the
   board, not the parts: they redraw while the simulation runs, and a filter on them would slow that down. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bb-canvas svg [fill="#fdfaf3"], :root:not([data-theme="light"]) .wk-diagram svg [fill="#fdfaf3"] { fill: var(--bb-table); } /* the table, and holes you see it through */
  :root:not([data-theme="light"]) .bb-canvas svg [stroke="#fdfaf3"], :root:not([data-theme="light"]) .wk-diagram svg [stroke="#fdfaf3"] { stroke: var(--bb-table); } /* the halo around labels */
  :root:not([data-theme="light"]) .bb-canvas .bb-on-table, :root:not([data-theme="light"]) .wk-diagram .bb-on-table { fill: #e2e8f0; }
  :root:not([data-theme="light"]) .bb-canvas .bb-rail-label.plus, :root:not([data-theme="light"]) .wk-diagram .bb-rail-label.plus { fill: #fca5a5; }
  :root:not([data-theme="light"]) .bb-canvas .bb-rail-label.minus, :root:not([data-theme="light"]) .wk-diagram .bb-rail-label.minus { fill: #93c5fd; }
  :root:not([data-theme="light"]) .wk-diagram .bb-warm { fill: #fbbf24; }
  :root:not([data-theme="light"]) .bb-canvas .bb-board, :root:not([data-theme="light"]) .bb-canvas .bb-part:not(.sel), :root:not([data-theme="light"]) .wk-diagram .bb-board { filter: drop-shadow(0 0 1.2px rgba(226, 232, 240, 0.6)); } /* a faint light edge so a black board or part does not melt into the dark mat */
}
:root[data-theme="dark"] .bb-canvas svg [fill="#fdfaf3"], :root[data-theme="dark"] .wk-diagram svg [fill="#fdfaf3"] { fill: var(--bb-table); } /* the table, and holes you see it through */
:root[data-theme="dark"] .bb-canvas svg [stroke="#fdfaf3"], :root[data-theme="dark"] .wk-diagram svg [stroke="#fdfaf3"] { stroke: var(--bb-table); } /* the halo around labels */
:root[data-theme="dark"] .bb-canvas .bb-on-table, :root[data-theme="dark"] .wk-diagram .bb-on-table { fill: #e2e8f0; }
:root[data-theme="dark"] .bb-canvas .bb-rail-label.plus, :root[data-theme="dark"] .wk-diagram .bb-rail-label.plus { fill: #fca5a5; }
:root[data-theme="dark"] .bb-canvas .bb-rail-label.minus, :root[data-theme="dark"] .wk-diagram .bb-rail-label.minus { fill: #93c5fd; }
:root[data-theme="dark"] .wk-diagram .bb-warm { fill: #fbbf24; }
:root[data-theme="dark"] .bb-canvas .bb-board, :root[data-theme="dark"] .bb-canvas .bb-part:not(.sel), :root[data-theme="dark"] .wk-diagram .bb-board { filter: drop-shadow(0 0 1.2px rgba(226, 232, 240, 0.6)); } /* a faint light edge so a black board or part does not melt into the dark mat */

/* Circuit check popup: the panel floats over the workspace while the circuit has errors */
.check-popup {
  position: fixed;
  right: calc(var(--side-w) + 16px);
  bottom: 18px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: min(70vh, 640px);
  overflow: auto;
  background: var(--surface);
  border: 2px solid var(--danger);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28);
  padding: 12px 14px;
  z-index: 65;
}
.check-popup[hidden] { display: none; }
.check-popup #check-panel { padding: 0; border: 0; margin: 0; }
.check-popup #check-panel h2 { padding-right: 32px; }
.check-popup-close { position: absolute; top: 8px; right: 8px; }
/* the check only applies to the schematic, like the side panel it comes from */
body.hide-side .check-popup { display: none; }
#check-panel h2:focus { outline: none; }

/* ---------- Icons (js/icons.js) and the modern touches that go with them ---------- */
.ico { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
.btn.small .ico { width: 14px; height: 14px; }
.icon-btn .ico { width: 18px; height: 18px; }
#menu-export button { display: flex; align-items: center; gap: 10px; }
#menu-export button .ico { color: var(--muted); }
.menu b .ico { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; }
.tabs button { display: inline-flex; align-items: center; gap: 6px; }
.ctx-menu button { justify-content: flex-start; gap: 10px; }
.ctx-menu .ctx-label { flex: 1; }
.ctx-menu .ico { width: 15px; height: 15px; color: var(--muted); }
.ctx-menu button.danger:not(:disabled) .ico { color: inherit; }
.hints-note .ico, .issue-actions .ico { width: 14px; height: 14px; }
.proj-list .icon-btn .ico { width: 16px; height: 16px; }

/* Numbers line up in columns (0.000 W, 220 Ω, 100%) */
.zoom, .stats b, .table td, .kv dd, #power-summary, .kb-h { font-variant-numeric: tabular-nums; }

/* A tidier type scale: headings a touch tighter, labels a touch lighter */
h2 { letter-spacing: -0.01em; font-weight: 650; }
.panel h2 { font-size: 14px; }
.field > span { font-weight: 500; }

/* Power tables: whole words and whole numbers only (they used to break as "Microcontrolle r" and "ACTIV E") */
#power-summary .table { table-layout: auto; }
#power-summary .table th, #power-summary .table td { overflow-wrap: normal; word-break: normal; white-space: nowrap; padding: 6px 8px; }
#power-summary .table th { text-transform: none; letter-spacing: 0; font-size: 11px; font-weight: 600; }
#power-summary .table th + th, #power-summary .table td + td { text-align: right; }
