/* CUBROID coding workspace. Scoped so build, drive and block lab retain their layouts. */
:root{--editor-width:68vw}
.draft-status{font-size:11px;color:#90cdbd;white-space:nowrap;flex-shrink:0;max-width:130px;overflow:hidden;text-overflow:ellipsis}
.draft-status[hidden]{display:none}
.draft-status[data-state=draftReady],.draft-status[data-state=draftSaving]{color:#adc0d4}
.draft-status[data-state=draftFailed],.draft-status[data-state=draftUnreadable]{color:#f4bd87}
@media(max-width:1100px){.draft-status{max-width:80px;font-size:10px}}
.app.code-active{grid-template-columns:minmax(0,1fr) var(--editor-width);grid-template-rows:50px minmax(0,1fr)}
.app.code-active #lpan{display:none!important}
.app.code-active #sc{grid-column:1;grid-row:2;min-width:0}
.app.code-active .hdr{gap:6px;padding-inline:10px;overflow-x:auto;white-space:nowrap;scrollbar-width:none}
.app.code-active .hdr .logo{font-size:15px;flex-shrink:0}
.app.code-active .hdr .hsep{display:none}
.app.code-active .hdr .mtab{padding:8px 10px;white-space:nowrap}
.app.code-active .hdr .btn{white-space:nowrap;flex-shrink:0}
.app.code-active .hdr .hright{gap:4px;flex-wrap:nowrap}
.app.code-active #stepGuide,.app.code-active #gearRow{display:none!important}
.app.code-active #hudSpd{font-size:12px;max-width:150px}
.app.code-active #cams{display:flex;flex-wrap:wrap;justify-content:center;gap:4px}
.code-overlay{--ed-font:18px;--ed-frame:#1e2a3a;--ed-panel:#223246;--ed-control:#2c4056;--ed-border:#425970;--ed-ink:#e8f1fa;--ed-muted:#adc0d4;--ed-accent:#00d4ff;--ed-canvas:#e1e9f0;--ed-grid:#b9c9d6;width:var(--editor-width);max-width:100vw;top:50px;bottom:0;transition:transform .2s;box-shadow:-8px 0 32px #06132624}
.code-overlay.running{width:var(--editor-width)}
.code-overlay.running .code-palette-col{display:flex}
.code-panel{background:var(--ed-frame);border-left:1px solid var(--ed-border);backdrop-filter:none;color:var(--ed-ink);min-width:0}
.code-panel-header{min-height:62px;padding:8px 14px;gap:8px;background:var(--ed-frame);border-bottom:1px solid var(--ed-border);flex-wrap:wrap}
.code-tabs{gap:4px;flex-shrink:0}
.code-tab{font-size:16px;min-height:44px;border:0;border-radius:10px;background:var(--ed-control);color:var(--ed-muted);padding:9px 14px}
.code-tab.active{background:#17475b;color:var(--ed-accent);box-shadow:inset 0 -3px var(--ed-accent)}
.code-panel-close{width:40px;height:40px;color:var(--ed-muted);background:var(--ed-control);flex-shrink:0}
.ed-view-tools{display:flex;align-items:center;gap:8px;margin-left:auto}
.ed-view-tools button,.ed-selection-tools button{min-width:42px;height:42px;border:1px solid var(--ed-border);border-radius:9px;background:var(--ed-control);color:var(--ed-ink);font-family:inherit;font-size:14px;font-weight:600;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
.ed-view-tools button:hover,.ed-selection-tools button:hover{background:#344e65;border-color:var(--ed-accent)}
.ed-font-controls{display:flex;align-items:center;gap:2px;background:#182536;border-radius:10px;padding:2px}
.ed-font-controls button{border:0;background:transparent;font-size:15px}
#edFontLabel{min-width:24px;text-align:center;font-size:13px;font-weight:700;color:var(--ed-muted)}
#edFocus{padding:0 12px;color:var(--ed-accent)}
.ed-resizer{position:absolute;left:-5px;top:0;bottom:0;width:10px;cursor:col-resize;z-index:4;touch-action:none}
.ed-resizer:after{content:'';position:absolute;top:45%;left:3px;width:4px;height:44px;border-radius:4px;background:#7089a2}
.ed-resizer:hover:after,.ed-resizer:focus:after{background:var(--ed-accent)}
.code-panel-body{min-height:0;min-width:0}
.code-palette-col{width:206px;min-width:0;padding:14px 12px;display:flex;flex-direction:column;gap:12px;background:var(--ed-frame);overflow-y:auto;border-right:1px solid var(--ed-border);scrollbar-width:thin;scrollbar-color:#59718a var(--ed-frame)}
.ed-palette-title{font-size:13px;font-weight:800;color:var(--ed-muted);letter-spacing:.03em}
.ed-categories{display:flex;flex-wrap:wrap;gap:5px;flex-shrink:0}
.ed-categories button{border:1px solid var(--ed-border);background:var(--ed-panel);color:var(--ed-muted);border-radius:8px;min-height:40px;display:flex;align-items:center;gap:5px;padding:7px 8px;font-family:inherit;font-size:12px;font-weight:700;cursor:pointer;flex:1 1 45%;white-space:normal;text-align:left}
.ed-categories button svg{flex-shrink:0;color:var(--block-bg)}
.ed-categories button:hover{border-color:var(--block-bg)}
.ed-categories button[aria-selected=true]{background:var(--block-bg);border-color:var(--block-edge);color:var(--block-ink);box-shadow:inset 0 -2px var(--block-edge)}
.ed-categories button[aria-selected=true] svg{color:inherit}
.ed-command-list{display:flex;flex-direction:column;gap:12px;padding-block:6px}
.code-palette-col .cmd-btn{position:relative;display:flex;align-items:center;gap:8px;min-height:56px;padding:12px 10px;font-family:inherit;font-size:16px;line-height:1.4;border-radius:9px;border:1px solid var(--block-edge);border-bottom:4px solid var(--block-edge);background:var(--block-bg);color:var(--block-ink);touch-action:pan-y;box-shadow:0 2px 4px #162f4810}
.cmd-btn svg{flex-shrink:0}
.ed-add{font-size:22px;margin-left:auto;opacity:.6}
.ed-palette-hint{font-size:12px;color:var(--ed-muted);line-height:1.6;margin:0}
.code-prog-col{padding:14px;min-width:0;background:var(--ed-panel)}
.code-prog-header{margin:0 0 10px;gap:8px;flex-wrap:wrap}
.ed-workspace-title{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:800;color:var(--ed-ink)}
#edCount{display:inline-flex;align-items:center;justify-content:center;min-width:26px;height:26px;border-radius:8px;background:var(--ed-control);color:var(--ed-muted);font-size:13px}
.prog-hdr-actions{gap:6px;flex-wrap:wrap}
.code-overlay .mini-btn{min-width:40px;min-height:40px;padding:8px 10px;font-family:inherit;font-size:13px;font-weight:600;display:inline-flex;align-items:center;justify-content:center;background:var(--ed-control);border:1px solid var(--ed-border);border-radius:8px;color:var(--ed-ink);cursor:pointer}
.code-overlay button:disabled{opacity:.38;cursor:default}
.code-overlay button:focus-visible,.code-overlay select:focus-visible,.code-overlay input:focus-visible{outline:3px solid #18a5db;outline-offset:2px}
.prog-ex-sel{min-height:40px;max-width:145px;font-family:inherit;font-size:13px;font-weight:600;color:var(--ed-ink);background:var(--ed-control);border:1px solid var(--ed-border);border-radius:8px;padding:7px}
.ed-selection-tools{display:flex;align-items:center;gap:6px;margin-bottom:10px;min-height:42px}
#edSelection{flex:1;font-size:12px;color:var(--ed-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ed-selection-tools button{width:42px;font-size:20px}
.code-prog-col .prog-list{padding:22px 18px;position:relative;border:1px solid #adc1d0;border-radius:14px;background-color:var(--ed-canvas);background-image:radial-gradient(var(--ed-grid) 1px,transparent 1px);background-size:18px 18px;overflow:auto;scrollbar-width:thin;scrollbar-color:#8099ad var(--ed-canvas);scroll-padding:16px;min-height:80px;isolation:isolate}
.ed-start{display:flex;align-items:center;gap:10px;width:max-content;background:#214660;border:1px solid #173449;border-bottom:4px solid #173449;border-radius:20px 20px 8px 8px;color:#fff;font-size:var(--ed-font);font-weight:800;padding:14px 22px;position:relative}
.ed-start svg{color:var(--ed-accent)}
.ed-start:after,.code-prog-col .prog-item:not(.ed-cap):after{content:'';position:absolute;bottom:-8px;left:34px;width:24px;height:9px;border-radius:0 0 5px 5px;background:var(--block-edge,#173449);z-index:2}
.code-prog-col .prog-item{display:flex;flex-wrap:wrap;align-items:center;gap:9px;margin:0;min-height:64px;padding:12px 14px;font-size:var(--ed-font);font-weight:700;line-height:1.4;background:var(--block-bg);color:var(--block-ink);border:1px solid var(--block-edge);border-bottom:4px solid var(--block-edge);border-radius:9px;box-shadow:0 2px 4px #18314a0d;cursor:pointer;max-width:100%;transition:none}
.prog-item:hover{filter:none}
.code-prog-col .prog-item.sel{outline:3px solid #087da3;outline-offset:3px;box-shadow:0 0 0 6px #00d4ff33;z-index:3;background:var(--block-bg)}
.code-prog-col .prog-item.active{outline:4px solid #12a865;outline-offset:3px;animation:none;box-shadow:0 0 0 8px #b7efcf;background:var(--block-bg);z-index:3}
.code-prog-col .prog-item .pnum{font-size:11px;color:var(--block-ink);opacity:.6;min-width:12px}
.ed-grip{display:inline-flex;align-items:center;justify-content:center;width:26px;align-self:stretch;color:var(--block-ink);opacity:.6;font-size:24px;cursor:grab;touch-action:none}
.ed-command-name{display:flex;align-items:center;gap:8px;flex:1;min-width:80px}
.ed-command-name svg{flex-shrink:0}
.ed-param{display:inline-flex;align-items:center;gap:7px;white-space:nowrap}
.code-prog-col .pinp-dur,.code-prog-col .pinp-count{width:74px;height:42px;border:1px solid var(--block-edge);border-radius:9px;background:#fff;color:#203a50;padding:6px 8px;font-family:inherit;font-size:var(--ed-font);text-align:center}
.code-prog-col .psel{height:42px;min-width:85px;max-width:100%;background:#fff;color:#253e55;border:1px solid var(--block-edge);border-radius:9px;font-family:inherit;font-size:calc(var(--ed-font) - 2px);padding:6px 8px;flex:0 1 auto}
.ed-scope{background:var(--block-bg);border-left:10px solid var(--block-edge);border-radius:10px;position:relative;min-width:0}
.ed-scope>.prog-item{border-left:0;border-radius:0 9px 9px 0}
.ed-scope-body{padding:10px 0 10px 16px;margin-left:7px;min-height:54px;background:var(--ed-canvas);border-radius:10px 0 0 10px;background-image:radial-gradient(var(--ed-grid) 1px,transparent 1px);background-size:18px 18px}
.code-prog-col .ed-cap{min-height:36px;padding:6px 14px;font-size:13px;border-bottom-width:2px;opacity:.9}
.ed-slot{display:block;height:16px;min-height:16px;width:100%;margin:0;padding:0;border:0;background:transparent;color:transparent;border-radius:6px;position:relative;cursor:copy;transition:background .12s}
.ed-slot:hover,.ed-slot:focus-visible{background:#d5e8fb;color:#2176af;outline:0;font-size:16px;line-height:16px}
.ed-slot.empty{min-height:62px;height:auto;padding:14px;line-height:1.5;border:2px dashed #a9bfd4;background:#ffffff66;color:#627f99;font-size:14px;margin:6px 0}
.ed-slot.ed-drop-target{background:#b9e7fb;border:2px dashed #0282ba;color:#075f85;min-height:26px}
.code-prog-col .prog-empty{font-size:14px;color:#637a93;line-height:1.7;margin:14px 10px}
.ed-structure-error{padding:12px;border:1px solid #eebc83;border-radius:8px;background:#fff1db;color:#85491b;font-size:13px}
.ed-drag-ghost{position:fixed;pointer-events:none;z-index:10000;background:#204c70;color:white;font:700 18px sans-serif;padding:15px 22px;border-radius:12px;box-shadow:0 8px 24px #122a4844;max-width:300px}
/* Shared hues tie command blocks, category tabs and Python chips to the robot palette. */
.code-overlay .pi-motor,.code-overlay .pi-motor2,.ed-categories [data-category=car],.ed-categories [data-category=motor]{--block-bg:#66badd;--block-edge:#337fa2;--block-ink:#103b52}
.code-overlay .pi-led,.ed-categories [data-category=led],.py-api-chip.l{--block-bg:#78c5ab;--block-edge:#3d8c74;--block-ink:#173f34}
.code-overlay .pi-master,.ed-categories [data-category=master],.py-api-chip.m{--block-bg:#68bdbc;--block-edge:#358786;--block-ink:#123e41}
.code-overlay .pi-sound,.ed-categories [data-category=sound],.py-api-chip.snd{--block-bg:#dfa28b;--block-edge:#ac6c54;--block-ink:#573124}
.code-overlay .pi-wait,.ed-categories [data-category=ctrl]{--block-bg:#e9c47c;--block-edge:#b08a43;--block-ink:#533d18}
.code-overlay .pi-stop{--block-bg:#df9188;--block-edge:#ad5b54;--block-ink:#582724}
.code-overlay .pi-sensor,.ed-categories [data-category=sensor],.py-api-chip.s{--block-bg:#85c5d6;--block-edge:#4c90a5;--block-ink:#173e4a}
.code-overlay .pi-loop,.ed-categories [data-category=flow]{--block-bg:#eca86d;--block-edge:#b57841;--block-ink:#583617}
.code-overlay .pi-ai,.ed-categories [data-category=ai],.py-api-chip.ai{--block-bg:#a8addd;--block-edge:#737bb3;--block-ink:#30355a}
.code-prog-actions{margin-top:12px}
.code-prog-col .run-btn,.code-prog-col .stop-prog-btn{min-height:50px;margin:0;font-size:17px;font-weight:800;border-radius:12px;background:#08b6d4;color:#092937;box-shadow:0 3px 0 #087c93}
.code-prog-col .stop-prog-btn{background:#df9188;color:#582724;box-shadow:0 3px 0 #ad5b54}
.code-prog-col .step-btn,.code-prog-col .step-next-btn{min-height:50px;margin:0;font-size:17px;font-weight:800;border-radius:12px;background:#f2c14e;color:#3d2e05;box-shadow:0 3px 0 #b98d1f;border:none}
.code-prog-col .step-btn{flex:0 0 auto;padding:0 16px}
.code-prog-col .step-next-btn{flex:1}
.code-prog-col .prog-output{min-height:32px;max-height:65px;margin-top:9px;color:var(--ed-muted);font-size:12px;background:#19283a;padding:8px 12px;line-height:1.5;white-space:pre-wrap}
.ed-hidden{display:none!important}
.editor-focus .app.code-active{grid-template-columns:0 1fr}
.editor-focus .code-overlay,.editor-focus .code-overlay.running{width:100vw}
.editor-focus .ed-resizer{display:none}
/* Python fills its panel. Identical metrics on text, highlight, and gutter. */
.py-editor-col{flex:1;width:100%;min-width:0;border-radius:0;background:#172337}
.py-toolbar{order:-2;padding:10px 14px;gap:8px;flex-wrap:wrap;background:var(--ed-frame);border-bottom:1px solid var(--ed-border)}
.py-ex-btn,.py-blocks2py-btn{font-family:inherit;font-size:14px;min-height:42px;padding:8px 12px;color:var(--ed-ink);background:var(--ed-control);border:1px solid var(--ed-border);border-radius:9px}
.py-file-label{color:var(--ed-muted);font-size:12px}
.py-api-tools{order:-1;background:var(--ed-panel);color:var(--ed-muted);padding:0}
.py-api-tools summary{cursor:pointer;padding:10px 16px;font-size:13px;font-weight:700;min-height:40px;list-style:none}
.py-api-tools summary:before{content:'＋';margin-right:8px}
.py-api-tools[open] summary:before{content:'−'}
.py-api-bar{padding:8px 14px;background:var(--ed-panel);border-color:var(--ed-border);gap:6px}
.py-api-chip{font-family:inherit;min-height:42px;font-size:14px;padding:9px 12px;background:var(--block-bg,#66badd);color:var(--block-ink,#103b52);border-color:var(--block-edge,#337fa2);display:inline-flex;align-items:center;gap:4px}
.py-api-chip.s,.py-api-chip.l,.py-api-chip.m,.py-api-chip.snd,.py-api-chip.ai{color:var(--block-ink);background:var(--block-bg);border-color:var(--block-edge)}
.py-chip-hint{color:var(--ed-muted);background:var(--ed-panel);font-size:13px;padding:0 14px}
.py-chip-hint:empty{display:none}
.py-line-nums,.py-highlight,.py-textarea{font-size:var(--ed-font);line-height:1.65}
.py-line-nums{width:54px;padding:18px 12px 18px 0;color:#8195ae;background:#142033;border-color:#2a3b52}
.py-highlight,.py-textarea{padding:18px;white-space:pre;word-wrap:normal;overflow:auto;tab-size:4;font-family:'Fira Code','Courier New',monospace}
.py-highlight{color:#e1eaf5;background:#172337;scrollbar-width:none}
.py-edit-area{background:#172337}
.py-textarea{background:transparent;caret-color:#fff}
.py-hl-cmt{color:#91a2b9}
.py-actions{padding:10px 14px;background:#172337}
.py-run-btn,.py-stop-btn{min-height:48px;font-size:17px;border-radius:10px;font-family:inherit;font-weight:800}
.py-run-btn{background:#08b6d4;color:#092937;box-shadow:0 3px 0 #087c93}
.py-stop-btn{background:#df9188;color:#582724;box-shadow:0 3px 0 #ad5b54}
.py-console-header{background:#101b2c;color:#95aec8;padding:7px 14px;font-size:12px}
.py-console-clear{color:#a2b5ce;min-height:30px}
.py-output{font-size:14px!important;min-height:58px;height:70px;padding:10px 16px!important;background:#111d2f!important;color:#c9dfc7!important}
.py-console-drag{background:#182a40;color:#a1b8d0;min-height:16px}
#pyErrLineBg{height:calc(var(--ed-font) * 1.65);z-index:1}
.py-ac-popup{max-width:100%;font-size:16px;line-height:1.5}
.py-ac-item{min-height:38px;padding:8px 12px}
.py-ac-desc{font-size:12px}
#codeOverlay[data-tab=python] #edPaletteToggle{display:none}
@media(min-width:1600px){.code-palette-col{width:250px}.code-prog-col{padding:20px}.code-prog-col .prog-list{padding:28px}}
@media(max-width:1100px){
 .code-palette-col{width:175px;padding:10px}.code-palette-col .cmd-btn{font-size:14px;padding:10px 8px}.ed-categories button{font-size:11px}
 .code-prog-col{padding:10px}.code-prog-col .prog-list{padding:18px 10px}.ed-command-name{min-width:95px}.ed-grip{width:18px}
 .ed-view-tools{gap:4px}.code-panel-header{padding:8px}.ed-font-controls{display:none}
}
@media(max-width:900px){
 .app.code-active{grid-template-columns:1fr;grid-template-rows:50px 160px minmax(0,1fr)}
 .app.code-active #sc{grid-column:1;grid-row:2;height:160px}
 .code-overlay,.code-overlay.running{width:100%;top:210px;max-width:100vw}
 .code-panel-header{min-height:54px;flex-wrap:nowrap}.code-tab{font-size:14px;padding:8px 12px}
 .code-palette-col{width:195px}.ed-font-controls{display:flex}.ed-resizer{display:none}
 .app.code-active #hudSpd{display:none!important}.app.code-active #cams{right:8px;left:auto;bottom:8px}
 .editor-focus .app.code-active{grid-template-columns:1fr;grid-template-rows:50px 0 1fr}.editor-focus .app.code-active #sc{height:0;visibility:hidden}
 .editor-focus .code-overlay{top:50px}
}
@media(max-width:600px){
 .app.code-active .hdr{flex-wrap:nowrap;padding:4px;gap:4px}.app.code-active .hdr .logo{font-size:12px}.app.code-active .hdr .btn{min-width:36px;padding:6px}.app.code-active .hdr .mtab{min-width:36px}
 .app.code-active{grid-template-rows:50px 130px minmax(0,1fr)}.app.code-active #sc{height:130px}.code-overlay,.code-overlay.running{top:180px}
 #blockCodePanel{flex-direction:column}.code-palette-col{width:100%;max-height:162px;padding:7px 10px;gap:6px;flex-shrink:0;border-right:0;border-bottom:1px solid var(--ed-border);overflow-y:auto}
 .ed-palette-title,.ed-palette-hint{display:none}.ed-categories{flex-wrap:nowrap;overflow-x:auto;flex-shrink:0}.ed-categories button{flex:0 0 auto;min-height:36px;padding:6px;font-size:11px}
 .ed-command-list{flex-direction:row;flex-wrap:wrap;gap:6px;padding:4px 0}.code-palette-col .cmd-btn{min-height:44px;padding:8px;font-size:13px;flex:1 1 auto;gap:5px}.ed-add{font-size:17px}
 .code-prog-col{padding:8px;flex:1;min-height:0}.ed-workspace-title{font-size:15px}.code-prog-header{gap:5px;margin-bottom:6px;flex-wrap:nowrap}.prog-hdr-actions{gap:4px;flex-wrap:nowrap}
 .code-overlay .mini-btn{min-width:34px;min-height:36px;padding:6px;font-size:12px}.prog-ex-sel{max-width:92px;min-height:36px;font-size:12px}#edCount{display:none}
 .ed-selection-tools{min-height:36px;margin-bottom:6px;gap:5px}.ed-selection-tools button{width:38px;min-width:38px;height:36px}#edSelection{font-size:11px}
 .code-prog-col .prog-list{padding:16px 10px}.code-prog-col .prog-item{padding:10px 8px;gap:6px}.ed-grip{width:18px}.ed-command-name{min-width:70px;gap:5px}.code-prog-col .prog-item .pnum{display:none}
 .code-prog-col .pinp-dur,.code-prog-col .pinp-count{width:62px}.ed-scope{border-left-width:7px}.ed-scope-body{padding-left:9px;margin-left:3px}
 .ed-view-tools{gap:4px}.ed-font-controls{display:none}.code-panel-header{gap:5px;padding:6px 8px}.code-panel-close{width:32px;min-width:32px}.ed-view-tools button{height:38px;min-width:36px}#edFocus{font-size:12px;padding-inline:8px}
 .code-prog-actions{margin-top:7px}.code-prog-col .run-btn,.code-prog-col .stop-prog-btn,.code-prog-col .step-btn,.code-prog-col .step-next-btn{min-height:44px}.code-prog-col .prog-output{max-height:42px;min-height:25px;margin-top:6px;padding:5px 8px}
 .py-toolbar{padding:8px;gap:6px}.py-ex-btn,.py-blocks2py-btn{font-size:12px;min-height:36px;padding:6px 8px}.py-file-label{display:none}.py-line-nums{width:38px;padding-right:8px}.py-highlight,.py-textarea{padding:18px 12px}.py-output{height:50px;min-height:40px}.py-api-tools[open]{max-height:180px;overflow:auto}
}
@media(prefers-reduced-motion:reduce){.code-overlay,.prog-item{transition:none;animation:none}}
