:root {
  --accent: #2f6bff;
  --accent-weak: #eaf0ff;
  --bg: #ffffff;
  --panel-bg: #ffffff;
  --border: #e2e8f0;
  --text: #2c3e50;
  --text-2: #7a8699;
  --danger: #e5484d;
  --shadow: 0 2px 12px rgba(31, 45, 61, 0.12);
  --shadow-sm: 0 1px 4px rgba(31, 45, 61, 0.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", Avenir, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #f2f4f7;
  overflow: hidden;
}
.hidden { display: none !important; }

/* ---------- 顶部工具栏 ---------- */
.topbar {
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.tb-left, .tb-right { display: flex; align-items: center; }
.tb-right { gap: 10px; }
.brand { font-weight: 700; color: var(--accent); margin-right: 4px; white-space: nowrap; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 10px; }
.tb-group { display: flex; align-items: center; gap: 4px; }

.btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #2053e0; color: #fff; }
.btn.block { width: 100%; }
.icon-btn { padding: 0; width: 30px; font-size: 17px; }
.caret { font-size: 11px; opacity: 0.7; }
.zoom-val { font-size: 12px; min-width: 48px; text-align: center; color: var(--text-2); }

.sel-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.sel {
  height: 30px;
  min-width: 110px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  padding: 0 8px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.sel:focus { border-color: var(--accent); }

.dropdown { position: relative; }

/* ---------- 通用菜单 ---------- */
.menu {
  position: absolute;
  min-width: 150px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 2000;
}
.menu-item {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.menu-item:hover { background: var(--accent-weak); color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: #fdecec; color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 8px; }
#exportMenu { top: 34px; right: 0; }
#ctxMenu { position: fixed; left: 0; top: 0; z-index: 3000; }

/* ---------- 主区域 ---------- */
#main { display: flex; height: calc(100% - 44px); }
#canvasWrap {
  position: relative;
  flex: 1;
  min-width: 0;
  background: #fff;
}
#mindMapContainer { width: 100%; height: 100%; }
#mindMapContainer > * { margin: 0; padding: 0; }
#mindMapContainer svg { display: block; }

/* 节点操作条 */
#nodeBar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 6px 10px;
  z-index: 100;
  max-width: calc(100% - 40px);
  flex-wrap: wrap;
  justify-content: center;
}
.nbtn {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.nbtn:hover { background: var(--accent-weak); color: var(--accent); }
.nbtn.primary { background: var(--accent); color: #fff; }
.nbtn.primary:hover { background: #2053e0; color: #fff; }
.nbtn.danger:hover { background: #fdecec; color: var(--danger); }
.nsep { width: 1px; height: 16px; background: var(--border); margin: 0 2px; }

/* ---------- 右侧面板 ---------- */
#sidebar {
  display: flex;
  width: 300px;
  flex: none;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
}
#sidebar.collapsed { width: 34px; }
.tabs {
  width: 34px;
  flex: none;
  background: #f8fafc;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
  gap: 4px;
}
.tab {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  color: var(--text-2);
}
.tab:hover { background: var(--accent-weak); color: var(--accent); }
.tab.active { background: var(--accent); color: #fff; }
#sideBody { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 12px 24px; }
#sidebar.collapsed #sideBody { display: none; }

.panel-hd {
  font-size: 12px;
  color: var(--text-2);
  margin: 14px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.panel-hd:first-child { margin-top: 2px; }
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}
.row > label { width: 44px; flex: none; color: var(--text-2); }
.row .sel { flex: 1; min-width: 0; }
.range { flex: 1; min-width: 0; accent-color: var(--accent); }
.val { width: 26px; flex: none; text-align: right; font-size: 12px; color: var(--text-2); }
.color { width: 30px; height: 28px; padding: 1px; border: 1px solid var(--border); border-radius: 4px; background: #fff; cursor: pointer; }
.mini-btn {
  width: 30px; height: 28px; border: 1px solid var(--border); background: #fff;
  border-radius: 4px; cursor: pointer; font-weight: 700; color: var(--text);
}
.mini-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.row.actions { margin-top: 18px; }

.empty-tip { font-size: 13px; color: var(--text-2); padding: 40px 8px; text-align: center; }

/* 列表(结构/主题) */
.item-list { display: flex; flex-direction: column; gap: 4px; }
.item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
}
.item:hover { border-color: var(--accent); color: var(--accent); }
.item.active { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.item .dot {
  width: 14px; height: 14px; flex: none;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
}
.item .nm { flex: 1; }

/* ---------- 对话框 ---------- */
#dlgMask {
  position: fixed; inset: 0;
  background: rgba(31, 45, 61, 0.4);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dlg {
  width: 420px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.dlg-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.dlg-body { font-size: 13px; }
.dlg-body label { display: block; color: var(--text-2); margin: 10px 0 4px; }
.dlg-body label:first-child { margin-top: 0; }
.dlg-body input, .dlg-body textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: vertical;
}
.dlg-body input:focus, .dlg-body textarea:focus { border-color: var(--accent); }
/* 对话框内：输入框 + 图床上传按钮同行 */
.dlg-upload { display: flex; gap: 8px; align-items: stretch; }
.dlg-upload input { flex: 1; min-width: 0; }
.dlg-upload .dlg-upload-btn { flex: none; height: auto; padding: 8px 12px; white-space: nowrap; }
.dlg-ft { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- 轻提示 ---------- */
#toastBox {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  background: rgba(31, 45, 61, 0.9);
  color: #fff;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

/* 备注浮层 */
#notePop {
  position: fixed;
  z-index: 2500;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 13px;
  max-width: 320px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
