* { margin:0; padding:0; box-sizing:border-box; }
:root {
  --bg-dark: #000000;
  --bg-panel: #111214;
  --bg-item: #1e1f22;
  --bg-hover: #2b2d31;
  --bg-select: #404249;
  --border: #1e1f22;
  --text: #dbdee1;
  --text-dim: #80848e;
  --text-head: #f2f3f5;
  --accent: #5865F2;
  --accent-hover: #4752c4;
  --err: #da373c;
  --btn-blue: #5865F2;
  --toolbar-h: 40px;
  --menubar-h: 28px;
}
html, body { width:100%; height:100%; overflow:hidden; font-family:'Inter', sans-serif; font-size:13px; background:var(--bg-dark); color:var(--text); }

#menubar {
  height:var(--menubar-h); background:var(--bg-panel); display:flex; align-items:center;
  border-bottom:1px solid var(--border); padding:0 8px; position:relative; z-index:999;
}
.menu-item {
  padding:0 12px; height:100%; display:flex; align-items:center;
  cursor:pointer; font-size:13px; font-weight:500; color:var(--text-head); position:relative;
}
.menu-item:hover, .menu-item.open { background:var(--bg-hover); border-radius: 4px; }
.dropdown {
  display:none; position:absolute; top:100%; left:0;
  background:var(--bg-panel); border:1px solid var(--border); min-width:220px;
  z-index:9999; box-shadow:0 8px 16px rgba(0,0,0,0.4); border-radius:4px; padding:6px;
}
.dropdown.visible { display:block; }
.dd-item {
  padding:8px 12px; cursor:pointer; color:var(--text); font-weight:400;
  border-radius:3px; display:flex; align-items:center; justify-content:space-between;
}
.dd-item:hover { background:var(--accent); color:#fff; }
.dd-sep { height:1px; background:var(--border); margin:4px 0; }

#toolbar {
  height:var(--toolbar-h); background:var(--bg-panel); display:flex; align-items:center;
  border-bottom:1px solid var(--bg-dark); padding:0 8px; gap:4px;
}
.tb-group { display:flex; align-items:center; gap:2px; padding:0 8px; border-right:1px solid var(--border); height:24px; }
.tb-group:last-child { border-right:none; }
.tb-btn {
  width:32px; height:32px; display:flex; flex-direction:column; align-items:center;
  justify-content:center; cursor:pointer; border-radius:4px; color:var(--text-dim); gap:2px;
}
.tb-btn:hover { background:var(--bg-hover); color:var(--text); }
.tb-btn.active { background:var(--bg-select); color:var(--text-head); }
.tb-btn svg { width:16px; height:16px; }
.tb-btn span { display:none; } 
.tb-label { font-size:12px; color:var(--text-dim); padding:0 6px; font-weight:500; }
.snap-input {
  width:50px; background:var(--bg-item); border:1px solid var(--border); color:var(--text);
  padding:4px 6px; font-size:12px; outline:none; border-radius:3px; font-family:inherit;
}

#app { display:flex; flex-direction:column; height:calc(100vh - var(--menubar-h) - var(--toolbar-h)); position:relative; }
#main-content { display:flex; flex:1; overflow:hidden; flex-direction:row; background:var(--bg-dark); gap:2px; }

#explorer, #properties {
  display:flex; flex-direction:column; background:var(--bg-panel); overflow:hidden; flex:1;
}

#explorer-header, #properties-header {
  height:36px; background:var(--bg-panel); border-bottom:1px solid var(--bg-dark);
  display:flex; align-items:center; padding:0 12px; gap:8px; font-size:12px; font-weight:600; color:var(--text-head); text-transform:uppercase; letter-spacing:0.5px;
}
#explorer-search {
  height:24px; background:var(--bg-dark); border:none; color:var(--text);
  padding:0 8px; font-size:12px; outline:none; border-radius:4px; flex:1; font-family:inherit;
}

#explorer-list { flex:1; overflow-y:auto; padding:6px 0; }
.tree-node { user-select:none; }
.tree-row {
  height:26px; display:flex; align-items:center; cursor:pointer; padding-right:8px; white-space:nowrap; overflow:hidden;
}
.tree-row:hover { background:var(--bg-hover); }
.tree-row.selected { background:var(--bg-select); color:var(--text-head); }
.tree-row.drag-over { border-bottom: 2px solid var(--accent); }
.tree-indent { display:inline-block; width:20px; flex-shrink:0; }
.tree-arrow {
  width:20px; height:20px; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; color:var(--text-dim); font-size:10px; transition:transform 0.15s;
}
.tree-arrow.open { transform:rotate(90deg); }
.tree-label { font-size:13px; flex:1; overflow:hidden; text-overflow:ellipsis; padding-left:4px; }
.tree-label.editing {
  background:var(--bg-dark); border:1px solid var(--accent); outline:none;
  color:var(--text-head); padding:2px 4px; border-radius:3px;
}
.tree-node > .tree-children { display:none; }
.tree-node.expanded > .tree-children { display:block; }

#properties-list { flex:1; overflow-y:auto; padding-bottom:16px; }
.prop-section { margin-bottom: 4px; }
.prop-section-title {
  padding:6px 12px; background:var(--bg-item); font-size:11px; font-weight:600;
  color:var(--text-dim); cursor:pointer; display:flex; align-items:center; gap:6px; text-transform:uppercase;
}
.prop-section-title:hover { color:var(--text-head); }
.prop-section-title .arr { font-size:9px; }
.prop-section.collapsed .prop-rows { display:none; }
.prop-row { display:flex; min-height:28px; align-items:center; padding:2px 0; }
.prop-name {
  width:40%; padding:0 12px; font-size:12px; color:var(--text-dim); flex-shrink:0;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.prop-val { flex:1; padding:0 12px 0 0; display:flex; align-items:center; }
.prop-input {
  width:100%; background:var(--bg-dark); border:1px solid transparent; color:var(--text-head);
  font-size:12px; outline:none; font-family:inherit; padding:4px 6px; border-radius:3px; transition: border-color 0.15s;
}
.prop-input:focus { border-color:var(--accent); }
.prop-checkbox { cursor:pointer; width:14px; height:14px; accent-color:var(--accent); }
.prop-color-swatch {
  width:20px; height:20px; border-radius:3px; border:1px solid var(--border); cursor:pointer; flex-shrink:0; margin-right:6px;
}
.prop-select {
  width:100%; background:var(--bg-dark); border:none; color:var(--text-head);
  font-size:12px; outline:none; font-family:inherit; cursor:pointer; padding:4px 6px; border-radius:3px;
}

#script-editor {
  display:none; position:absolute; inset:0; background:var(--bg-dark); z-index:500; flex-direction:column;
}
#script-editor.visible { display:flex; }
#script-editor-header {
  height:40px; background:var(--bg-panel); border-bottom:1px solid var(--border);
  display:flex; align-items:center; padding:0 16px; gap:8px;
}
#script-editor-header .title { font-size:14px; font-weight:600; color:var(--text-head); flex:1; }
#script-editor-area {
  flex:1; width:100%; background:var(--bg-dark); border:none; color:#d4d4d4; font-family:'Consolas','Courier New',monospace;
  font-size:14px; resize:none; outline:none; padding:16px; line-height:1.5; overflow:auto; tab-size:4;
}

.resize-handle { width:4px; cursor:col-resize; background:transparent; flex-shrink:0; z-index:10; }
.resize-handle:hover, .resize-handle.dragging { background:var(--accent); }

#modal-overlay {
  display:none; position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:10000; align-items:center; justify-content:center;
}
#modal-overlay.visible { display:flex; }
.modal {
  background:var(--bg-panel); border:1px solid var(--border); min-width:400px; max-width:600px; width:90%; border-radius:8px; overflow:hidden; box-shadow:0 8px 24px rgba(0,0,0,0.5);
}
.modal-title {
  padding:16px; background:var(--bg-panel); display:flex; align-items:center; justify-content:space-between;
  font-size:16px; font-weight:600; color:var(--text-head); border-bottom:1px solid var(--border);
}
.modal-title button { background:none; border:none; color:var(--text-dim); cursor:pointer; font-size:16px; }
.modal-title button:hover { color:var(--text-head); }
.modal-body { padding:20px 16px; max-height:70vh; overflow-y:auto; }
.modal-footer { padding:16px; background:var(--bg-item); display:flex; gap:12px; justify-content:flex-end; }
.form-group { margin-bottom:16px; }
.form-group label { display:block; font-size:12px; font-weight:600; color:var(--text-head); margin-bottom:8px; text-transform:uppercase; letter-spacing:0.3px; }
.form-group input, .form-group textarea, .form-group select {
  width:100%; background:var(--bg-dark); border:none; color:var(--text); padding:10px; font-size:14px; outline:none; border-radius:4px; font-family:inherit;
}
.form-group input:focus, .form-group textarea:focus { outline: 1px solid var(--accent); }
.form-group textarea { resize:vertical; min-height:80px; }
.form-row { display:flex; gap:16px; }
.form-row .form-group { flex:1; }
.form-section-title { font-size:12px; font-weight:600; color:var(--text-dim); margin-bottom:12px; text-transform:uppercase; letter-spacing:0.5px; }
.text-dim { color:var(--text-dim); }

.btn { padding:8px 16px; font-size:14px; font-weight:500; border:none; cursor:pointer; border-radius:4px; font-family:inherit; transition:0.15s; }
.btn-primary { background:var(--btn-blue); color:#fff; }
.btn-primary:hover { background:var(--accent-hover); }
.btn-secondary { background:transparent; color:var(--text); }
.btn-secondary:hover { text-decoration:underline; }

.publish-target-group { display:flex; gap:12px; margin-bottom:16px; }
.publish-target-opt {
  flex:1; padding:12px; background:var(--bg-dark); border:1px solid var(--border);
  cursor:pointer; text-align:center; border-radius:4px; transition:0.15s; font-weight:500;
}
.publish-target-opt:hover { background:var(--bg-hover); }
.publish-target-opt.selected { border-color:var(--accent); background:rgba(88, 101, 194, 0.1); color:var(--accent); }

#insert-dialog .obj-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; max-height:360px; overflow-y:auto; }
.ins-obj-btn {
  padding:12px 8px; background:var(--bg-item); border:1px solid transparent; cursor:pointer; text-align:center; border-radius:4px; transition:0.15s; color:var(--text-head); font-weight:500; font-size:13px;
}
.ins-obj-btn:hover { background:var(--bg-hover); border-color:var(--border); }
.ins-filter { margin-bottom:16px; }
.ins-filter input {
  width:100%; background:var(--bg-dark); border:none; color:var(--text); padding:10px; font-size:14px; outline:none; border-radius:4px;
}
.ins-category-tabs { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:16px; }
.ins-cat-tab {
  padding:6px 12px; background:var(--bg-item); border-radius:16px; font-size:12px; font-weight:500; cursor:pointer; color:var(--text-dim); transition:0.15s;
}
.ins-cat-tab:hover, .ins-cat-tab.active { background:var(--bg-select); color:var(--text-head); }

#ctx-menu {
  display:none; position:fixed; background:var(--bg-panel); border:1px solid var(--bg-dark);
  z-index:99999; min-width:180px; box-shadow:0 8px 16px rgba(0,0,0,0.5); border-radius:4px; padding:6px;
}
#ctx-menu.visible { display:block; }
.ctx-item {
  padding:8px 12px; cursor:pointer; font-size:13px; font-weight:500; color:var(--text); border-radius:3px;
}
.ctx-item:hover { background:var(--accent); color:#fff; }
.ctx-item.danger:hover { background:var(--err); }
.ctx-sep { height:1px; background:var(--border); margin:4px 0; }

.notif {
  position:fixed; bottom:24px; right:24px; background:var(--bg-panel); border:1px solid var(--border);
  padding:12px 16px; font-size:13px; font-weight:500; color:var(--text-head); border-radius:4px;
  box-shadow:0 8px 16px rgba(0,0,0,0.4); z-index:99999; opacity:0; transition:opacity 0.25s; pointer-events:none;
}
.notif.show { opacity:1; }
.notif.success { border-left: 4px solid #23a559; }
.notif.error { border-left: 4px solid var(--err); }

::-webkit-scrollbar { width:8px; height:8px; }
::-webkit-scrollbar-track { background:var(--bg-dark); }
::-webkit-scrollbar-thumb { background:var(--bg-item); border-radius:4px; }
::-webkit-scrollbar-thumb:hover { background:var(--bg-select); }

@media (orientation: portrait) {
  #main-content { flex-direction: column; }
  .resize-handle { width: 100%; height: 4px; cursor: row-resize; }
}
