/* K STEAM-inspired arrangement, using only Druk controls and brand assets. */
:root{--editor-blue:#2877df;--editor-bg:#e7f0ff;--editor-panel:#fff;--editor-soft:#f5f8fd;--editor-border:#c8d3e1;--editor-text:#24364b;--editor-muted:#52677e}
html[data-theme="dark"]{--editor-blue:#194d91;--editor-bg:#172538;--editor-panel:#1c2c42;--editor-soft:#203149;--editor-border:#526880;--editor-text:#e5edf7;--editor-muted:#b7c7db}
body{background:var(--editor-bg);color:var(--editor-text)}
html header{height:auto;min-height:54px;background:var(--editor-blue);color:white;border:0;padding:7px 12px;gap:8px 16px;flex-wrap:wrap}
header .brand{min-width:0;max-width:100%;flex:1 1 290px;gap:8px}
header .brand>div{min-width:0}header .brand strong{font-size:14px;gap:4px 8px;line-height:1.5}
header .brand-dz{font-size:25px;line-height:1.6;overflow-wrap:anywhere}
header .brand-logo{flex:0 0 44px;width:44px;height:34px;padding:0;border:0;border-radius:4px;background:transparent}
header .brand-logo img{width:44px;height:32px;object-fit:contain}
header .header-actions{margin-left:auto;flex-wrap:wrap;gap:6px;justify-content:flex-start;max-width:100%;flex-shrink:1}
html header :is(button,select){height:auto;min-height:34px;background:#165ab5;border:1px solid #ffffff70;color:white;border-radius:5px;padding:5px 10px}
html header :is(button,select):hover{background:#124d9c}
html header select option{color:var(--editor-text);background:var(--editor-panel)}
html #upload{background:#247d35;border-color:#a6e0b0;color:white;font-weight:700}
html #upload:hover{background:#196729}html #check{background:#fff;color:#174c91;border-color:#fff}
html #editor-connection{order:3;flex:1 0 100%;min-width:0;display:flex;flex-wrap:wrap;gap:6px 10px;font-size:12px;color:white}
#editor-connection .bridge-board{margin-right:auto}#editor-connection .muted{color:white;white-space:normal;overflow-wrap:anywhere}
#editor-connection #port{width:150px;max-width:100%}#editor-connection button{width:auto;min-width:34px;padding:5px 10px}
html nav.toolbar{height:auto;min-height:44px;overflow:visible;flex-wrap:wrap;gap:7px;padding:6px 10px;background:var(--editor-bg);border-color:var(--editor-border)}
.toolbar .group{gap:5px;padding-right:7px;align-items:center;min-width:0;flex-wrap:wrap}
.toolbar :is(button,select),.editor-menu summary{height:auto;min-height:32px;border-radius:5px;font-size:12px;padding:6px 10px}
.toolbar select{max-width:245px;min-width:0}.toolbar .spacer{min-width:0}
.editor-menu{position:relative;flex-shrink:0}
.editor-menu summary{cursor:pointer;border:1px solid var(--editor-border);background:var(--editor-panel);font-weight:600}
.editor-menu[open] summary{background:var(--editor-soft)}
.editor-menu-items{position:absolute;top:calc(100% + 5px);left:0;z-index:50;width:230px;max-width:calc(100vw - 24px);padding:7px;display:flex;flex-direction:column;gap:4px;border:1px solid var(--editor-border);border-radius:8px;background:var(--editor-panel);box-shadow:0 8px 25px #10264326}
.editor-menu-items :is(button,a){text-align:left;white-space:normal;height:auto;padding:9px;font-size:13px}
.editor-menu-items a{color:var(--editor-text);text-underline-offset:3px}
main#surface{gap:8px;padding:0 8px 6px 0;min-height:200px;overflow:hidden}
.workspace-panel{border:1px solid var(--editor-border);border-radius:0 8px 8px 0;overflow:hidden;background:var(--editor-panel);flex:1;min-width:0}
.workspace-tag{display:none}
/* Blockly sets these surfaces inline; override only the palette surfaces. */
html[lang="en"] .blocklyToolbox{min-width:88px;background:var(--editor-panel)!important;border-right:1px solid var(--editor-border)!important}
html[lang="dz"] .blocklyToolbox{min-width:110px}
.blocklyToolboxCategory{border-radius:0;min-height:48px;padding:4px 7px}
html .blocklyToolboxCategoryLabel{color:var(--editor-text)!important}
html .blocklyFlyoutBackground{fill:var(--editor-soft)!important}
html .blocklyToolboxSelected{background:var(--editor-bg)!important}
html .blocklyToolboxSelected .blocklyToolboxCategoryLabel{color:var(--editor-text)!important}
.workspace-tools{right:18px;bottom:28px;max-width:calc(100% - 36px);flex-wrap:wrap;border-radius:8px;padding:3px;box-shadow:0 3px 12px #10264320;background:var(--editor-panel)}
#editor-right{flex:0 0 32%;min-width:290px;display:flex;flex-direction:column;gap:8px;min-height:0}
#editor-right[hidden]{display:none}
html #editor-right #code-panel{position:static;inset:auto;flex:1;min-height:160px;min-width:0;display:flex;border:1px solid var(--editor-border);border-radius:8px;overflow:hidden;box-shadow:none;background:var(--editor-panel)}
html #editor-right #code-panel[hidden]{display:none}
.code-heading{padding:8px 10px;gap:6px;flex-wrap:wrap;background:var(--editor-soft)}
.code-heading strong{font-size:13px}.code-heading select{min-width:0;max-width:100%;font-size:12px}
.code-heading #close-code{margin-left:auto}
.code-note{font-size:12px;padding:7px 10px;color:var(--editor-muted)}
html #code{font:13px/1.65 Consolas,monospace;padding:12px;background:var(--editor-panel);color:var(--editor-text);min-height:80px;overflow:auto;white-space:pre}
.code-footer{padding:7px 10px;gap:6px;flex-wrap:wrap}.code-footer button{height:auto;min-height:30px;font-size:12px}
#editor-right #log-panel{height:28%;min-height:120px;flex-shrink:0;background:var(--editor-panel);color:var(--editor-text);border:1px solid var(--editor-border);border-radius:8px;padding:8px 10px;overflow:auto}
#editor-right:has(#code-panel[hidden]) #log-panel{flex:1;height:auto}
#log-panel pre{font:12px/1.5 Consolas,monospace;margin-top:12px;overflow-wrap:anywhere}
.output-title{font-size:12px;font-weight:600;color:var(--editor-muted)}#close-log{font-size:12px;height:auto;min-height:28px;margin-left:8px}
html footer{height:auto;min-height:34px;font-size:11px;padding:5px 10px;flex-wrap:wrap;gap:5px 8px;background:var(--editor-panel);border-color:var(--editor-border)}
#upload-target{white-space:normal}#status{min-width:80px;flex:1;white-space:normal;overflow-wrap:anywhere}
footer #draft-status{max-width:100%;height:auto;white-space:normal}.dot{flex-shrink:0}
html dialog{border:1px solid var(--editor-border);border-radius:10px;padding:20px;background:var(--editor-panel);color:var(--editor-text);overflow:auto}
.dialog-heading{gap:12px;align-items:flex-start}.dialog-heading h2{line-height:1.5;overflow-wrap:anywhere;min-width:0}
dialog .row{flex-wrap:wrap}dialog button{height:auto;min-height:34px;white-space:normal;margin:3px 0}dialog .help{color:var(--editor-muted)}
html :is(button,select,input,textarea,a,summary):focus-visible{outline:3px solid #f5ae22;outline-offset:2px}
html #code:focus-visible{outline-offset:-3px}
:root[lang="dz"] :is(.toolbar button,.toolbar summary,.toolbar select){font-family:"Microsoft Himalaya","Noto Sans Tibetan",sans-serif;font-size:19px;line-height:1.5;height:auto;min-height:36px}
@media(max-width:1100px){#editor-right{flex-basis:38%;min-width:270px}.toolbar .spacer{display:none}}
@media(max-width:900px){body{overflow:auto;height:auto;min-height:100dvh}main#surface{flex-direction:column;overflow:visible;flex:none}.workspace-panel{flex:none;height:58dvh;min-height:350px}#editor-right{flex:none;width:100%;min-width:0;height:520px;padding-left:8px}#editor-right #code-panel{min-height:200px}header .header-actions{margin-left:0}#editor-connection .bridge-board{flex-basis:100%}.toolbar .group:has(#example){flex:1 1 260px}.toolbar #example{flex:1;max-width:100%;width:160px}footer #status{flex-basis:60%}}
@media(max-width:480px){header .brand strong{font-size:13px}.toolbar .group{border:0;padding-right:0}.toolbar :is(button,select){max-width:100%}.workspace-tools button{padding:0 5px}#editor-connection #connection{flex-basis:100%}dialog{padding:14px}dialog .row input{flex-basis:100%}}
/* Tibetan glyphs need a larger UI size than Latin at equal legibility. */
html[lang="dz"] :is(.code-note,.output-title,.code-heading strong,footer){font-size:18px;line-height:1.6}
html[lang="dz"] .brand strong,html[lang="dz"] .bridge-board{font-family:"Segoe UI",sans-serif}
html[lang="dz"] #connection{font-family:"Segoe UI","Microsoft Himalaya",sans-serif;font-size:12px}
html[lang="dz"] dialog{font-size:20px;line-height:1.6}
html[data-theme="dark"] header{background:var(--editor-blue)}
#editor-connection .bridge-board{display:inline-block}

/* 007: brand and connection sequence share DOM, visual and keyboard order. */
html header .brand{flex:0 1 auto;gap:12px}
html header .brand strong{font-size:22px;line-height:1.4;flex-wrap:wrap}
html header .brand-dz{font-size:32px;line-height:1.5}
html header .brand-logo{flex:0 0 56px;width:56px;height:44px;min-height:44px;padding:0;background:transparent;border:0}
html header .brand-logo img{width:56px;height:40px;object-fit:contain}
html header .brand-language{display:flex;align-items:center;gap:6px;margin-left:0}
html header .header-actions{display:none}
html #editor-connection{order:0;justify-content:flex-start;align-items:center;flex-basis:100%}
html header #board-summary{flex-basis:100%;order:0;font-size:12px;line-height:1.5;color:white}
html #editor-connection #connection{flex:0 1 auto;max-width:260px}
html #editor-connection .bridge-download-link{flex:0 1 auto;white-space:normal}
html #dialog-close{flex:0 0 44px;width:44px;min-width:44px;height:44px;min-height:44px;font:24px/1 "Segoe UI",sans-serif;padding:0;margin:0;display:grid;place-items:center}
html .dialog-heading{align-items:flex-start;gap:12px}
html .dialog-heading h2{flex:1;padding-top:7px}
@media(max-width:480px){html header .brand strong{font-size:20px}html header .brand-dz{font-size:30px}html #editor-connection #connection{flex-basis:auto}html header .brand{flex-basis:100%}}
/* Keep the shared modal title and close control visible while its body scrolls. */
html #dialog[open]{display:flex;flex-direction:column;max-height:85dvh;overflow:hidden}
html #dialog .dialog-heading{flex:0 0 auto}
html #dialog-body{min-height:0;overflow:auto;overscroll-behavior:contain}
/* The language-wide button font must not shrink the universal close glyph. */
html #dialog-close{font-family:"Segoe UI",sans-serif!important;font-size:24px!important}
/* 008: one scrollable header row; editor tools remain in the toolbar. */
html header{flex-wrap:nowrap;align-items:center;gap:8px;padding:7px 10px;min-height:62px;overflow-x:auto;overflow-y:hidden;scroll-padding-inline:12px}
html header .brand{flex:0 0 auto;gap:8px;max-width:none}
html header .brand strong{flex-wrap:nowrap;white-space:nowrap;font-size:22px;gap:5px}
html header .brand-dz{white-space:nowrap;font-size:32px;overflow-wrap:normal}
html header .brand-language{flex:0 0 auto;gap:0}
html header .brand-language>span{display:none}
html header #language-select{width:76px;padding:5px;font:12px/1.5 "Segoe UI","Microsoft Himalaya",sans-serif}
html #editor-connection{flex:0 0 auto;flex-basis:auto;flex-wrap:nowrap;gap:6px;min-width:max-content;width:auto}
html #editor-connection :is(button,select){flex:0 0 auto;white-space:nowrap;font-size:12px;padding:5px 7px;min-width:0}
html #editor-connection #port{width:94px}
html #editor-connection #ports{width:30px;padding:5px}
html #editor-connection .bridge-download-link{flex:0 0 auto;width:auto;white-space:nowrap;padding:6px 7px;font-size:12px;min-height:34px}
html #operation-status{display:flex;align-items:center;gap:6px 10px;flex:0 1 auto;flex-wrap:wrap;min-width:0;max-width:calc(100vw - 20px);white-space:normal}
html #operation-status #connection{flex:0 1 auto;width:auto;min-width:0;max-width:none;font:12px/1.4 "Segoe UI","Microsoft Himalaya",sans-serif;white-space:normal;overflow-wrap:anywhere;user-select:text}
html #connection[data-kind="error"]{color:#fff1b5;font-weight:700}
html #connection[data-kind="success"]{color:#e0ffd8;font-weight:700}
html #operation-status #operation-details{font-size:12px;padding:5px;min-width:0}
html #editor-connection :is(#bridge-connect,#bridge-menu-button,#board-select){border-width:2px;border-style:solid}
html #editor-connection :is(#bridge-connect,#bridge-menu-button)[data-bridge-ready="not-ready"],html #editor-connection #board-select[data-board-ready="not-ready"]{border-color:#d73736}
html #editor-connection :is(#bridge-connect,#bridge-menu-button)[data-bridge-ready="ready"],html #editor-connection #board-select[data-board-ready="ready"]{border-color:#168b49}
html #editor-connection :is(#bridge-connect,#bridge-menu-button)[data-bridge-ready="checking"],html #editor-connection #board-select[data-board-ready="checking"]{border-color:#d18a10;border-style:dashed}
html[data-theme="dark"] #editor-connection :is(#bridge-connect,#bridge-menu-button)[data-bridge-ready="not-ready"],html[data-theme="dark"] #editor-connection #board-select[data-board-ready="not-ready"]{border-color:#ff6d69}
html[data-theme="dark"] #editor-connection :is(#bridge-connect,#bridge-menu-button)[data-bridge-ready="ready"],html[data-theme="dark"] #editor-connection #board-select[data-board-ready="ready"]{border-color:#52d88b}
html[data-theme="dark"] #editor-connection :is(#bridge-connect,#bridge-menu-button)[data-bridge-ready="checking"],html[data-theme="dark"] #editor-connection #board-select[data-board-ready="checking"]{border-color:#ffc04d}
html #editor-connection :is(#bridge-connect,#bridge-menu-button,#board-select):focus-visible{outline:3px solid #274dff;outline-offset:2px}
.connection-settings{border:1px solid var(--editor-border);border-radius:8px;padding:8px 12px;background:var(--editor-soft)}
#settings-status{margin:4px 0;overflow-wrap:anywhere}#settings-port{max-width:100%;min-width:140px}
.connection-settings .help{margin:6px 0;font-size:12px}.connection-settings .row{padding:5px 0}
html[lang="dz"] header #language-select{font-size:19px!important;width:76px}
html[lang="dz"] #editor-connection :is(button,select){padding:4px 6px}
html[lang="dz"] #editor-connection .bridge-download-link{font:12px/1.5 "Segoe UI",sans-serif}
html[lang="dz"] #operation-status #operation-details{font-family:"Segoe UI",sans-serif!important;font-size:12px!important}
@media(max-width:600px){html header{min-height:62px}html header .brand{flex-basis:auto}html header .brand strong{font-size:22px}html header .brand-dz{font-size:32px}html #operation-status{max-width:calc(100vw - 20px)}}
.connection-settings .help{font-family:"Segoe UI",sans-serif;line-height:1.6}
#settings-advanced>summary{cursor:pointer;padding:8px 0;font:13px/1.5 "Segoe UI",sans-serif}

/* 009: isolate Blockly's internal z-index from the visible toolbar popup layer. */
main#surface{position:relative;isolation:isolate;z-index:0}
nav.toolbar{position:relative;z-index:1;overflow:visible}
nav.toolbar .editor-menu-items{position:fixed;min-width:180px;max-width:calc(100vw - 16px);overflow:auto;box-sizing:border-box}
#new-shortcut,#open-shortcut,#save-shortcut{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px}
.palette-action-group{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto}
.toolbar .palette-action-group :is(#palette-toggle,#blocks-png){display:inline-flex;align-items:center;justify-content:center;height:36px;min-height:36px}
.toolbar .palette-action-group #blocks-png{width:38px;min-width:38px;padding:5px}
.project-save-group{display:flex;align-items:center;gap:5px;flex:0 1 300px;min-width:185px;max-width:min(340px,100%)}
.project-save-group #save-shortcut{flex:0 0 44px}
nav.toolbar #project-filename{box-sizing:border-box;flex:1 1 auto;min-width:0;width:230px;height:44px;padding:7px 10px;border:1px solid var(--editor-border);border-radius:5px;background:var(--editor-panel);color:var(--editor-text);font:14px/1.5 "Segoe UI","Microsoft Himalaya",sans-serif;text-overflow:clip}
nav.toolbar #project-filename::placeholder{color:var(--editor-muted);opacity:1}
@media(max-width:480px){.project-save-group{flex-basis:min(100%,300px);max-width:100%}}
.board-connection-body .druk-board-cards{margin:8px 0;gap:10px;grid-template-columns:repeat(3,minmax(0,1fr))}
.board-connection-body .druk-board-card{gap:4px;padding:8px!important;text-align:center}
.board-connection-body .druk-board-card img{height:95px;aspect-ratio:auto}
.board-connection-body .druk-board-options{margin:6px 0}
#nano-bootloader{display:flex;gap:12px}
#nano-bootloader button{display:flex;align-items:center;justify-content:center;gap:10px;flex:1;min-height:48px;border:2px solid var(--editor-border);font:16px/1.5 "Segoe UI",sans-serif}
#nano-bootloader button[aria-checked="true"]{border-color:#225deb;background:#e8efff;color:#172b3f}
.nano-check{width:18px;font-weight:bold}
.board-actions{justify-content:flex-end;padding-top:8px;background:var(--editor-panel)}
.board-actions button{min-height:44px}
@media(max-width:600px){.board-connection-body .druk-board-card img{height:60px}.board-connection-body .druk-board-card strong{font-size:16px}#nano-bootloader button{gap:5px;flex-wrap:wrap}.board-actions{position:sticky;bottom:0}}
/* Keep connection actions reachable while advanced/error content scrolls. */
html .board-actions{position:sticky;bottom:0;z-index:1;margin-bottom:0;padding-bottom:4px;box-shadow:0 -5px 8px var(--editor-panel)}
html .board-actions button{min-height:44px}

/* 010: block-only white labels; editable fields have an opaque dark surface. */
g.blocklyBlock .blocklyText{fill:#fff!important}
.blocklyBlock .blocklyFieldRect{fill:#223248!important;fill-opacity:1!important}
g.blocklyBlock .blocklyDropdownArrow{fill:#fff!important}
g.blocklyDisabled>path.blocklyPath{fill:#536174!important;fill-opacity:1!important}
g.blocklyDisabled:not(.blocklySelected)>path.blocklyPath{stroke:#b8c5d6;stroke-dasharray:4 3}
html .blocklyWidgetDiv .blocklyHtmlInput{color:#fff!important;background:#223248!important;caret-color:#fff;opacity:1}
.blocklyWidgetDiv .blocklyHtmlInput::selection{color:#fff;background:#235aab}
html header #language-select,html[lang="dz"] header #language-select{width:180px;min-width:180px;font-family:"Segoe UI","Microsoft Himalaya",sans-serif!important;font-size:18px!important;line-height:1.6;min-height:42px}

g.blocklyBlock:is(.blocklyShadow,.math_number,.text)>path.blocklyPath{fill:#223248!important}

