:root {
  color-scheme: light;
  --bg: #eef3f4;
  --surface: #ffffff;
  --line: #d6e1e3;
  --text: #172426;
  --muted: #5b6c72;
  --accent: #0f766e;
  --accent-soft: #dff6f2;
  --blue: #285e8f;
  --blue-soft: #e8f1f8;
  --amber: #a65f00;
  --amber-soft: #fff3df;
  --shadow: 0 14px 34px rgba(19, 40, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.canvas-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.canvas-toolbar {
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(240px, 360px) minmax(250px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: #10292d;
  color: #f5fbfb;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #d9fffb;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.brand p {
  margin: 3px 0 0;
  color: #b8c8ca;
  font-size: 12px;
}

.canvas-search {
  display: grid;
  gap: 4px;
}

.canvas-search span {
  color: #b8c8ca;
  font-size: 12px;
}

.canvas-search input {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 0 10px;
}

.chip-bar,
.zoom-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chip-bar button,
.zoom-controls button {
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #f5fbfb;
  padding: 0 9px;
  font-size: 14px;
}

.chip-bar button.active,
.chip-bar button:hover,
.zoom-controls button:hover {
  background: #e6fbf7;
  color: #0f2a2d;
}

.canvas-frame {
  min-height: 0;
  padding: 12px;
}

.canvas-inspector {
  display: none;
}

.canvas-viewport {
  position: relative;
  height: calc(100vh - 96px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(15, 118, 110, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.05) 1px, transparent 1px),
    #fbfdfd;
  background-size: 32px 32px;
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
}

.canvas-viewport.dragging {
  cursor: grabbing;
}

.canvas-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.edge-layer,
.node-layer {
  position: absolute;
  inset: 0;
}

#treatmentLayer {
  z-index: 3;
}

#needLayer,
#regimenLayer {
  z-index: 2;
}

.node-layer {
  pointer-events: none;
}

.node-layer > * {
  pointer-events: auto;
}

.edge-layer {
  pointer-events: none;
  overflow: visible;
}

.edge {
  stroke: #b7c9cd;
  stroke-width: 2.2;
  fill: none;
}

.edge.active {
  stroke: var(--accent);
  stroke-width: 3.2;
}

.need-edge.active {
  stroke: var(--amber);
}

.mind-node {
  position: absolute;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 8px 20px rgba(19, 40, 45, 0.1);
  display: grid;
  gap: 4px;
  align-content: center;
}

.toggle-mark {
  position: absolute;
  left: -13px;
  top: calc(50% - 13px);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(19, 40, 45, 0.14);
}

.toggle-mark.fixed {
  border-color: #9db9b7;
  color: #52706d;
}

.mind-node strong,
.mind-node small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
}

.mind-node strong {
  -webkit-line-clamp: 2;
}

.mind-node small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
}

.root-node {
  width: 300px;
  min-height: 132px;
  padding: 18px 24px;
  border: 2px solid var(--accent);
  background: linear-gradient(180deg, #ffffff, #edf9f7);
}

.root-node strong {
  font-size: 21px;
}

.branch-node {
  width: 220px;
  min-height: 80px;
  padding: 12px 18px;
  border-color: #a9c8c4;
  background: var(--accent-soft);
}

.branch-node strong {
  font-size: 16px;
}

.treatment-mind-node {
  width: 250px;
  min-height: 88px;
  padding: 12px 18px;
  border-radius: 18px;
  border-left: 5px solid var(--blue);
  text-align: left;
}

.mind-node:hover,
.mind-node.active,
.mind-node.matched {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14), var(--shadow);
}

.treatment-mind-node.active,
.treatment-mind-node:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.need-bubble {
  position: absolute;
  width: 250px;
  min-height: 96px;
  padding: 11px 13px;
  border: 1px solid #e7c98e;
  border-left: 5px solid var(--amber);
  border-radius: 16px;
  background: #fffaf2;
  box-shadow: 0 8px 18px rgba(80, 55, 16, 0.09);
  display: grid;
  gap: 4px;
}

.need-bubble span {
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}

.need-bubble strong {
  font-size: 15px;
}

.need-bubble small {
  color: var(--muted);
  line-height: 1.35;
}

.need-bubble.matched {
  box-shadow: 0 0 0 3px rgba(166, 95, 0, 0.14), var(--shadow);
}

.xmind-detail-panel {
  position: absolute;
  width: 380px;
  max-height: 570px;
  overflow: auto;
  border: 1px solid #bfd0d6;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.xmind-detail-panel header {
  display: grid;
  gap: 5px;
}

.xmind-detail-panel header span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.xmind-detail-panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.xmind-detail-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.regimen-section,
.need-inline-section {
  display: grid;
  gap: 8px;
}

.regimen-section h3,
.need-inline-section h3 {
  margin: 0;
  color: var(--accent);
  font-size: 14px;
}

.evidence-group {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid #e1ebee;
  border-radius: 6px;
  background: #f7fafb;
}

.evidence-group h4 {
  margin: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: baseline;
  color: var(--blue);
  font-size: 13px;
}

.evidence-group h4 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.evidence-group button {
  width: 100%;
  border: 1px solid #dbe7ea;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  padding: 8px 9px;
  line-height: 1.35;
}

.evidence-group button:hover,
.evidence-group button.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.need-inline-section div {
  padding: 9px;
  border: 1px solid #efd8aa;
  border-radius: 6px;
  background: var(--amber-soft);
}

.need-inline-section strong {
  color: var(--amber);
}

.canvas-search-results {
  margin: 0 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.canvas-search-results[hidden] {
  display: none;
}

.canvas-search-results strong {
  color: var(--text);
}

@media (max-width: 1120px) {
  .canvas-toolbar {
    grid-template-columns: 1fr;
  }

  .canvas-viewport {
    height: 70vh;
  }
}

@media (max-width: 720px) {
  .canvas-toolbar {
    padding: 10px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .chip-bar,
  .zoom-controls {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .canvas-frame {
    padding: 8px;
  }
}
