﻿:root {
  --bg: #faf7f0;
  --bg-soft: #f3eee2;
  --panel: #ffffff;
  --panel-strong: #f4f0e6;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e5dfd0;
  --line-soft: #efeadc;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --accent-soft: #d6efeb;
  --primary-mark: #ca8a04;
  --primary-mark-soft: #fef3c7;
  --blue: #2563eb;
  --red: #dc2626;
  --amber: #b7791f;
  --green: #15803d;
  --violet: #7c3aed;
  --shadow: 0 8px 22px rgb(31 41 51 / 8%);
  --shadow-soft: 0 2px 6px rgb(31 41 51 / 5%);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.005em;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.6) 0%, transparent 35%),
    radial-gradient(circle at 88% 82%, rgba(216, 203, 182, 0.45) 0%, transparent 40%);
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf6 0%, #fdf5e2 100%);
  color: var(--text);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 1px 1px rgba(124, 96, 56, 0.04);
  transition: border-color 140ms ease, background 140ms ease, transform 80ms ease, box-shadow 140ms ease;
}

button:hover {
  border-color: #b9aa96;
  background: linear-gradient(180deg, #fff8e6 0%, #fceec8 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 2px 6px rgba(124, 96, 56, 0.10);
}

button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 3px rgb(15 118 110 / 22%);
}

button:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 2px rgba(124, 96, 56, 0.12);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w, 360px) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  padding: 16px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96) 0%, rgba(248, 241, 224, 0.92) 100%);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.4) inset;
  overflow-y: auto;
}

.sidebar-resize-handle {
  position: fixed;
  top: 0;
  left: var(--sidebar-w, 360px);
  width: 8px;
  height: 100vh;
  margin-left: -4px;
  cursor: ew-resize;
  z-index: 50;
  background: transparent;
  transition: background 0.15s ease;
}
.sidebar-resize-handle:hover {
  background: rgba(15, 118, 110, 0.18);
}

.brand {
  display: block;
  padding: 0 2px 16px;
  border-bottom: 1px solid rgba(183, 168, 137, 0.42);
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand h1,
.brand p,
.panel-heading h2,
.insight-panel p {
  margin: 0;
}

.brand h1 {
  font-size: 25px;
  line-height: 1.05;
  letter-spacing: 0;
  color: #1f2933;
  font-weight: 850;
}

.brand p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  letter-spacing: 0;
}

.brand-return {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 2px 10px 2px 2px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: #43564f;
  font-size: 13.5px;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
  transition: color 140ms ease, transform 120ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.brand-return-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  background: linear-gradient(180deg, #fffefa 0%, #f3f7f2 100%);
  color: var(--accent-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 1px 2px rgba(87, 71, 44, 0.07);
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.brand-return-icon .ico {
  transform: rotate(180deg);
}

.brand-return-text {
  position: relative;
}

.brand-return:hover {
  background: rgba(15, 118, 110, 0.06);
  color: var(--accent);
}

.brand-return:hover .brand-return-icon {
  background: linear-gradient(180deg, #f7fffd 0%, #dcefeb 100%);
  transform: translateX(-1px);
}

.brand-section-tag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 24px;
  padding-left: 12px;
  border-left: 1px solid rgba(183, 168, 137, 0.72);
  color: #80683f;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

.input-panel,
.handoff-panel,
.relation-panel,
.question-panel,
.insight-panel,
.ai-prompt-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #fffdf6 0%, #fbf5e8 100%);
  padding: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(124, 96, 56, 0.04),
    0 1px 2px rgba(124, 96, 56, 0.04);
}

.node-detail-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #fffdf6 0%, #fbf5e8 100%);
  padding: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(124, 96, 56, 0.04),
    0 1px 2px rgba(124, 96, 56, 0.04);
}

.kind-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px !important;
  font-size: 11px !important;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #fff;
}
.kind-pill.kind-problem      { color: var(--violet); border-color: rgba(124,58,237,0.35); background: rgba(124,58,237,0.06); }
.kind-pill.kind-contradiction{ color: var(--red);    border-color: rgba(220,38,38,0.35);  background: rgba(220,38,38,0.06); }
.kind-pill.kind-assumption   { color: var(--amber);  border-color: rgba(183,121,31,0.4);  background: rgba(183,121,31,0.08); }
.kind-pill.kind-evidence     { color: var(--green);  border-color: rgba(21,128,61,0.35);  background: rgba(21,128,61,0.06); }
.kind-pill.kind-question     { color: var(--blue);   border-color: rgba(37,99,235,0.35);  background: rgba(37,99,235,0.06); }
.kind-pill.kind-action       { color: #ea580c;       border-color: rgba(234,88,12,0.4);   background: rgba(234,88,12,0.08); }

.nd-title {
  margin: 6px 0 12px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.nd-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 8px;
}

.nd-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #faf3e3 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.nd-stat-num {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.nd-stat-lbl {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.nd-stat.is-primary-stat .nd-stat-num {
  color: var(--primary-mark);
}

.nd-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 2px 0 8px;
  font-size: 11.5px;
  line-height: 1.4;
}
.nd-crumb {
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.nd-crumb:hover {
  background: rgba(15, 118, 110, 0.10);
  color: var(--accent-strong);
  border-color: var(--accent);
}
.nd-crumb.is-current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-strong);
  cursor: default;
}
.nd-crumb-sep {
  color: var(--muted);
  font-weight: 700;
  user-select: none;
}
.nd-crumb.kind-problem      { color: var(--violet); }
.nd-crumb.kind-contradiction{ color: var(--red); }
.nd-crumb.kind-assumption   { color: var(--amber); }
.nd-crumb.kind-evidence     { color: var(--green); }
.nd-crumb.kind-question     { color: var(--blue); }
.nd-crumb.kind-action       { color: #ea580c; }

.nd-links {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.nd-links-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.nd-links-lbl {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-weight: 700;
  margin-right: 2px;
}
.nd-link-item {
  cursor: pointer;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  transition: background 120ms ease, transform 80ms ease, border-color 120ms ease;
  text-decoration: none;
}
.nd-link-item:hover {
  background: rgba(15, 118, 110, 0.08);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.nd-link-item.kind-problem      { border-left: 3px solid var(--violet); }
.nd-link-item.kind-contradiction{ border-left: 3px solid var(--red); }
.nd-link-item.kind-assumption   { border-left: 3px solid var(--amber); }
.nd-link-item.kind-evidence     { border-left: 3px solid var(--green); }
.nd-link-item.kind-question     { border-left: 3px solid var(--blue); }
.nd-link-item.kind-action       { border-left: 3px solid #ea580c; }

/* ===== 光标语义 ===== */
.react-flow__pane                          { cursor: grab; }
.react-flow.dragging .react-flow__pane,
.react-flow__pane:active                   { cursor: grabbing; }
.react-flow__node .cognitive-node          { cursor: grab; }
.react-flow__node.dragging .cognitive-node,
.react-flow__node:active .cognitive-node   { cursor: grabbing; }
.react-flow__node .cognitive-node .node-title,
.react-flow__node .cognitive-node textarea,
.react-flow__node .cognitive-node input,
.react-flow__node .cognitive-node .node-content-render { cursor: text; }
.react-flow__node .cognitive-node .node-icon.is-clickable,
.react-flow__node .cognitive-node button,
.react-flow__node .cognitive-node .weight-slider,
.react-flow__node .cognitive-node a { cursor: pointer; }
.react-flow__handle                        { cursor: crosshair; }
.react-flow__edge-path                     { cursor: pointer; }

.input-panel label {
  display: block;
  margin-bottom: 8px;
  color: #3d4852;
  font-size: 13px;
  font-weight: 700;
}

textarea,
.relation-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 11px;
  line-height: 1.5;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(124, 96, 56, 0.06);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea:focus,
.relation-panel input:focus {
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 2px rgba(124, 96, 56, 0.04),
    0 0 0 3px rgb(15 118 110 / 15%);
}

#problemInput {
  min-height: 150px;
  resize: vertical;
}

.compact-textarea {
  min-height: 110px;
  resize: vertical;
  font-size: 12px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.wide-btn {
  width: 100%;
  margin-top: 10px;
}

.primary-btn {
  border-color: var(--accent);
  background: linear-gradient(180deg, #14a193 0%, var(--accent) 50%, var(--accent-strong) 100%);
  color: white;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 2px 8px rgba(15, 118, 110, 0.28);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.primary-btn:hover {
  border-color: var(--accent-strong);
  background: linear-gradient(180deg, #17b3a3 0%, var(--accent-strong) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 4px 12px rgba(15, 118, 110, 0.38);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-heading h2 {
  font-size: 14px;
}

.panel-heading span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.question-panel ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.question-panel li {
  color: #3d4852;
  line-height: 1.45;
  cursor: pointer;
}

.question-panel li:hover {
  color: var(--accent-strong);
}

.insight-panel p {
  color: #3d4852;
  line-height: 1.55;
}

.canvas-shell {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  min-width: 0;
  background:
    radial-gradient(circle at 25% 30%, rgba(255, 252, 240, 0.6) 0, transparent 45%),
    radial-gradient(circle at 75% 70%, rgba(216, 203, 182, 0.35) 0, transparent 50%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.31 0 0 0 0 0.24 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    #f4efe5;
  background-blend-mode: normal, normal, multiply, normal;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(252, 247, 236, 0.95) 0%, rgba(248, 241, 224, 0.85) 100%);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  padding: 10px 16px;
  min-width: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 1px 0 rgba(0, 0, 0, 0.02);
}

.toolbar-group {
  flex-wrap: wrap;
  min-width: 0;
  position: relative;
}

.toolbar-group + .toolbar-group::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
  opacity: 0.7;
}

.toolbar-group button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.35);
}

.toolbar-group button:active {
  transform: scale(0.94);
}

.toolbar-group,
.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-group button {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
  font-weight: 800;
}

.toolbar-group.project-picker {
  gap: 6px;
}

.project-select {
  height: 36px;
  min-width: 160px;
  max-width: 240px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #2c2418);
  cursor: pointer;
}

.toolbar-group.project-picker button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.status-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #faf3e3 100%);
  padding: 6px 11px;
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 1px rgba(124, 96, 56, 0.04);
}

.status-strip span.stat b {
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.status-strip span.stat .ico {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
}

.status-strip span.zoom b {
  color: var(--accent-strong);
}

.flow-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #f4efe5;
}

.react-flow {
  --xy-background-color: #f4efe5;
  --xy-edge-stroke-default: #867767;
  --xy-edge-stroke-selected-default: var(--accent);
  --xy-controls-button-background-color-default: #fffdf8;
  --xy-controls-button-background-color-hover-default: #fff6df;
  --xy-controls-button-color-default: var(--text);
  --xy-minimap-background-color-default: #fffdf8;
}

.react-flow__edge-path {
  stroke-width: 2.2;
  transition: stroke-width 140ms ease, filter 140ms ease;
}

.react-flow__edge:hover .react-flow__edge-path {
  stroke-width: 3.4;
  filter: drop-shadow(0 0 6px rgba(15, 118, 110, 0.35));
}

.react-flow__edge.selected .react-flow__edge-path {
  stroke-width: 3.2;
  filter: drop-shadow(0 0 4px rgba(15, 118, 110, 0.5));
  stroke-dasharray: 6 3;
  animation: edge-march 800ms linear infinite;
}

@keyframes edge-march {
  to { stroke-dashoffset: -18; }
}

.react-flow__edge.selected .react-flow__edge-textbg {
  fill: #fffaef;
}

.react-flow__edge.selected .react-flow__edge-text {
  fill: var(--accent-strong);
}

.react-flow__edge-textbg {
  fill: #f4efe5;
}

.react-flow__edge-text {
  fill: #5f554a;
  font-size: 12px;
  font-weight: 700;
}

.cognitive-node {
  width: 280px;
  min-height: 180px;
  border: 3px solid var(--node-border, #94a3b8);
  border-width: var(--node-border-w, 3px);
  border-radius: 16px;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 12px 32px -8px rgba(15, 23, 42, 0.10);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 8px;
  transition: box-shadow 220ms ease, transform 220ms ease;
}

.node-weight-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 26px;
  height: 18px;
  border: none;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.85);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--node-header-fg, #334155);
  padding: 0;
  z-index: 5;
  -moz-appearance: textfield;
  appearance: textfield;
}
.node-weight-badge::-webkit-outer-spin-button,
.node-weight-badge::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.node-weight-badge:focus { outline: 1px solid var(--accent); }

.node-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  --rh: var(--node-dot, rgba(15, 118, 110, 0.55));
  background:
    linear-gradient(135deg, transparent 50%, var(--rh) 50%, var(--rh) 62%, transparent 62%, transparent 72%, var(--rh) 72%, var(--rh) 84%, transparent 84%);
  z-index: 6;
  user-select: none;
}
.node-resize-handle:hover { filter: brightness(0.85); }

/* 紧凑模式：节点向上缩到标题栏高度，隐藏内容区，仍可继续拖拽尺寸 */
.cognitive-node.is-compact { min-height: 0; overflow: hidden; }
.cognitive-node.is-compact .node-content-wrap { display: none; }

/* handle 圆点跟随节点 kind 颜色 */
.cognitive-node .react-flow__handle {
  background: var(--node-border, #0f766e) !important;
  border-color: var(--node-border, #0f766e) !important;
}

.cognitive-node.is-selected {
  outline: 3px solid rgb(15 118 110 / 22%);
  animation: node-selected-pulse 2.4s ease-in-out infinite;
}

@keyframes node-selected-pulse {
  0%, 100% {
    box-shadow:
      var(--shadow),
      0 0 0 0 rgba(15, 118, 110, 0.28);
  }
  50% {
    box-shadow:
      var(--shadow),
      0 0 0 10px rgba(15, 118, 110, 0);
  }
}

/* ===== 性能模式：节点>120 关闭重型动效 ===== */
.react-flow.perf-mode .cognitive-node.is-selected {
  animation: none;
}
.react-flow.perf-mode .cognitive-node {
  transition: none;
}
.react-flow.perf-mode .cognitive-node:hover {
  transform: none;
}

.react-flow__node.edge-endpoint-hi .cognitive-node {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
  transition: outline 120ms ease;
}

.cognitive-node[data-kind="problem"] {
  --node-border: #7c3aed;
  --node-header-bg: #f5f3ff;
  --node-header-fg: #5b21b6;
  --node-dot: #7c3aed;
}

.cognitive-node[data-kind="contradiction"] {
  --node-border: #dc2626;
  --node-header-bg: #fef2f2;
  --node-header-fg: #b91c1c;
  --node-dot: #dc2626;
}

.cognitive-node[data-kind="assumption"] {
  --node-border: #d97706;
  --node-header-bg: #fffbeb;
  --node-header-fg: #92670e;
  --node-dot: #d97706;
}

.cognitive-node[data-kind="evidence"] {
  --node-border: #16a34a;
  --node-header-bg: #f0fdf4;
  --node-header-fg: #166534;
  --node-dot: #16a34a;
}

.cognitive-node[data-kind="question"] {
  --node-border: #2563eb;
  --node-header-bg: #eff6ff;
  --node-header-fg: #1d4ed8;
  --node-dot: #2563eb;
}

.cognitive-node[data-kind="action"] {
  --node-border: #ea580c;
  --node-header-bg: #fff7ed;
  --node-header-fg: #c2410c;
  --node-dot: #ea580c;
}

.node-header {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--node-header-bg, #f8fafc);
  color: var(--node-header-fg, #111827);
  border-radius: 9px;
  position: relative;
}

.node-header::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 16px;
  margin-top: -8px;
  background: var(--node-dot, #94a3b8);
  border-radius: 0 2px 2px 0;
}

.node-header .node-title {
  color: var(--node-header-fg, #111827);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.1px;
}

.node-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.node-icon.is-clickable {
  cursor: pointer;
  user-select: none;
  padding: 3px 5px;
  border-radius: 7px;
  transition: background 140ms ease, transform 120ms ease;
}
.node-icon.is-clickable:hover {
  background: var(--bg-soft);
  transform: scale(1.18);
}
.node-icon.is-clickable:active {
  transform: scale(0.92);
}

/* kind 语义化色相图标 */
.kind-svg { display: inline-flex; align-items: center; line-height: 0; }
.kind-svg svg { display: block; }
.kind-svg[data-kind="problem"] svg { color: var(--violet); }
.kind-svg[data-kind="contradiction"] svg { color: var(--red); }
.kind-svg[data-kind="assumption"] svg { color: var(--amber); }
.kind-svg[data-kind="evidence"] svg { color: var(--green); }
.kind-svg[data-kind="question"] svg { color: var(--blue); }
.kind-svg[data-kind="action"] svg { color: #ea580c; }

.node-title,
.node-kind,
.node-content {
  border: 1px solid transparent;
  outline: none;
}

.node-title {
  min-width: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}
.node-title::placeholder {
  color: #c3b9a4;
  font-weight: 600;
  font-style: italic;
}

.node-kind {
  border-radius: 999px;
  background: var(--panel-strong);
  color: #665b4e;
  padding: 3px 7px;
  font-size: 11px;
}

.node-content {
  width: 100%;
  min-height: 82px;
  margin: 0;
  resize: vertical;
  border-radius: 7px;
  background: transparent;
  color: #3d4852;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding: 8px 11px;
}

.node-title {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.node-title:focus,
.node-kind:focus,
.node-content:focus {
  border-color: var(--line);
  background: white;
}

.node-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #ebe2d5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
}

.weight-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
  cursor: help;
}

.weight-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 6px;
  background: linear-gradient(180deg, #0d8478 0%, var(--accent) 100%);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(15, 118, 110, 0.25);
  transition: background 160ms ease;
}

/* 自定义丝滑 range slider */
.weight-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right,
    var(--accent) 0%,
    var(--accent) calc((var(--w, 3) - 1) * 11.11%),
    rgba(15, 118, 110, 0.12) calc((var(--w, 3) - 1) * 11.11%),
    rgba(15, 118, 110, 0.12) 100%);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  transition: background 120ms ease;
}
.weight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.35);
  cursor: grab;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.weight-slider::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}
.weight-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.25);
  box-shadow: 0 0 0 6px rgba(15, 118, 110, 0.18), 0 2px 6px rgba(15, 118, 110, 0.35);
}
.weight-slider:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.5);
  outline-offset: 2px;
}

.node-handle {
  width: 10px;
  height: 10px;
  border: 2px solid white;
  background: var(--accent);
}

.canvas-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 360px));
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 253 248 / 92%);
  padding: 8px 14px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 45vh) minmax(0, 1fr);
  }

  .sidebar {
    height: auto;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .canvas-shell {
    min-height: 0;
  }
}

.search-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 96px;
  animation: fade-in 160ms ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.search-overlay.is-centered {
  align-items: center;
  padding-top: 0;
}

.search-modal {
  width: min(560px, 80vw);
  background: linear-gradient(180deg, #fffdf6 0%, #faf3e3 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow:
    0 32px 80px rgba(15, 23, 42, 0.32),
    0 8px 20px rgba(15, 23, 42, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popover-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.search-input {
  border: 0;
  outline: 0;
  padding: 14px 16px;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 360px;
  overflow-y: auto;
}

.search-results li {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.search-results li:hover {
  background: rgba(59, 130, 246, 0.08);
}

.search-title {
  font-weight: 600;
  color: var(--ink);
}

.search-content {
  font-size: 12px;
  color: var(--ink-dim, #64748b);
}

.ctx-menu {
  position: fixed;
  z-index: 60;
  min-width: 180px;
  max-width: 240px;
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #fffdf6 0%, #f9f1de 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow:
    0 20px 48px rgba(15, 23, 42, 0.22),
    0 4px 12px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: popover-in 140ms cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top left;
}

@keyframes popover-in {
  from { opacity: 0; transform: scale(0.92) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ctx-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  min-height: 32px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ctx-menu button .ico svg { width: 15px; height: 15px; color: var(--muted); }
.ctx-menu button:hover .ico svg { color: var(--accent); }
.ctx-menu button.danger .ico svg { color: var(--red); }

.ctx-menu button:hover {
  background: rgba(15, 118, 110, 0.08);
}

.ctx-menu button.danger {
  color: var(--red);
}

.ctx-menu button.danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

.help-modal {
  width: min(560px, 80vw);
  background: linear-gradient(180deg, #fffdf6 0%, #faf3e3 100%);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow:
    0 32px 80px rgba(15, 23, 42, 0.32),
    0 8px 20px rgba(15, 23, 42, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  padding: 22px 26px;
  max-height: 80vh;
  overflow-y: auto;
  animation: popover-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.help-modal h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.help-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.help-table td:first-child {
  width: 220px;
  font-family: "JetBrains Mono", Consolas, monospace;
  color: var(--accent-strong);
  white-space: nowrap;
}

.help-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.ctx-menu button {
  font-size: 13px;
}

.help-table td:first-child {
  font-size: 12px;
}

.help-modal h2 {
  color: var(--accent-strong);
}

/* ===== 统一美化迭代 ===== */
.input-panel,
.handoff-panel,
.relation-panel,
.question-panel,
.insight-panel {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02), 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

.input-panel:hover,
.relation-panel:hover,
.question-panel:hover,
.insight-panel:hover {
  border-color: #cdbfa9;
}button {
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}

button:active {
  transform: translateY(1px);
}

.toolbar-group button:hover {
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

/* 滚动条 */
.sidebar::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.help-modal::-webkit-scrollbar,
.ctx-menu::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.help-modal::-webkit-scrollbar-thumb,
.ctx-menu::-webkit-scrollbar-thumb {
  background: #d6cbb8;
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #b9aa96;
}

/* React Flow Controls / MiniMap 圆角统一 */
.react-flow__controls,
.react-flow__minimap {
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}

.react-flow__minimap {
  background: linear-gradient(180deg, #fffdf6 0%, #f4ead6 100%) !important;
}

.react-flow__minimap-mask {
  fill: rgba(15, 118, 110, 0.08);
  stroke: rgba(15, 118, 110, 0.45);
  stroke-width: 1.5;
}

.react-flow__minimap-node {
  fill: var(--accent);
  fill-opacity: 0.65;
  stroke: var(--accent-strong);
  stroke-width: 0.6;
}

.react-flow__controls button {
  background: linear-gradient(180deg, #fffdf6 0%, #fbf2dc 100%);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  transition: background 140ms ease, color 140ms ease;
}
.react-flow__controls button:hover {
  background: linear-gradient(180deg, #fff8e0 0%, #fceec0 100%);
  color: var(--accent-strong);
}
.react-flow__controls button svg {
  fill: currentColor;
}

/* 节点 hover 微抬升 */
.cognitive-node {
  transition: box-shadow 140ms ease, transform 140ms ease;
}

.cognitive-node:hover {
  box-shadow: 0 22px 40px rgb(31 41 51 / 16%), 0 0 0 1px rgba(15, 118, 110, 0.18);
  transform: translateY(-1px);
}

/* 主要矛盾标记 */
.cognitive-node.is-primary {
  border-top-color: var(--primary-mark);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 2px var(--primary-mark-soft),
    0 0 0 6px rgba(202, 138, 4, 0.12),
    0 0 24px rgba(202, 138, 4, 0.18);
  animation: primary-halo 2.8s ease-in-out infinite;
}
@keyframes primary-halo {
  0%, 100% {
    box-shadow:
      var(--shadow),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      0 0 0 2px var(--primary-mark-soft),
      0 0 0 6px rgba(202, 138, 4, 0.10),
      0 0 20px rgba(202, 138, 4, 0.14);
  }
  50% {
    box-shadow:
      var(--shadow),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      0 0 0 2px var(--primary-mark-soft),
      0 0 0 8px rgba(202, 138, 4, 0.18),
      0 0 32px rgba(202, 138, 4, 0.28);
  }
}
.cognitive-node.is-primary::before {
  content: "★ 主要矛盾";
  position: absolute;
  top: -10px;
  left: 10px;
  padding: 2px 9px;
  background: linear-gradient(180deg, #f5b942, var(--primary-mark));
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 6px rgba(202, 138, 4, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 0 rgba(120, 70, 0, 0.35);
  z-index: 2;
}

/* 焦点模式：非邻居淡化 */
.react-flow__node.dim-out {
  opacity: 0.25;
  filter: grayscale(0.6);
  transition: opacity 200ms ease, filter 200ms ease;
}
.react-flow__node:not(.dim-out) {
  transition: opacity 200ms ease, filter 200ms ease;
}

/* 权重视觉化：边框厚度由 inline --node-border-w 控制（按权重线性 1→4px 半步取整） */
.cognitive-node[data-weight="6"], .cognitive-node[data-weight="7"] {
  box-shadow: 0 10px 26px rgb(31 41 51 / 10%);
}
.cognitive-node[data-weight="8"], .cognitive-node[data-weight="9"], .cognitive-node[data-weight="10"] {
  box-shadow: 0 14px 32px rgb(31 41 51 / 14%);
}
.cognitive-node[data-weight="9"] .node-title,
.cognitive-node[data-weight="10"] .node-title {
  font-weight: 800;
}

/* mini-toolbar 主要矛盾按钮高亮 */
.node-mini-toolbar button.is-primary-on {
  background: var(--primary-mark);
  color: #fff;
  border-color: var(--primary-mark);
}

/* ===== 节点 mini toolbar ===== */
.node-mini-toolbar {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
  z-index: 5;
  animation: mini-toolbar-pop 140ms ease-out;
}

@keyframes mini-toolbar-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.node-mini-toolbar button {
  min-height: 28px;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  border-radius: 6px;
  background: #fffdf8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 通用 inline svg icon 容器 */
.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: currentColor;
}
.ico svg {
  display: block;
  width: 18px;
  height: 18px;
}
.toolbar-group button .ico svg { width: 17px; height: 17px; }
.node-mini-toolbar button .ico svg { width: 15px; height: 15px; }

/* save-status 状态点 */
.save-status {
  position: relative;
  padding-left: 18px !important;
}
.save-status::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  box-shadow: 0 0 0 0 transparent;
  transition: background 200ms ease, box-shadow 200ms ease;
}
.save-status.save-saved::before {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18), 0 0 6px rgba(22, 163, 74, 0.45);
}
.save-status.save-saving::before {
  background: #ca8a04;
  animation: save-pulse 1s ease-in-out infinite;
}
.save-status.save-error::before {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22), 0 0 8px rgba(220, 38, 38, 0.55);
  animation: error-shake 360ms ease-in-out;
}
@keyframes save-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(202, 138, 4, 0.55), 0 0 6px rgba(202, 138, 4, 0.5);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 6px rgba(202, 138, 4, 0), 0 0 6px rgba(202, 138, 4, 0.5);
    opacity: 0.75;
  }
}
@keyframes error-shake {
  0%, 100% { transform: translate(-0%, -50%); }
  25%      { transform: translate(-2px, -50%); }
  75%      { transform: translate(2px, -50%); }
}

.node-mini-toolbar button:hover {
  background: #fff6df;
}

.node-mini-toolbar button.danger {
  color: var(--red);
}

.node-mini-toolbar button.danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

/* ===== 节点内容 markdown 渲染 / 编辑切换 ===== */
.node-content-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 0;
  padding: 0 4px 4px;
}

.node-content-wrap .node-content {
  flex: 1 1 auto;
  width: 100%;
  margin: 0;
  resize: none;
  border-radius: 0;
  background: transparent;
  color: #2b3138;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding: 8px 12px;
  border: none;
  outline: none;
  display: block;
  box-shadow: none;
}

.node-content-render {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: #2b3138;
  border-radius: 0;
  background: transparent;
  cursor: text;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition: background 140ms ease;
  position: relative;
}

.node-content-render:hover {
  background: rgba(15, 118, 110, 0.05);
  box-shadow: inset 2px 0 0 rgba(15, 118, 110, 0.35);
}

.node-content-render .node-content-empty {
  color: var(--muted);
  font-style: italic;
}

.node-content-render > div {
  margin: 0;
}

.node-content-render ul {
  margin: 4px 0;
  padding-left: 18px;
}

.node-content-render code {
  background: rgba(15, 23, 42, 0.06);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
}

.node-content-render a {
  color: var(--blue);
  text-decoration: underline;
}

.node-image {
  display: block;
  width: calc(100% - 24px);
  max-height: 150px;
  margin: 0 12px 8px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

/* ===== AI Prompt 面板 ===== */
.ai-prompt-panel {
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}
.ai-prompt-panel.is-open {
  padding: 0;
  box-shadow:
    0 8px 20px rgba(15, 118, 110, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.ai-prompt-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #0f766e 0%, #0ea5a4 50%, #d97706 100%);
  opacity: 0.85;
  pointer-events: none;
}
.ai-prompt-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  transition: background 120ms ease;
}
.ai-prompt-toggle:hover {
  background: rgba(15, 118, 110, 0.05);
  border-radius: 0;
}
.ai-prompt-title {
  flex: 1;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  color: #0f766e;
}
.ai-prompt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #0f766e 0%, #065f5b 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.35);
}
.ai-prompt-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
.ai-prompt-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 12px 14px;
}
.ai-prompt-steps {
  list-style: none;
  margin: 0 0 4px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.06) 0%, rgba(15, 118, 110, 0.02) 100%);
  border: 1px solid rgba(15, 118, 110, 0.15);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: var(--text);
}
.ai-prompt-steps li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.5;
}
.ai-prompt-steps b {
  color: #0f766e;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.ai-prompt-textarea {
  width: 100%;
  min-height: 200px;
  max-height: 340px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fffefa 0%, #fdfbf2 100%);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(124, 96, 56, 0.08);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.ai-prompt-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 2px rgba(124, 96, 56, 0.08),
    0 0 0 3px rgba(15, 118, 110, 0.18);
}
.ai-prompt-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: stretch;
}
.ai-prompt-actions button {
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 80ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
  border: 1px solid transparent;
}
.ai-prompt-actions button:active {
  transform: translateY(1px);
}
.ai-prompt-actions .ai-prompt-copy {
  grid-column: 1 / 2;
  background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
  color: #fff;
  border-color: rgba(15, 118, 110, 0.5);
  box-shadow: 0 3px 8px rgba(15, 118, 110, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.ai-prompt-actions .ai-prompt-copy:hover {
  background: linear-gradient(180deg, #2dd4bf 0%, #14b8a6 100%);
  box-shadow: 0 5px 12px rgba(15, 118, 110, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.ai-prompt-copy-with-json {
  grid-column: 2 / 3;
  background: linear-gradient(180deg, #fffdf6 0%, #f7e8c1 100%);
  border-color: rgba(202, 154, 90, 0.45) !important;
  color: #7a4c1a;
  box-shadow: 0 3px 8px rgba(202, 154, 90, 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.ai-prompt-copy-with-json:hover {
  background: linear-gradient(180deg, #fffef9 0%, #f1d99b 100%);
  border-color: rgba(202, 154, 90, 0.70) !important;
  box-shadow: 0 5px 12px rgba(202, 154, 90, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.ai-prompt-actions > button:nth-child(3) {
  grid-column: 1 / 3;
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--line) !important;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
  font-size: 11.5px;
}
.ai-prompt-actions > button:nth-child(3):hover {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.ai-prompt-import-btn {
  width: 100%;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px dashed rgba(15, 118, 110, 0.45);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.06) 0%, rgba(15, 118, 110, 0.12) 100%);
  color: #0f766e;
  font-weight: 700;
  font-size: 12.5px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.ai-prompt-import-btn:hover {
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.10) 0%, rgba(15, 118, 110, 0.18) 100%);
  border-color: var(--accent);
  border-style: solid;
}
.ai-prompt-import-btn:active {
  transform: translateY(1px);
}

/* ===== AI Import Modal ===== */
.ai-import-modal {
  width: 600px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-import-hint {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 0;
}
.ai-import-textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(124, 96, 56, 0.08);
}
.ai-import-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 1px 2px rgba(124, 96, 56, 0.08), 0 0 0 3px rgba(15, 118, 110, 0.18);
}
.ai-import-error {
  color: #b91c1c;
  font-size: 12.5px;
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 6px;
  padding: 6px 10px;
}
.ai-import-mode {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text);
}
.ai-import-mode label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* ===== 折叠徽章 + 折叠态节点 ===== */
.collapsed-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 4;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f5b942 0%, #d97706 100%);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow:
    0 3px 8px rgba(217, 119, 6, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.collapsed-badge:hover {
  transform: scale(1.08);
  box-shadow: 0 5px 12px rgba(217, 119, 6, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.cognitive-node.is-collapsed {
  box-shadow:
    0 0 0 2px rgba(217, 119, 6, 0.45),
    0 6px 14px rgba(217, 119, 6, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.cognitive-node.is-collapsed::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  background: linear-gradient(135deg, transparent 0%, transparent 70%, rgba(217, 119, 6, 0.10) 100%);
  pointer-events: none;
}

/* ===== 自动布局 dropdown ===== */
.layout-picker {
  display: inline-flex;
  align-items: stretch;
  position: relative;
}
.layout-picker > button {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
.layout-mode-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-left: 1px solid rgba(124, 96, 56, 0.12);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background: linear-gradient(180deg, #fffdf6 0%, #fdf5e2 100%);
  padding: 0 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  min-width: 24px;
  transition: background 120ms ease, color 120ms ease;
}
.layout-mode-select:hover {
  background: linear-gradient(180deg, #fffef9 0%, #f8edcf 100%);
  color: var(--accent-strong);
}

/* ===== layout-picker dropdown ===== */
.layout-picker { position: relative; display: inline-flex; align-items: stretch; }
.layout-picker .layout-main { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.layout-picker .layout-caret {
  border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(15,76,68,0.15);
  padding: 0 6px; min-width: 22px; font-size: 12px; color: var(--ink-soft);
}
.layout-picker.is-open .layout-caret { color: var(--accent-strong); background: rgba(15,118,110,0.08); }
.layout-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
  background: #fff; border: 1px solid rgba(15,76,68,0.16); border-radius: 10px;
  box-shadow: 0 14px 36px rgba(15,76,68,0.18), 0 2px 6px rgba(15,76,68,0.08);
  padding: 6px; min-width: 260px; display: flex; flex-direction: column; gap: 2px;
}
.layout-menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 10px; border: none; background: transparent; border-radius: 6px;
  cursor: pointer; text-align: left; transition: background 0.12s;
}
.layout-menu-item:hover { background: rgba(15,118,110,0.08); }
.layout-menu-item.is-active { background: linear-gradient(180deg, rgba(15,118,110,0.12), rgba(15,118,110,0.05)); }
.layout-menu-item strong { font-size: 13px; color: var(--ink); font-weight: 600; }
.layout-menu-item.is-active strong { color: var(--accent-strong); }
.layout-menu-item span { font-size: 11px; color: var(--ink-soft); line-height: 1.4; }

/* override toolbar-group button width for layout picker */
.toolbar-group .layout-picker { width: auto; padding: 0; }
.toolbar-group .layout-picker .layout-main { width: 38px; }
.toolbar-group .layout-picker .layout-caret { width: 20px; min-width: 20px; }
.toolbar-group .layout-menu .layout-menu-item {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; height: auto; padding: 8px 10px; place-items: stretch;
}

/* fix dropdown z-index */
.layout-picker { z-index: 100; }
.layout-picker.is-open { z-index: 9999; }
.layout-menu { z-index: 9999 !important; }

/* lift toolbar above reactflow canvas so dropdown menus are visible */
.toolbar { position: relative; z-index: 1000; }

/* ============ Batch3a~6 cumulative styles (appended by agent) ============ */

/* Batch3a: node color cycle */
.cognitive-node[data-color="red"]    { --node-accent: #ef4444; border-color: rgba(239,68,68,0.55); }
.cognitive-node[data-color="orange"] { --node-accent: #f97316; border-color: rgba(249,115,22,0.55); }
.cognitive-node[data-color="amber"]  { --node-accent: #f59e0b; border-color: rgba(245,158,11,0.55); }
.cognitive-node[data-color="green"]  { --node-accent: #10b981; border-color: rgba(16,185,129,0.55); }
.cognitive-node[data-color="blue"]   { --node-accent: #3b82f6; border-color: rgba(59,130,246,0.55); }
.cognitive-node[data-color="purple"] { --node-accent: #a855f7; border-color: rgba(168,85,247,0.55); }
.cognitive-node[data-color="red"]    .node-header,
.cognitive-node[data-color="orange"] .node-header,
.cognitive-node[data-color="amber"]  .node-header,
.cognitive-node[data-color="green"]  .node-header,
.cognitive-node[data-color="blue"]   .node-header,
.cognitive-node[data-color="purple"] .node-header { background: color-mix(in srgb, var(--node-accent, currentColor) 18%, transparent); }

/* Batch3a: node shape cycle */
.cognitive-node[data-shape="rounded"] { border-radius: 22px; }
.cognitive-node[data-shape="capsule"] { border-radius: 999px; padding: 6px 18px; }
.cognitive-node[data-shape="capsule"] .node-content-wrap,
.cognitive-node[data-shape="capsule"] .node-footer,
.cognitive-node[data-shape="capsule"] .node-image { display: none !important; }
.cognitive-node[data-shape="ghost"]   { border-style: dashed; background: transparent; }

/* Batch3a: dark theme */
body[data-theme="dark"] { --paper: #1a1f2e; --ink: #e5e7eb; --ink-soft: #9ca3af; --line: #374151; --accent: #14b8a6; background: #0f1419; color: var(--ink); }
body[data-theme="dark"] .react-flow { background: #0f1419; }
body[data-theme="dark"] .react-flow__background { background: #0f1419; }
body[data-theme="dark"] .react-flow__background pattern circle,
body[data-theme="dark"] .react-flow__background pattern rect { fill: #1f2937; }
body[data-theme="dark"] .cognitive-node { background: #1f2937; color: var(--ink); }
body[data-theme="dark"] .cognitive-node .node-content-render,
body[data-theme="dark"] .cognitive-node .node-content-render > div,
body[data-theme="dark"] .cognitive-node .node-content-empty { color: var(--ink); }
body[data-theme="dark"] .cognitive-node .node-title,
body[data-theme="dark"] .cognitive-node .node-content,
body[data-theme="dark"] .cognitive-node textarea,
body[data-theme="dark"] .cognitive-node input { background: transparent; color: var(--ink); }
/* chip 标题保留 kind 深色，避免白字 on 浅色 chip 看不见 */
body[data-theme="dark"] .cognitive-node .node-header .node-title,
body[data-theme="dark"] .cognitive-node .node-header input,
body[data-theme="dark"] .cognitive-node .node-header textarea { color: var(--node-header-fg, #334155); }

/* ===== 暗色主题：快捷键说明弹窗 ===== */
body[data-theme="dark"] .help-modal {
  background: linear-gradient(180deg, #1f2937 0%, #1a202c 100%);
  border-color: #3a4256;
  color: var(--ink);
  box-shadow: 0 32px 80px rgba(0,0,0,0.55), 0 8px 20px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}
body[data-theme="dark"] .help-modal h2 { color: var(--ink); }
body[data-theme="dark"] .help-table td { border-bottom-color: #2d3344; color: var(--ink); }
body[data-theme="dark"] .help-table td:first-child { color: #7dd3c0; }
body[data-theme="dark"] .help-modal::-webkit-scrollbar-thumb { background: #3a4256; }
body[data-theme="dark"] .cognitive-node textarea:focus,
body[data-theme="dark"] .cognitive-node input:focus { background: #232a3d; }
body[data-theme="dark"] .toolbar { background: #1a1f2e; border-color: #2a3142; }
body[data-theme="dark"] .toolbar button { background: #232a3d; color: var(--ink); border-color: #3a4256; }
body[data-theme="dark"] .toolbar button:hover { background: #2a3142; }
body[data-theme="dark"] .toolbar button.is-active { background: var(--accent); color: #0f1419; }
body[data-theme="dark"] .layout-menu { background: #1f2937; border-color: #3a4256; color: var(--ink); }
body[data-theme="dark"] .layout-menu-item:hover { background: #232a3d; }
body[data-theme="dark"] .layout-menu-item.is-active { background: rgba(20,184,166,0.22); }
body[data-theme="dark"] .react-flow__minimap { background: #1a1f2e; }
body[data-theme="dark"] .react-flow__controls button { background: #232a3d; color: var(--ink); border-color: #3a4256; }
body[data-theme="dark"] .canvas-hint, body[data-theme="dark"] .save-status, body[data-theme="dark"] .stat { color: var(--ink-soft); }
/* 暗色：sidebar brand 标题渐变 + 副标题 */
body[data-theme="dark"] .brand {
  border-bottom-color: #2a3142;
}
body[data-theme="dark"] .brand h1 {
  color: #e2e8f0;
}
body[data-theme="dark"] .brand p { color: var(--ink-soft); }
body[data-theme="dark"] .brand-return { color: #cbd5e1; }
body[data-theme="dark"] .brand-return-icon {
  border-color: #334155;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(22, 31, 46, 0.95) 100%);
  color: #99f6e4;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.03),
    0 1px 2px rgba(0,0,0,0.25);
}
body[data-theme="dark"] .brand-return:hover { color: #99f6e4; }
body[data-theme="dark"] .brand-return:hover {
  background: rgba(20, 184, 166, 0.10);
}
body[data-theme="dark"] .brand-section-tag {
  border-left-color: #475569;
  color: #f8d48b;
}
/* 暗色：顶部状态条 + 底部画布提示 */
body[data-theme="dark"] .status-strip span {
  background: linear-gradient(180deg, #1f2937 0%, #1a202c 100%);
  border-color: #3a4256;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 1px 1px rgba(0,0,0,0.3);
}
body[data-theme="dark"] .status-strip span.stat b { color: var(--ink); }
body[data-theme="dark"] .canvas-hint {
  background: rgba(31, 41, 55, 0.92);
  border-color: #3a4256;
}

/* Batch4a: 4-direction handles */
.node-handle-hidden { opacity: 0; transition: opacity 120ms ease; }
.react-flow__node:hover .node-handle-hidden,
.react-flow__node.selected .node-handle-hidden { opacity: 0.55; }

/* Batch4b: drag alignment guides */
.drag-guide-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
.drag-guide { position: absolute; background: #ef4444; box-shadow: 0 0 4px rgba(239,68,68,0.5); }
.drag-guide-v { top: 0; bottom: 0; width: 1px; }
.drag-guide-h { left: 0; right: 0; height: 1px; }

.edge-relation-picker {
  background: rgba(255, 253, 246, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 12px 32px rgba(15, 23, 42, 0.18),
    0 2px 6px rgba(15, 23, 42, 0.08);
  padding: 14px 14px 12px;
  width: 320px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--ink, #1f2937);
}
.edge-relation-picker .erp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}
.edge-relation-picker .erp-title {
  flex: 1;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink, #1f2937);
  font-size: 14px;
}
.edge-relation-picker .erp-link { display: none; }
.edge-relation-picker .erp-close-x {
  border: none;
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted, #6b7280);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.edge-relation-picker .erp-close-x:hover { background: rgba(15, 23, 42, 0.12); color: var(--ink, #1f2937); }

.edge-relation-picker .erp-group {
  display: flex;
  gap: 8px;
  align-items: center;
}
.edge-relation-picker .erp-group-label {
  flex-shrink: 0;
  width: 40px;
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
  text-align: right;
  letter-spacing: 0.04em;
}
.edge-relation-picker .erp-chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.edge-relation-picker .erp-chip {
  --chip: #64748b;
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--chip);
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip) 14%, #ffffff);
  overflow: hidden;
  transition: transform 0.1s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.edge-relation-picker .erp-chip:hover {
  background: color-mix(in srgb, var(--chip) 22%, #ffffff);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.10);
}
.edge-relation-picker .erp-chip.is-active {
  background: var(--chip);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--chip) 40%, transparent);
}
.edge-relation-picker .erp-chip.is-active .erp-chip-apply { color: #ffffff; font-weight: 600; }
.edge-relation-picker .erp-chip.is-thick { border-width: 2px; }
.edge-relation-picker .erp-chip.is-thick .erp-chip-apply { font-weight: 700; letter-spacing: 0.05em; }
.edge-relation-picker .erp-chip-apply {
  padding: 2px 11px;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.3;
  color: color-mix(in srgb, var(--chip) 75%, #0f172a);
  font-weight: 600;
  display: inline-block;
  box-sizing: border-box;
  min-height: 0;
  height: auto;
  border-radius: 0;
  box-shadow: none;
}
.edge-relation-picker .erp-chip-del {
  padding: 0 6px;
  border: none;
  border-left: 1px solid color-mix(in srgb, var(--chip) 30%, transparent);
  background: transparent;
  color: color-mix(in srgb, var(--chip) 60%, transparent);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.edge-relation-picker .erp-chip-del:hover { color: #b91c1c; background: rgba(185, 28, 28, 0.08); }

/* 改名时的输入框样式 */
.edge-relation-picker .erp-chip-edit {
  background: transparent;
  border: none;
  outline: none;
  padding: 2px 8px;
  margin: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: color-mix(in srgb, var(--chip) 75%, #0f172a);
  width: 72px;
  min-width: 56px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--chip);
}
.edge-relation-picker .erp-chip.is-editing { background: color-mix(in srgb, var(--chip) 22%, #ffffff); }

.edge-relation-picker .erp-add {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.edge-relation-picker .erp-add input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink, #1f2937);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.edge-relation-picker .erp-add input:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.55);
  background: #fff;
}
.edge-relation-picker .erp-add select {
  padding: 4px 6px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink, #1f2937);
  cursor: pointer;
}
.edge-relation-picker .erp-add-btn {
  padding: 0 12px;
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.14), rgba(15, 118, 110, 0.06));
  color: var(--accent, #0f766e);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
}
.edge-relation-picker .erp-add-btn:hover { background: linear-gradient(180deg, rgba(15, 118, 110, 0.22), rgba(15, 118, 110, 0.10)); }

.edge-relation-picker .erp-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.edge-relation-picker .erp-row-label {
  flex-shrink: 0;
  width: 40px;
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
  text-align: right;
  letter-spacing: 0.04em;
}
.edge-relation-picker .erp-swatches {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.edge-relation-picker .erp-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.edge-relation-picker .erp-swatch:hover { transform: scale(1.12); box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16); }
.edge-relation-picker .erp-swatch.is-auto {
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted, #6b7280);
  font-size: 10px;
  font-weight: 700;
}
.edge-relation-picker .erp-swatch.is-active {
  outline: 2px solid rgba(15, 118, 110, 0.85);
  outline-offset: 2px;
}
.edge-relation-picker .erp-arrows {
  flex: 1;
  display: flex;
  gap: 5px;
}
.edge-relation-picker .erp-arrow {
  flex: 1;
  padding: 5px 6px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 11.5px;
  color: var(--ink, #1f2937);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.edge-relation-picker .erp-arrow:hover { background: rgba(15, 118, 110, 0.08); }
.edge-relation-picker .erp-arrow.is-active {
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.22), rgba(15, 118, 110, 0.12));
  border-color: rgba(15, 118, 110, 0.55);
  color: var(--accent, #0f766e);
  font-weight: 600;
}
.edge-relation-picker .erp-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  padding-top: 10px;
}
.edge-relation-picker .erp-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 8px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-size: 12px;
  color: var(--ink, #1f2937);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.edge-relation-picker .erp-action:hover { background: rgba(15, 118, 110, 0.10); }
.edge-relation-picker .erp-action.danger { color: #b91c1c; border-color: rgba(185, 28, 28, 0.25); }
.edge-relation-picker .erp-action.danger:hover { background: rgba(185, 28, 28, 0.10); }



/* ===== Reconnect UX: endpoint dots become the primary interactive affordance ===== */
/* Hover/connecting feedback for handles.
   IMPORTANT: DO NOT use `transform: scale(...)` on .react-flow__handle —
   it OVERWRITES ReactFlow's centering translate(...) and makes the handle
   visually jump on hover (looks like "a duplicate green dot appears
   offset from the original"). Use width/height with negative margin instead. */
.react-flow__handle {
  transition: width 0.15s, height 0.15s, margin 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.react-flow__handle-connecting {
  background: #f59e0b !important;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.3);
}
.react-flow__handle-valid {
  background: #10b981 !important;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.35);
}

/* Edge endpoint reconnect dots: visible, filled, distinct */
.react-flow__edgeupdater {
  r: 0;
  fill: transparent;
  pointer-events: none;
  transition: r 0.18s ease, fill 0.18s ease, opacity 0.18s ease;
}
/* Only show endpoint dots on the SELECTED edge (Figma / Miro style) */
.react-flow__edge.selected .react-flow__edgeupdater {
  r: 8;
  fill: #0f766e;
  stroke: #ffffff;
  stroke-width: 2;
  pointer-events: all;
  cursor: grab;
  opacity: 1;
}
.react-flow__edge.selected .react-flow__edgeupdater:hover {
  fill: #14b8a6;
  r: 11;
  cursor: grabbing;
  filter: drop-shadow(0 0 4px rgba(20, 184, 166, 0.55));
}

/* When any edge is selected, hide ALL node handles to prevent visual overlap
   with the endpoint updater dots. Handles return after deselecting.
   IMPORTANT: DO NOT use display:none — ReactFlow computes edge endpoint
   positions from handle.getBoundingClientRect(); display:none collapses the
   rect to (0,0,0,0) and the edge endpoints drift away from the node.
   Use visibility:hidden (keeps layout box) + pointer-events:none instead. */
.flow-wrap.has-edge-selected .react-flow__handle {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* During an active connect-drag, light up ALL handles as possible drop targets
   so users see where they can connect to. */
.react-flow:has(.react-flow__handle-connecting) .react-flow__handle {
  opacity: 0.9 !important;
  pointer-events: all !important;
  background: #ffffff !important;
  border: 2px solid #10b981 !important;
}
.react-flow:has(.react-flow__handle-connecting) .react-flow__handle:hover {
  background: #10b981 !important;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.35);
}

/* During an active RECONNECT drag (dragging an existing edge's endpoint),
   show all handles on all nodes as drop targets. This overrides the
   "has-edge-selected hides handles" rule because the dragged edge is still
   marked selected during reconnect. */
.flow-wrap.is-reconnecting .react-flow__handle,
.flow-wrap.is-reconnecting.has-edge-selected .react-flow__handle {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: all !important;
  background: #ffffff !important;
  border: 2px solid #10b981 !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.22);
}
.flow-wrap.is-reconnecting .react-flow__handle:hover {
  background: #10b981 !important;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.5);
}

/* Edge line feedback: bolder on hover, accent color on selected */
.react-flow__edge-path {
  transition: stroke 0.15s, stroke-width 0.15s;
}
.react-flow__edge:hover .react-flow__edge-path {
  stroke-width: 2.4;
}
.react-flow__edge.selected .react-flow__edge-path {
  stroke: #0f766e;
  stroke-width: 2.8;
}

/* Ghost connection line during reconnect: clearly visible but not loud */
.react-flow__connection-path {
  stroke: #0f766e;
  stroke-width: 2.5;
  stroke-dasharray: 6 4;
  opacity: 0.85;
}


/* ===== Apple Sonoma Glass Skin (v=28) ===========================
   Appended overrides — keeps base styles intact, swaps surfaces
   to translucent + backdrop-filter blur. Reversible by deleting
   this block.
================================================================ */
:root {
  --glass-bg: rgba(255, 253, 246, 0.62);
  --glass-bg-strong: rgba(255, 253, 246, 0.78);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-border-soft: rgba(15, 23, 42, 0.06);
  --glass-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 8px 28px rgba(15, 23, 42, 0.10),
    0 2px 6px rgba(15, 23, 42, 0.05);
  --glass-shadow-soft:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 3px 12px rgba(15, 23, 42, 0.07);
  --glass-blur: saturate(180%) blur(22px);
  --glass-blur-soft: saturate(160%) blur(14px);
}
[data-theme="dark"] {
  --glass-bg: rgba(28, 30, 38, 0.55);
  --glass-bg-strong: rgba(28, 30, 38, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-soft: rgba(255, 255, 255, 0.05);
  --glass-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 8px 28px rgba(0, 0, 0, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.30);
  --glass-shadow-soft:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 3px 12px rgba(0, 0, 0, 0.35);
}

/* --- Sidebar ----------------------------------------------------- */
.sidebar {
  background: var(--glass-bg-strong) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow-soft);
}

/* --- Top toolbar groups ----------------------------------------- */
.toolbar {
  background: transparent !important;
}
.toolbar-group {
  background: var(--glass-bg-strong) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow-soft);
  border-radius: 12px !important;
}
.toolbar-group + .toolbar-group::before {
  display: none;
}

/* --- Buttons (global glass white-frost) --------------------------
   注意：不要用 !important，否则会盖掉 .erp-swatch 内联背景色等。
   依赖 stylesheet 顺序 + 内联/更高特异性自动胜出。
   排除带内联背景色的 swatch，避免误伤调色板。 */
button:not(.erp-swatch) {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 2px rgba(15, 23, 42, 0.06);
}
button:not(.erp-swatch):hover {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 4px 12px rgba(15, 23, 42, 0.10);
}
button:not(.erp-swatch):active {
  background: rgba(255, 255, 255, 0.92);
}
[data-theme="dark"] button:not(.erp-swatch) {
  background: rgba(255, 255, 255, 0.07);
  color: #e5e7eb;
}
[data-theme="dark"] button:not(.erp-swatch):hover {
  background: rgba(255, 255, 255, 0.12);
}

/* keep accent / danger buttons distinguishable */
button.is-active:not(.erp-swatch),
.toolbar-group button.is-active {
  background: color-mix(in srgb, var(--accent) 22%, rgba(255,255,255,0.6));
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--accent-strong);
}

/* --- Search / modals --------------------------------------------- */
.search-overlay {
  background: rgba(15, 23, 42, 0.25) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.search-modal,
.search-results {
  background: var(--glass-bg-strong) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow);
}

/* --- Context menu / dropdowns ------------------------------------ */
.ctx-menu {
  background: var(--glass-bg-strong) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow);
}
.ctx-menu button {
  background: transparent !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none !important;
  box-shadow: none !important;
  min-height: 30px;
}
.ctx-menu button:hover {
  background: rgba(15, 23, 42, 0.06) !important;
}

/* --- Cognitive node cards ---------------------------------------- */
[data-theme="dark"] .cognitive-node {
  color: #e5e7eb;
}

/* --- Status bar / generic floating chips ------------------------- */
.status-chip,
.zoom-indicator,
.save-indicator {
  background: var(--glass-bg-strong) !important;
  backdrop-filter: var(--glass-blur-soft);
  -webkit-backdrop-filter: var(--glass-blur-soft);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow-soft);
}

/* --- React Flow controls (zoom in/out/fit) ----------------------- */
.react-flow__controls,
.react-flow__controls button {
  background: var(--glass-bg-strong) !important;
  backdrop-filter: var(--glass-blur-soft);
  -webkit-backdrop-filter: var(--glass-blur-soft);
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow-soft);
}

/* --- Inputs / textareas ------------------------------------------ */
input[type="text"],
input[type="search"],
textarea,
select {
  background: rgba(255, 255, 255, 0.65) !important;
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  border: 1px solid var(--glass-border) !important;
}
input[type="text"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  background: rgba(255, 255, 255, 0.92) !important;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent) !important;
}
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #e5e7eb;
}

/* --- Dark theme global bg --------------------------------------- */
[data-theme="dark"] {
  background: #14161c;
}
[data-theme="dark"] body,
[data-theme="dark"] #root {
  background:
    radial-gradient(circle at 12% 18%, rgba(80, 100, 130, 0.18) 0%, transparent 35%),
    radial-gradient(circle at 88% 82%, rgba(60, 80, 110, 0.20) 0%, transparent 40%),
    #14161c !important;
  color: #e5e7eb;
}

/* ===== End Glass Skin ========================================== */
