/* the breadboard bench. same studio as mini: a dark room, glass panels, one warm light.
   the room's glow comes from the circuit itself (--light, 0..1, set from js as bulbs and LEDs light up). */
@property --light { syntax: '<number>'; inherits: true; initial-value: 0; }

.bb-stage {
  --g-ink: #eef2f7;
  --g-muted: rgba(226, 232, 240, .62);
  --g-faint: rgba(226, 232, 240, .42);
  --g-line: rgba(255, 255, 255, .1);
  --g-fill: rgba(255, 255, 255, .06);
  --g-fill-2: rgba(255, 255, 255, .11);
  --g-teal: #5eead4;
  --g-amber: #fbbf5a;
  --g-red: #ff6b6b;
  --ease: cubic-bezier(.2, .8, .2, 1);
  position: relative; isolation: isolate; overflow: hidden;
  border-radius: 28px; color: var(--g-ink);
  padding: 30px 32px 26px;
  background:
    radial-gradient(40% 46% at 45% 58%, rgba(255, 176, 72, calc(var(--light) * .3)) 0%, transparent 70%),
    radial-gradient(120% 70% at 50% 110%, #1b2531 0%, transparent 60%),
    linear-gradient(180deg, #121820 0%, #0c1118 100%);
  transition: --light .5s ease;
}
.bb-stage [hidden] { display: none !important; }
.bb-stage noscript p, .lab-stage noscript p { margin: 24px 0 0; padding: 14px 18px; border-radius: 14px; background: rgba(255,255,255,.06); color: #eef2f7; max-width: 32rem; }
.bb-stage button, .bb-stage summary { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.bb-stage :focus-visible { outline: 2px solid var(--g-teal); outline-offset: 2px; }
.bb-stage .glass {
  background: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .04));
  border: 1px solid var(--g-line);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 24px 48px -24px rgba(0, 0, 0, .6);
}

/* ---------- title (page content) ---------- */
.bb-intro { max-width: min(40rem, calc(100% - 430px)); margin-bottom: 26px; }
.bb-intro h1 { margin: 0; font-size: clamp(2.1rem, 4vw, 3.3rem); font-weight: 750; letter-spacing: -.035em; line-height: 1; color: #fff; }
.bb-intro p { margin: 12px 0 0; color: var(--g-muted); font-size: 1.02rem; line-height: 1.5; max-width: 30rem; }

/* ---------- top right tools ---------- */
.bb-top { position: absolute; top: 30px; right: 32px; z-index: 5; display: flex; gap: 8px; align-items: center; }
.bb-icon { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 50%; cursor: pointer; transition: background .2s, border-color .2s, opacity .2s; }
.bb-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bb-icon:hover { background: var(--g-fill-2); }
.bb-icon:disabled { opacity: .35; cursor: default; }
.bb-icon[aria-pressed="true"] { background: rgba(94, 234, 212, .14); border-color: rgba(94, 234, 212, .4); color: var(--g-teal); }
.bb-chip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer; font-size: .9rem; font-weight: 550; list-style: none; }
.bb-chip::-webkit-details-marker { display: none; }
.bb-chip::after { content: ''; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: translateY(-2px) rotate(45deg); opacity: .7; }
.bb-examples { position: relative; margin-right: 4px; }
.bb-ex-list { position: absolute; right: 0; top: 48px; width: 300px; max-height: min(80vh, 660px); overflow-y: auto; padding: 6px; border-radius: 18px; display: grid; gap: 2px; background: #151c26 !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .75) !important; }
.bb-ex { text-align: left; display: grid; gap: 2px; padding: 10px 12px; border: 0; border-radius: 12px; background: none; cursor: pointer; }
.bb-ex:hover { background: var(--g-fill-2); }
.bb-ex strong { font-size: .92rem; font-weight: 600; }
.bb-ex span { font-size: .82rem; color: var(--g-muted); line-height: 1.35; }

/* ---------- the bench: tray | board | panel ---------- */
.bb-main { display: grid; grid-template-columns: minmax(0, 1fr) 290px; grid-template-rows: auto 1fr; gap: 14px 18px; align-items: start; }
.bb-tray { grid-column: 1; grid-row: 1; display: flex; gap: 2px; padding: 5px; border-radius: 20px; overflow-x: auto; scrollbar-width: none; }
.bb-tray::-webkit-scrollbar { display: none; }
.bb-tile { flex: 1 0 68px; display: grid; justify-items: center; gap: 3px; padding: 7px 4px 7px; border: 1px solid transparent; border-radius: 16px; background: none; cursor: pointer; transition: background .2s, border-color .2s; }
.bb-tile span { font-size: .7rem; font-weight: 550; color: var(--g-muted); line-height: 1.1; text-align: center; }
.bb-tile:hover { background: var(--g-fill); }
.bb-tile[aria-pressed="true"] { background: rgba(94, 234, 212, .1); border-color: rgba(94, 234, 212, .35); }
.bb-tile[aria-pressed="true"] span { color: var(--g-teal); }
.bb-tile-icon { width: 46px; height: 32px; pointer-events: none; }
.bb-tile-icon .glow { opacity: .55 !important; }
.ico-line { fill: none; stroke: var(--g-ink); stroke-width: 2; stroke-linejoin: round; }
.ico-meter { fill: #f2c14e; stroke: #8a6a1a; }
.ico-meter-screen { fill: #1e2a1f; }

.bb-bench { grid-column: 1; grid-row: 2; position: relative; min-width: 0; }
.bb-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; border-radius: 18px; }
.bb-svg { display: block; width: 100%; height: auto; max-height: min(64vh, 660px); touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; overflow: visible; }
.bb[data-tool="pointer"] .part { cursor: grab; }
/* a finger on a part drags it; a finger anywhere else on the board scrolls */
.bb .part, .bb .battery { touch-action: none; }
.bb[data-tool="pointer"] .part-switch, .bb .part-button { cursor: pointer; }
.bb:not([data-tool="pointer"]) .bb-svg { cursor: crosshair; }
.bb .battery { cursor: pointer; }

/* the side panel */
.bb-side { grid-column: 2; grid-row: 1 / span 2; position: relative; display: flex; flex-direction: column; border-radius: 22px; padding: 18px 18px 14px; min-height: 100%; }
.bb-insp { flex: 1; }
.bb-side h2, .bb-missions h2 { margin: 0; font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; }
.bb-sub { margin: 6px 0 0; color: var(--g-muted); font-size: .86rem; line-height: 1.45; }
.bb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; margin: 16px 0 4px; }
.bb-stat { padding: 10px 10px 9px; border-radius: 14px; background: rgba(0, 0, 0, .22); border: 1px solid rgba(255, 255, 255, .05); }
.bb-stat span { display: block; font-size: .72rem; color: var(--g-faint); }
.bb-stat b { display: block; margin-top: 3px; font-size: 1.02rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.bb-label { margin: 16px 0 8px; font-size: .78rem; color: var(--g-faint); }
.bb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bb-chip-s { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--g-line); background: var(--g-fill); font-size: .8rem; cursor: pointer; font-variant-numeric: tabular-nums; transition: background .15s, border-color .15s; }
.bb-chip-s:hover { background: var(--g-fill-2); }
.bb-chip-s[aria-pressed="true"] { background: #fff; color: #0f172a; border-color: #fff; }
.bb-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.bb-swatch { width: 26px; height: 26px; border-radius: 50%; padding: 0; border: 2px solid transparent; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55), transparent 45%), var(--c); cursor: pointer; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.bb-swatch[aria-pressed="true"] { border-color: #0e141b; box-shadow: 0 0 0 2px #fff; }
.bb-range { width: 100%; accent-color: var(--g-teal); }
.bb-actions { display: flex; flex-wrap: nowrap; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--g-line); }
.bb-act { padding: 8px 12px; border-radius: 12px; border: 1px solid var(--g-line); background: var(--g-fill); font-size: .84rem; font-weight: 550; cursor: pointer; }
.bb-act:hover { background: var(--g-fill-2); }
.bb-act.primary { background: #fff; color: #0f172a; border-color: #fff; }
.bb-act.danger { margin-left: auto; color: var(--g-red); }
.bb-note { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(94, 234, 212, .07); color: var(--g-muted); font-size: .82rem; line-height: 1.45; }
@media (pointer: coarse) { .bb-keys { display: none !important; } }
.bb-keys { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 16px; color: var(--g-faint); font-size: .76rem; }
.bb-keys kbd { display: inline-block; min-width: 18px; padding: 1px 5px; margin-right: 3px; border-radius: 5px; background: var(--g-fill-2); color: var(--g-ink); font: inherit; font-size: .72rem; text-align: center; }
.bb-list { display: grid; gap: 2px; }
.bb-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: left; font-size: .86rem; }
.bb-row:hover { background: var(--g-fill); }
.bb-row b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--g-muted); }
.bb-row .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.2); }
.bb-row .dot.on { background: var(--g-amber); box-shadow: 0 0 8px var(--g-amber); }
.bb-row .dot.bad { background: var(--g-red); }
.bb-safe-track { position: relative; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .08); }
.bb-safe-track .zone { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: rgba(94, 234, 212, .35); }
.bb-safe-track .limit { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--g-red); }
.bb-safe-track b { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #9aa4b2; border: 2px solid #0e141b; transition: left .3s var(--ease); }
.bb-safe-track b.good { background: var(--g-teal); }
.bb-safe-track b.hot { background: var(--g-red); }
.bb-safe-scale { display: flex; justify-content: space-between; margin-top: 6px; font-size: .7rem; color: var(--g-faint); }

/* ---------- bottom: what's happening + missions ---------- */
.bb-say { margin: -4px -4px 16px; padding: 12px 14px 12px 16px; border-radius: 14px; background: rgba(251, 191, 90, .08); border-left: 3px solid var(--g-amber); font-size: .9rem; line-height: 1.5; color: var(--g-ink); }
.bb-missions-btn { display: flex; align-items: center; gap: 10px; margin: 16px -4px -2px; padding: 11px 12px; border: 1px solid var(--g-line); border-radius: 14px; background: var(--g-fill); cursor: pointer; font-size: .88rem; white-space: nowrap; }
.bb-missions-btn:hover { background: var(--g-fill-2); }
.bb-missions-btn::after { content: ''; margin-left: auto; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-top: 1.6px solid currentColor; transform: rotate(-45deg); opacity: .6; }
.bb-missions-btn b { font-weight: 650; font-variant-numeric: tabular-nums; }
.bb-missions-btn .ring { width: 20px; height: 20px; border-radius: 50%; background: conic-gradient(var(--g-teal) calc(var(--p) * 360deg), rgba(255,255,255,.12) 0); -webkit-mask: radial-gradient(circle, transparent 6px, #000 6.5px); mask: radial-gradient(circle, transparent 6px, #000 6.5px); }
.bb-missions { position: absolute; left: 10px; right: 10px; bottom: 66px; z-index: 6; padding: 18px; border-radius: 22px; background: #151c26 !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .75) !important; }
.bb-missions ul { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.bb-missions li { position: relative; padding: 8px 10px 8px 34px; border-radius: 10px; font-size: .88rem; color: var(--g-ink); }
.bb-missions li::before { content: ''; position: absolute; left: 10px; top: 50%; width: 14px; height: 14px; margin-top: -8px; border-radius: 50%; border: 1.6px solid rgba(255, 255, 255, .3); }
.bb-missions li.done { color: var(--g-muted); }
.bb-missions li.done::before { background: var(--g-teal); border-color: var(--g-teal); }
.bb-missions li.done::after { content: ''; position: absolute; left: 15px; top: 50%; width: 4px; height: 8px; margin-top: -6px; border-right: 2px solid #0e141b; border-bottom: 2px solid #0e141b; transform: rotate(45deg); }

.bb-toast { position: absolute; left: 50%; top: 10px; z-index: 8; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; padding: 9px 16px; border-radius: 999px; background: rgba(15, 20, 27, .92); border: 1px solid var(--g-line); font-size: .86rem; transition: opacity .25s, transform .35s var(--ease); white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
.bb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.bb-toast.good { border-color: rgba(94, 234, 212, .45); color: var(--g-teal); }

.bb-meter-tag { position: absolute; z-index: 4; transform: translate(-50%, calc(-100% - 14px)); padding: 7px 11px; border-radius: 12px; background: #f2c14e; color: #1a1406; pointer-events: none; display: grid; text-align: center; box-shadow: 0 10px 24px -10px rgba(0,0,0,.6); }
.bb-meter-tag b { font-size: 1rem; font-variant-numeric: tabular-nums; }
.bb-meter-tag span { font-size: .7rem; opacity: .75; }
.bb-meter-tag::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; margin-left: -5px; background: inherit; transform: rotate(45deg); }

/* ---------- the board ---------- */
.bb-body { fill: #ebe9e3; }
.bb-edge { fill: rgba(255, 255, 255, .7); }
.bb-gap { fill: #d6d2c8; }
.bb-railbed { fill: rgba(0, 0, 0, .025); }
.hole { fill: #c9c4b8; }
.hole-in { fill: #2f3134; }
.rail-plus { stroke: #e5484d; stroke-width: 1.4; fill: #e5484d; }
.rail-minus { stroke: #3b82f6; stroke-width: 1.4; fill: #3b82f6; }
.rail-label { font: 700 13px system-ui, sans-serif; stroke: none; text-anchor: middle; }
.row-label, .col-label { font: 500 8.5px system-ui, sans-serif; fill: #a29c8f; text-anchor: middle; }
.strip { fill: rgba(94, 234, 212, .16); stroke: rgba(20, 160, 140, .55); stroke-width: 1; pointer-events: none; }

/* ---------- parts ---------- */
.leg { stroke: #b8bec6; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.leg-foot { fill: #8d949c; }
.wire { stroke-width: 4.2; fill: none; stroke-linecap: round; }
.wire-shadow { stroke: rgba(0, 0, 0, .22); stroke-width: 5; fill: none; stroke-linecap: round; transform: translate(1px, 2.5px); }
.wire-shine { stroke: rgba(255, 255, 255, .35); stroke-width: 1.1; fill: none; stroke-linecap: round; transform: translate(-.6px, -1px); }
.wire-end { stroke: rgba(0, 0, 0, .25); stroke-width: .8; }
.wire-tip { fill: #d6d9dd; }
.res-body { fill: #dcc39a; stroke: #b0956a; stroke-width: .8; }
.res-shine { fill: rgba(255, 255, 255, .35); }
.pin-mark { font: 700 9px system-ui, sans-serif; fill: #e5484d; text-anchor: middle; }
.led-dome { stroke: rgba(0, 0, 0, .25); stroke-width: .8; }
.led-shine { fill: none; stroke: rgba(255, 255, 255, .7); stroke-width: 1.4; stroke-linecap: round; }
.led-core { fill: #fff; opacity: .85; pointer-events: none; }
.diya-clay { fill: #b5652a; stroke: #7a3f14; stroke-width: 1; }
.flame { fill: #ffb703; stroke: #ff7b00; stroke-width: 1; transform-box: fill-box; transform-origin: 50% 100%; animation: flicker .18s infinite alternate; }
@keyframes flicker { from { transform: scale(1, 1); } to { transform: scale(.92, 1.08); } }
.smoke { font: 600 10px system-ui, sans-serif; fill: #6b7280; }
.smoke-trail { fill: none; stroke: rgba(120, 120, 120, .6); stroke-width: 2; stroke-linecap: round; animation: smoke 2.4s ease-in-out infinite; }
@keyframes smoke { 0% { opacity: 0; transform: translateY(4px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }
.bulb-glass { stroke: rgba(120, 130, 140, .55); stroke-width: .9; }
.bulb-base { fill: #b7bcc2; stroke: #8b9198; stroke-width: .6; }
.bulb-thread { stroke: #8b9198; stroke-width: .8; }
.bulb-post { stroke: #9aa0a6; stroke-width: .9; fill: none; }
.filament { fill: none; stroke-linecap: round; }
.bulb-core { fill: #fff8e5; pointer-events: none; filter: blur(2px); }
.glass-shine { fill: none; stroke: rgba(255, 255, 255, .8); stroke-width: 1.8; stroke-linecap: round; }
.btn-base { fill: #2a2d31; stroke: #16181b; }
.btn-dot { fill: #6b7076; }
.btn-cap { fill: #e5484d; stroke: #9f2328; stroke-width: 1; transition: r .08s; }
.btn-cap.pressed { fill: #b9363a; }
.sw-body { fill: #2a2d31; stroke: #16181b; }
.sw-track { fill: #121417; }
.sw-track.on { fill: #0f3d36; }
.sw-knob { fill: #f4f5f6; stroke: #9aa0a6; stroke-width: .6; transition: x .18s var(--ease, ease); }
.sw-label { font: 600 8px system-ui, sans-serif; fill: #8b8578; text-anchor: middle; }
.pot-body { fill: #2563eb; stroke: #1d3f99; }
.pot-knob { fill: #f4f5f6; stroke: #9aa0a6; }
.pot-mark { stroke: #1f2937; stroke-width: 2.2; stroke-linecap: round; }
.motor-can { fill: #aab1b9; stroke: #6f767e; stroke-width: .8; }
.motor-shine { fill: rgba(255, 255, 255, .45); }
.motor-shaft { fill: #6f767e; }
.fan-blade { fill: #f59e0b; stroke: #b45309; stroke-width: .6; }
.fan-hub { fill: #374151; }
.fan-blades { transform-box: view-box; transform-origin: 0 0; }
.fan.spinning .fan-blades { animation: spin var(--spin) linear infinite; }
.fan.spinning.backwards .fan-blades { animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.buzz-body { fill: #1f2226; stroke: #0b0c0e; }
.buzz-ring { fill: none; stroke: #3a3e44; stroke-width: 1.2; }
.buzz-hole { fill: #000; }
.buzz-wave { fill: none; stroke: var(--g-teal, #5eead4); stroke-width: 1.6; stroke-linecap: round; animation: wave .5s ease-out infinite; }
@keyframes wave { from { opacity: 1; } to { opacity: 0; } }
.hot { animation: hot 1s ease-in-out infinite alternate; }
@keyframes hot { to { opacity: .2; } }
.glow { pointer-events: none; }
.pool { mix-blend-mode: multiply; }
.hit { fill: transparent; stroke: transparent; stroke-width: 14; }
.hit.thin { fill: none; stroke-width: 9; }
.part.selected > :not(.hit):not(.glow) { filter: drop-shadow(0 0 2.5px rgba(94, 234, 212, .95)); }
.part.lifted { opacity: .35; }
.battery.selected > rect:first-child { filter: drop-shadow(0 0 4px rgba(94, 234, 212, .9)); }
.coach { fill: rgba(94, 234, 212, .12); stroke: var(--g-teal, #5eead4); stroke-width: 2.5; pointer-events: none; transform-box: fill-box; transform-origin: center; animation: coach 1.8s ease-out infinite; }
@keyframes coach { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.ghost-ok { opacity: .55; pointer-events: none; }
.ghost-bad { opacity: .35; pointer-events: none; filter: grayscale(1) sepia(1) hue-rotate(-50deg) saturate(3); }
.ghost-wire { fill: none; stroke: var(--g-teal, #5eead4); stroke-width: 3; stroke-dasharray: 5 5; stroke-linecap: round; }
.pick { fill: rgba(94, 234, 212, .2); stroke: var(--g-teal, #5eead4); stroke-width: 2; pointer-events: none; }
.pick.bad { fill: rgba(255, 107, 107, .15); stroke: var(--g-red, #ff6b6b); }
.probe { fill: #f2c14e; stroke: #8a6a1a; stroke-width: 1.5; pointer-events: none; }
.ghost, .g-flow, .g-labels { pointer-events: none; }

/* current: little dots running from + to − */
.flow { fill: none; stroke: #ffd27a; stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 0 10; animation: flow var(--dur, 1s) linear infinite; opacity: .95; filter: drop-shadow(0 0 2px rgba(255, 190, 80, .9)); }
.flow.back { animation-direction: reverse; }
@keyframes flow { to { stroke-dashoffset: -10; } }

/* readings on the parts */
.reading rect { fill: rgba(15, 20, 27, .82); }
.reading text { font: 600 9px system-ui, sans-serif; fill: #eef2f7; text-anchor: middle; font-variant-numeric: tabular-nums; }
.reading.bad rect { fill: rgba(127, 29, 29, .9); }

/* the battery */
.bat-holder { fill: #1d2025; stroke: #0c0d0f; }
.bat-aa { fill: #2f6fd6; }
.bat-aa-top { fill: #c9a227; }
.bat-sign { fill: #1f1f22; font: 700 12px system-ui, sans-serif; text-anchor: middle; }
.bat-9v { fill: #27292e; stroke: #0c0d0f; }
.bat-band { fill: #f2c14e; }
.bat-tip { fill: #c8ccd1; stroke: #7b8189; }
.usb-board { fill: #155e52; stroke: #0b3a33; }
.usb-port { fill: #c8ccd1; stroke: #7b8189; }
.usb-led { fill: #3b3f45; }
.usb-led.on { fill: #5eead4; filter: drop-shadow(0 0 4px #5eead4); }
.bat-label { fill: #fff; font: 750 18px system-ui, sans-serif; text-anchor: middle; }
.bat-9v ~ .bat-label { fill: #1a1406; }
.bat-label.small { font-size: 9px; font-weight: 600; fill: rgba(255, 255, 255, .85); }
.bat-caption { fill: #cdd5df; font: 600 11px system-ui, sans-serif; text-anchor: middle; }
.bat-hint { fill: rgba(226, 232, 240, .45); font: 10px system-ui, sans-serif; text-anchor: middle; }
.lead { fill: none; stroke-width: 3.6; stroke-linecap: round; }
.lead-plus { stroke: #e5484d; }
.lead-minus { stroke: #2b2f36; }
.lead-shine { fill: none; stroke: rgba(255, 255, 255, .22); stroke-width: 1; stroke-linecap: round; }

/* lights off: the room goes dark and only what's lit glows */
.bb-stage.bb-dark-room { background: radial-gradient(46% 52% at 52% 44%, rgba(255, 190, 92, calc(var(--light) * .3)) 0%, transparent 70%), #07090c; }
.bb-dark .g-board, .bb-dark .battery > :not(.flow) { filter: brightness(.22); transition: filter .5s; }
.bb-dark .part :not(g):not(.glow):not(.flame):not(.led-dome):not(.led-core):not(.bulb-glass):not(.bulb-core):not(.filament):not(.hit):not(.diya-clay):not(.wire-end):not(.oled-text):not(.oled-bar):not(.esp-led.on) { filter: brightness(.32); }
.bb-dark .oled-px { filter: drop-shadow(0 0 2px rgba(150, 220, 255, 1)) drop-shadow(0 0 6px rgba(120, 200, 255, .6)); }
.bb-dark .diya-clay { filter: brightness(.85); }
.bb-dark .glow { opacity: 1 !important; }
.bb-dark .reading { opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  .flame, .flow, .fan.spinning .fan-blades, .buzz-wave, .coach, .smoke-trail, .hot { animation: none; }
  .flow { stroke-dasharray: 0 10; }
}

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .bb-intro { max-width: none; }
  .bb-top { position: static; flex-wrap: wrap; margin-bottom: 14px; }
  .bb-ex-list { left: 0; right: auto; }
  .bb-main { grid-template-columns: minmax(0, 1fr); }
  .bb-side { grid-column: 1; grid-row: 3; min-height: 0; }
}
@media (max-width: 760px) {
  .bb-stage { padding: 20px 14px 16px; border-radius: 22px; }
  .bb-intro { max-width: none; margin-bottom: 14px; }
  .bb-intro h1 { font-size: 2.1rem; }
  .bb-top { position: static; gap: 6px; margin-bottom: 12px; }
  .bb-icon { width: 38px; height: 38px; }
  .bb-icon[aria-label="Redo"] { display: none; }
  .bb-chip { height: 38px; padding: 0 14px; }
  .bb-ex-list { left: 0; right: auto; width: min(300px, 80vw); }
  .bb-main { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .bb-tile { flex: 0 0 64px; }
  .bb-intro p { font-size: .95rem; }
  .bb-main { display: flex; flex-direction: column; }
  .bb-main > *, .bb-bench { min-width: 0; max-width: 100%; }
  .bb-side { display: contents; }
  .bb-tray { order: 1; }
  .bb-bench { order: 2; }
  .bb-say { order: 3; margin: 0; }
  .bb-insp { order: 4; padding: 16px; border-radius: 18px; background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.04)); border: 1px solid var(--g-line); }
  .bb-missions-btn { order: 5; margin: 0; width: 100%; }
  .bb-missions { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; max-height: 70vh; overflow-y: auto; }
  .bb-svg { min-width: 600px; max-height: none; }
}

/* touch screens: bigger targets */
@media (pointer: coarse) {
  .bb-swatch { width: 34px; height: 34px; }
  .bb-chip-s { padding: 9px 13px; }
  .bb-act { padding: 11px 14px; }
  .bb-row { padding: 11px 10px; }
  .bb-ex { padding: 13px 12px; }
}

/* ---------- new parts ---------- */
.diode-body { fill: #2b2e33; stroke: #15171a; stroke-width: .6; }
.diode-band { fill: #c9ced6; }
.cap-can { fill: #1f4fa3; stroke: #163a7a; stroke-width: .8; }
.cap-stripe { fill: #c9d6ee; opacity: .85; }
.cap-charge { fill: #5eead4; opacity: .9; }
.cap-top { fill: #b8c2cf; stroke: #8994a3; stroke-width: .5; }
.cap-minus { font: 700 7px system-ui, sans-serif; fill: #1f4fa3; text-anchor: middle; }
.ldr-body { fill: #e9d8b4; stroke: #a8875a; stroke-width: .8; }
.ldr-track { fill: none; stroke: #b5452b; stroke-width: 1.3; stroke-linejoin: round; }
.ldr-ray { fill: none; stroke: #fbbf24; stroke-width: 1.4; stroke-linecap: round; }
.npn-body { fill: #24272b; stroke: #0f1113; stroke-width: .8; }
.npn-label { font: 700 6.5px system-ui, sans-serif; fill: #c9ced6; text-anchor: middle; letter-spacing: .04em; }
.npn-pin { font: 600 7px system-ui, sans-serif; fill: #8b8578; text-anchor: middle; }

/* ---------- show flow ---------- */
.bb-flow-btn { gap: 8px; border: 1px solid var(--g-line); }
.bb-flow-btn::after { display: none; }
.bb-flow-btn i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .25); transition: background .2s, box-shadow .2s; }
.bb-flow-btn[aria-pressed="true"] { background: rgba(251, 191, 90, .14); border-color: rgba(251, 191, 90, .45); color: var(--g-amber); }
.bb-flow-btn[aria-pressed="true"] i { background: var(--g-amber); box-shadow: 0 0 10px var(--g-amber); }
.bb-flowview .flow { stroke-width: 4.2; stroke-dasharray: 0 13; filter: drop-shadow(0 0 4px rgba(255, 200, 90, 1)); stroke: #ffe3a3; }
.bb-flowview .wire { stroke-width: 5; }
.bb-flowview .g-board { opacity: .8; }
.bb-legend { display: none; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin-top: 10px; font-size: .8rem; color: var(--g-muted); }
.bb-flowview .bb-legend { display: flex; }
.bb-legend span { display: inline-flex; align-items: center; gap: 8px; }
.bb-legend .dots { width: 26px; height: 4px; background: radial-gradient(circle, #ffe3a3 1.6px, transparent 2px) 0 50% / 8px 4px repeat-x; filter: drop-shadow(0 0 3px #fbbf5a); }
.bb-legend .ramp { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #ef4444, #3b82f6); }
.bb-legend em { font-style: normal; font-weight: 700; color: var(--g-ink); }

/* ---------- dragging parts from the tray ---------- */
.bb-drag-chip { position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none; padding: 6px 12px; border-radius: 999px; background: #151c26; color: #eef2f7; border: 1px solid rgba(255, 255, 255, .15); font: 600 .8rem system-ui, sans-serif; box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .6); transition: opacity .15s; }
.bb-drag-chip.on-board { opacity: 0; }
.bb-dragging, .bb-dragging * { cursor: grabbing !important; }
.bb-tile { touch-action: pan-x; }
.ghost-wire.bad { stroke: var(--g-red, #ff6b6b); }
.bb-export .bb-ex-list { width: 320px; }

/* ---------- wire handles ---------- */
.wire-handle { fill: #fff; stroke: var(--g-teal, #5eead4); stroke-width: 2.5; pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.bb[data-tool="pointer"] .part-wire { cursor: move; }

/* ---------- zoom + pan ---------- */
.bb-scroll.zoomed { overflow: auto; overscroll-behavior: contain; }
.bb-scroll.zoomed .bb-svg { margin: 0 auto; }
/* under the board, never on it: it used to hide the bottom-right holes and the wire ends in them */
.bb-zoom { position: relative; z-index: 3; width: max-content; margin: 8px 0 0 auto; display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 14px; background: rgba(21, 28, 38, .92); border: 1px solid var(--g-line); box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .6); }
.bb-zbtn, .bb-zlabel { height: 32px; border: 0; border-radius: 10px; background: none; color: var(--g-ink); cursor: pointer; display: grid; place-items: center; }
.bb-zbtn { width: 32px; padding: 0; }
.bb-zbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bb-zlabel { min-width: 52px; padding: 0 6px; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bb-zbtn:hover, .bb-zlabel:hover { background: var(--g-fill-2); }
.bb-zbtn[aria-pressed="true"] { background: rgba(94, 234, 212, .16); color: var(--g-teal); }
.bb-hand .bb-svg, .bb-hand .bb-svg * { cursor: grab !important; }
.bb-panning .bb-svg, .bb-panning .bb-svg * { cursor: grabbing !important; }
@media (pointer: coarse) { .bb-zbtn, .bb-zlabel { height: 40px; } .bb-zbtn { width: 40px; } }

/* ---------- advanced parts ---------- */
.leg.long { stroke-width: 2.4; }
.rgb-dome { stroke: rgba(0, 0, 0, .25); stroke-width: .8; }
.rgb-rim { fill: #d6dbe1; }
.rgb-glow { pointer-events: none; filter: blur(6px); }
.chip-body { fill: #1f2226; stroke: #0c0d0f; stroke-width: .8; }
.chip-notch { fill: none; stroke: #4b5058; stroke-width: 1.2; }
.chip-dot { fill: #6b7280; }
.chip-pin { fill: #c9ced6; stroke: #8b929b; stroke-width: .4; }
.chip-label { font: 700 8px system-ui, sans-serif; fill: #d6dbe1; text-anchor: middle; letter-spacing: .06em; }
.chip-out { fill: #3a3f46; }
.chip-out.on { fill: #ff4d4d; filter: drop-shadow(0 0 3px #ff4d4d); }
.bb-tile { flex: 1 0 60px; }

/* ---------- ESP32 + OLED ---------- */
.esp-pcb { fill: #17191d; stroke: #050607; stroke-width: .8; }
.esp-antenna { fill: none; stroke: #c9a23a; stroke-width: 1.4; stroke-linejoin: round; }
.esp-usb { fill: #c8ced6; stroke: #7b838d; stroke-width: .6; }
.esp-usb-in { fill: #3a3f46; }
.esp-can { fill: #c9ced6; stroke: #8b929b; stroke-width: .6; }
.esp-can-label { font: 700 6px system-ui, sans-serif; fill: #4b5058; text-anchor: middle; letter-spacing: .02em; }
.esp-name { font: 600 6.5px system-ui, sans-serif; fill: #8b929b; text-anchor: middle; letter-spacing: .04em; }
.esp-pin { fill: #d4b24c; stroke: #8a6d1d; stroke-width: .5; }
.esp-pin.high { fill: #ffe08a; filter: drop-shadow(0 0 2px #ffd166); }
.esp-pin-label { font: 600 5.2px system-ui, sans-serif; fill: #e7e9ec; text-anchor: middle; }
.esp-pin-label.pwr { fill: #ff8c82; }
.esp-led { fill: #3a2a2a; }
.esp-led.d2 { fill: #232a3a; }
.esp-led.pwr.on { fill: #ff4d4d; filter: drop-shadow(0 0 3px #ff4d4d); }
.esp-led.d2.on { fill: #5aa9ff; filter: drop-shadow(0 0 4px #5aa9ff); }
.oled-pcb { fill: #1d4f91; stroke: #12335f; stroke-width: .8; }
.oled-hole { fill: #0e1b2c; stroke: #c9a23a; stroke-width: .8; }
.oled-glass { fill: #05070a; stroke: #2a3340; stroke-width: .8; }
.oled-text { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; fill: #d8f3ff; }
.oled-bar { fill: #d8f3ff; }
.oled-px { filter: drop-shadow(0 0 1.2px rgba(150, 220, 255, .9)); }
.oled-pin-label { font: 700 5.6px system-ui, sans-serif; fill: #e9f0f8; text-anchor: middle; }
.oled-pin { fill: #d4b24c; stroke: #8a6d1d; stroke-width: .6; }
.oled-pin-in { fill: #4a3a10; }
.bb-code { margin: 0; max-height: 260px; overflow: auto; padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .06); font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #d7e0ea; white-space: pre; tab-size: 2; }
.bb-pins { display: grid; gap: 4px; }
.bb-pin-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: 10px; background: rgba(0, 0, 0, .2); font-size: .82rem; font-variant-numeric: tabular-nums; }
.bb-pin-row b { font-weight: 650; }
.bb-pin-row span { color: var(--g-muted); }
.bb-pin-row.warn { background: rgba(255, 107, 107, .12); color: var(--g-red); }
.bb-note.warn { background: rgba(255, 107, 107, .1); color: #ffb4ad; }

/* ---------- tray: basic | advanced ---------- */
.bb-groups { flex: 0 0 auto; display: grid; align-content: center; gap: 3px; padding: 0 4px; margin: 0 2px; border-left: 1px solid var(--g-line); border-right: 1px solid var(--g-line); }
.bb-group { border: 0; border-radius: 9px; padding: 5px 9px; background: none; color: var(--g-muted); font-size: .72rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.bb-group:hover { background: var(--g-fill); }
.bb-group[aria-pressed="true"] { background: #fff; color: #0f172a; }
.bb-tile.meter-tile { margin-left: auto; }

/* ---------- full screen ---------- */
.bb-full-title { display: none; margin-right: auto; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.bb-full-title span { color: var(--g-muted); font-weight: 500; font-size: .86rem; }
.bb-stage.bb-full { position: fixed; inset: 0; z-index: 1000; width: 100vw; height: 100vh; height: 100dvh; max-width: none; margin: 0; border-radius: 0; padding: 12px 16px 14px; display: flex; flex-direction: column; overflow: hidden; }
.bb-stage.bb-full > :not(.bb) { display: none !important; }
.bb-full .bb { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bb-full .bb-top { position: static; margin: 0 0 10px; flex-wrap: wrap; justify-content: flex-end; }
.bb-full .bb-full-title { display: flex; }
.bb-full .bb-main { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr); }
.bb-full .bb-bench { grid-row: 2; height: 100%; min-height: 0; display: flex; flex-direction: column; }
.bb-full .bb-scroll { flex: 1; min-height: 0; overflow: auto; }
.bb-full .bb-zoom { flex: none; align-self: flex-end; }
.bb-full .bb-scroll:not(.zoomed) .bb-svg { width: 100%; height: 100%; max-height: none; min-width: 0; }
.bb-full .bb-side { grid-row: 1 / span 2; min-height: 0; max-height: 100%; overflow-y: auto; }
html.bb-full-lock, html.bb-full-lock body { overflow: hidden; }
@media (max-width: 1100px) {
  .bb-full .bb-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .bb-full .bb-side { grid-row: 3; max-height: 30vh; }
}
@media (max-width: 760px) {
  /* phones: the page scrolls inside full screen; the board fills most of the height and pans sideways */
  .bb-stage.bb-full { padding: 10px; overflow-y: auto; display: block; }
  .bb-full .bb, .bb-full .bb-main { flex: none; min-height: auto; }
  .bb-full .bb-main { display: flex; }
  .bb-full .bb-bench { flex: 0 0 auto; height: 62dvh; align-self: stretch; width: 100%; }
  .bb-full .bb-scroll:not(.zoomed) .bb-svg { width: auto; height: 100%; max-width: none; min-width: 0; }
  .bb-full .bb-side { max-height: none; overflow: visible; }
  .bb-full .bb-full-title span { display: none; }
}
.bb-ex-head { padding: 10px 12px 4px; font-size: .72rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--g-faint); }
/* phones: the examples and export menus span the toolbar instead of hanging off the screen */
@media (max-width: 760px) {
  .bb-top { position: relative; top: auto; right: auto; }
  .bb-examples { position: static; }
  .bb-ex-list, .bb-export .bb-ex-list { left: 0; right: 0; width: auto; top: calc(100% + 6px); }
}

/* ---------- servo, temperature sensor, relay ---------- */
.servo-wire { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.servo-case { fill: #2f6fd6; stroke: #1d4a99; stroke-width: .8; }
.servo-label { font: 700 6.5px system-ui, sans-serif; fill: #dbe7fb; text-anchor: middle; letter-spacing: .04em; }
.servo-gear { fill: #e8edf2; stroke: #9aa5b1; stroke-width: .6; }
.servo-arm { fill: #f8fafc; stroke: #9aa5b1; stroke-width: .7; }
.servo-hub { fill: #9aa5b1; }
.servo-angle { font: 700 7px system-ui, sans-serif; fill: #334155; text-anchor: middle; }
.tmp-reading { font: 700 7.5px system-ui, sans-serif; fill: #b4532a; text-anchor: middle; }
.relay-pcb { fill: #1d4f91; stroke: #12335f; stroke-width: .8; }
.relay-box { fill: #2563eb; stroke: #1e40af; stroke-width: .8; }
.relay-label { font: 700 5.6px system-ui, sans-serif; fill: #e0e7ff; text-anchor: middle; }
.relay-label.small { font-size: 4.6px; font-weight: 600; opacity: .8; }
.relay-terminal { fill: #1a7f4f; stroke: #0f5132; stroke-width: .8; }
.relay-screw { fill: #c9ced6; stroke: #6b7280; stroke-width: .6; }
.relay-led { fill: #3a1a1a; }
.relay-led.on { fill: #ff4d4d; filter: drop-shadow(0 0 3px #ff4d4d); }
.relay-switch { fill: none; stroke: #c9ced6; stroke-width: 1.6; stroke-linecap: round; }
.relay-switch.on { stroke: #fde68a; }
.oled-text.oled-off, .oled-fill.oled-off { fill: #000; }
.oled-fill.oled-on { fill: #d8f3ff; }
.oled-stroke { fill: none; stroke-width: .6; }
.oled-stroke.oled-on { stroke: #d8f3ff; }
.oled-stroke.oled-off { stroke: #000; }
.bb-dark .part :is(.oled-fill, .oled-stroke) { filter: none; }

/* ---------- code editor + serial monitor ---------- */
.bb-serial { margin: 0; min-height: 64px; max-height: 150px; overflow: auto; padding: 10px 12px; border-radius: 12px; background: #05080c; border: 1px solid rgba(255, 255, 255, .06);
  font: 11.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #9fe6b8; white-space: pre-wrap; word-break: break-word; }
.bb-editor { position: absolute; z-index: 40; top: 12px; right: 12px; bottom: 12px; width: min(680px, calc(100% - 24px)); display: flex; flex-direction: column; border-radius: 20px; overflow: hidden;
  background: #0b1017; border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); }
.bb-editor-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--g-line); }
.bb-editor-bar strong { font-size: .95rem; }
.bb-editor-bar span { flex: 1; color: var(--g-muted); font-size: .8rem; }
.bb-editor-tpl { background: var(--g-fill); color: var(--g-ink); border: 1px solid var(--g-line); border-radius: 10px; padding: 6px 8px; font: inherit; font-size: .82rem; }
.bb-editor-tpl option { background: #151c26; }
.bb-editor-wrap { position: relative; flex: 1; min-height: 240px; display: flex; overflow: hidden; }
.bb-editor-gutter, .bb-editor-text { margin: 0; padding: 12px 10px; font: 13px/19px ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.bb-editor-gutter { width: 44px; flex: 0 0 auto; overflow: hidden; text-align: right; color: rgba(226, 232, 240, .3); background: rgba(255, 255, 255, .02); user-select: none; }
.bb-editor-text { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: #e6edf3; white-space: pre; overflow: auto; tab-size: 2; caret-color: var(--g-teal); }
.bb-editor-text:focus-visible { outline: 0; }
.bb-editor-msg { padding: 8px 14px; font-size: .82rem; border-top: 1px solid var(--g-line); min-height: 36px; }
.bb-editor-msg.ok { color: #9fe6b8; }
.bb-editor-msg.bad { color: #ffb4ad; background: rgba(255, 107, 107, .08); }
.bb-editor-foot { display: flex; gap: 8px; padding: 10px 14px 14px; }
.bb-editor-foot .bb-act { padding: 9px 16px; }
/* the editor on a phone lives on the page itself, so it carries the studio colours with it */
.bb-editor-page { --g-ink: #eef2f7; --g-muted: rgba(226, 232, 240, .62); --g-faint: rgba(226, 232, 240, .42); --g-line: rgba(255, 255, 255, .1);
  --g-fill: rgba(255, 255, 255, .06); --g-fill-2: rgba(255, 255, 255, .11); --g-teal: #5eead4; --g-red: #ff6b6b; color: var(--g-ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
.bb-editor-page button { font: inherit; color: inherit; }
@media (max-width: 760px) {
  .bb-editor { position: fixed; inset: 0; width: auto; border-radius: 0; z-index: 2000; }
  .bb-editor-bar span { display: none; }
}
