/* Amaete Circuits: the bench page. Desktop: the 3D bench on the left, the lesson card and code in a rail on the right,
   the lesson strip along the bottom. Phones: one control bar, the bench on top, the lesson in a bottom sheet;
   Code, Try it, Parts and Tools open in the sheet's place so the circuit stays in view. */
:root {
  --bg: #EEF0EA; --stage: #E4E8E0; --panel: #FAFBF7; --ink: #141A21; --muted: #5B6570; --line: #D3D8CE;
  --accent: #0E7C6B; --accent-ink: #FFFFFF; --signal: #E07F22; --code-bg: #F3F5EF;
  --k: #1F5FA8; --fn: #B0531A; --num: #0E7C6B; --com: #8A939B; --str: #9A3F86; --curline: rgba(14,124,107,.12);
  --danger: #C4372B; --grid: #CDD3C8; --ok: #3FBF6A;
  --font-display: "Chakra Petch", "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-code: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --code-fs: 13px; --code-lh: 20px;
  --sheet-bg: var(--panel);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1417; --stage: #161D21; --panel: #1A2227; --ink: #E7ECE9; --muted: #95A1A8;
    --line: #2B353B; --accent: #3CC2A8; --accent-ink: #08201B; --signal: #F29B45; --code-bg: #131A1E;
    --k: #7DB2F0; --fn: #F0A36B; --num: #5FD3BC; --com: #6E7A82; --str: #D98BC8;
    --curline: rgba(60,194,168,.14); --danger: #F0685B; --grid: #232C31;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1417; --stage: #161D21; --panel: #1A2227; --ink: #E7ECE9; --muted: #95A1A8;
  --line: #2B353B; --accent: #3CC2A8; --accent-ink: #08201B; --signal: #F29B45; --code-bg: #131A1E;
  --k: #7DB2F0; --fn: #F0A36B; --num: #5FD3BC; --com: #6E7A82; --str: #D98BC8;
  --curline: rgba(60,194,168,.14); --danger: #F0685B; --grid: #232C31;
  color-scheme: dark;
}
@media (pointer: coarse) { :root { --code-fs: 16px; --code-lh: 24px; } }

[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* desktop: the lessons in a pane on the left, the bench full-bleed with its title over it, one control bar,
   and a drawer on the right for the lesson, Try it, Code, Parts, Tools or Tune */
.app { height: 100%; display: grid; grid-template-columns: var(--pane-w) minmax(0, 1fr); --pane-w: 288px; }
body.paneoff .app, body.panefold .app { --pane-w: 0px; grid-template-columns: minmax(0, 1fr); }
.pane { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); overflow: hidden; }
body.paneoff .pane, body.panefold .pane { display: none; }
.pane-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 20px 14px 12px 20px; }
.pane-l { overflow-y: auto; flex: 1; padding: 0 10px 16px; }
.pane .list { display: grid; gap: 1px; align-content: start; }
.pane .item { padding: 7px 8px; gap: 10px; grid-template-columns: 32px 1fr; }
.pane .item .b { width: 30px; height: 30px; font-size: 11px; }
.pane .item .t { font-family: var(--font-body); font-weight: 500; font-size: 13.5px; letter-spacing: 0; text-transform: none; line-height: 1.3; }
.pane .item .d { font-size: 12px; }
.pane .item.on { box-shadow: inset 3px 0 0 var(--accent); }
.pane .trk { padding-top: 16px; }
.pane-x { width: 32px; height: 32px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--muted); display: grid; place-items: center; flex: none; }
.pane-x:hover { background: var(--code-bg); color: var(--ink); }
.pane-x svg { width: 18px; height: 18px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand svg { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .06em; text-transform: uppercase; line-height: 1.1; }
.brand-tag { font-family: var(--font-display); font-size: 10px; letter-spacing: .16em; white-space: nowrap; text-transform: uppercase; color: var(--muted); }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; background: var(--panel); white-space: nowrap; color: inherit; text-decoration: none; }

.main { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
.stage { background: var(--stage) radial-gradient(circle, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.4px) 0 0 / 22px 22px; }
.hero { position: absolute; left: 32px; top: 26px; max-width: min(520px, 46%); z-index: 3; pointer-events: none; }
.hero > * { pointer-events: auto; }
.hero .eyebrow { display: inline-block; font-family: var(--font-display); font-weight: 700; font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--signal); text-decoration: none; }
.hero h1 { margin: 6px 0 8px; font-family: var(--font-display); font-weight: 600; font-size: clamp(28px, 3.1vw, 44px); line-height: 1.04; letter-spacing: .01em; text-wrap: balance; }
.hero p { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--muted); max-width: 44ch; }
.hero h1, .hero p, .hero .eyebrow { text-shadow: 0 0 6px var(--stage), 0 0 14px var(--stage), 0 0 22px var(--stage); }
.pane-o { display: none; width: 36px; height: 36px; margin: 0 0 12px -4px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; cursor: pointer; place-items: center; color: var(--ink); }
.pane-o svg { width: 18px; height: 18px; }
body.paneoff .pane-o, body.panefold .pane-o { display: grid; }
.topr { position: absolute; right: 20px; top: 20px; display: flex; gap: 8px; z-index: 4; }
.topr button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px 7px 11px; font: 500 13px var(--font-body); color: var(--ink); cursor: pointer; }
.topr button:hover { background: var(--code-bg); }
.topr button[aria-expanded="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.topr svg { width: 15px; height: 15px; }
/* the drawer */
.rail { width: 400px; border-left: 1px solid var(--line); background: var(--panel); }
.rail .card { border: 0; border-radius: 0; background: none; }
.rail .card.code { min-height: 100%; }
.pnl-h.dk, .rail > .card > .pnl-h { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px 18px; font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.rail > .card > .pnl-h .pnl-x { display: block; }
.rail .code-head h3 { display: none; }
.rail .code-head { padding-top: 4px; }
/* the lower middle: the walkthrough caption and the status line, above the control bar */
.lower { position: absolute; left: 50%; transform: translateX(-50%); bottom: 88px; width: min(620px, calc(100% - 140px)); display: grid; gap: 8px; z-index: 3; }
.caption { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px 16px; box-shadow: 0 10px 28px rgba(10,20,20,.12); }
.cap-h { display: flex; align-items: center; gap: 6px; }
.cap-h > span:first-child { font-family: var(--font-code); font-size: 11.5px; color: var(--muted); min-width: 40px; }
.cap-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; margin-right: 6px; }
.cap-bar i { display: block; height: 100%; width: 0; background: var(--accent); }
.cap-h button { width: 30px; height: 30px; border: 0; background: none; border-radius: 8px; cursor: pointer; display: grid; place-items: center; color: var(--ink); font-size: 14px; }
.cap-h button.spd { width: auto; min-width: 40px; padding: 0 6px; font-family: var(--font-code); font-size: 12px; font-weight: 600; }
.cap-h button:hover { background: var(--code-bg); }
.cap-h svg { width: 16px; height: 16px; }
.caption p { margin: 6px 0 0; font-size: 16px; line-height: 1.45; text-wrap: pretty; }
body.playing .status:not(.bad) { display: none; }
body.playing .dock .runb { display: none !important; }
/* the control bar */
.dock { position: fixed; z-index: 8; bottom: 20px; left: calc(var(--stage-l, 288px) + var(--stage-w, 900px) / 2); transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 10px 28px rgba(10,20,20,.12); max-width: calc(var(--stage-w, 900px) - 32px); }
.dock button { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border: 0; background: none; border-radius: 999px; font: 500 13.5px var(--font-body); color: var(--ink); cursor: pointer; white-space: nowrap; }
.dock button:hover { background: var(--code-bg); }
.dock button svg { width: 16px; height: 16px; flex: none; }
.dock button.ic { width: 40px; padding: 0; justify-content: center; }
.dock button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.dock .playb { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.dock .playb:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.dock .playb.on { background: var(--ink); color: var(--bg); }
.dock .runb.stop { color: var(--danger); }
.dock .runb.changed { background: var(--signal); color: #1b1006; }
.dock .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex: none; }
.dock .quick { display: flex; gap: 2px; padding: 0 4px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); margin: 0 4px; }
.dock .quick[hidden] { display: none; }
.dock .chip { font-size: 13px; padding: 0 12px; }
.dock .chip[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.dock .ph, .dock .dk-hide, .dock .sh { display: none; }
body.compact .dock .sh, body.tight .dock .sh { display: inline; }
body.tight .dock .lng, body.tight .dock .quick, body.tight .topr button span { display: none; }
body.tight .dock .dk-hide { display: inline-flex; }
body.tight .topr button { padding: 8px 10px; }
body.tight .hero { max-width: calc(100% - 300px); }
body.compact .dock .lng { display: none; }
.fly { position: absolute; right: 16px; top: 68px; bottom: 92px; width: 350px; max-width: calc(100% - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(10,20,20,.14); z-index: 5; display: flex; flex-direction: column; }
.fly > header .x { display: block; }
.fly > header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.fly h3 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: .1em; text-transform: uppercase; }
.fly header small { color: var(--muted); font-family: var(--font-display); font-weight: 600; letter-spacing: .04em; }
.fly .list { overflow-y: auto; padding: 6px 8px 10px; display: grid; gap: 2px; align-content: start; }
.fly .x, .pnl-x { margin-left: auto; width: 32px; height: 32px; border: 0; background: none; border-radius: 8px; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); display: none; }
.item { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; font: inherit; color: inherit; text-decoration: none; }
.item:hover, .item.on { background: var(--code-bg); }
.item[disabled], .item.off { cursor: default; opacity: .55; }
.item[disabled]:hover, .item.off:hover { background: none; }
.item .b { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; font-family: var(--font-code); font-size: 12px; color: var(--accent); }
.item .b svg { width: 18px; height: 18px; }
.item.part { grid-template-columns: 64px 1fr; }
.item.part .b { width: 64px; height: 64px; border-radius: 10px; background: var(--stage); overflow: hidden; }
.item.part .b img { width: 64px; height: 64px; display: block; }
.item .t { display: block; font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.item .d { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.trk { font-family: var(--font-display); font-weight: 700; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 12px 8px 4px; }
.status { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px 7px 12px; z-index: 3; }
.status i { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.status.bad i { background: var(--signal); }
.status.short { border-color: var(--danger); }
.status.short i { background: var(--danger); animation: blink .5s steps(2) infinite; }
.status p { margin: 0; font-size: 12.5px; line-height: 1.35; }
.status button { border: 1px solid var(--line); background: none; border-radius: 7px; padding: 5px 9px; font: inherit; font-family: var(--font-display); font-weight: 700; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); cursor: pointer; white-space: nowrap; }
.status button:hover { background: var(--code-bg); }
@keyframes blink { to { opacity: .2; } }
.set { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set .seg { display: flex; gap: 4px; }
.set .seg button { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.set .seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.set .seg .sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.set.wide { grid-template-columns: 1fr; gap: 8px; }
.set.wide .seg { flex-wrap: wrap; }
.switch { width: 46px; height: 26px; border-radius: 13px; border: 0; background: var(--line); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 23px; }
#leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 1; }
#leaders { --lead: #FFC21A; }
:root[data-lead="white"] #leaders { --lead: #FFFFFF; }
:root[data-lead="dark"] #leaders { --lead: #141A21; }
:root[data-lead="teal"] #leaders { --lead: #2BB39E; }
#leaders .lead { fill: none; stroke: var(--lead); stroke-width: 2.2; stroke-dasharray: 6 4; filter: drop-shadow(0 0 1px rgba(0, 0, 0, .55)); }
:root[data-lead="dark"] #leaders .lead { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .6)); }
#leaders .ldot { fill: #fff; stroke: #2BB39E; stroke-width: 4; }
.ccard { position: absolute; left: 0; top: 0; width: 214px; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; z-index: 2; }
.ccard svg { width: 26px; height: 26px; color: var(--ink); }
.ccard b { display: block; font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.ccard span { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.ptag { position: absolute; left: 0; top: 0; white-space: nowrap; z-index: 2; }
.ptag i { position: absolute; left: 0; top: 0; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3.5px solid #3BA79E; box-sizing: border-box; z-index: 1; }
.ptag span { position: absolute; left: 0; top: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px; font-family: var(--font-display); font-weight: 700; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
#leaders .lead.tl { stroke-width: 2; stroke-dasharray: none; }

.stage { position: relative; overflow: hidden; min-height: 0; touch-action: none; }
.stage canvas#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.stage canvas#c:active { cursor: grabbing; }

.readout { position: absolute; right: 20px; top: 68px; justify-content: flex-end; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; max-width: calc(100% - 24px); z-index: 2; }
.gauge { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; display: grid; gap: 2px; min-width: 112px; align-content: start; }
.gauge .lbl { font-family: var(--font-display); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.gauge .lbl.st { letter-spacing: .08em; }
.gauge .val { font-family: var(--font-code); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gauge .val small { font-size: 11px; color: var(--muted); font-weight: 400; }
.gauge canvas { position: static; width: 132px; height: 26px; cursor: default; }
.gauge.pwm .val { color: var(--signal); }

.tools { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; z-index: 3; }
.tools button { width: 36px; height: 36px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.tools button:hover { background: var(--code-bg); }
.tools button[aria-pressed="true"] { color: var(--accent); }
.tools svg { width: 17px; height: 17px; }
.tools .sep { height: 1px; background: var(--line); margin: 3px 6px; }

.hint { display: none; position: absolute; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); font-size: 11px; color: var(--muted); pointer-events: none; z-index: 2; }

#labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; }

.pop { position: absolute; width: 250px; max-width: calc(100% - 24px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(10,20,20,.14); z-index: 6; }
.pop h3 { margin: 0 24px 4px 0; font-family: var(--font-display); font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.pop p { margin: 0; color: var(--muted); font-size: 13px; }
.pop .x { position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; border: 0; background: none; cursor: pointer; border-radius: 6px; }
.pop .x:hover { background: var(--code-bg); }
.pop .swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pop .swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.pop .swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }

.rail { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow-y: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.info { flex: none; }
.tabs { display: flex; gap: 4px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 10px 10px; font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabpanel { padding: 14px 16px 16px; }
.tabpanel h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; text-wrap: balance; }
.tabpanel h4 { margin: 14px 0 6px; font-family: var(--font-display); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.tabpanel p { margin: 0 0 12px; color: var(--muted); max-width: 62ch; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.facts li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; font-size: 13px; }
.facts .ico { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--ink); }
.facts .ico svg { width: 18px; height: 18px; }
.steps-h { margin: 18px 0 8px; }
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.steps button { width: 100%; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: center; text-align: left; padding: 7px 10px 7px 7px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: 13px; line-height: 1.35; cursor: pointer; }
.steps button:hover { border-color: var(--accent); }
.steps .n { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-family: var(--font-code); font-size: 12px; font-weight: 600; }
.steps li.on button { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.steps li.on .n { background: var(--accent); color: var(--accent-ink); }
.check { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.check h4 { margin: 0 0 6px; }
.check .q { margin: 0 0 10px; font-weight: 600; color: var(--ink); }
.check .opts { display: grid; gap: 6px; }
.check .opts button { text-align: left; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.check .opts button:hover { border-color: var(--accent); }
.check .opts .right { border-color: var(--ok); box-shadow: inset 3px 0 0 var(--ok); }
.check .opts .wrong { border-color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }
.check .why { margin: 10px 0 0; font-size: 13px; }
body.nocode .runb, body.nocode .dock [data-panel="code"], body.nocode [data-act="board"], body.nocode .vgrid [data-act="board"] { display: none !important; }
code.inl { font-family: var(--font-code); font-size: 12px; background: var(--code-bg); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; color: var(--fn); }
table.pins { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.pins th, table.pins td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.pins th { font-family: var(--font-display); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.25); }
dl.specs { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
dl.specs dt { color: var(--muted); }
dl.specs dd { margin: 0; font-variant-numeric: tabular-nums; }
.buy { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.buy td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
.buy td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.mistakes { display: flex; flex-wrap: wrap; gap: 6px; }
.mistakes button { border: 1px solid var(--line); background: var(--code-bg); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; min-height: 36px; }
.mistakes button[aria-pressed="true"] { border-color: var(--signal); box-shadow: inset 0 0 0 1px var(--signal); }
.mistakes .fix { border-color: var(--accent); color: var(--accent); }
.buy tr.tot td { border-bottom: 0; font-weight: 600; color: var(--ink); padding-top: 8px; }
.cur { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.cur select { font: inherit; font-size: 13px; color: var(--ink); background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-height: 36px; max-width: 100%; }
.buy-note { font-size: 12px; margin: 10px 0 0 !important; }

.code { display: flex; flex-direction: column; min-height: 360px; flex: 1; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 8px 16px; }
.code-head h3 { margin: 0; font-family: var(--font-display); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.run { display: inline-flex; align-items: center; gap: 7px; border: 0; background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.run svg { width: 14px; height: 14px; }
.run.stop { background: var(--danger); color: #fff; }
.presets { display: flex; gap: 6px; padding: 0 12px 10px 16px; flex-wrap: wrap; }
.presets button { border: 1px solid var(--line); background: var(--code-bg); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.presets button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.knobs { display: grid; gap: 6px; margin: 0 12px 10px 16px; }
.knob { display: grid; grid-template-columns: 150px minmax(0, 1fr) 74px; gap: 10px; align-items: center; font-size: 12.5px; }
.knob .kn b { display: block; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.knob .kn small { display: block; color: var(--muted); font-family: var(--font-code); font-size: 11px; }
.knob input { width: 100%; accent-color: var(--signal); min-height: 28px; }
.knob output { font-family: var(--font-code); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.code-help { margin: 0 12px 10px 16px; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.code-help.warn { color: var(--ink); background: color-mix(in srgb, var(--signal) 18%, transparent); border-left: 3px solid var(--signal); padding: 6px 10px; border-radius: 6px; }
.run.changed, body.compact .dock .runb.changed { background: var(--signal); color: #1b1006; }

.ed-scroll { margin: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--code-bg); overflow: auto; min-height: 140px; flex: 1; }
.ed { display: flex; min-width: max-content; min-height: 100%; }
.gutter { flex: none; padding: 10px 8px 10px 12px; text-align: right; color: var(--com); font-family: var(--font-code); font-size: var(--code-fs); line-height: var(--code-lh); user-select: none; white-space: pre; position: sticky; left: 0; background: var(--code-bg); z-index: 2; }
.ed-body { position: relative; flex: 1; }
.ed-body pre, .ed-body textarea { margin: 0; padding: 10px 14px 10px 6px; font-family: var(--font-code); font-size: var(--code-fs); line-height: var(--code-lh); white-space: pre; tab-size: 2; border: 0; box-sizing: border-box; }
.ed-body pre { position: relative; pointer-events: none; color: var(--ink); z-index: 1; min-height: 100%; }
.ed-body textarea { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; background: transparent; color: transparent; caret-color: var(--ink); outline: none; overflow: hidden; z-index: 1; }
.ed-body textarea::selection { background: rgba(31,95,168,.25); color: transparent; }
.curline { position: absolute; left: 0; right: 0; height: var(--code-lh); background: var(--curline); border-left: 3px solid var(--accent); z-index: 0; transition: top .08s; }
.t-k { color: var(--k); } .t-fn { color: var(--fn); } .t-n { color: var(--num); } .t-c { color: var(--com); font-style: italic; } .t-s { color: var(--str); }

.serial { margin: 10px 12px 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.serial-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-family: var(--font-display); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.sdot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sdot.s-up { background: #E3A21A; } .sdot.s-run { background: #2BB673; } .sdot.s-err { background: var(--danger); }
.serial-state { color: var(--muted); }
.serial-head button { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; letter-spacing: .14em; }
.serial-log { height: 104px; overflow-y: auto; padding: 6px 10px; font-family: var(--font-code); font-size: 12px; line-height: 18px; white-space: pre-wrap; word-break: break-word; }
.serial-log .err { color: var(--danger); }
.serial-log .sys { color: var(--muted); }
.serial-in { display: flex; border-top: 1px solid var(--line); }
.serial-in input { flex: 1; min-width: 0; border: 0; background: none; padding: 6px 10px; font-family: var(--font-code); font-size: 12px; color: var(--ink); outline: none; }
.serial-in button { border: 0; border-left: 1px solid var(--line); background: none; padding: 0 12px; font-family: var(--font-display); font-weight: 700; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }

/* the Try it card: whatever the project lets you poke */
.try { padding: 12px 16px 14px; }
.try h3 { margin: 0 0 8px; font-family: var(--font-display); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.ctl { display: grid; gap: 4px; padding: 6px 0; }
.ctl label, .ctl .nm { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.ctl label b, .ctl .nm b { font-family: var(--font-code); font-weight: 600; font-size: 12.5px; color: var(--accent); }
.ctl input[type=range] { width: 100%; accent-color: var(--accent); min-height: 28px; }
.ctl .keys { display: flex; flex-wrap: wrap; gap: 6px; }
.ctl .keys button, .ctl > button { border: 1px solid var(--line); background: var(--code-bg); border-radius: 9px; padding: 7px 12px; min-width: 44px; min-height: 40px; font-family: var(--font-display); font-weight: 700; letter-spacing: .06em; cursor: pointer; }
.ctl > button { justify-self: start; }
.ctl .keys button:active, .ctl > button:active { background: var(--accent); color: var(--accent-ink); }
.ctl .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }

/* tools */
.tool { padding: 10px 8px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.tool:last-child { border-bottom: 0; }
.tool h4 { margin: 0; font-family: var(--font-display); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.tool p { margin: 0; color: var(--muted); font-size: 12.5px; }
.tool .seg { display: flex; flex-wrap: wrap; gap: 4px; }
.tool .seg button { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; min-height: 32px; }
.tool .seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tool .lcd { font-family: var(--font-code); font-size: 26px; font-weight: 600; background: #B9C9A2; color: #1D2914; border-radius: 8px; padding: 6px 12px; text-align: right; font-variant-numeric: tabular-nums; }
.tool .grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tool .grid3.bands3 { grid-template-columns: 1fr 1fr 1.5fr; }
.tool .grid3 label { display: grid; gap: 2px; font-size: 11px; color: var(--muted); font-family: var(--font-display); letter-spacing: .1em; text-transform: uppercase; }
.tool input, .tool select { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 8px; background: var(--code-bg); color: var(--ink); padding: 7px 8px; font-family: var(--font-code); font-size: 13px; min-height: 36px; }
.tool .bands { display: flex; gap: 4px; align-items: center; justify-content: center; background: #D9C59B; border-radius: 18px; padding: 8px 18px; }
.tool .bands i { width: 12px; height: 30px; border-radius: 2px; display: block; }
.tool .out { font-family: var(--font-code); font-size: 14px; }

/* the phone control bar and the bottom sheet exist only on phones */
.sheet-top, .pnl-h, .peek { display: none; }

@media (prefers-reduced-motion: reduce) { .curline { transition: none; } * { transition: none !important; animation: none !important; } }

/* ---------- phones ---------- */
body.compact { overflow: hidden; }
body.compact .app { height: 100dvh; display: block; padding: 0; position: relative; }
body.compact .pane, body.compact .hero, body.compact .topr, body.compact .hint, body.compact .tools, body.compact .dock .dk, body.compact .dock .quick { display: none !important; }
body.compact .dock .ph { display: inline-flex; }
body.compact .lower { display: contents; }
body.compact .status { position: absolute; z-index: 3; }
body.compact .caption { position: fixed; left: 8px; right: 8px; bottom: calc(var(--below, 120px) + 76px); z-index: 11; padding: 8px 10px 10px 12px; }
body.compact .caption p { font-size: 14.5px; }
body.compact.sheet .caption { top: var(--cap-top, 8px); bottom: auto; }
body.compact.playing .status { display: none; }
body.compact .readout { right: 8px; top: 8px; justify-content: flex-start; }
body.compact .rail { width: auto; border-left: 0; }
body.compact .rail > .card > .pnl-h { display: none; }
body.compact .rail .card[hidden] { display: block !important; }
body.compact .rail .card.code[hidden], body.compact .rail .card.trycard[hidden] { display: none !important; }
body.compact .main { display: block; height: 100%; }
body.compact .stage { position: fixed; inset: 0; border: 0; border-radius: 0; }
body.compact .readout { left: 8px; top: 8px; right: 8px; gap: 6px; flex-wrap: nowrap; overflow: hidden; }
body.compact .gauge { min-width: 0; padding: 4px 8px; border-radius: 9px; }
body.compact .gauge .lbl { font-size: 9px; letter-spacing: .12em; }
body.compact .gauge .val { font-size: 13px; }
body.compact .gauge canvas { width: 92px; height: 20px; }
body.compact .status { top: var(--status-top, 66px); bottom: auto; left: 8px; right: 8px; width: auto; transform: none; padding: 5px 6px 5px 10px; gap: 8px; }
body.compact .status p { font-size: 12px; line-height: 1.3; }
body.compact .status button { padding: 7px 9px; min-height: 34px; }
body.compact .ptag span { font-size: 10px; padding: 2px 7px; }
body.compact .pop { z-index: 12; }
body.compact .fly { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; height: var(--pnl-h, 46dvh); border-radius: 18px 18px 0 0; border: 0; border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0,0,0,.12); z-index: 9; padding-bottom: env(safe-area-inset-bottom, 0px); }
body.compact .fly .x, body.compact .pnl-x { display: block; }
/* the control bar: Run, then the panels as tabs */
body.compact .dock { display: flex; position: fixed; left: 8px; right: 8px; bottom: calc(var(--below, 120px) + 8px); transform: none; max-width: none; z-index: 11; gap: 2px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 24px rgba(10,20,20,.16); justify-content: space-between; }
body.compact .dock button { flex: 1 1 0; min-width: 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 48px; padding: 0 2px; border: 0; background: none; border-radius: 12px; font-family: var(--font-display); font-weight: 700; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); cursor: pointer; }
body.compact .dock button svg { width: 19px; height: 19px; flex: none; }
body.compact .dock button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
body.compact .dock .playb { flex: 0 0 auto; flex-direction: row; gap: 6px; padding: 0 12px; font-size: 12px; margin-right: 2px; background: var(--accent); color: var(--accent-ink); }
body.compact .dock .playb.on { background: var(--ink); color: var(--bg); }
body.compact .dock .runb { flex: 0 0 auto; flex-direction: row; gap: 6px; padding: 0 12px; font-size: 12px; background: none; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); margin-right: 2px; }
body.compact .dock .runb svg { width: 14px; height: 14px; }
body.compact .dock .runb.stop { background: none; color: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger); }
.vgrid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)) !important; gap: 6px !important; padding: 10px 12px !important; }
.vgrid button { display: grid; justify-items: center; gap: 4px; padding: 10px 4px; min-height: 64px; border: 1px solid var(--line); border-radius: 12px; background: var(--code-bg); cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.vgrid button svg { width: 20px; height: 20px; }
.vgrid button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
/* the sheet: the lesson card, peeking, open or tucked away */
body.compact .rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 68dvh; background: var(--sheet-bg); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.12); z-index: 10; overflow: hidden; display: block; padding: 0 0 calc(10px + env(safe-area-inset-bottom, 0px)); transform: translateY(calc(100% - var(--peek, 120px))); transition: transform .3s cubic-bezier(.2,.8,.2,1); overscroll-behavior: contain; }
body.compact .rail.open { transform: none; overflow-y: auto; touch-action: pan-y; }
body.compact .rail .card { border: 0; border-radius: 0; background: none; }
body.compact .rail .code, body.compact .rail .trycard { display: none; }
body.compact .sheet-top { display: flex; justify-content: center; position: sticky; top: 0; z-index: 3; padding: 8px 0 4px; background: var(--sheet-bg); touch-action: none; }
body.compact .sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px 0; }
body.compact .sheet-x { position: absolute; right: 10px; top: 4px; display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 11px 4px 8px; font: 600 12px var(--font-body); color: var(--ink); cursor: pointer; min-height: 30px; }
body.compact .sheet-x svg { width: 14px; height: 14px; transform: rotate(180deg); transition: transform .25s; }
body.compact .rail.open .sheet-x svg { transform: none; }
body.compact .sheet-tk { position: absolute; left: 10px; top: 4px; display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 4px 10px 4px 7px; font: 600 12px var(--font-body); color: var(--muted); cursor: pointer; min-height: 30px; }
body.compact .sheet-tk svg { width: 14px; height: 14px; }
body.compact .rail.open .sheet-tk, body.compact .rail.tuck .sheet-tk { display: none; }
body.compact .rail .tabs { padding: 0 10px; }
body.compact .rail .tabpanel { padding: 12px 18px 16px; }
body.compact .rail .tabpanel h2 { font-size: 19px; }
body.compact .rail:not(.open) .tabs { display: none; }
body.compact .rail:not(.open) .tabpanel[data-panel="overview"] > :not(h2):not(p.lead) { display: none; }
body.compact .rail:not(.open) .tabpanel[data-panel="overview"] p.lead { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
body.compact .rail:not(.open) .tabpanel:not([data-panel="overview"]) { display: none; }
body.compact .rail:not(.open) .tabpanel[data-panel="overview"] { display: block !important; padding-top: 2px; }
body.compact .rail.tuck .tabpanel { visibility: hidden; }
/* a panel open in the sheet's place: Code, Try it, Parts, Tools, Lessons, Settings */
body.compact.panel .rail { transform: translateY(100%); pointer-events: none; }
#pnls { display: contents; }
body.compact .pnl { position: fixed; left: 0; right: 0; bottom: 0; height: var(--pnl-h, 46dvh); background: var(--panel); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.12); z-index: 9; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); }
body.compact .pnl .pnl-h { display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px 16px; font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
body.compact .pnl.code { min-height: 0; flex: none; }
body.compact .pnl.code .code-head { display: none; }
body.compact .pnl.code .ed-scroll { flex: 1; min-height: 80px; max-height: none; }
body.compact .pnl.code .serial-log { height: 72px; }
body.compact .pnl.trycard { overflow-y: auto; }
body.compact .pnl.trycard .try h3 { display: none; }

/* landscape phones: the bench on the left, the sheet as a column on the right */
body.land .stage { right: var(--col-w, 330px); }
body.land .rail, body.land .pnl, body.land .fly { left: auto; right: 0; top: 0; bottom: 0; width: var(--col-w, 330px); height: auto; max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--line); box-shadow: none; transform: none; }
body.land .rail { overflow-y: auto; }
body.land .rail .sheet-top { display: none; }
body.land .rail:not(.open) .tabs { display: flex; }
body.land .rail:not(.open) .tabpanel[data-panel="overview"] > * { display: revert; }
body.land .rail:not(.open) .tabpanel[data-panel="overview"] p.lead { -webkit-line-clamp: unset; display: block; }
body.land.panel .rail { transform: none; visibility: hidden; }
body.land .dock { left: 8px; right: calc(var(--col-w, 330px) + 8px); bottom: 8px; }
body.land .dock button { height: 44px; }
/* phones: the sliders stay compact so the code still shows */
body.compact .knobs { gap: 0; margin-bottom: 6px; }
body.compact .knob { grid-template-columns: 84px minmax(0, 1fr) 70px; gap: 8px; }
body.compact .knob .kn small { display: none; }
body.compact .code-help:not(.warn) { display: none; }
