@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Share+Tech+Mono&family=Exo+2:wght@300;400;600&display=swap');

/* ── Planner CSS variables + root layout (replaces body in standalone version) ── */
#map-editor-root {
    --bg-deep:      #0a0d13;
    --bg-panel:     #0f1520;
    --bg-card:      #141c2b;
    --bg-hover:     #1a2438;
    --border:       #1e2d45;
    --border-bright:#2a4060;
    --accent:       #3b82f6;
    --accent2:      #f59e0b;
    --danger:       #ef4444;
    --success:      #22c55e;
    --text:         #c8d8f0;
    --text-dim:     #556b8a;
    --text-bright:  #e8f0ff;

    font-family: 'Exo 2', sans-serif;
    background:  var(--bg-deep);
    color:       var(--text);
    display:     flex;
    flex:        1;
    overflow:    hidden;
    user-select: none;
    min-height:  0; /* allow flex shrink inside site-main */
}

#map-editor-root * { box-sizing: border-box; margin: 0; padding: 0; }

/* SIDEBAR */
#map-editor-root #sidebar{width:260px;min-width:260px;background:var(--bg-panel);border-right:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden;z-index:10;}
#map-editor-root #sidebar-header{padding:14px 16px;border-bottom:1px solid var(--border);background:linear-gradient(135deg,#0d1829,#111d30);}
#map-editor-root #sidebar-header h1{font-family:'Rajdhani',sans-serif;font-size:1.25rem;font-weight:700;color:var(--text-bright);letter-spacing:2px;text-transform:uppercase;}
#map-editor-root #sidebar-header p{font-size:0.7rem;color:var(--text-dim);letter-spacing:1px;margin-top:2px;font-family:'Share Tech Mono',monospace;}
#map-editor-root #autosave-indicator{font-size:.6rem;font-family:'Share Tech Mono',monospace;color:var(--success);margin-top:4px;opacity:0;transition:opacity .4s;}
#map-editor-root #autosave-indicator.show{opacity:1;}
#map-editor-root #elements-list{overflow-y:auto;flex:1;padding:4px 0 12px;}
#map-editor-root #elements-list::-webkit-scrollbar{width:4px;}
#map-editor-root #elements-list::-webkit-scrollbar-thumb{background:var(--border-bright);border-radius:2px;}
#map-editor-root .el-cat{padding:8px 12px 4px;}
#map-editor-root .el-cat-lbl{font-family:'Share Tech Mono',monospace;font-size:.62rem;letter-spacing:2px;color:var(--accent);text-transform:uppercase;margin-bottom:4px;opacity:.8;display:flex;align-items:center;justify-content:space-between;}
#map-editor-root .el-item{display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:0;cursor:grab;border:1px solid transparent;margin-bottom:3px;transition:all .15s;background:var(--bg-card);}
#map-editor-root .el-item:hover{background:var(--bg-hover);border-color:var(--border-bright);transform:translateX(2px);}
#map-editor-root .el-item:active{cursor:grabbing;opacity:.7;}
#map-editor-root .el-icon{width:32px;height:32px;border-radius:0;display:flex;align-items:center;justify-content:center;font-family:'Rajdhani',sans-serif;font-weight:700;font-size:.9rem;flex-shrink:0;}
#map-editor-root .el-info{flex:1;min-width:0;}
#map-editor-root .el-name{font-size:.82rem;font-weight:600;color:var(--text-bright);font-family:'Rajdhani',sans-serif;letter-spacing:.5px;}
#map-editor-root .el-size{font-size:.65rem;color:var(--text-dim);font-family:'Share Tech Mono',monospace;}
#map-editor-root .el-note{font-size:.6rem;color:var(--accent2);font-family:'Share Tech Mono',monospace;margin-top:1px;}
#map-editor-root .el-item .cust-acts{display:flex;gap:3px;opacity:0;transition:opacity .15s;flex-shrink:0;}
#map-editor-root .el-item:hover .cust-acts{opacity:1;}
#map-editor-root .cust-act{width:18px;height:18px;border:1px solid var(--border-bright);background:var(--bg-deep);color:var(--text-dim);font-size:9px;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:0;padding:0;transition:all .12s;flex-shrink:0;}
#map-editor-root .cust-act:hover{color:var(--text-bright);border-color:var(--accent);}
#map-editor-root .cust-act.del:hover{border-color:var(--danger);color:var(--danger);}

/* TOOLBAR */
#map-editor-root #toolbar{display:flex;align-items:center;gap:6px;padding:7px 12px;background:var(--bg-panel);border-bottom:1px solid var(--border);flex-shrink:0;flex-wrap:wrap;}
#map-editor-root .tg{display:flex;align-items:center;gap:4px;padding:0 8px;border-right:1px solid var(--border);}
#map-editor-root .tg:last-child{border-right:none;margin-left:auto;}
#map-editor-root .tb{padding:5px 10px;border-radius:0;border:1px solid var(--border);background:var(--bg-card);color:var(--text);font-family:'Rajdhani',sans-serif;font-size:.8rem;font-weight:600;letter-spacing:.5px;cursor:pointer;transition:all .15s;white-space:nowrap;}
#map-editor-root .tb:hover{background:var(--bg-hover);border-color:var(--accent);color:var(--text-bright);}
#map-editor-root .tb.success{background:#14532d;border-color:var(--success);color:var(--success);}
#map-editor-root .tb.success:hover{background:#166534;color:#fff;}
#map-editor-root .tb.warn{border-color:#b45309;color:#f59e0b;}
#map-editor-root .tb.warn:hover{background:#451a03;color:var(--accent2);}
#map-editor-root .tb.pan-active{background:var(--accent);border-color:var(--accent);color:#fff;}
#map-editor-root #zoom-display{font-family:'Share Tech Mono',monospace;font-size:.75rem;color:var(--accent);min-width:48px;text-align:center;}
#map-editor-root #coord-display{font-family:'Share Tech Mono',monospace;font-size:.72rem;color:var(--text-dim);min-width:130px;}
#map-editor-root .tb-hint{font-family:'Share Tech Mono',monospace;font-size:.65rem;color:var(--text-dim);}

/* MAIN */
#map-editor-root #main{flex:1;display:flex;flex-direction:column;overflow:hidden;}
#map-editor-root #canvas-container{flex:1;overflow:hidden;position:relative;background:radial-gradient(ellipse at center,#0e1828 0%,#080c12 100%);}
#map-editor-root #canvas-container.mode-pan{cursor:grab;}
#map-editor-root #canvas-container.mode-pan.panning{cursor:grabbing;}
#map-editor-root #canvas-container.mode-select{cursor:default;}
#map-editor-root #canvas-container.mode-paint{cursor:none;}
#map-editor-root #canvas-container.mode-gridfill{cursor:crosshair;}
#map-editor-root #sel-box{display:none;position:absolute;border:1.5px dashed #60a5fa;background:rgba(96,165,250,.08);pointer-events:none;z-index:8000;}
#map-editor-root .map-element.multi-selected{border-color:#f59e0b!important;border-width:2px!important;}
#map-editor-root .gridfill-ghost{position:absolute;pointer-events:none;border:1px solid rgba(16,185,129,.7);background:rgba(16,185,129,.15);z-index:7000;}
#map-editor-root #gridfill-rect{display:none;position:absolute;border:1.5px dashed rgba(16,185,129,.8);background:rgba(16,185,129,.06);pointer-events:none;z-index:7500;}
#map-editor-root #gridfill-bar{display:none;position:fixed;bottom:12px;left:50%;transform:translateX(-50%);background:rgba(10,13,19,.92);border:1px solid #10b981;color:#10b981;font-family:'Share Tech Mono',monospace;font-size:.7rem;padding:6px 14px;letter-spacing:1px;z-index:500;pointer-events:none;gap:12px;align-items:center;}
#map-editor-root #gridfill-bar.show{display:flex;}
#map-editor-root #paint-indicator{display:none;position:fixed;bottom:12px;right:12px;background:rgba(16,185,129,.15);border:1px solid #10b981;color:#10b981;font-family:'Share Tech Mono',monospace;font-size:.7rem;padding:5px 10px;letter-spacing:1px;z-index:500;pointer-events:none;}
#map-editor-root #paint-indicator.show{display:block;}
#map-editor-root .el-item.paint-active{background:rgba(16,185,129,.15)!important;border-color:#10b981!important;color:#10b981;}
#map-editor-root .el-item.paint-active .el-name{color:#10b981!important;}
#map-editor-root #ghost-el{display:none;position:absolute;pointer-events:none;z-index:9000;border:1.5px solid rgba(16,185,129,.9);transition:left .04s,top .04s;}
#map-editor-root #ghost-el .ghost-inner{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden;}
#map-editor-root #ghost-el .ghost-label{font-family:'Rajdhani',sans-serif;font-weight:700;color:#fff;text-shadow:0 1px 4px rgba(0,0,0,.9);text-align:center;line-height:1.1;}
#map-editor-root #ghost-el .ghost-sublbl{font-family:'Exo 2',sans-serif;font-weight:600;color:rgba(255,255,255,.8);text-align:center;}
#map-editor-root #ghost-el .ghost-coord{position:absolute;bottom:2px;left:3px;font-family:'Share Tech Mono',monospace;color:rgba(255,255,255,.9);line-height:1;white-space:nowrap;text-shadow:0 1px 3px rgba(0,0,0,.9);}
#map-editor-root #ghost-el .ghost-cross{position:absolute;inset:0;pointer-events:none;}
#map-editor-root #ghost-el .ghost-cross::before,#map-editor-root #ghost-el .ghost-cross::after{content:'';position:absolute;background:rgba(16,185,129,.6);}
#map-editor-root #ghost-el .ghost-cross::before{top:50%;left:0;right:0;height:1px;transform:translateY(-50%);}
#map-editor-root #ghost-el .ghost-cross::after{left:50%;top:0;bottom:0;width:1px;transform:translateX(-50%);}
#map-editor-root #map-viewport{position:absolute;transform-origin:0 0;}
#map-editor-root #grid-canvas{position:absolute;top:0;left:0;pointer-events:none;}
#map-editor-root #elements-layer{position:absolute;top:0;left:0;}

/* MAP ELEMENTS */
#map-editor-root .map-element{position:absolute;display:flex;align-items:center;justify-content:center;cursor:move;border-radius:0;flex-direction:column;overflow:visible;border:1px solid transparent;transition:border-width .08s,border-color .08s;}
#map-editor-root .map-element:hover{z-index:100!important;}
#map-editor-root .map-element.selected{border-width:2px!important;z-index:200!important;}
#map-editor-root .el-inner{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden;border-radius:0;}
#map-editor-root .el-label{font-family:'Rajdhani',sans-serif;font-weight:700;text-align:center;color:#fff;text-shadow:0 1px 4px rgba(0,0,0,.9);pointer-events:none;line-height:1.1;}
#map-editor-root .el-sublbl{font-family:'Exo 2',sans-serif;font-weight:600;color:rgba(255,255,255,.8);text-align:center;pointer-events:none;margin-top:1px;}
#map-editor-root .el-coord{position:absolute;bottom:2px;left:3px;font-family:'Share Tech Mono',monospace;color:rgba(255,255,255,.85);pointer-events:none;line-height:1;white-space:nowrap;text-shadow:0 1px 3px rgba(0,0,0,.9);}
#map-editor-root .el-del{position:absolute;top:-1px;right:-1px;width:13px;height:13px;border-radius:0;background:rgba(239,68,68,.9);border:none;color:#fff;font-size:8px;display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;transition:opacity .15s;z-index:10;line-height:1;}
#map-editor-root .el-edt{position:absolute;top:-1px;right:14px;width:13px;height:13px;border-radius:0;background:rgba(59,130,246,.9);border:none;color:#fff;font-size:8px;display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;transition:opacity .15s;z-index:10;line-height:1;}
#map-editor-root .map-element:hover .el-del{opacity:1;}
#map-editor-root .map-element:hover .el-edt{opacity:1;}
#map-editor-root .contam-ring{position:absolute;border-radius:0;pointer-events:none;border:2px dashed rgba(245,158,11,.55);background:rgba(245,158,11,.04);}

/* MODALS */
#map-editor-root .modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.72);z-index:1000;align-items:center;justify-content:center;backdrop-filter:blur(3px);}
#map-editor-root .modal-overlay.show{display:flex;}
#map-editor-root .modal{background:var(--bg-panel);border:1px solid var(--border-bright);border-radius:0;padding:24px;min-width:340px;max-width:460px;width:90%;box-shadow:0 20px 60px rgba(0,0,0,.8);max-height:90vh;overflow-y:auto;}
#map-editor-root .modal h2{font-family:'Rajdhani',sans-serif;font-weight:700;font-size:1.2rem;letter-spacing:2px;text-transform:uppercase;color:var(--text-bright);margin-bottom:16px;border-bottom:1px solid var(--border);padding-bottom:10px;}
#map-editor-root .mf{margin-bottom:14px;}
#map-editor-root .mf label{display:block;font-size:.72rem;font-family:'Share Tech Mono',monospace;color:var(--text-dim);margin-bottom:5px;letter-spacing:1px;text-transform:uppercase;}
#map-editor-root .mf input[type=text],#map-editor-root .mf input[type=number]{width:100%;padding:8px 12px;background:var(--bg-card);border:1px solid var(--border-bright);border-radius:0;color:var(--text-bright);font-family:'Share Tech Mono',monospace;font-size:.9rem;outline:none;transition:border-color .15s;}
#map-editor-root .mf input:focus{border-color:var(--accent);}
#map-editor-root .mhint{font-size:.65rem;color:var(--text-dim);font-family:'Share Tech Mono',monospace;margin-top:3px;}
#map-editor-root .ma{display:flex;gap:8px;justify-content:flex-end;margin-top:20px;}
#map-editor-root .btn{padding:8px 18px;border-radius:0;border:1px solid var(--border-bright);cursor:pointer;font-family:'Rajdhani',sans-serif;font-weight:600;font-size:.9rem;letter-spacing:.5px;transition:all .15s;}
#map-editor-root .btn-p{background:var(--accent);border-color:var(--accent);color:#fff;}
#map-editor-root .btn-p:hover{filter:brightness(1.15);}
#map-editor-root .btn-s{background:var(--bg-card);color:var(--text);}
#map-editor-root .btn-s:hover{background:var(--bg-hover);color:var(--text-bright);}
#map-editor-root .btn-reset{background:var(--bg-card);color:var(--accent2);border-color:#78350f;}
#map-editor-root .btn-reset:hover{background:#451a03;color:var(--accent2);}

/* COLOR PICKER */
#map-editor-root .swatches{display:flex;flex-wrap:wrap;gap:7px;margin-top:6px;}
#map-editor-root .swatch{width:28px;height:28px;border-radius:0;cursor:pointer;border:2px solid transparent;transition:all .1s;flex-shrink:0;}
#map-editor-root .swatch:hover{transform:scale(1.12);}
#map-editor-root .swatch.sel{border-color:#fff;box-shadow:0 0 0 2px var(--accent);}
#map-editor-root .cpick-row{display:flex;align-items:center;gap:8px;margin-top:10px;}
#map-editor-root .cpick-row label{font-size:.68rem;font-family:'Share Tech Mono',monospace;color:var(--text-dim);letter-spacing:1px;}
#map-editor-root input[type=color]{width:36px;height:28px;border:1px solid var(--border-bright);border-radius:0;background:var(--bg-card);cursor:pointer;padding:2px;}

/* CONTEXT MENU */
#map-editor-root #ctx-menu{display:none;position:fixed;background:var(--bg-panel);border:1px solid var(--border-bright);border-radius:0;padding:4px 0;min-width:200px;z-index:9999;box-shadow:0 8px 24px rgba(0,0,0,.6);}
#map-editor-root #ctx-menu.show{display:block;}
#map-editor-root .ci{padding:7px 14px;font-size:.82rem;font-family:'Rajdhani',sans-serif;font-weight:500;cursor:pointer;color:var(--text);letter-spacing:.5px;display:flex;justify-content:space-between;align-items:center;}
#map-editor-root .ci:hover{background:var(--bg-hover);color:var(--text-bright);}
#map-editor-root .ci.danger:hover{color:var(--danger);}
#map-editor-root .ci-hint{font-size:.65rem;color:var(--text-dim);font-family:'Share Tech Mono',monospace;}
#map-editor-root .cs{height:1px;background:var(--border);margin:3px 0;}

/* STATUS BAR */
#map-editor-root #statusbar{background:var(--bg-panel);border-top:1px solid var(--border);padding:4px 14px;display:flex;gap:20px;align-items:center;font-family:'Share Tech Mono',monospace;font-size:.68rem;color:var(--text-dim);flex-shrink:0;}
#map-editor-root .si span{color:var(--text);}
#map-editor-root ::-webkit-scrollbar{width:5px;height:5px;}
#map-editor-root ::-webkit-scrollbar-thumb{background:var(--border-bright);border-radius:0;}

/* MAP SLOTS PANEL */
#map-editor-root #slots-panel{border-top:1px solid var(--border);flex-shrink:0;}
#map-editor-root #slots-header{display:flex;align-items:center;justify-content:space-between;padding:7px 12px 5px;cursor:pointer;user-select:none;}
#map-editor-root #slots-header span{font-family:'Share Tech Mono',monospace;font-size:.62rem;letter-spacing:2px;color:var(--accent);text-transform:uppercase;opacity:.8;}
#map-editor-root #slots-header .slots-toggle{font-size:.7rem;color:var(--text-dim);transition:transform .2s;}
#map-editor-root #slots-header.open .slots-toggle{transform:rotate(180deg);}
#map-editor-root #slots-list{display:none;padding:0 8px 8px;}
#map-editor-root #slots-list.open{display:block;}
#map-editor-root .slot-item{display:flex;align-items:center;gap:6px;padding:5px 7px;border:1px solid var(--border);background:var(--bg-card);margin-bottom:4px;cursor:pointer;transition:all .15s;position:relative;}
#map-editor-root .slot-item:hover{background:var(--bg-hover);border-color:var(--border-bright);}
#map-editor-root .slot-item.active{border-color:var(--accent);background:rgba(59,130,246,.12);}
#map-editor-root .slot-item.active::before{content:'';position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--accent);}
#map-editor-root .slot-thumb{width:40px;height:28px;background:var(--bg-deep);border:1px solid var(--border);flex-shrink:0;overflow:hidden;position:relative;}
#map-editor-root .slot-thumb canvas{position:absolute;top:0;left:0;}
#map-editor-root .slot-info{flex:1;min-width:0;}
#map-editor-root .slot-name{font-family:'Rajdhani',sans-serif;font-weight:600;font-size:.78rem;color:var(--text-bright);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
#map-editor-root .slot-meta{font-family:'Share Tech Mono',monospace;font-size:.58rem;color:var(--text-dim);margin-top:1px;}
#map-editor-root .slot-actions{display:flex;gap:3px;opacity:0;transition:opacity .15s;}
#map-editor-root .slot-item:hover .slot-actions{opacity:1;}
#map-editor-root .slot-btn{width:18px;height:18px;border:1px solid var(--border-bright);background:var(--bg-hover);color:var(--text-dim);font-size:9px;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:0;transition:all .15s;}
#map-editor-root .slot-btn:hover{color:var(--text-bright);}
#map-editor-root .slot-btn.del:hover{border-color:var(--danger);color:var(--danger);}
#map-editor-root #btn-slot-new{width:100%;padding:5px;border:1px dashed var(--border-bright);background:transparent;color:var(--text-dim);font-family:'Rajdhani',sans-serif;font-weight:600;font-size:.75rem;letter-spacing:.5px;cursor:pointer;transition:all .15s;margin-top:2px;border-radius:0;}
#map-editor-root #btn-slot-new:hover{border-color:var(--accent);color:var(--accent);background:rgba(59,130,246,.06);}

/* ALIGNMENT GUIDES */
#map-editor-root .align-guide{position:absolute;pointer-events:none;z-index:8500;}
#map-editor-root .align-guide.h{left:0;right:0;height:1px;background:rgba(96,165,250,.6);}
#map-editor-root .align-guide.v{top:0;bottom:0;width:1px;background:rgba(96,165,250,.6);}

/* NOTE TOOLTIP */
#map-editor-root .el-note-icon{position:absolute;bottom:-1px;right:-1px;width:10px;height:10px;background:var(--accent2);clip-path:polygon(100% 0,100% 100%,0 100%);pointer-events:none;z-index:5;}
#map-editor-root .el-note-tooltip{display:none;position:fixed;background:#1a2438;border:1px solid var(--accent2);color:var(--text-bright);font-family:'Exo 2',sans-serif;font-size:.75rem;padding:6px 10px;max-width:220px;z-index:9998;pointer-events:none;white-space:pre-wrap;line-height:1.4;box-shadow:0 4px 16px rgba(0,0,0,.6);}

/* MISC */
#map-editor-root .tb:disabled{opacity:.35;cursor:not-allowed;}
#map-editor-root .tb:disabled:hover{background:var(--bg-card);border-color:var(--border);color:var(--text);}
#map-editor-root .bulk-hint{font-size:.68rem;color:var(--text-dim);font-family:'Share Tech Mono',monospace;margin-top:4px;font-style:italic;}
#map-editor-root .bulk-hint b{color:var(--accent2);}

/* Textarea inside modal */
#map-editor-root .mf textarea{width:100%;padding:8px 12px;background:var(--bg-card);border:1px solid var(--border-bright);border-radius:0;color:var(--text-bright);font-family:'Exo 2',sans-serif;font-size:.82rem;outline:none;resize:vertical;transition:border-color .15s;}
#map-editor-root .mf textarea:focus{border-color:var(--accent);}
