* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "Microsoft YaHei", sans-serif;
  background: #1e1e1e;
  color: #d4d4d4;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 顶栏 */
.app { display: flex; flex: 1; min-height: 0; }
.footer {
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #007acc;
  border-top: 1px solid #3e3e42;
  color: #fff;
  font-size: 12px;
}

/* 侧边栏树 */
.tree-panel {
  width: 420px;
  background: #252526;
  border-right: 1px solid #3e3e42;
  display: flex;
  flex-direction: column;
}
.tree-header {
  padding: 12px 16px;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tree-header h2 { font-size: 16px; color: #e0e0e0; }
.tree-actions { display: flex; gap: 6px; }

.tree-container { flex: 1; overflow-y: auto; padding: 8px; }
.tree-container::-webkit-scrollbar { width: 8px; }
.tree-container::-webkit-scrollbar-thumb { background: #424242; border-radius: 4px; }

.tree-node { user-select: none; }
.tree-node-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  gap: 4px;
}
.tree-node-row:hover { background: #2a2d2e; }
.tree-node-row.selected { background: #094771; }
.tree-toggle {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 10px;
  color: #888;
  flex-shrink: 0;
}
.tree-toggle.empty { visibility: hidden; }
.tree-label {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #d4d4d4;
}
.tree-label .type-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.type-0 { background: #3e3e42; color: #888; }
.type-1 { background: rgba(14,99,156,0.25); color: #4fc1ff; }
.type-2 { background: rgba(45,125,50,0.25); color: #89d185; }
.type-3 { background: rgba(204,102,0,0.25); color: #e8a33d; }
.type-4 { background: rgba(114,46,209,0.25); color: #c586f7; }
.type-5 { background: rgba(235,47,150,0.25); color: #f78dc4; }

.tree-children { margin-left: 20px; border-left: 1px solid #3e3e42; padding-left: 4px; }

.node-actions { display: none; gap: 3px; }
.tree-node-row:hover .node-actions { display: flex; }

/* 右侧编辑面板 */
.edit-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
}
.edit-header {
  padding: 12px 20px;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.edit-header h2 { font-size: 16px; color: #e0e0e0; }
.edit-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.edit-body::-webkit-scrollbar { width: 8px; }
.edit-body::-webkit-scrollbar-thumb { background: #424242; border-radius: 4px; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #bbb;
}
.form-group label .hint {
  font-weight: normal;
  color: #666;
  font-size: 12px;
  margin-left: 6px;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #3e3e42;
  border-radius: 4px;
  font-size: 13px;
  transition: border .2s;
  background: #252526;
  color: #d4d4d4;
}
.form-control:focus {
  outline: none;
  border-color: #0e639c;
  box-shadow: 0 0 0 2px rgba(14,99,156,.3);
}
textarea.form-control {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.options-editor {
  border: 1px solid #3e3e42;
  border-radius: 4px;
  padding: 12px;
  background: #252526;
}
.option-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.option-row input { flex: 1; }
.option-row .opt-key { width: 90px; }

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #555;
  font-size: 14px;
}

/* 按钮 */
.btn {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
}
.btn-primary { background: #0e639c; color: #fff; }
.btn-primary:hover { background: #1177bb; }
.btn-success { background: #097120; color: #fff; }
.btn-success:hover { background: #0a8025; }
.btn-danger { background: #a1260d; color: #fff; }
.btn-danger:hover { background: #c42b1a; }
.btn-default { background: #3e3e42; color: #ccc; border: 1px solid #4e4e52; }
.btn-default:hover { background: #4e4e52; color: #fff; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

.readonly-field {
  background: #1a1a1a !important;
  color: #666 !important;
  cursor: not-allowed;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #252526;
  border: 1px solid #3e3e42;
  border-radius: 8px;
  width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 12px 20px;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 15px; color: #e0e0e0; }
.modal-close {
  cursor: pointer;
  font-size: 20px;
  color: #888;
  border: none;
  background: none;
}
.modal-close:hover { color: #fff; }
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-body textarea {
  width: 100%;
  height: 400px;
  font-family: "Consolas", monospace;
  font-size: 12px;
  border: 1px solid #3e3e42;
  border-radius: 4px;
  padding: 10px;
  resize: none;
  background: #1e1e1e;
  color: #d4d4d4;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #3e3e42;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* CodeMirror 暗色适配 */
.modal-body .CodeMirror {
  height: 400px;
  font-size: 12px;
  font-family: "Consolas", "Courier New", monospace;
  border: 1px solid #3e3e42;
  border-radius: 4px;
}
.CodeMirror-gutters { background: #1e1e1e !important; border-right: 1px solid #3e3e42 !important; }
.CodeMirror-linenumber { color: #666 !important; }

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #097120;
  color: #fff;
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 2000;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.error { background: #a1260d; }

/* 移动节点弹窗 */
.move-tree { max-height: 450px; overflow-y: auto; border: 1px solid #3e3e42; border-radius: 4px; padding: 8px; }
.move-tree::-webkit-scrollbar { width: 8px; }
.move-tree::-webkit-scrollbar-thumb { background: #424242; border-radius: 4px; }
.move-tree-node { user-select: none; }
.move-tree-row {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  gap: 6px;
  font-size: 13px;
  color: #d4d4d4;
}
.move-tree-row:hover { background: #2a2d2e; }
.move-tree-row.disabled { color: #555; cursor: not-allowed; }
.move-tree-row.disabled:hover { background: transparent; }
.move-tree-row.current { background: rgba(204,102,0,0.15); color: #e8a33d; font-weight: 600; }
.move-tree-toggle {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #888; flex-shrink: 0;
}
.move-tree-toggle.empty { visibility: hidden; }
.move-tree-label { flex: 1; }
.move-tree-children { margin-left: 18px; border-left: 1px solid #3e3e42; padding-left: 4px; }
.move-tree-root { font-weight: 600; color: #4fc1ff; }
