*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;font:16px system-ui,sans-serif;color:#18253a;background:#f5f7fa}button,a{font:inherit}button{min-height:44px;border:1px solid #ccd5e1;background:white;border-radius:9px;color:#18253a;padding:8px 12px;cursor:pointer}button:disabled{color:#77818e;background:#e9edf2;cursor:default}.primary{background:#243e60;color:white;border-color:#243e60}a{color:#243e60}h1{font-size:22px;margin:0}h2{font-size:18px}p,small{color:#526174}.screen[hidden]{display:none!important}.screen{height:100dvh;padding:12px;padding-bottom:max(12px,env(safe-area-inset-bottom));padding-top:max(12px,env(safe-area-inset-top))}.home{display:grid;place-items:center}.home-card{width:min(100%,460px);background:white;border:1px solid #dce3eb;border-radius:16px;padding:24px}.home-card h1{margin-top:16px}.home-card button{width:100%;margin-bottom:12px}.workspace{display:flex;flex-direction:column;gap:10px;max-width:1600px;margin:auto}header,footer{display:flex;gap:8px;align-items:center;flex-shrink:0}header h1{margin-left:8px}.tools button{flex:1;min-width:0;padding:6px 2px;font-size:clamp(11px,2.9vw,16px)}.stage{min-height:0;min-width:0;flex:1;display:grid;place-items:center;overflow:hidden;background:#fff;border:1px solid #dce3eb;border-radius:12px}.placeholder{text-align:center;color:#526174;border:2px dashed #aab8c8;border-radius:8px;width:min(90%,560px);height:90%;display:flex;flex-direction:column;justify-content:center}.prepare-body{display:flex;flex:1;min-height:0;gap:10px}aside{width:320px;padding:16px;background:white;border:1px solid #dce3eb;border-radius:12px;overflow:auto}.actions{display:grid;grid-template-columns:repeat(6,minmax(0,1fr))}.actions button{font-size:14px;padding:6px 2px}footer>.primary{flex:1}.mobile-only{display:none}@media(max-width:767px){.prepare-body{flex-direction:column}.mobile-only{display:inline-block}aside{display:none;width:100%;max-height:40%;flex-shrink:0}.prepare-body.editing aside{display:block}.prepare-body.editing .stage{overflow:auto;display:block}.prepare-body.editing .placeholder{height:360px;margin:12px auto}.actions{grid-template-columns:repeat(3,minmax(0,1fr))}.actions button{font-size:12px}}@media(max-height:420px){.screen{padding:6px;gap:5px}button{min-height:32px}.actions{grid-template-columns:repeat(6,minmax(0,1fr))}}
.setup{display:grid;place-items:center;overflow:auto}.setup .home-card{max-height:100%;overflow:auto}.setup h1{margin:12px 0}.step[hidden],.preview[hidden]{display:none!important}.step label{display:block;margin:8px 0}.step input,.step select{width:100%;font:inherit;min-height:40px}.step button{margin-top:10px}.choices{display:flex;gap:10px}.choices>*{flex:1;min-width:0}.preview{height:min(30dvh,240px);display:grid;place-items:center;background:#eef1f5;margin-top:10px}.preview img{max-width:100%;max-height:100%;min-height:0;object-fit:contain}.board{position:relative;flex:none;overflow:hidden;isolation:isolate}.board img,.board canvas{position:absolute;inset:0;width:100%;height:100%;display:block}.board img{object-fit:fill}.board canvas{pointer-events:none}.prepare-body.editing .board{margin:0 auto}footer button{min-width:0;font-size:clamp(11px,3vw,15px)}

.palette{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:5px;margin:8px 0}.palette .swatch{height:30px;min-height:30px;padding:0;margin:0;border:1px solid #aaa;border-radius:4px}.palette .swatch[aria-pressed=true]{outline:2px solid #2563eb;outline-offset:1px}fieldset{min-width:0;border:0;padding:0;margin:0}fieldset:disabled{opacity:.5}#editor label{display:block;margin:8px 0 3px}#editor textarea,#editor input{width:100%;font:inherit}#editor button:not(.swatch){margin-top:8px}#decor-preview{max-width:100%;max-height:80px;object-fit:contain}#blank-fields[hidden],#decor-preview[hidden]{display:none!important}#prepare-board{cursor:pointer}#prepare footer{flex-wrap:wrap}#editor{flex-shrink:0}
/* Stage 5: independently scrolling board and editor. */
#prepare .prepare-body{min-width:0;overflow:hidden}
#editor{display:flex;flex-direction:column;gap:8px;width:clamp(260px,32%,360px);padding:12px;min-height:0;overflow:hidden}
.editor-heading{display:flex;align-items:center;justify-content:space-between;flex-shrink:0}.editor-heading h2{margin:0}.editor-heading button{margin:0!important}
#selection-label{margin:0;flex-shrink:0;font-size:13px}
#panel-fields{flex:1;overflow:auto;min-height:0;padding:4px;overscroll-behavior:contain}
.editor-bottom{flex-shrink:0;display:flex;align-items:center;gap:8px}.editor-bottom button{flex:1;margin:0!important}#apply-status{font-size:12px;color:#206344}
#open-editor[hidden]{display:none!important}
@media(max-width:767px){
#editor{display:none;width:100%;max-height:min(48dvh,390px);flex:0 0 auto;padding:8px}
.prepare-body.editing #editor{display:flex}
.prepare-body.editing #prepare-stage{overflow:auto;display:block;overscroll-behavior:contain;scrollbar-gutter:auto;touch-action:pan-y}
.prepare-body.editing #prepare-board{margin:0 auto;touch-action:pan-y}
#prepare footer{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}#prepare footer button{padding:4px;min-height:38px}#prepare footer #start{grid-column:1/-1}
#editor .palette{gap:4px}#editor .palette .swatch{min-height:26px;height:26px}
}
@media(min-width:768px){#editor{max-height:none}#prepare-stage{overflow:hidden}}

#run-board{touch-action:none;user-select:none;cursor:pointer}#run-board img{-webkit-user-drag:none;pointer-events:none}#toggle-mode[data-operation=open]:not(:disabled){background:#235b91;color:white}#toggle-mode[data-operation=close]:not(:disabled){background:#a53c39;color:white}

#lock[aria-pressed=true]{background:#a53c39;color:#fff;border-color:#a53c39}#wake[aria-pressed=true]:not(:disabled){background:#235b91;color:#fff}#wake-status{font-size:12px;margin:0;color:#9a3412;flex-shrink:0}#wake-status[hidden]{display:none}#storage-status{position:fixed;bottom:8px;left:8px;right:8px;z-index:20;background:#fff4d5;color:#713f12;border:1px solid #d6a64a;border-radius:8px;padding:8px;font-size:13px;pointer-events:none}#storage-status[hidden]{display:none}

#export-status{font-size:12px;margin:0;flex-shrink:0}#export-status[hidden]{display:none}#export-preview{max-width:90vw;max-height:90dvh;border:1px solid #ccd5e1;border-radius:12px}#export-preview-img{display:block;max-width:100%;max-height:60dvh;margin:auto}#export-preview a,#export-preview button{display:block;margin:12px auto}
