/* Breadboard Lab. Original School Launch styles. */
:root {
  --ink: #2a211b; --muted: #6b5d52; --paper: #f7f2e8; --card: #fffdf8; --line: #e2d7c5; --brick: #8c3b22; --brick-dk: #6e2c18;
  --ok: #1d6b3a; --okbg: #e8f5ec; --no: #9a2a12; --nobg: #fdeee8; --warn: #8a5a00; --focus: #1f5f8b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { line-height: 1.5; font-size: 16px; overflow-x: hidden; }
.app { max-width: 1240px; margin: 0 auto; padding: 12px 16px 40px; }
a { color: var(--brick); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.noscript { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.top { margin-bottom: 8px; }
.top .back { font-size: 14px; font-weight: 600; text-decoration: none; }
.top h1 { margin: 4px 0 0; font-size: 28px; color: var(--brick); letter-spacing: 0.01em; }
.top .sub { margin: 2px 0 0; color: var(--muted); }
.lessons { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.lessonbtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 12px 6px 6px; font: inherit; font-size: 14px; cursor: pointer; min-height: 40px; }
.lessonbtn .num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #efe6d6; font-weight: 700; font-size: 13px; }
.lessonbtn.on { border-color: var(--brick); background: #fbeee6; }
.lessonbtn.on .num { background: var(--brick); color: #fff; }
.lessonbtn .tick { color: var(--ok); font-weight: 700; }
.safety { display: block; background: #fff7df; border: 1px solid #ecd9a0; border-left: 5px solid #d4a017; border-radius: 6px; padding: 8px 12px; font-size: 14px; margin: 6px 0 12px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.bench, .side > * { min-width: 0; }
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.lesson-head h2 { margin: 0; font-size: 21px; }
.lesson-head p { margin: 4px 0 8px; }
.stepsbox { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin-bottom: 10px; }
.stepsbox summary, .why summary, .kbd summary { cursor: pointer; font-weight: 700; }
.steps { margin: 6px 0 4px; padding-left: 22px; }
.steps li { margin: 3px 0; }
.traybar { position: sticky; top: 0; z-index: 5; background: var(--paper); padding: 6px 0 2px; margin: 0 -2px; }
.tray { display: flex; flex-wrap: wrap; gap: 6px; }
.traybtn { display: inline-flex; align-items: center; gap: 4px; border: 2px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 10px 4px 4px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 44px; touch-action: none; color: var(--ink); }
.traybtn.on { border-color: var(--brick); background: #fbeee6; }
.ticon { width: 40px; height: 24px; }
.toolopts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; min-height: 0; font-size: 14px; }
.toolopts:empty { display: none; }
.hint { min-height: 1.5em; margin: 4px 0 2px; font-size: 14px; color: var(--muted); }
.board-wrap { background: #e9e1d2; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.boardsvg { display: block; width: 100%; height: auto; max-height: calc(100vh - 150px); user-select: none; -webkit-user-select: none; }
button { font: inherit; }
.actions, .codebtns, .controls, .selbar .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.controls { margin: 8px 0; font-size: 14px; }
.actions button, .codebtns button, .feedback button, .kform button { border: 1px solid #cdbfa8; background: var(--card); border-radius: 6px; padding: 8px 12px; cursor: pointer; min-height: 40px; color: var(--ink); }
button.primary { background: var(--brick) !important; border-color: var(--brick-dk) !important; color: #fff !important; font-weight: 700; }
button.small { border: 1px solid #cdbfa8; background: var(--card); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 14px; min-height: 36px; color: var(--ink); }
button.small[aria-pressed="true"] { background: #e7f0f7; border-color: var(--focus); }
button.danger { color: var(--no); }
button.link { border: 0; background: none; color: var(--brick); text-decoration: underline; cursor: pointer; padding: 2px; font-size: 14px; }
.slider { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
.slider span:first-child { font-weight: 600; }
.slider input { width: 150px; }
.slider .dark, .slider .brightlbl { font-size: 12px; color: var(--muted); }
.selbar { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.selbar p { margin: 0 0 6px; }
.selbar .reading { font-weight: 700; color: var(--focus); }
.feedback { border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.feedback.ok { background: var(--okbg); border: 1px solid #b6dcc2; }
.feedback.no { background: var(--nobg); border: 1px solid #f0c3b3; }
.feedback .ftitle { margin: 0; font-weight: 700; }
.feedback ul { margin: 6px 0; padding-left: 20px; }
.feedback li.error { color: var(--no); }
.feedback li.warn { color: var(--warn); }
.plist h3, .side h3 { font-size: 17px; margin: 0 0 6px; }
.plist { font-size: 14px; margin-top: 10px; }
.plist ul { margin: 0; padding-left: 18px; }
.kbd { margin-top: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 14px; }
.kform { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.kform input, .kform select, .toolopts select, .selbar select { font: inherit; font-size: 15px; padding: 5px; border: 1px solid #cdbfa8; border-radius: 5px; background: #fff; color: var(--ink); }
.note { font-size: 13px; color: var(--muted); margin: 4px 0; }
.codebox, .ohm, .why, .questions { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.codebox h4 { margin: 10px 0 4px; font-size: 14px; }
.editor { display: flex; border: 1px solid #cdbfa8; border-radius: 6px; background: #1e1b18; overflow: hidden; }
.gutter { margin: 0; padding: 8px 6px; color: #8d8174; background: #2a2622; text-align: right; font: 13px/18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow: hidden; height: 300px; min-width: 30px; user-select: none; }
.tawrap { position: relative; flex: 1; min-width: 0; }
.code { display: block; width: 100%; height: 300px; margin: 0; border: 0; padding: 8px; resize: vertical; background: transparent; color: #f3ead9; font: 13px/18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; overflow: auto; tab-size: 2; position: relative; z-index: 1; }
.code:focus-visible { outline: 2px solid #f3c56b; outline-offset: -2px; }
.linemark { position: absolute; left: 0; right: 0; top: 0; height: 18px; background: rgba(243, 197, 107, 0.22); border-left: 3px solid #f3c56b; pointer-events: none; }
.linemark.err { background: rgba(255, 90, 60, 0.28); border-left-color: #ff6a4a; }
.codeerr { color: var(--no); font-weight: 600; margin: 6px 0; font-size: 14px; }
.codeerr:empty { display: none; }
.codebtns { margin-top: 8px; }
.runstatus { font-size: 13px; color: var(--muted); }
.serial { margin: 0; min-height: 60px; max-height: 160px; overflow: auto; background: #f1ece2; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.ohm .calc { font-weight: 700; }
.ohm .meter { color: var(--focus); font-weight: 600; }
.ohm p, .why p { margin: 6px 0; }
.questions ol { margin: 0; padding-left: 20px; }
.questions li { margin: 4px 0; }
.dragghost { position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, -140%); background: var(--brick); color: #fff; font-size: 13px; font-weight: 700; padding: 4px 8px; border-radius: 6px; }
[hidden] { display: none !important; }

/* SVG art */
.pcb { fill: #1f6f6a; stroke: #15504c; stroke-width: 2; }
.usb { fill: #c9ccd1; stroke: #8b9097; }
.jack { fill: #26292d; }
.chip { fill: #1d1d1f; }
.chipleg { fill: #b8bcc2; }
.boardlabel { fill: #e8f4ef; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.tiny { fill: #cfe7df; font-size: 7px; font-weight: 600; }
.onled { fill: #7dff8a; }
.l13 { fill: #5a4a22; }
.l13.on { fill: #ffb21f; }
.header { fill: #121212; }
.pinhole { fill: #3b3b3b; stroke: #8f8f8f; stroke-width: 0.8; }
.pinlabel { fill: #f2f6f4; font-size: 8.5px; font-weight: 700; }
.pinlabel.gnd { fill: #d6dbe0; }
.pinlabel.pwr { fill: #ffb4a8; }
.bbbody { fill: #f4f1ea; stroke: #d8d0c0; stroke-width: 1.5; }
.groove { fill: #e2dccf; }
.rail { stroke-width: 1.5; }
.rail.plus { stroke: #d62828; }
.rail.minus { stroke: #2b59c3; }
.raillabel { font-size: 11px; font-weight: 800; }
.raillabel.plus { fill: #d62828; }
.raillabel.minus { fill: #2b59c3; }
.rowlabel, .collabel { fill: #9b917f; font-size: 8px; font-weight: 600; }
.hole { fill: #5c5548; }
.hit { fill: transparent; cursor: pointer; }
.hit:hover { fill: rgba(31, 95, 139, 0.16); }
.wirestart { fill: none; stroke: var(--focus); stroke-width: 2.5; }
.part { cursor: grab; touch-action: none; }
.dragging .part { pointer-events: none; }
.parthit { fill: transparent; }
.part.sel .parthit { fill: rgba(31, 95, 139, 0.1); stroke: var(--focus); stroke-width: 1.5; stroke-dasharray: 3 2; }
.leg { stroke: #9aa0a6; stroke-width: 2; stroke-linecap: round; }
.ledbody { stroke: rgba(0, 0, 0, 0.35); stroke-width: 1; }
.ledbody.red { fill: #c8281d; } .ledbody.red.lit { fill: #ff5a3c; }
.ledbody.yellow { fill: #c9a300; } .ledbody.yellow.lit { fill: #ffe14a; }
.ledbody.green { fill: #1f8f3a; } .ledbody.green.lit { fill: #5cff7c; }
.ledbody.burned { fill: #4a4440 !important; }
.ledflat { stroke: rgba(0, 0, 0, 0.45); stroke-width: 1.5; }
.plus { font-size: 9px; font-weight: 800; fill: #b0261a; }
.smoke { fill: #8a8580; opacity: 0.5; }
.resbody { fill: #e7cf9f; stroke: #b99a5f; stroke-width: 1; }
.btnbody { fill: #2f3136; }
.btncap { fill: #b91c1c; stroke: #7f1414; stroke-width: 1; }
.btncap.down { fill: #7f1414; }
.potbody { fill: #2c5aa0; }
.potknob { fill: #e8e8e8; stroke: #9a9a9a; }
.potmark { stroke: #2c2c2c; stroke-width: 2; stroke-linecap: round; }
.ldrbody { fill: #f2d6a2; stroke: #b98d43; }
.ldrtrack { fill: none; stroke: #b5401f; stroke-width: 1.2; }
.buzzbody { fill: #1b1b1b; }
.buzzhole { fill: #555; }
.wave { fill: none; stroke: #1b1b1b; stroke-width: 1.5; opacity: 0.6; animation: wave 0.6s ease-in-out infinite alternate; }
.wireline { fill: none; stroke-width: 4; stroke-linecap: round; }
.wirehit { fill: none; stroke: transparent; stroke-width: 14; }
.part.wire.sel .wireline { stroke-width: 6; }
.wireend { fill: #9aa0a6; }
.ghostpart { opacity: 0.55; }
.ghostpart .leg, .ghostpart .wireline { stroke: #16a34a; stroke-dasharray: 3 2; }
.ghostpart.bad { opacity: 0.4; }
.ghostpart.bad .leg { stroke: #d62828; }
.flow { fill: none; stroke: #fff4b8; stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 2 8; animation: flow 1.2s linear infinite; opacity: 0.95; }
.flow.mid { animation-duration: 0.8s; }
.flow.fast { animation-duration: 0.45s; }
.flow.slow { animation-duration: 2.2s; }
.flow.rev { animation-direction: reverse; }
@keyframes flow { to { stroke-dashoffset: -20; } }
@keyframes wave { from { opacity: 0.2; } to { opacity: 0.8; } }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .app { padding: 8px 10px 32px; }
  .top h1 { font-size: 24px; }
  .lessonbtn { padding: 4px 10px 4px 4px; font-size: 13px; }
  .board-wrap { padding: 2px; margin: 0 -4px; }
  .slider input { width: 120px; }
  .gutter, .code { height: 260px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .flow { stroke-dasharray: 5 4; }
}
