/* ===== 在线思维流程绘图工具页样式（原创） ===== */

.tool-main {
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 18px;
  padding: 22px 20px 32px;
  align-items: start;
}

/* ---- 左侧工具栏 ---- */
.tool-panel { padding: 16px; position: sticky; top: 76px; }
.panel-block { margin-bottom: 16px; }
.panel-block:last-of-type { margin-bottom: 8px; }
.panel-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.type-switch { display: flex; gap: 8px; flex-wrap: wrap; }
.type-switch .btn { border: 1px solid var(--line); background: #fff; color: var(--text); flex: 1; white-space: nowrap; }
.type-switch .btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.type-select {
  width: 100%; padding: 8px 10px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--primary); border-radius: 8px; background: #fff;
  color: var(--ink); cursor: pointer;
}
.type-select:focus { outline: 2px solid rgba(31,78,140,.35); }
.btn-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-grid .btn { flex: 1 1 calc(50% - 8px); white-space: nowrap; }
.btn-grid .btn:disabled { opacity: .45; cursor: not-allowed; }
#btn-connect.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.panel-hint { font-size: 12.5px; color: var(--muted); line-height: 1.8; border-top: 1px dashed var(--line); padding-top: 10px; }

/* ---- 右侧画布 ---- */
.canvas-wrap {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}
#canvas {
  display: block;
  margin: 0 auto; /* 居中且溢出时仍可横向滚动 */
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  flex: none;
  user-select: none;
}
#canvas.connecting { cursor: crosshair; }

/* SVG 内部元素样式（由 JS 创建，class 在此定义） */
.node { cursor: move; }
.node .node-body { fill: #fdf7ea; stroke: var(--accent); stroke-width: 1.6; }
.node.shape-cloud .node-body { fill: #eef4fc; stroke: var(--primary); }
.node.selected .node-body { stroke: #c0392b; stroke-width: 2.4; }
.node.connect-src .node-body { stroke: #2e8b57; stroke-width: 2.6; stroke-dasharray: 6 3; }
.node text { font-size: 13px; fill: var(--ink); font-family: var(--font); pointer-events: none; }
.edge path.edge-line { stroke: var(--primary); stroke-width: 1.8; fill: none; }
.edge path.edge-hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.edge.selected path.edge-line { stroke: #c0392b; stroke-width: 2.6; }
.and-gate { fill: #fff; stroke: var(--primary); stroke-width: 1.6; }

/* 节点四方向快捷操作柄（悬停节点时显示） */
.node-handle { opacity: 0; transition: opacity .15s; cursor: crosshair; }
.node:hover .node-handle { opacity: 1; }
.node-handle:hover { fill: #eef4fc; }
.node-handle-plus { opacity: 0; transition: opacity .15s; user-select: none; }
.node:hover .node-handle-plus { opacity: 1; }
.link-temp { pointer-events: none; }

/* ---- 节点文字编辑弹框 ---- */
.node-editor {
  position: fixed;
  z-index: 150;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  padding: 10px;
  width: 240px;
}
.node-editor textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.node-editor textarea:focus { outline: 2px solid rgba(31,78,140,.35); border-color: var(--primary); }
.node-editor-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---- 我的图抽屉 ---- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,25,40,.4); z-index: 120; }
.drawer {
  position: absolute; top: 0; right: 0; height: 100%;
  width: 340px; max-width: 90vw;
  border-radius: 0; display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { color: var(--ink); font-size: 17px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px 18px; }
.drawer-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 30px 0; }
.diagram-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.diagram-item:hover { border-color: var(--primary); background: #f4f8fd; }
.diagram-item .di-title { font-weight: 600; color: var(--ink); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.diagram-item .di-type { font-size: 11px; background: var(--primary); color: #fff; border-radius: 4px; padding: 0 6px; }
.diagram-item .di-type.ec { background: var(--accent); }
.diagram-item .di-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; align-items: center; }
.diagram-item .di-del { border: none; background: none; color: #c0392b; cursor: pointer; font-size: 12.5px; padding: 2px 4px; }
.diagram-item .di-del:hover { text-decoration: underline; }

/* ---- 响应式：手机端上下堆叠 ---- */
@media (max-width: 860px) {
  .tool-main { grid-template-columns: 1fr; }
  .tool-panel { position: static; }
}
