/* Block Studio — Circuit Lab (component simulator). Uses the app's tokens (app.css :root). */
.circuit-view { position: absolute; inset: 0; display: none; z-index: 100; overflow: hidden; background: var(--bg); }
.app[data-panel="circuit"] .circuit-view { display: flex !important; }
.app[data-panel="circuit"] .right-panel, .app[data-panel="circuit"] #splitRight, .app[data-panel="circuit"] .side-panel,
.app[data-panel="circuit"] #splitLeft, .app[data-panel="circuit"] #dock, .app[data-panel="circuit"] #btnRevealRight,
.app[data-panel="circuit"] #tbUndoGroup { display: none !important; }

.cl { display: flex; flex-direction: column; width: 100%; height: 100%; min-width: 0; font-family: var(--font); color: var(--text); }
.cl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.cl-title { font-size: 15px; } .cl-badge { font: 600 11px/1 var(--mono); color: var(--text-2); background: var(--surface-3); border-radius: 999px; padding: 4px 8px; }
.cl-sp { flex: 1; } .cl-seg { display: inline-flex; gap: 4px; } .cl-l { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.cl-file { cursor: pointer; }
.cl-main { flex: 1; display: grid; grid-template-columns: 196px minmax(0, 1fr) 340px; min-height: 0; }

/* parts bin */
.cl-bin { border-right: 1px solid var(--border); background: var(--surface); overflow: auto; padding: 8px; }
.cl-bin .input { width: 100%; margin-bottom: 6px; }
.cl-bin h5 { margin: 10px 2px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cl-pb { display: flex; align-items: center; gap: 6px; width: 100%; border: 1px solid transparent; background: none; border-radius: var(--radius-sm); padding: 3px 4px; cursor: pointer; text-align: left; font-size: 12.5px; color: var(--text); }
.cl-pb:hover { background: var(--surface-3); } .cl-pb.on { border-color: var(--accent); background: var(--accent-50); }
.cl-icon { width: 46px; height: 32px; flex: none; color: var(--text-2); }
.cl-icon line, .cl-icon path, .cl-icon polyline, .cl-icon circle, .cl-icon rect { stroke: currentColor; }

/* sheet */
.cl-sheet { position: relative; min-width: 0; min-height: 0; outline: none; background: #FBFCFD; }
.cl-svg { width: 100%; height: 100%; display: block; color: #2A3139; touch-action: none; user-select: none; }
.gdot { fill: #C9D0D8; }
.cl-svg line, .cl-svg path, .cl-svg polyline { stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.cl-svg .th { stroke-width: 2.4; } .cl-svg .thick { stroke-width: 4; } .cl-svg .thin { stroke-width: 1.1; } .cl-svg .dash { stroke-dasharray: 3 3; stroke-width: 1.1; }
.cl-svg .body, .cl-icon .body { fill: #FFFFFF; stroke: currentColor; stroke-width: 1.6; }
.cl-svg .fill, .cl-icon .fill { fill: currentColor; stroke: none; } .cl-svg .nofill { fill: none; }
.cl-svg .res { fill: #E8D4B0; } .cl-svg .res.hot { fill: #FF8B6B; filter: drop-shadow(0 0 4px #FF4D2E); }
.cl-svg .t { font: 600 11px var(--mono); fill: currentColor; stroke: none; } .cl-svg .t.sm { font-size: 10px; } .cl-svg .t.xs { font-size: 8.5px; font-weight: 600; }
.cl-svg .t.c { text-anchor: middle; } .cl-svg .t.r { text-anchor: end; } .cl-svg .t.b { font-weight: 800; font-size: 13px; }
.cl-icon .t { font: 600 11px var(--mono); fill: currentColor; stroke: none; } .cl-icon .t.c { text-anchor: middle; } .cl-icon .t.r { text-anchor: end; } .cl-icon .t.xs { font-size: 8px; }
.cl-icon .bp { fill: #1F7A4D; stroke: none; } .cl-icon .lcd { fill: #DDEBD2; } .cl-icon .glow { display: none; } .cl-icon .state { fill: #CBD2D9; }
.cl-icon .hit, .cl-svg .hit { fill: transparent; stroke: none; }
.cl-svg .glow { stroke: none; filter: blur(6px); transition: opacity .08s; }
.cl-svg .cap { fill: #E5484D; stroke: currentColor; }
.cl-svg .state { fill: #CBD2D9; stroke: currentColor; stroke-width: 1; } .cl-svg .state.on { fill: #22C55E; filter: drop-shadow(0 0 3px #22C55E); }
.cl-svg .lcd { fill: #DDEBD2; stroke: #5C6B52; stroke-width: 1; } .cl-svg .lcdt { font: 700 11px var(--mono); fill: #1D2A17; }
.cl-svg .prop { fill: #8A96A3; }
.cl-svg .bp { fill: #1F7A4D; stroke: #145A38; stroke-width: 1.2; } .cl-svg .bp.pwr { fill: #B8332A; stroke: #7E1F18; } .cl-svg .bp.gnd { fill: #3A4148; stroke: #22272C; }
.cl-svg .bp.out { fill: #2A9C63; } .cl-svg .bp.out.hi { fill: #3CD38B; filter: drop-shadow(0 0 4px #3CD38B); }
.cl-svg [data-live="buzz"].on { fill: #FFD84A; }
.cl-svg .sun { stroke: #E0A100; }
.cl-p { cursor: move; } .cl-p.clickable { cursor: pointer; }
.cl-box { fill: transparent; stroke: none; rx: 6; }
.cl-p:hover .cl-box { fill: rgba(62, 155, 224, .06); stroke: rgba(62, 155, 224, .35); stroke-dasharray: 4 3; }
.cl-p.sel .cl-box { fill: rgba(243, 122, 51, .07); stroke: var(--accent); stroke-dasharray: none; stroke-width: 1.4; }
.cl-pin { fill: #FFFFFF; stroke: #59626B; stroke-width: 1.2; cursor: crosshair; opacity: .0; transition: opacity .1s; }
.cl-p:hover .cl-pin, .cl-p.sel .cl-pin { opacity: 1; } .cl-pin:hover { fill: var(--accent); stroke: var(--accent); }
.cl-w { stroke-width: 3; stroke: #7C8794; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.cl-w.sel { stroke-width: 4.5; filter: drop-shadow(0 0 3px rgba(243, 122, 51, .8)); }
.cl-wh { stroke: transparent !important; stroke-width: 12 !important; cursor: pointer; }
.cl-dot { fill: #2A3139; }
.cl-wp { stroke: var(--accent) !important; stroke-width: 2.4 !important; stroke-dasharray: 6 4; }
.cl-wpd { fill: var(--accent); stroke: none; }
[data-over] { pointer-events: none; }
.cl-ghost { opacity: .45; pointer-events: none; }
.cl-lbl { font: 700 11px var(--mono); fill: #4A515B; text-anchor: middle; pointer-events: none; } .cl-lbl.bpl { fill: #FFFFFF; font-size: 10.5px; }
.cl-rd { font: 600 10.5px var(--mono); fill: #2E6FB0; text-anchor: middle; pointer-events: none; }
.cl-tip { position: absolute; pointer-events: none; background: #1E2329; color: #fff; font: 12px var(--mono); border-radius: 6px; padding: 4px 8px; box-shadow: var(--shadow-md); white-space: nowrap; z-index: 3; }
.cl-tip[hidden] { display: none; }
.cl-status { position: absolute; left: 10px; bottom: 8px; font: 11.5px var(--mono); color: var(--text-2); background: rgba(255, 255, 255, .85); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; }
.cl-events { position: absolute; right: 10px; bottom: 8px; max-width: 60%; font-size: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.cl-events div { background: #FFF4E5; border: 1px solid #F2C27D; color: #7A4B00; border-radius: 6px; padding: 3px 8px; }

/* side */
.cl-side { border-left: 1px solid var(--border); background: var(--surface-2); overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.cl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow-xs); }
.cl-card h4 { margin: 0 0 6px; font-size: 13.5px; }
.cl-m { margin: 4px 0 8px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.cl-f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); margin: 6px 0; }
.cl-f > span:first-child { display: flex; justify-content: space-between; } .cl-f input[type=range] { width: 100%; accent-color: var(--accent); }
.cl-f .input.bad { border-color: var(--red); }
.cl-u { display: flex; align-items: center; gap: 4px; } .cl-u .input { width: 90px; }
.cl-kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 12px; margin-top: 6px; } .cl-kv span { color: var(--muted); } .cl-kv b { font: 600 12px var(--mono); text-align: right; }
.cl-scope { width: 100%; height: auto; aspect-ratio: 560 / 300; border-radius: 8px; display: block; }
.cl-row { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; font-size: 12px; color: var(--text-2); align-items: center; }
.cl-scope-read { font: 12px/1.5 var(--mono); margin-top: 6px; color: var(--text-2); }

@media (max-width: 1100px) { .cl-main { grid-template-columns: 160px minmax(0, 1fr) 280px; } }
@media (max-width: 820px) { .cl-main { grid-template-columns: 1fr; grid-template-rows: auto minmax(320px, 1fr) auto; } .cl-bin { max-height: 160px; border-right: 0; border-bottom: 1px solid var(--border); } .cl-side { border-left: 0; } }

/* ---- Block Studio 1.0: Circuit Lab module host (js/circuit/circuit-lab-host.js) ---- */
.circuit-view.clh { flex-direction: column; min-height: 0; }
.clh-bar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--border, #e5e7eb); background: var(--surface, #fff); flex: 0 0 auto; font-size: 12.5px; }
.clh-tabs { display: inline-flex; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; overflow: hidden; }
.clh-tabs button { border: 0; background: transparent; padding: 5px 12px; font: inherit; cursor: pointer; color: var(--text-2, #475569); }
.clh-tabs button.on { background: var(--accent-50, #FFF3EB); color: var(--accent-600, #E2651D); font-weight: 600; }
.clh-badge { color: var(--text-3, #64748b); }
.clh-sp { flex: 1; }
.clh-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2, #475569); }
.clh-stat { font-family: var(--mono, 'JetBrains Mono', monospace); font-size: 11.5px; color: var(--text-3, #64748b); min-width: 190px; text-align: right; }
.clh-lab, .clh-classic { flex: 1 1 auto; min-height: 0; position: relative; }
.clh-lab[hidden], .clh-classic[hidden] { display: none !important; }
.clh-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0e1419; }
.clh-classic { display: flex; } .clh-classic > .cl { flex: 1 1 auto; min-width: 0; }
/* Robot Lab view (robot/robot-lab-host.js) */
.robot-view { position: absolute; inset: 0; display: none; z-index: 100; overflow: hidden; background: var(--bg); }
.app[data-panel="robot"] .robot-view { display: flex !important; }
.app[data-panel="robot"] .right-panel, .app[data-panel="robot"] #splitRight, .app[data-panel="robot"] .side-panel,
.app[data-panel="robot"] #splitLeft, .app[data-panel="robot"] #dock, .app[data-panel="robot"] #btnRevealRight,
.app[data-panel="robot"] #tbUndoGroup { display: none !important; }
.rlh-frame { flex: 1; border: 0; width: 100%; height: 100%; min-height: 0; }
.robot-view.rlh { flex-direction: column; }
.rlh-bar { display: flex; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--border, #0002); background: var(--panel, var(--bg)); flex: none; }
.rlh-btn { font: inherit; font-size: 12.5px; padding: 3px 10px; border-radius: 6px; border: 1px solid transparent; background: none; color: inherit; cursor: pointer; }
.rlh-btn:hover { background: var(--hover, #0001); }
.rlh-btn.on { border-color: var(--accent, #F37A33); }
