/* Circuit Lab. Tokens, the top bar (.gn/.sn) and shared blocks come from benchtop/css/frame.css (homepage look, 2026-10-17);
   buttons, inputs, tables and tags start from benchtop/css/app.css (physics: black and white) and are restyled at the end of this file. */
:root { --cl-board: #ffffff; --cl-cable: #3a4048; --cl-shine: rgba(255, 255, 255, .35); --cl-dot: #f5a400; --cl-hot: #ff3b30; --cl-fit: #ff8a00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --cl-board: #050505; --cl-cable: #a7afba; --cl-shine: rgba(255, 255, 255, .45); --cl-dot: #ffcc33; } }
:root[data-theme="dark"] { --cl-board: #050505; --cl-cable: #a7afba; --cl-shine: rgba(255, 255, 255, .45); --cl-dot: #ffcc33; }

body.cl-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

.cl-main { flex: 1; width: 100%; padding: 14px max(14px, env(safe-area-inset-right, 0px)) 24px max(14px, env(safe-area-inset-left, 0px)); }
.cl-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr) 330px; gap: 14px; align-items: start; }

/* left: toolbox and experiment list */
.cl-left { position: sticky; top: 64px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; padding: 10px; }
.cl-tabs { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.cl-tabs button { flex: 1; border: 0; background: none; padding: 7px 6px; border-radius: 7px; font-weight: 600; font-size: 14px; color: var(--muted); }
.cl-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.cl-leftbody { overflow-y: auto; overscroll-behavior: contain; padding: 0 2px 6px; }
.cl-tip { margin: 2px 0 6px; font-size: 13px; }
.cl-gh { margin: 12px 0 6px; font: 600 11.5px/1.2 var(--font-body); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.cl-pal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cl-pal { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 12px; font-weight: 500; line-height: 1.15; text-align: center; cursor: grab; }
.cl-pal svg { width: 64px; height: 40px; color: var(--ink); }
.cl-pal:hover { border-color: var(--accent); background: var(--surface); }
.cl-explink { display: flex; gap: 9px; width: 100%; text-align: left; padding: 9px 8px; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--ink); font: inherit; }
.cl-explink:hover { background: var(--surface-2); }
.cl-explink.on { border-color: var(--accent); background: var(--accent-soft); }
.cl-exp-n { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); font: 700 11px/1 var(--font-mono); color: var(--muted); margin-top: 1px; }
.cl-exp-b { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.cl-exp-b .note { font-size: 12.5px; }
.cl-exp-b .lvl-tag { align-self: flex-start; }

/* centre: toolbar and board */
.cl-center { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cl-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.cl-tbg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.cl-tb { display: inline-flex; align-items: center; gap: 5px; min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: var(--ink); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cl-tb svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cl-tb:hover:not([disabled]) { background: var(--surface-2); }
.cl-tb[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.cl-tb[disabled] { opacity: .35; }
.cl-tb.done { background: var(--accent-soft); }
.cl-viewmenu { position: relative; display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.cl-viewmenu > summary { list-style: none; cursor: pointer; }
.cl-viewmenu > summary::-webkit-details-marker { display: none; }
.cl-viewmenu[open] > summary { background: var(--surface-2); }
.cl-menu { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-width: 210px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 28px rgba(0, 0, 0, .3); }
.cl-menu .cl-tb { justify-content: flex-start; }
.cl-boardwrap { position: relative; height: max(460px, calc(100vh - 150px)); border: 1px solid var(--line); border-radius: 14px; background: var(--cl-board); overflow: hidden; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 4%, transparent); }
.cl-board { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
.cl-board.wiring { cursor: crosshair; }
.cl-griddot { fill: var(--line-strong); opacity: .55; }
.cl-griddot.big { opacity: .9; }
.cl-warn { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--warn); color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.4; }
.cl-warn[hidden] { display: none; }
.cl-warn.hint { border-color: var(--line); font-weight: 500; }
.cl-warn.bad { background: #d70015; border-color: #d70015; color: #fff; animation: cl-pulse 1s ease-in-out infinite; }
@keyframes cl-pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 59, 48, .25); } }

/* wires */
.cl-wire .hit { stroke: transparent; stroke-width: 16; stroke-linecap: round; }
.cl-wire .cable { stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.cl-wire.real .cable { stroke: var(--cl-cable); stroke-width: 5.2; }
.cl-wire.real .shine { stroke: var(--cl-shine); stroke-width: 1.3; stroke-linecap: round; transform: translate(-0.8px, -0.8px); pointer-events: none; }
.cl-wire:hover .cable { stroke: var(--accent); }
.cl-wire.sel .cable { stroke: var(--cl-dot); }
.cl-wire.short .cable { stroke: var(--cl-hot); animation: cl-flick .18s steps(2) infinite; }
@keyframes cl-flick { 50% { opacity: .55; } }
/* current dots */
.cl-dots line { stroke: var(--cl-dot); stroke-width: 4.4; stroke-linecap: round; stroke-dasharray: 0.1 16; animation: cl-flow 1s linear infinite; filter: drop-shadow(0 0 2.5px var(--cl-dot)); pointer-events: none; }
.cl-board.symbol .cl-dots line { stroke-width: 3.6; }
.cl-dots line.hot { stroke: var(--cl-hot); filter: drop-shadow(0 0 4px var(--cl-hot)); }
@keyframes cl-flow { to { stroke-dashoffset: -16.1; } }
@media (prefers-reduced-motion: reduce) { .cl-dots line { animation: none; } }
/* parts, terminals, junctions */
.cl-part { color: var(--ink); cursor: grab; }
.cl-part:active { cursor: grabbing; }
.cl-part .hit { fill: transparent; }
.cl-part:hover .hit { fill: color-mix(in oklab, var(--ink) 5%, transparent); }
.cl-part.sel .hit { fill: color-mix(in oklab, var(--cl-dot) 10%, transparent); stroke: var(--cl-dot); stroke-width: 1.4; stroke-dasharray: 4 4; }
.cl-part.short { filter: drop-shadow(0 0 6px var(--cl-hot)); }
.cl-part.risk { filter: drop-shadow(0 0 5px rgba(255, 40, 40, .85)); }
.cl-risk rect { fill: #d70015; stroke: #fff; stroke-width: 1.5; }
.cl-label .cl-risk text { fill: #fff; stroke: none; text-anchor: middle; font: 700 12px/1 var(--font-body); letter-spacing: .01em; }
.cl-warn-h { font-size: 15px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.cl-part.oppose .hit { stroke: var(--warn); stroke-width: 1.6; stroke-dasharray: 3 3; fill: color-mix(in oklab, var(--warn) 10%, transparent); }
.cl-junc { fill: var(--ink); }
.cl-tdot { fill: var(--ink); }
.cl-open { fill: var(--cl-board); stroke: var(--muted); stroke-width: 1.6; }
.cl-open.term { stroke: var(--cl-dot); stroke-width: 2; }
.cl-pt { fill: transparent; cursor: crosshair; }
.cl-pt:hover { fill: color-mix(in oklab, var(--cl-dot) 28%, transparent); stroke: var(--cl-dot); stroke-width: 1.5; }
.cl-preview line { stroke: var(--cl-dot); stroke-width: 3; stroke-dasharray: 6 5; stroke-linecap: round; }
.cl-preview circle { fill: none; stroke: var(--cl-dot); stroke-width: 2; }
/* labels (always upright) */
.cl-label text { font: 700 12.5px/1 var(--font-body); fill: var(--ink); paint-order: stroke; stroke: var(--cl-board); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.cl-label.mid text { text-anchor: middle; }
.cl-label .val { font-weight: 500; fill: var(--muted); }
.cl-label .rd { font: 600 11.5px/1 var(--font-mono); fill: var(--cl-dot); }
:root:not([data-theme="dark"]) .cl-label .rd { fill: #b06d00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cl-label .rd { fill: var(--cl-dot); } }
.cl-nodev rect { fill: var(--surface); stroke: var(--line-strong); }
.cl-nodev text { font: 600 10.5px/1 var(--font-mono); fill: var(--ink); }
.cl-over { pointer-events: none; }

/* right: experiment and inspector */
.cl-right { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; overscroll-behavior: contain; }
.cl-right h2 { margin: 0 0 8px; font: 700 20px/1.2 var(--font-display); }
.cl-ih { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.cl-ih > svg { width: 64px; height: 40px; flex: none; color: var(--ink); }
.cl-ih h2 { margin: 0 0 6px; font-size: 18px; }
.cl-lab { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cl-lab input { width: 76px; padding: 4px 7px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); font: 600 13px var(--font-mono); color: var(--ink); }
.cl-ctls { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.cl-ctl { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; font-size: 13.5px; }
.cl-ctl > span:first-child { color: var(--muted); font-weight: 500; }
.cl-ctl.sl { grid-template-columns: 1fr auto; }
.cl-ctl.sl input[type="range"] { grid-column: 1 / -1; grid-row: 2; width: 100%; accent-color: var(--accent); }
.cl-ctl.sl output { font: 600 13px var(--font-mono); }
.cl-ctl select { padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 13.5px; }
.cl-ctl.tog input { width: 18px; height: 18px; accent-color: var(--accent); }
.cl-num { display: inline-flex; align-items: center; gap: 5px; }
.cl-num input { width: 96px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); font: 500 14px var(--font-mono); color: var(--ink); }
.cl-num i { font-style: normal; color: var(--muted); }
.cl-read { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.cl-rd { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.cl-rd span { color: var(--muted); }
.cl-rd b { font: 600 14px var(--font-mono); }
.cl-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cl-acts .btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cl-howto { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--muted); }
.cl-howto li { margin: 4px 0; }
.cl-exp { border-top: 3px solid var(--accent); }
.cl-exph { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cl-exph .btn { margin-left: auto; }
.cl-eyebrow { font: 700 11.5px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.cl-aim { margin: 0 0 8px; font-size: 14.5px; }
.cl-det { margin: 6px 0; font-size: 14px; }
.cl-det summary { cursor: pointer; font-weight: 600; }
.cl-det p { margin: 6px 0 0; color: var(--muted); }
.cl-steps { margin: 6px 0 0; padding-left: 20px; }
.cl-steps li { margin: 4px 0; }
.cl-vary { margin: 10px 0; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.cl-sugg { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.cl-livegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin: 8px 0; }
.cl-livegrid div { display: flex; flex-direction: column; gap: 2px; padding: 7px 9px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.cl-livegrid span { font-size: 12px; color: var(--muted); }
.cl-livegrid b { font: 600 15px var(--font-mono); }
.cl-recbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.cl-table { overflow-x: auto; }
.cl-table .table { font-size: 13px; }
.cl-gsvg { width: 100%; height: auto; display: block; }
.cl-gsvg .gl { stroke: var(--line); stroke-width: 1; }
.cl-gsvg .ax { stroke: var(--ink); stroke-width: 1.4; }
.cl-gsvg .tk { font: 500 9.5px var(--font-mono); fill: var(--muted); }
.cl-gsvg .al { font: 600 11px var(--font-body); fill: var(--ink); }
.cl-gsvg .fit { stroke: var(--cl-fit); stroke-width: 2; }
.cl-gsvg .pt path { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.cl-eq { margin: 4px 0 0; font-size: 13px; }
.cl-rebuild { margin-top: 8px; }

@media (max-width: 1260px) { .cl-layout { grid-template-columns: 210px minmax(0, 1fr) 290px; } .cl-tb.txt span { font-size: 12.5px; } }
@media (max-width: 1020px) {
  .cl-layout { grid-template-columns: 1fr; }
  .cl-center { order: 1; }
  .cl-left { order: 2; position: static; max-height: none; }
  .cl-right { order: 3; position: static; max-height: none; overflow: visible; }
  .cl-boardwrap { height: min(70vh, 640px); }
  .cl-pal-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .cl-leftbody { max-height: 360px; overscroll-behavior: auto; }
}
@media (max-width: 640px) {
  .cl-menu { left: auto; right: 0; max-width: calc(100vw - 28px); }
  .cl-main { padding-top: 10px; }
  .cl-boardwrap { height: 62vh; }
  .cl-tb.txt span { display: none; }
  .cl-tb.txt:not(:has(svg)) span { display: inline; }
}


/* ================= homepage-style restyle (2026-10-17) ================= */
/* top bar: Benchtop's .gn + .sn, with the grade / language / theme tools this page draws into #cl-tools */
.cl-page .gn-tools .seg { padding: 2px; }
.cl-page .gn-tools .seg button { padding: 3px 9px; font-size: 11.5px; font-weight: 600; }
.cl-pill { display: inline-grid; place-items: center; height: 26px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--seg-bg); color: var(--ink); font-size: 11.5px; font-weight: 600; -webkit-tap-highlight-color: transparent; }
.cl-pill.icon { width: 32px; height: 32px; padding: 0; background: none; }
.cl-pill.icon:hover { background: var(--seg-bg); }
.cl-pill svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tool-back { display: inline-flex; flex: none; align-items: center; gap: 4px; padding: 6px 13px 6px 8px; border-radius: 999px; background: var(--seg-bg); color: var(--ink); font-size: 13px; font-weight: 500; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.tool-back:hover { background: color-mix(in oklab, var(--seg-bg), var(--ink) 8%); }
.tool-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tool-back .short { display: none; }

/* page: grey tiles, pill controls, a rounded board */
.cl-main { padding-top: 16px; }
.cl-page .panel-card { padding: 16px; border-radius: 22px; }
.cl-left, .cl-right { top: calc(var(--snav) + 12px); max-height: calc(100vh - var(--snav) - 24px); }
.cl-tabs { gap: 0; padding: 3px; border: 0; border-radius: 999px; background: var(--seg-bg); margin-bottom: 10px; }
.cl-tabs button { border-radius: 999px; font-weight: 500; -webkit-tap-highlight-color: transparent; }
.cl-tabs button[aria-pressed="true"] { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.cl-gh { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; }
.cl-pal { border: 0; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px transparent; }
.cl-pal:hover { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent); }
.cl-explink { border: 0; border-radius: 14px; }
.cl-explink:hover { background: color-mix(in oklab, var(--surface-2), var(--ink) 5%); }
.cl-explink.on { border: 0; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent); }
.cl-exp-n { font: 600 11px/1 var(--font-body); background: var(--surface); }
.cl-tbg, .cl-viewmenu { padding: 3px; border: 0; border-radius: 999px; background: var(--seg-bg); }
.cl-tb { height: 30px; padding: 0 10px; border-radius: 999px; font-weight: 500; -webkit-tap-highlight-color: transparent; }
.cl-tb:hover:not([disabled]) { background: var(--seg-on); }
.cl-tb[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.cl-tb.done { background: var(--seg-on); box-shadow: inset 0 0 0 1.5px var(--accent); }
.cl-viewmenu[open] > summary { background: var(--seg-on); border-radius: 999px; }
.cl-menu { border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.cl-boardwrap { height: max(460px, calc(100vh - var(--snav) - 110px)); border: 0; border-radius: 22px; box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.cl-warn { border: 0; border-radius: 16px; background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--warn); }
.cl-warn.hint { box-shadow: none; }
.cl-warn.bad { background: #d70015; box-shadow: none; }
.cl-right h2 { font: 600 21px/1.2 var(--font-display); letter-spacing: -.01em; }
.cl-ih h2 { font-size: 18px; }
.cl-lab input, .cl-num input, .cl-ctl select { border: 0; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.cl-lab input:focus, .cl-num input:focus, .cl-ctl select:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.cl-read, .cl-livegrid div { border: 0; border-radius: 14px; background: var(--surface); }
.cl-exp { border-top: 0; }
.cl-eyebrow { font: 600 12px/1.2 var(--font-body); text-transform: none; letter-spacing: 0; }
.cl-vary { border: 0; border-radius: 16px; background: var(--surface); }
.cl-page .card .table { border-radius: 12px; }

@media (max-width: 1020px) {
  .cl-left, .cl-right { position: static; max-height: none; }
  .cl-boardwrap { height: min(70vh, 640px); }
}
@media (max-width: 734px) {
  .cl-page .gn-brand span { display: none; }
  .cl-page .gn-row { gap: 12px; }
  .cl-page .gn-tools { gap: 6px; }
  .cl-page .gn-tools .seg button { padding: 3px 7px; }
  .tool-back .long { display: none; }
  .tool-back .short { display: inline; }
  .cl-page .panel-card { padding: 14px 12px; border-radius: 20px; }
  .cl-boardwrap { height: 56vh; border-radius: 18px; } /* leaves room for the phone tab bar */
}
