.mind-map-page {
  --map-bg: #f5f7fb;
  --map-grid: rgba(100, 116, 139, 0.13);
  --map-line: #94a3b8;
  --map-card: #ffffff;
  --map-text: #172033;
  --map-muted: #64748b;
  --map-border: rgba(148, 163, 184, 0.42);
  color: var(--map-text);
}

.mind-map-page[data-theme="calm"] {
  --map-bg: #f3f7f7;
  --map-grid: rgba(71, 85, 105, 0.09);
  --map-line: #87a5a1;
}

.mind-map-page[data-theme="contrast"] {
  --map-bg: #0f172a;
  --map-grid: rgba(255, 255, 255, 0.08);
  --map-line: #cbd5e1;
  --map-card: #ffffff;
  --map-text: #0f172a;
  --map-muted: #475569;
  --map-border: rgba(255, 255, 255, 0.5);
}

.mind-map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.mind-map-eyebrow {
  margin: 0 0 5px;
  color: #0284c7;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mind-map-header h1 {
  margin: 0;
  color: #0f172a;
  font-size: clamp(25px, 3vw, 38px);
  font-weight: 800;
  letter-spacing: -0.035em;
}

.mind-map-lead {
  max-width: 760px;
  margin: 7px 0 0;
  color: #64748b;
  font-size: 14px;
}

.mind-map-header-actions,
.mind-map-toolbar,
.mind-map-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mind-map-secondary-action,
.mind-map-toolbar button {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.mind-map-secondary-action {
  padding: 9px 13px;
  white-space: nowrap;
}

.mind-map-secondary-action:hover,
.mind-map-toolbar button:hover {
  border-color: #7dd3fc;
  background: #f0f9ff;
  color: #0369a1;
}

.mind-map-shell {
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 52px rgba(15, 23, 42, 0.08);
}

.mind-map-toolbar {
  position: relative;
  z-index: 5;
  justify-content: space-between;
  padding: 11px 13px;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.96);
}

.mind-map-toolbar button {
  min-width: 34px;
  padding: 8px 10px;
  cursor: pointer;
}

.mind-map-zoom {
  min-width: 44px;
  color: #64748b;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.mind-map-search {
  position: relative;
  width: min(330px, 42vw);
}

.mind-map-search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: #94a3b8;
  stroke-linecap: round;
  stroke-width: 1.8;
  transform: translateY(-50%);
}

.mind-map-search input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 12px 8px 35px;
  background: #f8fafc;
  color: #1e293b;
  font-size: 13px;
  outline: none;
}

.mind-map-search input:focus {
  border-color: #38bdf8;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.mind-map-stage {
  position: relative;
  height: min(72vh, 760px);
  min-height: 520px;
  overflow: hidden;
  background-color: var(--map-bg);
  background-image: radial-gradient(circle, var(--map-grid) 1px, transparent 1.2px);
  background-size: 22px 22px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.mind-map-stage.is-dragging { cursor: grabbing; }

.mind-map-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
  will-change: transform;
}

.mind-map-lines,
.mind-map-nodes {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.mind-map-lines path {
  fill: none;
  stroke: var(--edge-color, var(--map-line));
  stroke-linecap: round;
  stroke-width: 2.2;
  opacity: 0.68;
  vector-effect: non-scaling-stroke;
}

.mind-map-node {
  position: absolute;
  display: flex;
  align-items: center;
  width: 218px;
  min-height: 54px;
  border: 1px solid color-mix(in srgb, hsl(var(--branch-hue) 72% 48%) 35%, var(--map-border));
  border-left: 5px solid hsl(var(--branch-hue) 72% 48%);
  border-radius: 12px;
  background: var(--map-card);
  box-shadow: 0 7px 18px rgba(15, 23, 42, 0.1);
  cursor: default;
  transition: box-shadow 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.mind-map-page[data-density="compact"] .mind-map-node {
  width: 190px;
  min-height: 44px;
  border-radius: 9px;
}

.mind-map-page[data-density="spacious"] .mind-map-node {
  width: 245px;
  min-height: 64px;
  border-radius: 14px;
}

.mind-map-page[data-theme="calm"] .mind-map-node {
  --branch-hue: 182 !important;
  border-left-color: #4f8f8a;
}

.mind-map-page[data-theme="contrast"] .mind-map-node {
  border-color: #0f172a;
  border-left-color: #0f172a;
  box-shadow: 0 8px 0 rgba(15, 23, 42, 0.16);
}

.mind-map-node:hover,
.mind-map-node:focus-within {
  z-index: 3;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.17);
  transform: translateY(-2px);
}

.mind-map-node.is-root {
  border: 0;
  background: linear-gradient(135deg, #0369a1, #0ea5e9);
  color: #fff;
  box-shadow: 0 12px 30px rgba(2, 132, 199, 0.3);
}

.mind-map-node.is-post {
  border-left-style: dashed;
  background: color-mix(in srgb, var(--map-card) 92%, hsl(var(--branch-hue) 80% 92%));
}

.mind-map-node.is-match {
  outline: 4px solid rgba(250, 204, 21, 0.58);
  outline-offset: 3px;
}

.mind-map-node.is-dimmed { opacity: 0.2; }

.mind-map-node-link {
  display: block;
  min-width: 0;
  flex: 1;
  padding: 10px 8px 10px 12px;
  color: inherit;
  text-decoration: none;
  user-select: text;
}

.mind-map-node-title {
  display: -webkit-box;
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.mind-map-node-meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  color: var(--map-muted);
  font-size: 10px;
}

.mind-map-node.is-root .mind-map-node-meta { color: rgba(255, 255, 255, 0.76); }

.mind-map-node-toggle {
  display: grid;
  width: 27px;
  height: 27px;
  margin-right: 9px;
  flex: 0 0 27px;
  place-items: center;
  border: 1px solid color-mix(in srgb, hsl(var(--branch-hue) 72% 48%) 35%, #cbd5e1);
  border-radius: 50%;
  background: #fff;
  color: #475569;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.mind-map-node.is-root .mind-map-node-toggle {
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.mind-map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px 18px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  transform: translate(-50%, -50%);
}

.mind-map-hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 4;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.84);
  color: #64748b;
  font-size: 10px;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

@media (max-width: 760px) {
  .mind-map-header { flex-direction: column; }
  .mind-map-header-actions { width: 100%; }
  .mind-map-toolbar { align-items: stretch; flex-direction: column; }
  .mind-map-search { width: 100%; }
  .mind-map-toolbar-group { overflow-x: auto; padding-bottom: 2px; }
  .mind-map-stage { height: 67vh; min-height: 470px; }
  .mind-map-hint { display: none; }
}
