/* Battery Builder: the battery workshop's test bench. Scene drawn by art.js (colors from the --bb-* properties below). */
html {
  --bb-wall: #e4ddd0; --bb-peg: #c3b9a7; --bb-wood1: #b07a45; --bb-wood2: #7a4b22; --bb-wood-line: #4f2e12;
  --bb-glass: #8fb3c4; --bb-line: #2a2f35; --bb-ink: #1d2a36; --bb-axis: #3d5163;
  --bb-sol-zn: #e9f0f3; --bb-sol-fe: #cfe6c2; --bb-sol-cu: #4f95da; --bb-sol-ag: #f1f4f6;
  --bb-gel: #f3ecd0; --bb-gel-kcl: #e6f0d6; --bb-plug: #fbfbf7;
  --bb-red: #d23a2c; --bb-black: #2b2f33; --bb-wire-off: #a7adb3;
  --bb-dev1: #f4f6f8; --bb-dev2: #d6dce2; --bb-lcd: #1f3a2e; --bb-lcd-t: #8cf5b4; --bb-lcd-err: #ffb4a8;
  --bb-gadget: #5d6670; --bb-gadget-bg: #e8ecef; --bb-led-off: #f3eed2; --bb-led-on: #ffe14d;
  --bb-cat: #f08a24; --bb-cat2: #a14e00; --bb-an: #8a4bd6; --bb-an2: #4e1f8f; --bb-e-arrow: #b58900;
  --bb-tag: rgba(255,255,255,.94); --bb-tag-line: #5d6a75; --bb-warn: #9c2a17;
  --bb-panel-bg1: #f3f7f9; --bb-panel-bg2: #e3edf1; --bb-accent: #21576b; --bb-ok: #13704a; --bb-bad: #b3261e; --bb-card: #ffffff;
}
html[data-theme="dark"] {
  --bb-wall: #2b2a28; --bb-peg: #1c1b1a; --bb-wood1: #7a5330; --bb-wood2: #4f3218; --bb-wood-line: #b88a5c;
  --bb-glass: #7d9cab; --bb-line: #0f1215; --bb-ink: #e8eef3; --bb-axis: #b9c8d4;
  --bb-sol-zn: #c9d4d9; --bb-sol-fe: #a9c99b; --bb-sol-cu: #3f7fc0; --bb-sol-ag: #d4dade;
  --bb-gel: #d9cfa6; --bb-gel-kcl: #c4d3ad; --bb-plug: #e2e2da;
  --bb-red: #ef5a4b; --bb-black: #9aa3ab; --bb-wire-off: #59626b;
  --bb-dev1: #46505a; --bb-dev2: #2e353c; --bb-gadget: #b9c2ca; --bb-gadget-bg: #222930; --bb-led-off: #8b876d;
  --bb-e-arrow: #ffd23f; --bb-tag: rgba(20,28,36,.94); --bb-tag-line: #93a3b1; --bb-warn: #ff9b8a;
  --bb-panel-bg1: #1f2a30; --bb-panel-bg2: #182227; --bb-accent: #7fc6de; --bb-ok: #4fd08c; --bb-bad: #ff8a80; --bb-card: #1f2630;
}

/* ── layout: bench (drawing + parts) | panel (table, labels, test) ── */
.bb { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 318px; gap: 10px; padding: 8px 10px;
  color: var(--tlg-text); font-size: 16px; }
.bb input, .bb button { font: inherit; }
.bb-bench { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }
.bb-scene { flex: 0 1 auto; min-height: 0; display: flex; justify-content: center; }
.bb-svg { display: block; width: 100%; height: auto; max-height: 278px; border-radius: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.bb-svg text { font-family: var(--tlg-font, system-ui, sans-serif); }
.bb-caption { margin: 0; min-height: 24px; font-size: 16px; font-weight: 600; line-height: 1.3; color: var(--bb-ink); }
.bb-caption.is-ok { color: var(--bb-ok); }
.bb-caption.is-bad { color: var(--bb-bad); }
.bb-parts { display: grid; grid-template-columns: minmax(0, 1fr) 168px minmax(0, 1fr); gap: 8px; }
.bb-panel { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: auto; padding: 8px 10px;
  background: linear-gradient(var(--bb-panel-bg1), var(--bb-panel-bg2)); color: var(--bb-ink); border: 3px solid var(--bb-accent);
  border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.bb-kicker { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-accent); }

/* cards */
.bb-card { display: grid; gap: 4px; align-content: start; padding: 6px 8px; background: var(--bb-card); color: var(--bb-ink);
  border: 2px solid var(--tlg-border, #c9cfd6); border-radius: 12px; min-width: 0; }
.bb-step { padding: 0; background: none; border: 0; }
.bb-card-h { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 17px; line-height: 1.15; }
.bb-card-b { display: grid; gap: 4px; }
.bb-n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--bb-accent);
  color: #fff; font-size: 16px; font-weight: 800; }
html[data-theme="dark"] .bb-n { color: #10242c; }
.bb-card.is-done .bb-n { background: var(--bb-ok); }
.bb-group { display: grid; gap: 2px; min-width: 0; }
.bb-group-l { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; font-size: 16px; font-weight: 700; line-height: 1.2; }
.bb-wire-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; }

/* tiles (radio groups) */
.bb-tiles { display: grid; gap: 5px; }
.bb-tiles--metal, .bb-tiles--sol { grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); }
.bb-tiles--bridge { grid-template-columns: 1fr; }
.bb-tiles--lead, .bb-tiles--two { grid-template-columns: 1fr 1fr; }
.bb-tiles--cells { grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); }
.bb-tiles--three { grid-template-columns: 1fr 1fr 1fr; }
.bb-tiles--ions { grid-template-columns: 1fr; gap: 4px; }
.bb-tile { position: relative; display: block; cursor: pointer; min-width: 0; }
.bb-tile-in { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; font-size: 16px; }
.bb-tile-b { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px; padding: 2px 6px;
  border: 2px solid #9fb2bc; border-radius: 9px; background: var(--bb-card); color: var(--bb-ink); line-height: 1.1; text-align: center; }
.bb-tile-b b { font-size: 17px; }
.bb-tiles--bridge .bb-tile-b { justify-content: flex-start; min-height: 38px; }
.bb-tiles--bridge .bb-tile-b small { font-size: 16px; opacity: .8; }
.bb-tiles--ions .bb-tile-b { min-height: 36px; justify-content: flex-start; text-align: left; }
.bb-tiles--three .bb-tile-b { font-size: 16px; padding: 2px 3px; }
.bb-tile-in:checked + .bb-tile-b { border-color: var(--bb-accent); background: var(--bb-accent); color: #fff; box-shadow: 0 2px 6px rgba(33,87,107,.35); }
html[data-theme="dark"] .bb-tile-in:checked + .bb-tile-b { color: #10242c; }
.bb-tile-in:focus-visible + .bb-tile-b { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.bb-tile-in:disabled, .bb-tile-in:disabled + .bb-tile-b { cursor: default; }
.is-sealed .bb-panel .bb-tile-b, .is-locked .bb-tile-b { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(33,87,107,.08) 6px 12px); }
.bb-sw { flex: none; width: 12px; height: 26px; border-radius: 2px; border: 1px solid rgba(0,0,0,.45); }
.bb-sw--Zn { background: linear-gradient(90deg, #8d9aa6, #dfe6ec, #8d9aa6); }
.bb-sw--Fe { background: linear-gradient(90deg, #555b61, #a9aeb3, #555b61); }
.bb-sw--Cu { background: linear-gradient(90deg, #b0582a, #f4b383, #b0582a); }
.bb-sw--Ag { background: linear-gradient(90deg, #b9c1c8, #ffffff, #b9c1c8); }
.bb-drop { flex: none; width: 11px; height: 15px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; border: 1px solid rgba(0,0,0,.45); }
.bb-drop--Zn { background: var(--bb-sol-zn); } .bb-drop--Fe { background: var(--bb-sol-fe); }
.bb-drop--Cu { background: var(--bb-sol-cu); } .bb-drop--Ag { background: var(--bb-sol-ag); }
.bb-tiles--sol .bb-tile-b { gap: 3px; padding: 2px 3px; }
.bb-tiles--sol .bb-tile-b b { font-size: 16px; }
.bb-plus { font-style: normal; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bb-red);
  color: #fff; font-weight: 900; font-size: 16px; line-height: 1; }

/* E° table */
.bb-table { padding: 4px 8px 5px; background: var(--bb-card); border: 2px solid var(--tlg-border, #c9cfd6); border-radius: 10px; }
.bb-table-h { margin: 0 0 2px; font-size: 16px; font-weight: 800; }
.bb-react { margin: 0; font-size: 18px; }
.bb-react-s { margin: 0; font-size: 15px; }
.bb-bridge-fixed { margin: 4px 0 0; font-size: 15px; line-height: 1.35; }
.bb-table-l { display: grid; grid-template-columns: auto auto auto auto; justify-content: space-between; gap: 0 8px; margin: 0; font-size: 16px; line-height: 1.3; }
.bb-table-l dt { font-weight: 600; }
.bb-table-l dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

/* prediction */
.bb-num { display: grid; grid-template-columns: minmax(0, 1fr) 128px; align-items: center; gap: 2px 8px; }
.bb-num-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.bb-num input { flex: 1 1 auto; min-width: 0; width: 100%; font-size: 17px; min-height: 40px; padding: 4px 8px; border: 2px solid #8ba5b0;
  border-radius: 8px; background: #fff; color: #1f2a30; }
html[data-theme="dark"] .bb-num input { background: #141c21; color: #eef4f7; border-color: #5d7e8b; }
.bb-num input:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.bb-num input:disabled { opacity: 1; background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(33,87,107,.09) 6px 12px), #eef3f5; color: #1f2a30; }
html[data-theme="dark"] .bb-num input:disabled { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(127,198,222,.1) 6px 12px), #18232a; color: #eef4f7; }
.bb-unit { font-weight: 700; }
.bb-mark { font-weight: 800; font-size: 16px; }
.bb-mark.is-ok { color: var(--bb-ok); }
.bb-mark.is-bad { color: var(--bb-bad); }
.bb-seal { margin: 0; font-size: 16px; font-weight: 700; color: var(--bb-accent); }

/* test */
.bb-run { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; flex: none; margin-top: auto; padding: 6px 12px;
  border: 0; border-radius: 10px; background: var(--bb-accent); color: #fff; font-size: 18px; font-weight: 800; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.25); }
html[data-theme="dark"] .bb-run { color: #10242c; }
.bb-run:hover:not(:disabled) { filter: brightness(1.08); }
.bb-run:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 3px; }
.bb-run:disabled { opacity: .55; cursor: default; box-shadow: none; }
.bb-run.is-done, html[data-theme="dark"] .bb-run.is-done { background: transparent; color: var(--bb-accent); border: 2px solid var(--bb-accent); opacity: 1; font-size: 16px; font-weight: 700; }
.bb-run-i { font-size: 20px; }

/* ── the bench drawing ── */
.bb-liq { fill-opacity: .78; transition: fill .25s; }
.is-empty .bb-liq-shade, .is-empty .bb-meniscus { display: none; }
.bb-meniscus { fill: #ffffff; opacity: .35; }
.bb-q { font-size: 30px; font-weight: 800; fill: var(--bb-axis); opacity: .6; }
.bb-strip-ghost { fill: none; stroke: var(--bb-wire-off); stroke-width: 2; stroke-dasharray: 5 5; }
.bb-strip-t { font-size: 16px; font-weight: 800; fill: #1b1f24; }
.bb-wire { fill: none; stroke-width: 5; stroke-linejoin: round; stroke-linecap: round; }
.bb-wire.is-off { stroke-dasharray: 2 8; stroke-width: 4; }
.bb-term text { font-size: 18px; font-weight: 900; fill: #fff; }
.bb-bridge-ghost { fill: none; stroke: var(--bb-wire-off); stroke-width: 18; stroke-opacity: .35; stroke-dasharray: 10 8; }
.bb-gel { stroke: var(--bb-gel); }
.bb-gel--KCl { stroke: var(--bb-gel-kcl); }
.bb-plug { fill: var(--bb-plug); stroke: #b9b3a0; stroke-width: 1; }
.bb-bridge-t { font-size: 17px; font-weight: 800; fill: var(--bb-ink); paint-order: stroke; stroke: var(--bb-wall); stroke-width: 4px; }
.bb-bridge-t.is-none { fill: var(--bb-warn); }
.bb-lcd-t { font-size: 18px; font-weight: 800; fill: var(--bb-lcd-t); font-family: ui-monospace, Menlo, Consolas, monospace !important; letter-spacing: .02em; }
.bb-lcd-t.is-err { fill: var(--bb-lcd-err); font-size: 17px; }
.bb-band-t { font-size: 16px; font-weight: 700; fill: var(--bb-ink); }
html[data-theme="dark"] .bb-band-t { fill: #eef2f5; }
.bb-led { fill: var(--bb-led-off); }
.bb-glow { opacity: 0; }
.bb-device.is-on .bb-led { fill: var(--bb-led-on); }
.bb-device.is-on .bb-glow { opacity: 1; animation: bb-flicker 2.4s ease-in-out infinite; }
@keyframes bb-flicker { 50% { opacity: .8; } }
.bb-device.is-on .bb-fan { animation: bb-spin .5s linear infinite; }
@keyframes bb-spin { to { transform: rotate(360deg); } }
.bb-device.is-on .bb-hand { animation: bb-spin 3s steps(12) infinite; }
.bb-waves { opacity: 0; }
.bb-device.is-on .bb-waves { animation: bb-buzz .6s ease-in-out infinite; }
@keyframes bb-buzz { 50% { opacity: 1; } }
.bb-device.is-cheer { animation: bb-hop .45s ease-in-out 2; transform-box: fill-box; transform-origin: center bottom; }
@keyframes bb-hop { 50% { transform: translateY(-4px); } }
.bb-pack-bg { fill: var(--bb-card); stroke: var(--tlg-border, #c9cfd6); stroke-width: 2; }
.bb-pack-cell { fill: #d9dee3; stroke: var(--bb-line); stroke-width: 1.4; }
.bb-pack-cell.is-shown { fill: var(--bb-sol-cu); }
.bb-pack-nub { fill: var(--bb-line); }
.bb-pack-link { stroke: var(--bb-red); stroke-width: 3; }
.bb-pack-t { font-size: 16px; font-weight: 800; fill: var(--bb-ink); }
.bb-pack-s { font-size: 16px; fill: var(--bb-axis); }
.bb-lab { font-size: 17px; font-weight: 800; fill: #fff7ea; paint-order: stroke; stroke: rgba(60,30,8,.6); stroke-width: 3px; }
.bb-model { font-size: 16px; font-weight: 700; fill: #f3e6d4; letter-spacing: .02em; }
.bb-e-t { font-size: 18px; font-weight: 900; fill: var(--bb-e-arrow); paint-order: stroke; stroke: var(--bb-wall); stroke-width: 4px; }
.bb-ion-t { font-size: 16px; font-weight: 800; fill: var(--bb-ink); paint-order: stroke; stroke: var(--bb-wall); stroke-width: 4px; }
.bb-e-arrow { stroke: var(--bb-e-arrow); stroke-width: 4; }
.bb-pit { fill: rgba(20,24,28,.55); }
.bb-wear { animation: bb-fade 1.2s ease-out both; }
@keyframes bb-fade { from { opacity: 0; } to { opacity: 1; } }
.bb-agcl circle { fill: #ffffff; stroke: #9aa3ab; stroke-width: .8; }
.bb-tag rect { fill: var(--bb-tag); stroke: var(--bb-tag-line); stroke-width: 1; }
.bb-tag text { font-size: 16px; font-weight: 800; fill: var(--bb-ink); }
.bb-warn text { fill: var(--bb-warn); }
.bb-half rect { fill: var(--bb-tag); stroke: var(--bb-accent); stroke-width: 2; }
.bb-half text { font-size: 16px; font-weight: 700; fill: var(--bb-ink); }
.bb-half .bb-half-h { font-weight: 900; fill: var(--bb-accent); }
.bb-half.is-pop, .bb-eq { animation: bb-fade .5s ease-out both; }
.bb-eq { font-size: 16px; font-weight: 800; fill: var(--bb-ink); paint-order: stroke; stroke: var(--bb-wall); stroke-width: 5px; }
.bb-ex { display: block; width: 100%; max-width: 440px; }

@media (max-width: 900px) {
  .bb { position: static; grid-template-columns: 1fr; }
  .bb-panel { overflow: visible; }
  .bb-svg { max-height: none; }
}
@media (max-width: 600px) {
  .bb-parts { grid-template-columns: 1fr; }
  .bb-wire-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .bb *, .bb *::before { animation: none !important; transition: none !important; }
}
