*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Manrope',sans-serif;font-size:13px;background:var(--bg);color:var(--text-secondary);overflow:hidden;height:100vh;width:100vw;user-select:none}
input,select,button,textarea{font-family:inherit;font-size:inherit}


/* Main layout */
.editor-wrap{margin-left:56px;height:100vh;display:flex;flex-direction:column}

/* Toolbar */
.toolbar{height:44px;background:var(--surface-800);border-bottom:1px solid var(--surface-600);display:flex;align-items:center;padding:0 12px;gap:4px;flex-shrink:0;z-index:20}
.toolbar-group{display:flex;align-items:center;gap:2px}
.toolbar-sep{width:1px;height:24px;background:var(--surface-600);margin:0 6px}
.tb{width:34px;height:34px;border:none;border-radius:8px;background:transparent;color:var(--text-primary);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .15s;position:relative}
.tb:hover{color:#fff;background:rgba(255,255,255,.08)}
.tb.active{color:var(--accent);background:var(--accent-bg)}
.tb:disabled{opacity:.3;cursor:default;pointer-events:none}
.tb svg{width:18px;height:18px}
.tb-label{font-size:11px;font-weight:500;padding:0 8px;white-space:nowrap}
.toolbar-right{margin-left:auto;display:flex;align-items:center;gap:4px}

/* Tool Options Bar */
.tool-options{height:36px;background:var(--surface-700);border-bottom:1px solid var(--surface-600);display:none;align-items:center;padding:0 12px;gap:8px;flex-shrink:0;z-index:19}
.tool-options.visible{display:flex}
.tool-options label{font-size:11px;color:var(--text-muted);white-space:nowrap}
.tool-options input[type="range"]{width:80px;accent-color:var(--accent);height:4px;cursor:pointer}
.tool-options input[type="number"]{width:60px;background:var(--surface-600);border:1px solid transparent;color:var(--text-secondary);padding:3px 6px;border-radius:5px;text-align:center;font-family:'JetBrains Mono',monospace;font-size:11px}
.tool-options input[type="number"]:focus{border-color:var(--accent);outline:none}
.tool-options select{background:var(--surface-600);border:1px solid transparent;color:var(--text-secondary);padding:3px 8px;border-radius:5px;cursor:pointer;font-size:11px}
.tool-options select:focus{border-color:var(--accent);outline:none}
.tool-options .opt-sep{width:1px;height:20px;background:var(--surface-600)}
.opt-btn{padding:3px 10px;border:1px solid var(--surface-600);border-radius:5px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:11px;transition:all .15s}
.opt-btn:hover{border-color:var(--text-muted)}
.opt-btn.primary{background:var(--accent);color:#000;border-color:var(--accent);font-weight:600}
.opt-btn.primary:hover{background:var(--accent-dim)}
.opt-toggle{padding:3px 8px;border:1px solid var(--surface-600);border-radius:5px;background:transparent;color:var(--text-muted);cursor:pointer;font-size:11px;transition:all .15s}
.opt-toggle.on{color:var(--accent);border-color:var(--accent);background:var(--accent-bg)}

/* Viewport */
.viewport{flex:1;overflow:hidden;position:relative;background:#2c2c30}
.viewport-checker{display:none}
.canvas-container{position:absolute;transform-origin:0 0;cursor:crosshair;background:#2c2c30}
.canvas-container.has-transparency{background-image:linear-gradient(45deg,#444 25%,transparent 25%),linear-gradient(-45deg,#444 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#444 75%),linear-gradient(-45deg,transparent 75%,#444 75%);background-size:16px 16px;background-position:0 0,0 8px,8px -8px,-8px 0;background-color:#333}
.canvas-container canvas{position:absolute;top:0;left:0}

/* Drop zone */
.dropzone{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:10;cursor:pointer;transition:background .2s}
.dropzone:hover{background:rgba(0,84,230,0.03)}
.dropzone.drag-over{background:rgba(0,84,230,0.06);border:2px dashed var(--accent)}
.dropzone-icon{width:64px;height:64px;border-radius:16px;background:var(--surface-700);border:2px dashed var(--surface-600);display:flex;align-items:center;justify-content:center;margin-bottom:16px;transition:all .3s}
.dropzone:hover .dropzone-icon{border-color:var(--accent);background:var(--accent-bg)}
.dropzone-icon svg{color:var(--text-muted);width:28px;height:28px}
.dropzone-text{font-size:15px;color:var(--text-secondary);margin-bottom:6px;font-weight:500}
.dropzone-hint{font-size:12px;color:var(--text-muted)}
.dropzone.hidden{display:none}

/* Status Bar */
.statusbar{height:28px;background:var(--surface-800);border-top:1px solid var(--surface-600);display:flex;align-items:center;padding:0 12px;gap:16px;flex-shrink:0;font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--text-secondary)}
.statusbar span{white-space:nowrap}
.status-accent{color:var(--accent)}

/* Export Modal */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.6);backdrop-filter:blur(4px);z-index:200;display:none;align-items:center;justify-content:center}
.modal-overlay.visible{display:flex}
.modal{background:var(--surface-700);border:1px solid var(--surface-600);border-radius:12px;padding:24px;width:380px;max-width:90vw}
.modal h3{font-size:16px;color:var(--text-primary);margin-bottom:16px;font-weight:600}
.modal-row{display:flex;align-items:center;gap:10px;margin-bottom:12px}
.modal-row label{font-size:12px;color:var(--text-muted);width:70px;flex-shrink:0}
.modal-row input,.modal-row select{flex:1;background:var(--surface-600);border:1px solid transparent;color:var(--text-secondary);padding:6px 10px;border-radius:6px;font-size:12px}
.modal-row input:focus,.modal-row select:focus{border-color:var(--accent);outline:none}
.modal-warning{font-size:11px;color:var(--warn);margin-bottom:12px;display:none}
.modal-warning.visible{display:block}
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:16px}
.modal-actions button{padding:6px 16px;border-radius:6px;border:1px solid var(--surface-600);background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px;font-weight:500;transition:all .15s}
.modal-actions button:hover{border-color:var(--text-muted)}
.modal-actions button.primary{background:var(--accent);color:#000;border-color:var(--accent)}
.modal-actions button.primary:hover{background:var(--accent-dim)}

/* Text overlay — Figma-style inline editor */
.text-overlay{position:absolute;z-index:15;display:none;pointer-events:auto;transform-origin:top left}
.text-editor{background:rgba(0,84,230,0.04);border:1.5px solid rgba(0,84,230,0.5);outline:none;padding:3px 6px;min-width:4px;min-height:1.2em;white-space:pre-wrap;word-break:break-word;cursor:text;caret-color:currentColor;user-select:text;-webkit-user-select:text;line-height:1.4;border-radius:3px;transition:border-color .15s}
.text-editor:focus{border-color:var(--accent);background:rgba(0,84,230,0.07);box-shadow:0 0 0 3px rgba(0,84,230,0.1)}
.text-editor:empty::before{content:'Введите текст…';color:rgba(255,255,255,0.25);pointer-events:none}

/* Tab Bar */
.tab-bar{height:30px;background:var(--surface-800);border-bottom:1px solid var(--surface-600);display:flex;align-items:stretch;overflow-x:auto;overflow-y:hidden;flex-shrink:0;scrollbar-width:none;z-index:18}
.tab-bar::-webkit-scrollbar{display:none}
.tab-item{display:flex;align-items:center;gap:5px;padding:0 8px 0 12px;border-right:1px solid var(--surface-600);white-space:nowrap;cursor:pointer;font-size:11px;color:var(--text-muted);flex-shrink:0;max-width:160px;transition:color .15s;position:relative}
.tab-item:hover{color:var(--text-secondary);background:rgba(255,255,255,.03)}
.tab-item.active{color:var(--text-primary);background:var(--surface-700);border-bottom:2px solid var(--accent)}
.tab-name{flex:1;overflow:hidden;text-overflow:ellipsis;min-width:40px}
.tab-close{width:16px;height:16px;border:none;background:transparent;color:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:3px;flex-shrink:0;font-size:14px;line-height:1;padding:0;transition:all .15s}
.tab-item:hover .tab-close,.tab-item.active .tab-close{color:var(--text-muted)}
.tab-close:hover{color:var(--danger)!important;background:rgba(255,82,82,.12)}
.tab-add{width:32px;border:none;background:transparent;color:var(--text-muted);cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:all .15s;border-right:1px solid var(--surface-600)}
.tab-add:hover{color:var(--text-secondary);background:rgba(255,255,255,.04)}

/* Color picker in toolbar */
.color-swatch{width:22px;height:22px;border-radius:6px;border:2px solid var(--surface-600);cursor:pointer;overflow:hidden;position:relative}
.color-swatch input{position:absolute;inset:-8px;width:calc(100% + 16px);height:calc(100% + 16px);cursor:pointer;opacity:0}

/* Crop overlay */
.crop-overlay{position:absolute;inset:0;z-index:12;display:none;pointer-events:none}
.crop-overlay.visible{display:block;pointer-events:auto}
.crop-handle{position:absolute;width:10px;height:10px;background:var(--accent);border:1px solid #000;border-radius:2px;cursor:pointer;z-index:13}

/* Context menu */
.ctx-menu{position:fixed;z-index:300;background:var(--surface-700);border:1px solid var(--surface-600);border-radius:10px;padding:4px;min-width:180px;box-shadow:0 8px 32px rgba(0,0,0,.5);display:none;backdrop-filter:blur(12px)}
.ctx-menu.visible{display:block}
.ctx-item{display:flex;align-items:center;gap:8px;padding:6px 12px;border-radius:6px;cursor:pointer;color:var(--text-secondary);font-size:12px;white-space:nowrap;transition:background .1s}
.ctx-item:hover{background:rgba(255,255,255,.06);color:var(--text-primary)}
.ctx-item.disabled{opacity:.3;pointer-events:none}
.ctx-item svg{width:15px;height:15px;flex-shrink:0;color:var(--text-muted)}
.ctx-item:hover svg{color:var(--text-secondary)}
.ctx-item .ctx-shortcut{margin-left:auto;font-size:10px;color:var(--text-muted);font-family:'JetBrains Mono',monospace}
.ctx-sep{height:1px;background:var(--surface-600);margin:4px 8px}

/* Scrollbar */
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--surface-600);border-radius:3px}

/* Layer Panel */
.layer-panel{position:absolute;right:12px;bottom:40px;width:240px;max-height:400px;background:var(--surface-800);border:1px solid var(--surface-600);border-radius:10px;z-index:15;display:none;flex-direction:column;backdrop-filter:blur(12px);overflow:hidden}
.layer-panel.visible{display:flex}
.layer-panel-header{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;border-bottom:1px solid var(--surface-600);font-size:11px;font-weight:600;color:var(--text-primary)}
.layer-panel-actions{display:flex;gap:2px}
.lpa-btn{width:28px;height:28px;border:none;border-radius:6px;background:transparent;color:var(--text-muted);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:16px;transition:all .15s;padding:0}
.lpa-btn:hover{color:var(--text-secondary);background:rgba(255,255,255,.06)}
.lpa-btn:disabled{opacity:.3;cursor:default;pointer-events:none}
.layer-list{flex:1;overflow-y:auto;padding:4px}
.layer-item{display:flex;align-items:center;gap:6px;padding:5px 6px;border-radius:6px;cursor:pointer;transition:background .1s;user-select:none}
.layer-item:hover{background:rgba(255,255,255,.04)}
.layer-item.active{background:var(--accent-bg);outline:1px solid rgba(0,84,230,.3)}
.layer-item.drag-over-top{box-shadow:0 -2px 0 var(--accent)}
.layer-item.drag-over-bottom{box-shadow:0 2px 0 var(--accent)}
.layer-vis{width:20px;height:20px;border:none;background:transparent;color:var(--text-muted);cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:4px;flex-shrink:0;font-size:12px;padding:0}
.layer-vis:hover{color:var(--text-secondary)}
.layer-vis.off{opacity:.3}
.layer-thumb{width:32px;height:32px;border-radius:4px;border:1px solid var(--surface-600);background-image:linear-gradient(45deg,#333 25%,transparent 25%),linear-gradient(-45deg,#333 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#333 75%),linear-gradient(-45deg,transparent 75%,#333 75%);background-size:8px 8px;background-position:0 0,0 4px,4px -4px,-4px 0;flex-shrink:0;overflow:hidden;position:relative}
.layer-thumb canvas{width:100%;height:100%;display:block}
.layer-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
.layer-name{font-size:11px;color:var(--text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.layer-name-input{font-size:11px;color:var(--text-secondary);background:var(--surface-600);border:1px solid var(--accent);border-radius:3px;padding:1px 4px;outline:none;width:100%;font-family:inherit}
.layer-meta{font-size:9px;color:var(--text-muted);font-family:'JetBrains Mono',monospace}
.layer-props{padding:6px 10px;border-top:1px solid var(--surface-600);display:flex;flex-direction:column;gap:5px}
.layer-props label{font-size:10px;color:var(--text-muted)}
.layer-props select{background:var(--surface-600);border:1px solid transparent;color:var(--text-secondary);padding:3px 6px;border-radius:4px;font-size:10px;cursor:pointer;width:100%;font-family:inherit}
.layer-props select:focus{border-color:var(--accent);outline:none}
.layer-props input[type="range"]{width:100%;accent-color:var(--accent);height:3px}
.lp-row{display:flex;align-items:center;gap:6px}
.lp-row label{width:55px;flex-shrink:0}
.lp-row span{font-size:10px;color:var(--text-muted);font-family:'JetBrains Mono',monospace;width:28px;text-align:right;flex-shrink:0}

@media(max-width:640px){

    .editor-wrap{margin-left:0;height:calc(100vh - 52px)}
}
