*{box-sizing:border-box;margin:0;padding:0}
body{font-family:system-ui,-apple-system,sans-serif;background:#1e1e2e;color:#cdd6f4;height:100vh;overflow:hidden}
button{font-family:inherit}

/* toolbar */
#toolbar{display:flex;align-items:center;justify-content:space-between;padding:.5rem 1rem;background:#181825;border-bottom:1px solid #313244;height:52px;gap:1rem;flex-wrap:nowrap;overflow-x:auto}
.toolbar-left,.toolbar-center,.toolbar-right{display:flex;align-items:center;gap:.4rem;flex-shrink:0}
.toolbar-left strong{margin-right:.75rem;color:#89b4fa;white-space:nowrap}
.sep{width:1px;height:22px;background:#313244;margin:0 .25rem}
.btn,.btn-sm{border:none;border-radius:6px;cursor:pointer;font-size:.85rem;padding:.4rem .85rem;background:#313244;color:#cdd6f4;transition:.15s;white-space:nowrap}
.btn-sm{padding:.35rem .6rem;font-size:.8rem}
.btn:hover,.btn-sm:hover{background:#45475a}
.btn.primary{background:#89b4fa;color:#1e1e2e;font-weight:600}
.btn.success{background:#a6e3a1;color:#1e1e2e;font-weight:600}
.btn-sm.warn{background:#f38ba8;color:#1e1e2e}
.dev-btn.active{background:#89b4fa;color:#1e1e2e}
select{background:#313244;color:#cdd6f4;border:1px solid #45475a;border-radius:6px;padding:.3rem .5rem;font-size:.85rem}
.save-status{font-size:.75rem;color:#a6adc8;min-width:90px;text-align:right}
.save-status.saving{color:#f9e2af}
.save-status.saved{color:#a6e3a1}
.save-status.error{color:#f38ba8}
.save-status.dirty{color:#f9e2af}

/* workspace layout */
#workspace{display:flex;height:calc(100vh - 52px)}
#leftPanel,#rightPanel{width:260px;flex-shrink:0;background:#181825;border-right:1px solid #313244;display:flex;flex-direction:column;overflow:hidden}
#rightPanel{border-right:none;border-left:1px solid #313244}
.panel-tabs{display:flex;border-bottom:1px solid #313244}
.ptab{flex:1;background:none;border:none;color:#a6adc8;padding:.6rem;cursor:pointer;font-size:.8rem;border-bottom:2px solid transparent}
.ptab.active{color:#89b4fa;border-bottom-color:#89b4fa}
.panel-pane{display:none;overflow-y:auto;flex:1;padding:.75rem}
.panel-pane.active{display:block}

/* blocks palette */
.block-cat{font-size:.7rem;text-transform:uppercase;color:#6c7086;margin:.75rem 0 .35rem;letter-spacing:.05em}
.block-cat:first-child{margin-top:0}
.block-grid{display:grid;grid-template-columns:1fr 1fr;gap:.5rem}
.block-item{background:#313244;border-radius:8px;padding:.6rem .4rem;text-align:center;font-size:.72rem;cursor:grab;user-select:none;border:1px solid transparent}
.block-item:hover{background:#45475a;border-color:#89b4fa}
.block-item .bi{font-size:1.3rem;display:block;margin-bottom:.25rem}

/* layers */
.layer-tree{font-size:.8rem}
.layer-node{padding:.3rem .4rem;border-radius:4px;cursor:pointer;display:flex;align-items:center;gap:.3rem;white-space:nowrap}
.layer-node:hover{background:#313244}
.layer-node.selected{background:#45475a;color:#89b4fa}
.layer-children{margin-left:1rem;border-left:1px dashed #313244;padding-left:.4rem}
.layer-toggle{width:14px;display:inline-block;cursor:pointer;color:#6c7086}

/* canvas */
#canvasArea{flex:1;background:#11111b;display:flex;align-items:center;justify-content:center;overflow:auto;padding:1rem}
#canvasFrame{background:#fff;transition:width .2s;height:100%;box-shadow:0 0 0 1px #313244;position:relative}
#canvasFrame.device-desktop{width:100%;max-width:100%}
#canvasFrame.device-tablet{width:768px;max-width:768px}
#canvasFrame.device-mobile{width:375px;max-width:375px}
#canvasIframe{width:100%;height:100%;border:none;display:block}

/* selection outline injected into iframe via JS, plus overlay toolbar */
.sel-toolbar{position:fixed;z-index:5000;display:flex;gap:2px;background:#89b4fa;border-radius:6px;overflow:hidden;box-shadow:0 2px 8px rgba(0,0,0,.4)}
.sel-toolbar.hidden{display:none}
.sel-toolbar button{background:#89b4fa;color:#1e1e2e;border:none;padding:.3rem .5rem;cursor:pointer;font-size:.85rem}
.sel-toolbar button:hover{background:#74a8f7}

/* style form */
.style-sector{margin-bottom:.5rem;border:1px solid #313244;border-radius:8px;overflow:hidden}
.style-sector-head{background:#1e1e2e;padding:.5rem .6rem;font-size:.78rem;color:#a6adc8;cursor:pointer;display:flex;justify-content:space-between}
.style-sector-body{padding:.6rem;display:none;background:#181825}
.style-sector.open .style-sector-body{display:block}
.style-row{display:flex;align-items:center;gap:.4rem;margin-bottom:.5rem}
.style-row label{flex:0 0 78px;font-size:.72rem;color:#a6adc8}
.style-row input[type=text],.style-row input[type=number],.style-row select{flex:1;background:#313244;color:#cdd6f4;border:1px solid #45475a;border-radius:4px;padding:.25rem .4rem;font-size:.78rem;width:100%}
.style-row input[type=color]{width:36px;height:26px;padding:0;border:1px solid #45475a;border-radius:4px;background:#313244}
.style-row input[type=range]{flex:1}

/* traits form */
.trait-row{margin-bottom:.6rem}
.trait-row label{display:block;font-size:.72rem;color:#a6adc8;margin-bottom:.25rem}
.trait-row input,.trait-row textarea,.trait-row select{width:100%;background:#313244;color:#cdd6f4;border:1px solid #45475a;border-radius:4px;padding:.35rem .5rem;font-size:.8rem}

/* modal */
.modal{position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:9999;display:flex;align-items:center;justify-content:center}
.modal.hidden{display:none}
.modal-content{background:#1e1e2e;border:1px solid #313244;border-radius:12px;width:90%;max-width:760px;max-height:85vh;overflow:auto;padding:1.5rem;position:relative}
.modal-close{position:absolute;top:.75rem;right:1rem;font-size:1.5rem;cursor:pointer;color:#a6adc8}
.modal h2{margin-bottom:1rem;color:#89b4fa}
.modal h3{margin-bottom:.75rem;color:#89b4fa}
.list-item{display:flex;justify-content:space-between;align-items:center;padding:.6rem;border-bottom:1px solid #313244}
.list-item:hover{background:#313244}
.badge{font-size:.7rem;padding:.15rem .4rem;border-radius:4px;background:#45475a}
#upload-area{border:2px dashed #45475a;border-radius:8px;padding:2rem;text-align:center;cursor:pointer;margin:1rem 0}
#upload-area:hover,#upload-area.dragover{border-color:#89b4fa;background:#313244}
.asset-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:.75rem}
.asset-card{background:#313244;border-radius:8px;overflow:hidden;text-align:center;font-size:.75rem}
.asset-card img{width:100%;height:80px;object-fit:cover}
.asset-card .asset-actions{display:flex;gap:.25rem;padding:.35rem}
.asset-card .asset-actions .btn-sm{flex:1;padding:.25rem}
.modal input[type=text],.modal input[type=search],.modal textarea,.modal select{width:100%;padding:.5rem;background:#313244;border:1px solid #45475a;border-radius:6px;color:#cdd6f4;margin-bottom:.75rem;font-family:inherit}
.modal label{display:block;margin-bottom:.25rem;font-size:.85rem;color:#a6adc8}
.modal textarea.code{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.8rem;min-height:260px;white-space:pre}
.empty-state{padding:2rem 1rem;text-align:center;color:#6c7086;font-size:.85rem}

::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:#313244;border-radius:5px}
::-webkit-scrollbar-thumb:hover{background:#45475a}
