/* Logic Studio (build/tools/logic-studio.mjs): the parts down the left,
   the board, and the chips panel on the right. */

.ls-work { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.ls-topline { display: flex; align-items: center; gap: 10px; min-height: 41px; padding-right: 8px; }
.ls-menubar { flex: 0 1 auto; min-width: 0; border-bottom: 0; }
.ls-name { flex: 1 1 auto; min-width: 60px; max-width: 360px; margin: 0 auto; padding: 5px 10px; color: var(--text); background: none; border: 1px solid transparent; border-radius: 0; font: inherit; font-weight: 600; text-align: center; text-overflow: ellipsis; }
.ls-name:hover { border-color: var(--border); }
.ls-name:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.ls-top-btns { display: flex; align-items: center; gap: 2px; }
.ls-top-btns .st-ib:disabled { opacity: 0.35; cursor: default; }
.st-ib[aria-pressed="true"] { color: var(--text); background: var(--tint); }
.ls-save { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }

.ls-body { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; min-height: 0; }
.ls-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg-deep); }
.ls-board { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.ls-stage.is-placing .ls-board { cursor: copy; }
.ls-msg { position: absolute; left: 12px; bottom: 10px; max-width: calc(100% - 24px); margin: 0; color: var(--muted); font-size: 12px; pointer-events: none; }
.ls-editing { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); margin: 0; padding: 4px 12px; color: var(--edge); background: var(--gold); font-size: 12px; font-weight: 700; pointer-events: none; }

.ls-dot { fill: rgba(255, 255, 255, 0.09); }
/* Pixel art: square ends, hard edges, 1 green and 0 blue (docs/STYLEGUIDE.md, Pixels). */
.ls-board { --ls-0: #3b5b9e; --ls-1: #3fb950; }
.ls-board :is(path, rect) { shape-rendering: crispEdges; }
.ls-bg { cursor: grab; }
.ls-stage.is-panning .ls-board, .ls-stage.is-panning .ls-bg { cursor: grabbing; }
.ls-wire { cursor: pointer; }
.ls-wire-hit { fill: none; stroke: transparent; stroke-width: 14; }
.ls-wire-line { fill: none; stroke: var(--ls-0); stroke-width: 4; stroke-linecap: square; stroke-linejoin: miter; transition: stroke 90ms ease, stroke-width 120ms ease; }
.ls-wire:hover .ls-wire-line { stroke-width: 6; }
.ls-wire.is-on .ls-wire-line { stroke: var(--ls-1); }
.ls-wire.is-selected .ls-wire-line { stroke-width: 6; filter: drop-shadow(2px 0 0 var(--gold)) drop-shadow(-2px 0 0 var(--gold)) drop-shadow(0 2px 0 var(--gold)) drop-shadow(0 -2px 0 var(--gold)); }
.ls-wire-dot { fill: var(--ls-0); }
.ls-wire.is-on .ls-wire-dot { fill: var(--ls-1); }
.ls-stage.is-moving .ls-wire-dot { display: none; }
/* With parts or a wire selected, their wires stand out and the rest fade. */
.has-focus .ls-wire:not(.is-lit) { opacity: 0.14; }
.ls-wire.is-lit .ls-wire-line { stroke-width: 6; }
.ls-drag-wire { stroke: var(--gold); stroke-dasharray: 6 5; pointer-events: none; transition: none; animation: ls-march 600ms linear infinite; }
.ls-drag-wire.is-snapped { stroke-dasharray: none; stroke-width: 4; animation: none; }
@keyframes ls-march { to { stroke-dashoffset: -22; } }
.ls-box { fill: rgba(139, 92, 246, 0.12); stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; pointer-events: none; }

.ls-part { cursor: grab; }
.ls-stage.is-moving, .ls-stage.is-moving .ls-part { cursor: grabbing; }
.ls-sel-ring { fill: none; stroke: none; }
.ls-part.is-selected .ls-sel-ring { stroke: var(--gold); stroke-width: 4; stroke-dasharray: 4 4; }
.ls-chip-box { stroke: #0d0b14; stroke-width: 4; paint-order: stroke; transition: filter 140ms ease; }
.ls-part.is-dragging { pointer-events: none; }
.ls-chip-box.is-gate { stroke: none; }
.ls-chip-cap { fill: rgba(255, 255, 255, 0.28); pointer-events: none; }
.ls-gate { fill: #f2efe6; stroke: #0d0b14; stroke-width: 4; paint-order: stroke; pointer-events: none; }
.ls-part.is-selected .ls-gate { stroke: var(--gold); }
.ls-chip-label.ls-gate-label { fill: var(--muted); font-size: 11px; }
.ls-part:has(.is-gate) .ls-pin-name { fill: #1a1626; }
path:is(.ls-lamp, .ls-light) { stroke: none; }
.ls-part.is-dragging .ls-chip-box, .ls-part.is-dragging .ls-gate, .ls-part.is-dragging :is(.ls-toggle, .ls-lamp) { filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.55)); }
.ls-part.is-new > :not(.ls-face) { animation: ls-pop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.3); transform-box: fill-box; transform-origin: center; }
@keyframes ls-pop { from { opacity: 0.4; transform: scale(0.85); } }
.ls-chip-label { fill: #fff; font: 700 13px var(--body); letter-spacing: 0.02em; pointer-events: none; }
.ls-pin-name { fill: rgba(255, 255, 255, 0.82); font: 600 10px var(--body); pointer-events: none; }
.ls-label { fill: var(--muted); font: 600 13px var(--body); pointer-events: none; }
.ls-pin { fill: #2a2540; stroke: #8b84a8; stroke-width: 2; cursor: crosshair; transition: stroke 120ms ease, fill 90ms ease; }
.ls-pin.is-on { fill: var(--ls-1); stroke: #b7f0c0; }
.ls-pin:hover { stroke: var(--gold); stroke-width: 4; }
/* While wiring, the pins the wire can join stand out, and the one it will join grows. */
.ls-stage.is-wiring-out .ls-pin[data-pin^="in:"], .ls-stage.is-wiring-in .ls-pin[data-pin^="out:"] { stroke: var(--gold); }
.ls-pin.is-target { stroke: var(--gold); stroke-width: 6; fill: var(--gold); }
.ls-toggle { fill: #c9c4d6; stroke: #2a2540; stroke-width: 4; paint-order: stroke; cursor: pointer; transition: fill 90ms ease, stroke 90ms ease; }
.ls-toggle:hover { stroke: var(--gold); }
.ls-toggle.is-on { fill: var(--ls-1); stroke: #2a2540; }
.ls-lamp { fill: color-mix(in srgb, var(--on, #ff5a5f) 22%, #0d0b14); stroke: #0d0b14; stroke-width: 2; transition: fill 90ms ease, filter 90ms ease; }
.ls-lamp.is-on { fill: var(--on, #ff5a5f); stroke: #ffb3b5; filter: drop-shadow(0 0 6px rgba(255, 90, 95, 0.8)); }
.ls-ghost { opacity: 0.45; pointer-events: none; }
body.ls-carrying, body.ls-carrying * { cursor: grabbing !important; }

.ls-side { position: relative; display: none; flex-direction: column; gap: 18px; width: 290px; padding: 14px 14px 20px; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--border); }
.ls-work.is-side-open .ls-side { display: flex; }
.ls-side-x { display: none; position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; place-items: center; padding: 0; color: var(--muted); background: none; border: 0; cursor: pointer; }
.ls-sec { display: flex; flex-direction: column; gap: 8px; }
.ls-sec[hidden] { display: none; }
.ls-sec-title { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.ls-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.ls-chip-row { display: flex; gap: 6px; }
.ls-chip-name { flex: 1; min-width: 0; padding: 8px 10px; font-size: 13px; }
.ls-chip-color { flex: none; width: 40px; height: auto; padding: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; cursor: pointer; }
.ls-chip-btns { display: flex; flex-wrap: wrap; gap: 6px; }
#ls-sel { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
#ls-sel .st-field { width: 100%; }
#ls-sel .input { padding: 8px 10px; font-size: 13px; }

.ls-tt { max-height: 340px; overflow: auto; border: 1px solid var(--border); }
.ls-tt:has(.ls-hint) { max-height: none; border: 0; }
.ls-table { width: 100%; border-collapse: collapse; font: 12px var(--mono); text-align: center; }
.ls-table th { position: sticky; top: 0; padding: 4px 6px; color: var(--text); background: var(--surface-2); font: 600 11px var(--body); white-space: nowrap; }
.ls-table th.is-in { color: var(--muted); }
.ls-table td { padding: 2px 6px; color: var(--muted); border-top: 1px solid var(--border); }
.ls-table td.is-one { color: #ff7a7e; font-weight: 700; }
.ls-table tr.is-now td { background: var(--tint); }

.ls-chips { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ls-chip-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; background: var(--surface-2); border: 1px solid var(--border); }
.ls-chip-dot { flex: none; width: 14px; height: 14px; border: 1px solid rgba(0, 0, 0, 0.4); }
.ls-chip-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12px; }
.ls-chip-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-chip-text small { color: var(--faint); }
.ls-chip-item .btn-small { padding: 4px 8px; font-size: 11px; }

/* The parts: groups on a rail, every part on the shelf beside it. */
.ls-palette { display: grid; grid-template-columns: 66px 200px; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }
.ls-rail { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; overflow-y: auto; border-right: 1px solid var(--border); }
.ls-rail-btn { --cat: #888; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 2px; color: var(--muted); background: none; border: 0; font: 600 10px/1.1 var(--body); cursor: pointer; }
.ls-rail-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--cat); border: 2px solid rgba(0, 0, 0, 0.35); transition: transform 120ms ease; }
.ls-rail-btn:hover, .ls-rail-btn.is-on { color: var(--text); }
.ls-rail-btn.is-on .ls-rail-dot { transform: scale(1.15); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--cat); }
.ls-rail-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ls-shelf { display: flex; flex-direction: column; min-height: 0; }
.ls-find { margin: 8px 8px 2px; padding: 6px 8px; font-size: 12px; }
.ls-bar { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 16px; }
.ls-bar-sec { --cat: #888; }
.ls-bar-head { margin: 12px 2px 6px; color: var(--cat); font: 700 0.68rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.ls-bar-items { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ls-bar-items .ls-hint { grid-column: 1 / -1; margin: 0; }
.ls-bar-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 6px 4px 7px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-top: 3px solid var(--cat); border-radius: 0; font: 600 11px/1.2 var(--body); cursor: grab; touch-action: pan-y; transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease; }
.ls-bar-pic { width: 100%; height: 44px; pointer-events: none; }
.ls-bar-pic * { pointer-events: none; animation: none; }
.ls-bar-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-bar-btn:hover { background: var(--tint); transform: translateY(-2px); }
.ls-bar-btn.is-active { box-shadow: 0 0 0 2px var(--gold); transform: translateY(-2px); }
.ls-bar-btn.is-lifted { opacity: 0.55; transform: translateY(-4px); }
.ls-bar-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

@media (max-width: 760px) {
  .ls-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .ls-palette { grid-row: 2; grid-template-columns: minmax(0, 1fr); border-right: 0; border-top: 1px solid var(--border); }
  .ls-rail { flex-direction: row; padding: 4px 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .ls-rail-btn { flex: none; flex-direction: row; gap: 6px; padding: 4px 8px; }
  .ls-rail-dot { width: 14px; height: 14px; }
  .ls-find { display: none; }
  .ls-bar { display: flex; gap: 12px; padding: 6px 8px 8px; overflow-x: auto; overflow-y: hidden; }
  .ls-bar-sec { flex: none; }
  .ls-bar-head { margin: 0 0 4px; }
  .ls-bar-items { display: flex; }
  .ls-bar-btn { width: 78px; touch-action: pan-x; }
}

@media (max-width: 899px) {
  .ls-side { position: absolute; inset: 0 0 0 auto; z-index: 3; width: min(320px, 92vw); box-shadow: var(--shadow); }
  .ls-side-x { display: grid; }
  .ls-name { display: none; }
}
@media (max-width: 560px) {
  .ls-save span { display: none; }
  .ls-top-btns { margin-left: auto; }
}

/* The other inputs and displays. */
.ls-button { fill: #3a3354; stroke: #8b84a8; stroke-width: 2; cursor: pointer; transition: fill 60ms ease, transform 60ms ease; transform-box: fill-box; transform-origin: center; }
.ls-button:hover { stroke: var(--gold); }
.ls-button.is-on { fill: #ff5a5f; stroke: #ffb3b5; transform: scale(0.92); }
.ls-clock { fill: #2a2540; stroke: #8b84a8; stroke-width: 2; transition: fill 60ms ease; }
.ls-clock.is-on { fill: #ff5a5f; stroke: #ffb3b5; }
.ls-clock-wave { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; pointer-events: none; }
.ls-one { fill: #ff5a5f; stroke: #ffb3b5; stroke-width: 2; }
.ls-one-text { fill: #fff; font: 800 16px var(--mono); pointer-events: none; }
.ls-io-box { fill: #2a2540; stroke: #5d5778; stroke-width: 1.5; }
.ls-io-box[data-number] { cursor: pointer; }
.ls-io-box[data-number]:hover { stroke: var(--gold); }
.ls-screen { fill: #120f1d; }
.ls-io-value { fill: #fff; font: 700 22px var(--mono); pointer-events: none; }
.ls-screen-text { fill: var(--on, #ff7a7e); }
.ls-io-note { fill: var(--muted); font: 600 9px var(--body); pointer-events: none; }
.ls-io-pin { fill: var(--muted); }
.ls-seg { fill: #2c1d26; transition: fill 60ms ease; }
.ls-seg.is-on { fill: var(--on, #ff5a5f); filter: drop-shadow(0 0 3px rgba(255, 90, 95, 0.7)); }
.ls-graph-lane { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.ls-graph-line { fill: none; stroke: var(--on, #ff5a5f); stroke-width: 2; stroke-linejoin: round; pointer-events: none; }

.ls-mark { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.ls-switch { fill: #3a3354; stroke: #8b84a8; stroke-width: 1.5; cursor: pointer; transition: fill 80ms ease; }
.ls-switch.is-on { fill: #ff5a5f; stroke: #ffb3b5; }
.ls-switch:hover { stroke: var(--gold); }
.ls-switch-knob { fill: #fff; pointer-events: none; transition: transform 100ms ease; }
.ls-switch-knob.is-on { transform: translateX(14px); }
.ls-die { fill: #fff; stroke: #8b84a8; stroke-width: 1.5; }
.ls-die-dot { fill: #2a2540; }
.ls-led { stroke-width: 1.5; }
.ls-rgb { fill: #1e1e1e; stroke: #5d5778; stroke-width: 2; }
.ls-term { fill: var(--on, #ff7a7e); font: 500 13px var(--mono); white-space: pre; pointer-events: none; }
.ls-suggest { margin: 0; padding: 7px 9px; color: var(--text); font-size: 12px; line-height: 1.4; background: var(--tint); border: 1px solid var(--tint-border); }
.ls-suggest[hidden] { display: none; }
.ls-suggest-use { margin-left: 2px; padding: 0; color: var(--gold); background: none; border: 0; font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.ls-suggest-use[hidden] { display: none; }
.ls-key { fill: #fff; font: 700 12px var(--body); pointer-events: none; }
.ls-key.is-long { font-size: 7.5px; }
.ls-label-part { fill: var(--text, #e8e4f4); font-weight: 700; font-family: var(--body); }
.ls-face .ls-io-box { stroke: rgba(0, 0, 0, 0.35); }
.ls-face [data-press] { cursor: pointer; }
/* Dragged off the board, parts are deleted when let go (as blocks are in the Python editor). */
.ls-palette { position: relative; }
.ls-palette.is-trash::after { content: "Drop here to delete"; position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 16px; color: #fff; font: 700 13px var(--body); text-align: center; background: rgba(224, 96, 90, 0.82); border: 2px dashed #ffb3b5; pointer-events: none; }
.ls-part.is-doomed { opacity: 0.45; }
.ls-stage.is-trash, .ls-stage.is-trash .ls-part { cursor: no-drop; }
.ls-zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 2px; padding: 2px; background: var(--surface); border: 1px solid var(--border); }
.ls-top-btns #ls-delete:not(:disabled):hover { color: #ff7a7e; }
.st-menu-keys:empty { display: none; }
/* The starting parts: Lights mix where they overlap, the Pointer pad, and bus wires. */
.ls-light { fill: #2c1d26; stroke: rgba(255, 255, 255, 0.12); stroke-width: 1; transition: fill 60ms ease; }
.ls-light.ls-mix { mix-blend-mode: screen; }
.ls-light.is-on { fill: var(--on, #ff5a5f); filter: drop-shadow(0 0 4px var(--on, #ff5a5f)); }
.ls-pad { fill: #120f1d; stroke: #5d5778; stroke-width: 1.5; cursor: crosshair; }
.ls-pad.is-clear { fill: transparent; stroke: rgba(255, 255, 255, 0.18); }
/* Lights on a face let the pointer through, to a see-through Pointer pad laid over them. */
.ls-face .ls-light { pointer-events: none; }
/* Hidden when off: a dashed outline on the board, nothing on a chip's face. */
.ls-light.is-hidden:not(.is-on) { fill: none; stroke: rgba(255, 255, 255, 0.25); stroke-dasharray: 3 3; }
.ls-face-item > .ls-light.is-hidden:not(.is-on) { stroke: none; }
.ls-label-part.is-hide:not(.is-on) { opacity: 0.25; }
.ls-face-item > .ls-label-part.is-hide:not(.is-on) { opacity: 0; }
.ls-label-part.is-dim:not(.is-on) { opacity: 0.25; }
.ls-keys { display: flex; flex-wrap: wrap; gap: 4px; }
.ls-face.is-many .ls-light.is-on { filter: none; }
.ls-pad-dot { fill: #8b84a8; pointer-events: none; }
.ls-pad-dot.is-on { fill: #ff5a5f; }
.ls-bus .ls-wire-line { stroke-width: 6; }
.ls-bus-bar { fill: #3bb4c9; stroke: rgba(0, 0, 0, 0.4); stroke-width: 1.5; }
.ls-px-box { pointer-events: none; }
.ls-px-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.ls-menu-head { margin: 6px 10px 2px; color: var(--accent-strong); font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; }
