:root {
  --mindmap-bg: #ffffff;
  --mindmap-canvas-bg: #ffffff;
  --mindmap-node-bg: transparent;
  --mindmap-node-text: #16181d;
  --mindmap-node-muted: #2b2f35;
  --mindmap-node-border: #dfa12f;
  --mindmap-node-shadow: none;
  --mindmap-connector: #dfa12f;
  --mindmap-selection: #2563eb;
  --mindmap-selection-bg: rgba(37, 99, 235, 0.08);
  --mindmap-root-min-width: 6em;
  --mindmap-root-min-height: calc(1.25em + 16px);
}

:root[data-skin="classic"] {
  --mindmap-bg: #ffffff;
  --mindmap-canvas-bg: #ffffff;
  --mindmap-node-text: #16181d;
  --mindmap-node-muted: #2b2f35;
  --mindmap-node-border: #dfa12f;
  --mindmap-connector: #dfa12f;
}

:root[data-theme="dark"] {
  --mindmap-bg: #ffffff;
  --mindmap-canvas-bg: #ffffff;
  --mindmap-node-text: #16181d;
  --mindmap-node-muted: #2b2f35;
  --mindmap-node-border: #dfa12f;
  --mindmap-node-shadow: none;
  --mindmap-connector: #dfa12f;
  --mindmap-selection: #2563eb;
  --mindmap-selection-bg: rgba(37, 99, 235, 0.08);
}

:root[data-theme="dark"][data-skin="classic"] {
  --mindmap-bg: #ffffff;
  --mindmap-canvas-bg: #ffffff;
  --mindmap-node-text: #16181d;
  --mindmap-node-muted: #2b2f35;
  --mindmap-node-border: #dfa12f;
  --mindmap-connector: #dfa12f;
}

:root[data-mindmap-background="paper"] {
  --mindmap-bg: #fbf7ec;
  --mindmap-canvas-bg: #fbf7ec;
}

:root[data-mindmap-background="blue"] {
  --mindmap-bg: #eef7ff;
  --mindmap-canvas-bg: #eef7ff;
}

:root[data-mindmap-background="green"] {
  --mindmap-bg: #f0faf4;
  --mindmap-canvas-bg: #f0faf4;
}

:root[data-mindmap-background="dark"] {
  --mindmap-bg: #12151b;
  --mindmap-canvas-bg: #12151b;
  --mindmap-node-text: #f5f7fb;
  --mindmap-node-muted: #e6e9ef;
  --mindmap-node-border: #e2aa3c;
  --mindmap-connector: #e2aa3c;
  --mindmap-selection: #8bb7ff;
  --mindmap-selection-bg: rgba(139, 183, 255, 0.16);
}

.mindmap-preview-host {
  padding: 22px 26px 34px;
  background: var(--mindmap-bg);
}

.mindmap-preview {
  min-height: 100%;
  color: var(--mindmap-node-text);
  font-family: SimSun, "宋体", NSimSun, "新宋体", STSong, serif;
  font-size: 1rem;
  line-height: 1.25;
  overflow: auto;
}

.mindmap-preview-empty {
  max-width: 520px;
  margin: 18px auto 0;
  padding: 22px 24px;
  border: 1px dashed var(--mindmap-connector);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  display: grid;
  gap: 5px;
  text-align: center;
}

.mindmap-canvas {
  min-width: max-content;
  position: relative;
  display: flex;
  align-items: center;
  gap: 58px;
  padding: 18px 0;
}

.mindmap-canvas::before {
  display: none;
}

.mindmap-side {
  min-width: max-content;
}

.mindmap-side-left .mindmap-node {
  text-align: right;
}

.mindmap-center {
  min-height: var(--mindmap-root-min-height);
  min-width: var(--mindmap-root-min-width);
  padding: 8px 10px 8px 5px;
  border: 2px solid var(--mindmap-node-border);
  border-radius: 8px;
  background: transparent;
  color: var(--mindmap-node-text);
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  font-size: 1em;
  font-weight: 400;
  text-align: left;
  box-shadow: var(--mindmap-node-shadow);
  align-self: center;
  word-break: keep-all;
  white-space: nowrap;
}

.mindmap-branch-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
}

.mindmap-branch-list::before {
  content: "";
  position: absolute;
  top: 20px;
  bottom: 20px;
  width: 0;
  border-left: 2px solid var(--mindmap-connector);
  border-radius: 999px;
  pointer-events: none;
}

.mindmap-branch-list .mindmap-branch-list::after {
  content: "";
  position: absolute;
  top: -30px;
  width: 0;
  height: 30px;
  border-left: 2px solid var(--mindmap-connector);
  border-radius: 999px;
  pointer-events: none;
}

.mindmap-branch {
  display: flex;
  align-items: center;
  gap: 58px;
  position: relative;
}

.mindmap-branch::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 58px;
  border-top: 2px solid var(--mindmap-connector);
  border-radius: 999px;
  pointer-events: none;
}

.mindmap-side-left .mindmap-branch-list {
  padding-right: 58px;
}

.mindmap-side-left .mindmap-branch-list::before,
.mindmap-side-left .mindmap-branch-list .mindmap-branch-list::after {
  right: 14px;
}

.mindmap-side-left .mindmap-branch::before {
  right: 0;
}

.mindmap-side-right .mindmap-branch-list {
  padding-left: 58px;
}

.mindmap-side-right .mindmap-branch-list::before,
.mindmap-side-right .mindmap-branch-list .mindmap-branch-list::after {
  left: 14px;
}

.mindmap-side-right .mindmap-branch::before {
  left: 0;
}

.mindmap-node {
  min-width: 0;
  padding: 7px 1em 8px;
  border: 0;
  border-bottom: 2px solid var(--mindmap-node-border);
  border-radius: 0;
  background: transparent;
  color: var(--mindmap-node-text);
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  font-weight: 400;
  box-shadow: var(--mindmap-node-shadow);
  word-break: keep-all;
  white-space: nowrap;
}

.mindmap-node-menu {
  appearance: none;
  width: 15px;
  height: 11px;
  flex: 0 0 auto;
  display: inline-block;
  border: 0;
  padding: 0;
  background-color: transparent;
  opacity: 0.95;
  background:
    linear-gradient(var(--mindmap-node-muted), var(--mindmap-node-muted)) 0 1px / 12px 1px no-repeat,
    linear-gradient(var(--mindmap-node-muted), var(--mindmap-node-muted)) 0 5px / 12px 1px no-repeat,
    linear-gradient(var(--mindmap-node-muted), var(--mindmap-node-muted)) 0 9px / 8px 1px no-repeat;
  cursor: pointer;
}

.mindmap-node-menu:hover {
  opacity: 1;
  filter: brightness(0.9);
}

.mindmap-empty-branch {
  min-height: 1px;
}

.mindmap-editor {
  grid-row: 3;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 0;
  background: var(--mindmap-bg);
  color: var(--mindmap-node-text);
}

.mindmap-editor[hidden] {
  display: none;
}

.mindmap-editor .jsmind-inner {
  background: var(--mindmap-canvas-bg);
  color: var(--mindmap-node-text);
  outline: 0;
}

.mindmap-editor jmnode {
  max-width: min(360px, 44vw);
  min-width: 0;
  width: fit-content;
  padding: 7px 0.5em 8px;
  border: 0;
  border-bottom: 2px solid var(--mindmap-node-border);
  border-radius: 0;
  background: transparent;
  color: var(--mindmap-node-text);
  box-shadow: var(--mindmap-node-shadow);
  box-sizing: border-box;
  display: inline-block;
  text-align: left;
  font: 400 var(--mindmap-editor-node-size, 16px)/1.25 SimSun, "宋体", NSimSun, "新宋体", STSong, serif;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
  cursor: default;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.mindmap-editor jmnode::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 50%;
  width: 14px;
  height: 11px;
  transform: translateY(-58%);
  background:
    linear-gradient(var(--mindmap-node-muted), var(--mindmap-node-muted)) 0 1px / 12px 1px no-repeat,
    linear-gradient(var(--mindmap-node-muted), var(--mindmap-node-muted)) 0 5px / 12px 1px no-repeat,
    linear-gradient(var(--mindmap-node-muted), var(--mindmap-node-muted)) 0 9px / 8px 1px no-repeat;
  pointer-events: none;
  display: none;
}

.mindmap-editor jmnode.has-note {
  padding-right: calc(0.5em + 20px);
}

.mindmap-editor jmnode.has-note::after {
  display: block;
}

.mindmap-editor jmnode:hover {
  border-color: var(--mindmap-node-border);
  background: var(--mindmap-selection-bg);
  color: var(--mindmap-node-text);
  box-shadow: var(--mindmap-node-shadow);
}

.mindmap-editor jmnode.root,
.mindmap-editor jmnode.mindmap-root-node {
  min-width: var(--mindmap-root-min-width);
  min-height: var(--mindmap-root-min-height);
  max-width: min(420px, 52vw);
  width: fit-content;
  padding: 8px 0.5em;
  border: 2px solid var(--mindmap-node-border);
  border-radius: 8px;
  background: var(--mindmap-canvas-bg);
  color: var(--mindmap-node-text);
  border-color: var(--mindmap-node-border);
  font-size: var(--mindmap-editor-node-size, 16px);
  font-weight: 400;
  text-align: left;
}

.mindmap-editor jmnode.selected {
  border-color: var(--mindmap-selection);
  background: var(--mindmap-selection-bg);
  color: var(--mindmap-node-text);
  box-shadow: var(--mindmap-node-shadow);
}

.mindmap-editor jmnode.is-editing,
.mindmap-editor jmnode.selected.is-editing,
.mindmap-editor jmnodes jmnode.is-editing:not(.root):not(.mindmap-root-node),
.mindmap-editor jmnodes jmnode.selected.is-editing:not(.root):not(.mindmap-root-node) {
  border-color: var(--mindmap-node-border) !important;
  background: transparent !important;
  color: var(--mindmap-node-text) !important;
  box-shadow: none !important;
}

.mindmap-editor jmnode.root.is-editing,
.mindmap-editor jmnode.mindmap-root-node.is-editing,
.mindmap-editor jmnodes jmnode.root.selected.is-editing,
.mindmap-editor jmnodes jmnode.mindmap-root-node.selected.is-editing {
  border-color: var(--mindmap-node-border) !important;
  background: var(--mindmap-canvas-bg) !important;
  color: var(--mindmap-node-text) !important;
  box-shadow: none !important;
}

.mindmap-editor jmnode.root.selected,
.mindmap-editor jmnode.mindmap-root-node.selected {
  background: var(--mindmap-selection-bg);
  color: var(--mindmap-node-text);
}

.mindmap-editor jmnode[contenteditable="true"] {
  cursor: text;
  user-select: text;
  outline: 0;
  box-shadow: var(--mindmap-node-shadow);
}

.mindmap-editor .jsmind-editor {
  appearance: none;
  width: 1ch;
  min-width: 1ch;
  max-width: min(360px, 44vw);
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  color: inherit !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  font: inherit !important;
  line-height: inherit !important;
}

.mindmap-editor .jsmind-editor:focus {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

.mindmap-editor jmexpander {
  z-index: 5;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border: 2px solid var(--mindmap-connector);
  border-radius: 50%;
  background: var(--mindmap-canvas-bg);
  color: var(--mindmap-connector);
  box-shadow: 0 0 0 2px var(--mindmap-canvas-bg);
  font: 400 12px/14px SimSun, "宋体", NSimSun, "新宋体", STSong, serif;
  text-align: center;
  cursor: pointer;
  opacity: 1;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}

.mindmap-editor jmexpander.is-expanded {
  opacity: 0;
  pointer-events: none;
}

.mindmap-editor jmexpander.is-expanded.is-hover-target {
  opacity: 1;
  pointer-events: auto;
}

.mindmap-editor jmexpander:hover {
  background: var(--mindmap-connector);
  border-color: var(--mindmap-connector);
  color: var(--mindmap-canvas-bg);
}

.mindmap-editor .jsmind-draggable-shadow-node {
  opacity: 0.7;
}

.mindmap-editor-fallback {
  margin: 18px;
  padding: 18px 20px;
  border: 1px dashed var(--mindmap-connector);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.mindmap-background-panel {
  min-width: 118px;
}

.mindmap-bg-swatch {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.mindmap-bg-swatch.is-white {
  background: #ffffff;
}

.mindmap-bg-swatch.is-paper {
  background: #fbf7ec;
}

.mindmap-bg-swatch.is-blue {
  background: #eef7ff;
}

.mindmap-bg-swatch.is-green {
  background: #f0faf4;
}

.mindmap-bg-swatch.is-dark {
  background: #12151b;
}

.mindmap-note-modal {
  width: min(560px, calc(100vw - 28px));
}

.mindmap-note-input {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-family: var(--document-font);
  font-size: 0.95rem;
  line-height: 1.55;
}

.mindmap-note-input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.mindmap-preview .mindmap-center,
.mindmap-editor jmnodes jmnode.root,
.mindmap-editor jmnodes jmnode.mindmap-root-node {
  border: 2px solid var(--mindmap-node-border) !important;
  border-radius: 8px !important;
  background: var(--mindmap-canvas-bg) !important;
  color: var(--mindmap-node-text) !important;
  font-family: SimSun, "宋体", NSimSun, "新宋体", STSong, serif !important;
  font-size: var(--mindmap-editor-node-size, 16px) !important;
  font-weight: 400 !important;
  line-height: 1.25 !important;
  min-width: var(--mindmap-root-min-width) !important;
  min-height: var(--mindmap-root-min-height) !important;
  width: fit-content !important;
  padding: 8px 0.5em !important;
}

.mindmap-preview .mindmap-node,
.mindmap-editor jmnodes jmnode:not(.root):not(.mindmap-root-node) {
  border: 0 !important;
  border-bottom: 2px solid var(--mindmap-node-border) !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--mindmap-node-text) !important;
  box-shadow: none !important;
  font-family: SimSun, "宋体", NSimSun, "新宋体", STSong, serif !important;
  font-weight: 400 !important;
  line-height: 1.25 !important;
  min-width: 0 !important;
  width: fit-content !important;
  padding: 7px 0.5em 8px !important;
  text-align: left !important;
}

.mindmap-preview .mindmap-center {
  border: 2px solid var(--mindmap-node-border) !important;
  border-radius: 8px !important;
}

.mindmap-editor jmnodes jmnode.selected:not(.root):not(.mindmap-root-node) {
  border-bottom-color: var(--mindmap-selection) !important;
  background: var(--mindmap-selection-bg) !important;
}

.mindmap-editor jmnodes jmnode.has-note:not(.root):not(.mindmap-root-node) {
  padding-right: calc(0.5em + 20px) !important;
}

.mindmap-editor jmnodes jmnode.root.selected,
.mindmap-editor jmnodes jmnode.mindmap-root-node.selected {
  border-color: var(--mindmap-selection) !important;
  background: var(--mindmap-canvas-bg) !important;
}

.mindmap-editor jmnodes jmnode:not(.has-note)::after {
  display: none !important;
}

.mindmap-editor jmnodes jmnode.has-note::after {
  display: block !important;
}
