/* ============================================================
   编辑器（对齐小程序最终版）
   ============================================================ */

.editor {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  z-index: 50;
}

/* ---------- 顶部导航 ---------- */

.ed-bar {
  flex: 0 0 auto;
  height: calc(52px + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  position: relative;
  z-index: 30;
}

/* 手机上这条之前没设 flex，返回 / 标题 / 分享会各占一行；
   加了分享按钮后尤其明显，所以基础样式里就排成一行 */
.ed-bar-inner {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* 右侧动作组：导出 / 分享 */
.ed-bar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.ed-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  flex: 0 0 auto;
}

.ed-icon-btn:active {
  background: #f1f5f9;
}

/* 「开着」的状态：背诵模式点了眼睛之后变蓝，再点一下退出 */
.ed-icon-btn.is-on {
  background: #eaf0ff;
  color: #2f5bd8;
}

.ed-icon-btn svg {
  width: 20px;
  height: 20px;
}

/**
 * 标题绝对居中。
 *
 * 之前靠 flex:1 挤在中间，左边只有返回键、右边是「导出 + 分享」两个按钮，
 * 标题就被右侧顶得偏左。改成绝对定位后，左右各有多少按钮都不影响居中。
 */
.ed-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 168px);
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ed-title span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-title svg {
  width: 13px;
  height: 13px;
  color: var(--ink-3);
  flex: 0 0 auto;
}

/* 标题改成绝对居中后不再需要右侧占位块（DOM 里留着不占位） */
.ed-holder {
  display: none;
}

/* ---------- 画布 ---------- */

.ed-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fff;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/**
 * 编辑态放开浏览器手势。
 *
 * touch-action 是**祖先链求交集**的：光给 .ed-input 写 auto 没用，
 * 父级 .ed-stage 的 none 会把结论按回 none —— 表现就是手机上长按只选得出
 * 第一个词（中文一个字），拖两端手柄完全没反应。
 * 编辑期间没有人需要画布手势（输入框自己会 return），所以这段放开最安全。
 */
.editor.is-editing .ed-stage {
  touch-action: manipulation;
}

.ed-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

/**
 * 只在「正在平移 / 缩放」时提升为合成层。
 *
 * 以前常驻 will-change: transform，浏览器会缓存缩放前的位图，
 * 放大后直接拉伸那张图 —— 文字看着发虚，折叠一次触发重排才重新变清晰。
 * 停下 200ms 后撤掉，让浏览器按最终缩放重新栅格化。
 */
.ed-canvas.is-moving {
  will-change: transform;
}

.ed-links {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

.ed-links path {
  fill: none;
  stroke: var(--line-color, #9294f5);
  stroke-width: 2;
  stroke-linecap: round;
}

.ed-ring {
  position: absolute;
  border-radius: 14px;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--sel), 0 0 0 7px var(--sel-glow);
  z-index: 1;
  opacity: 0;
}

.ed-ring.is-on {
  opacity: 1;
}

.ed-ring.is-glide {
  transition: left var(--ring-dur, 300ms) cubic-bezier(0.4, 0, 0.2, 1),
    top var(--ring-dur, 300ms) cubic-bezier(0.4, 0, 0.2, 1),
    width var(--ring-dur, 300ms) cubic-bezier(0.4, 0, 0.2, 1),
    height var(--ring-dur, 300ms) cubic-bezier(0.4, 0, 0.2, 1);
}

.node {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid #e8ecf5;
  background: #fff;
  color: #000;
  font-size: 14px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  /* 折叠 / 展开时位置由 transform 过渡过去，比整棵树重建后再硬跳自然得多 */
  transition: transform 0.2s cubic-bezier(0.32, 0.72, 0.28, 1), box-shadow 0.16s ease;
}

.node .label {
  max-width: 100%;
  white-space: pre;
  overflow: hidden;
  text-align: center;
}

/* 手动拖过宽度的节点：文字按宽度自动折行 */
.node.has-width {
  padding: 4px 14px;
}

.node.has-width .label {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
}

/**
 * 多行文字左对齐。
 *
 * 单行居中最耐看；一旦变成两行（回车硬换行，或拖窄了自动折行），
 * 居中的第二行会悬在中间，看起来像排版坏了。
 */
.node.is-multi .label,
.node.has-width .label {
  text-align: left;
}

/* 右边缘的宽度手柄只在桌面出现 */
.node-resize {
  display: none;
}

/* 只读（分享 / 精选）和付费锁住的内容都不该给改宽度 */
.editor.is-readonly .node-resize,
.node.is-locked .node-resize {
  display: none;
}

/* ---------- 节点里的图片 / 链接 ---------- */

.node.has-img {
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
}

.node.has-img .label {
  flex: 0 0 auto;
  max-height: 44px;
}

.node-img {
  position: relative;
  display: block;
  width: 100%;
  height: 72px;
  flex: 0 0 72px;
  border-radius: 9px;
  overflow: hidden;
  background: #f1f5f9;
  cursor: zoom-in;
}

.node-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.node-img.is-bad img {
  display: none;
}

.node-img.is-bad::after {
  content: '图片加载失败';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #94a3b8;
}

.node-link {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: var(--brand, #1b4f8a);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
  cursor: pointer;
}

.node-link svg {
  width: 10px;
  height: 10px;
}

.node.d0 {
  background: linear-gradient(135deg, var(--root-a), var(--root-b));
  border-color: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-radius: 16px;
  box-shadow: 0 8px 20px var(--root-glow);
}

.node.d1 {
  background: var(--l1-bg);
  border-color: var(--l1-bd);
  color: var(--l1-fg);
  font-weight: 600;
}

/* 三级及以后：框更矮、字更小（字号由布局按层级写进 inline style，这里只管圆角） */
.node.d2 {
  border-radius: 11px;
}

.node.d3,
.node.d4,
.node.d5,
.node.d6,
.node.d7,
.node.d8 {
  border-radius: 10px;
}

.node.is-collapsed {
  border-style: dashed;
}

.node.is-editing {
  visibility: hidden;
}

/**
 * 编辑中仍然保留右侧的 +：打完字直接点 + 加下一级/同级，
 * 不用先按回车结束编辑、再回来找按钮。
 * visibility 会被子元素继承，这里单独把它放出来即可。
 */
.node.is-editing .node-plus {
  visibility: visible;
}

/**
 * 拖宽已经拖到头（文字本来就一行）：整块画布换成禁止光标。
 * 节点自身有 cursor: pointer，只改 stage 的 cursor 会被它盖掉，所以用 !important 压住。
 */
.editor.is-widen-blocked,
.editor.is-widen-blocked * {
  cursor: not-allowed !important;
}

/**
 * 付费导图：超出试读层级的节点不可操作。
 * 模糊不在这里做 —— 交给出画布层那块整片毛玻璃（.ed-veil），
 * 一个个节点各自糊开看着像没加载完，糊成一片才像「锁住的内容」。
 */
.node.is-locked {
  filter: blur(3px);
  opacity: 0.8;
  cursor: default;
}

.node.is-locked .toggle {
  display: none;
}

.node .lock-badge {
  position: absolute;
  right: -8px;
  top: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.node .lock-badge svg {
  width: 10px;
  height: 10px;
}

/*
 * 折叠 / 展开按钮站在连接线的分岔点上。
 *
 * 连线是折线，拐点在「父节点右边 → 子节点左边」的正中间（H_GAP 68 的一半 = 34），
 * 所以按钮左边距 25px、宽 18px，圆心正好落在 34 —— 展开时那个「−」就压在拐角上，
 * 折叠时换成数字胶囊，往右让 5px 给引线留位置。
 * 右边的三颗 + 贴近框边（4px），两者错开，互不遮挡。
 */
.node .toggle {
  position: absolute;
  right: auto;
  left: calc(100% + 25px);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
  z-index: 3;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/**
 * 视觉上还是 18px 的小圆，但热区往外扩 8px（34px）。
 * 手机上这个按钮在缩放后的画布里更小，点偏一点就没反应 —— 这是「点了不动」的常见原因。
 */
.node .toggle::after {
  content: '';
  position: absolute;
  left: -8px;
  right: -8px;
  top: -8px;
  bottom: -8px;
  border-radius: 50%;
}

/* 按下去立刻有反馈，剩下的重排交给我们 */
.node .toggle:active {
  background: var(--sel, #6366f1);
  border-color: var(--sel, #6366f1);
  color: #fff;
}

/**
 * 折叠后：同一个位置换成「后面还有多少个节点」的胶囊（宽度跟着数字走）。
 * 位置继承 .node .toggle 的 left，这里只管外形。
 */
.node .toggle.is-count {
  /* 胶囊比圆点宽，往右让 5px 再往左画引线，免得左端压到 + 号 */
  left: calc(100% + 30px);
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  color: #475569;
}

/**
 * 框边到数字之间的引线：告诉眼睛「这个数字说的是这个框里的内容」。
 * 30px 正好是「框边 → 胶囊左边」的距离，压在 + 号下面
 * （+ 是 z-index 6，这条线跟着 toggle 的 3）。
 */
.node .toggle.is-count::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  width: 30px;
  height: 1px;
  background: rgba(15, 23, 42, 0.16);
  pointer-events: none;
}

/* 桌面：选中节点后，右侧 / 右上 / 右下各一个 + */
.node-plus {
  display: none;
}

.node.is-dragging {
  opacity: 0.42;
  /* 让 elementFromPoint 穿透到下面的目标节点，否则永远命中自己 */
  pointer-events: none;
}

/* Shift + 拖拽框选中的节点：虚线框，和单选环（实线 + 光晕）区分开 */
.node.is-picked {
  z-index: 3;
  outline: 2px solid rgba(99, 102, 241, 0.85);
  outline-offset: 3px;
}

/* 框选时的那个矩形 */
.ed-marquee {
  position: absolute;
  z-index: 12;
  border: 1.5px solid rgba(99, 102, 241, 0.9);
  background: rgba(99, 102, 241, 0.14);
  border-radius: 4px;
  pointer-events: none;
}

/**
 * 可放置的目标：主题色实环 + 外发光，呼吸一下提醒「松手就落这里」。
 * z-index 要压过拖拽预览框（.drag-ghost 是 9）：鼠标停在目标节点上时，
 * 预览框正好盖住节点，不抬起来的话环和插入线都被挡住，用户看不出会落到哪。
 */
.node.is-drop {
  z-index: 10;
  animation: drop-glow 1s ease-in-out infinite;
}

@keyframes drop-glow {
  0%,
  100% {
    box-shadow: 0 0 0 2px var(--sel), 0 0 0 7px var(--sel-glow), 0 0 16px 2px var(--sel-glow);
  }
  50% {
    box-shadow: 0 0 0 3px var(--sel), 0 0 0 11px var(--sel-glow), 0 0 26px 7px var(--sel-glow);
  }
}

/**
 * 拖拽落点的预览连线：从分叉支点连到跟手的虚影，虚线；松手后就变成那个位置的实线。
 *
 * 单独放一层 SVG 挂在 stage 上（不挂在节点里）：节点都在带 transform 的画布容器里，
 * 容器自成层叠上下文，节点 z-index 再高也压不过外面的拖拽预览框，线会被遮住。
 */
.drag-link {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 11;
  display: none;
  overflow: visible;
  pointer-events: none;
}

.drag-link path {
  fill: none;
  stroke-width: 2;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  opacity: 0.9;
}

/* 拖动时跟手的半透明预览框（放在 stage 层，按屏幕坐标走，不随画布缩放） */
.drag-ghost {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 14px;
  border: 1.5px dashed var(--sel, #6366f1);
  /* 半透明：鼠标停在目标节点上时，底下的落点环 / 插入线还能透出来 */
  background: rgba(255, 255, 255, 0.62);
  color: #0f172a;
  font-size: 14px;
  line-height: 1.3;
  text-align: center;
  white-space: pre;
  overflow: hidden;
  opacity: 0.92;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.22);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.drag-ghost .label {
  max-width: 100%;
  overflow: hidden;
}

.drag-ghost.d0 {
  background: linear-gradient(135deg, var(--root-a), var(--root-b));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.drag-ghost.d1 {
  background: var(--l1-bg);
  border-color: var(--l1-bd);
  color: var(--l1-fg);
  font-weight: 600;
}

.node.is-locked .node-plus {
  display: none !important;
}

/* 就地编辑：放在画布层里，跟着 transform 一起缩放，位置天然对齐 */
.ed-input {
  position: absolute;
  z-index: 10;
  /**
   * 这三条是给手机长按选字用的。画布本身 touch-action:none + user-select:none
   * （不这样没法做拖动 / 双指缩放），但这些会一起继承到输入框上 ——
   * 表现就是「长按只选得出一个字，拖动手柄没反应、选不了一段」。
   * 输入框里必须把浏览器自己的文本手势还回去。
   */
  touch-action: auto;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  margin: 0;
  /* border-box：JS 里给的 width 就是视觉总宽，和 .node 的算法口径一致 */
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid var(--l1-bd, #dfe3ff);
  border-radius: 14px;
  background: #fff;
  color: #000;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.3;
  text-align: center;
  outline: none;
  resize: none;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(27, 79, 138, 0.14);
}

/* 编辑中的多行文本同样左对齐，和提交后的显示保持一致，避免「一提交就跳位」 */
.ed-input.is-multi {
  text-align: left;
}

.ed-input.d0 {
  background: var(--root-b);
  border-color: transparent;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-radius: 16px;
}

.ed-input.d1 {
  background: var(--l1-bg);
  border-color: var(--l1-bd);
  color: var(--l1-fg);
  font-weight: 600;
}

/**
 * 正在改局部样式的那一段字：铺一层浅蓝底，看着和「选中了」一样。
 *
 * 打开样式面板时编辑框会收起来（textarea 里看不到颜色），原生选区高亮也就没了，
 * 用户会以为「刚才那下没选中」。所以在画布上把这段字自己标出来。
 */
.node .label .run-sel {
  background: rgba(59, 130, 246, 0.26);
  border-radius: 3px;
}

/**
 * 局部样式面板里回显「选了哪几个字」。
 *
 * 用 .unit-tip 那种浅灰小字根本看不清选的是啥，改成一块浅底引用。
 */
/* 选区长度兜底按钮：到头了（左边已是句首 / 右边已是句尾）就置灰 */
.ed-sheet .run-range .st-chip[disabled] {
  opacity: 0.4;
}

.ed-sheet .run-sample {
  margin: 2px 0 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f6fb;
  color: #334155;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
}

/**
 * 手机端「选中文字改样式」的浮动按钮。
 *
 * 编辑框里选中一段字之后浮到输入框上方，点它打开局部样式面板。
 * 位置由 JS 按输入框的 getBoundingClientRect 算（fixed），
 * z-index 压在遮罩（60）下面，面板一升起来就不会盖住面板。
 */
.ed-runchip {
  position: fixed;
  z-index: 55;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #1f2937;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 34px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.24);
  -webkit-tap-highlight-color: transparent;
}

.ed-runchip[hidden] {
  display: none;
}

/* ---------- 顶部左侧的主题按钮（小程序同款位置） ---------- */

.ed-theme-fab {
  position: absolute;
  left: 16px;
  top: 12px;
  z-index: 21;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
}

.ed-theme-fab svg {
  width: 22px;
  height: 22px;
}

/* ---------- 底部操作区 ---------- */

/**
 * --kb-h = 软键盘挡住的高度（editor.js 的 visualViewport 回调里写进来）。
 *
 * 手机上点开节点输入时，键盘会盖住视口底部：Android 一般会缩布局视口，
 * iOS 不缩，底栏就钻到键盘底下看不见了。这里把底栏整体抬 kbH，
 * 键盘收起时 kbH=0，自然落回底部 —— 也就是用户要的「工具栏浮在输入法上面」。
 */
.ed-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--kb-h, 0px);
  z-index: 20;
  padding-bottom: var(--safe-b);
  pointer-events: none;
}

/**
 * 点开节点打字（.is-editing）时，卡片和输入法之间**保留原来那 6px + 安全区的空隙**
 * （高度一点不减），只是把这段空隙铺成和卡片同色的毛玻璃：
 * 看过去是一层磨砂白，不会再从缝里透出画布的连线和节点。
 *
 * 用 is-editing 判定而不是「键盘高度 > 0」：Android 上键盘会缩布局视口，
 * 算出来的键盘高度是 0，但底栏一样贴着键盘，两种机型都要铺。
 * 高度 = 卡片下边距 6px + dock 自己的安全区 padding，正好盖住整条缝。
 */
.editor.is-editing .ed-dock::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(6px + var(--safe-b));
  /* 0.96 不是纯白：留一点磨砂质感，但背后的连线和节点已经看不出形状了 */
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

/**
 * 选中节点才出现的下排（样式 / 删除 / 子节点 / 同级）
 *
 * 它是 dock 的最后一个子元素 = 屏幕最底部；「子节点 / 同级」排在第 3、4 位，
 * space-between 让它们正好落在最右侧（拇指最顺的位置）。
 * 未选中时 display:none，不能用 transform 藏起来 —— 那样仍占高度，
 * 会把上面那排（撤销 / 折叠 / 导出）顶得离底。
 */
/**
 * 上下两排合成一张卡片。
 *
 * 以前两排各自是圆角卡、中间留 6px 间距，画布内容会从那道缝里透出来。
 * 现在外层卡片负责圆角 / 阴影，两排之间只用一条 1px 分隔线。
 */
/**
 * 手机端保持原来的 6px —— 这套位置是调试好的，不要跟着桌面一起改。
 * 桌面端贴边的 4px 写在下面的桌面媒体查询里（.ed-dock-card 覆盖）。
 */
.ed-dock-card {
  margin: 0 12px 6px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  pointer-events: auto;
}

.ed-actions {
  display: none;
  align-items: center;
  justify-content: space-around;
  padding: 3px 6px;
  border-top: 1px solid #f1f5f9;
}

.ed-actions.is-on {
  display: flex;
  animation: ed-actions-in 0.2s ease;
}

@keyframes ed-actions-in {
  from {
    transform: translateY(120%);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/**
 * 手机上两排都只留图标：
 * 图标本身已经说得清楚，省掉中文备注后每排从 ~68px 压到 ~44px，
 * 两排加起来少占 30px 画布高度。文字节点仍在 DOM 里（读屏和桌面端还用它）。
 */
.ed-act {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 38px;
  border-radius: 10px;
  color: var(--ink-2);
}

.ed-act svg {
  width: 21px;
  height: 21px;
}

.ed-tool > span,
.ed-act > span {
  display: none;
}

.ed-act.danger {
  color: #e5484d;
}

.ed-act:active {
  background: #f8fafc;
}

/* 上排：外观交给 .ed-dock-card，自己只负责排列 */
.ed-tools {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 3px 6px;
}

.ed-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 38px;
  color: var(--ink-2);
  border-radius: 10px;
}

.ed-tool svg {
  width: 20px;
  height: 20px;
}

.ed-tool:active {
  background: #f8fafc;
}

.ed-tool.is-off {
  opacity: 0.35;
  pointer-events: none;
}

/* 「样式 / 删除」只有桌面底部单排需要，手机上有专门的第二排 */
.ed-tool.only-pc {
  display: none;
}

/* 「移动」反过来：手机上代替拖拽，桌面直接拖节点换父级，按钮是多余的 */
.ed-tool.only-touch {
  display: flex;
}

.ed-tool.danger {
  color: #e5484d;
}

/**
 * 编辑中工具栏要不要让位：
 *   - 手机端**不隐藏**：键盘弹起时工具栏要停在输入法上面（.ed-dock 用 --kb-h 抬高）；
 *     以前这条规则是全局的，手机上一打字整条工具栏就没了。
 *   - 桌面端仍然收起，规则写在下面的桌面媒体查询里（桌面没有键盘遮挡问题）。
 */

/* 付费预览：工具整排收起，只留解锁条 */
.editor.is-locked .ed-dock-card {
  display: none;
}

.editor.is-locked .ed-paybar {
  bottom: calc(12px + var(--safe-b));
}

/* ---------- 付费导图的解锁条 ---------- */

.ed-paybar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + var(--safe-b) + 56px);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
}

.ed-paybar .pb-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
}

.ed-paybar .pb-text b {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

/* 价格亮在购买按钮旁边：预览时不点开就知道多少钱 */
.ed-paybar .pb-price {
  flex: 0 0 auto;
  font-size: 17px;
  font-weight: 800;
  color: #ffb27d;
  white-space: nowrap;
}

.ed-paybar .pb-price[hidden] {
  display: none;
}

/* 后台写的介绍：预览时先让用户知道买的是什么，最多两行，超了由 line-clamp 收尾补省略号 */
.ed-paybar .pb-intro {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.72);
}

.ed-paybar .pb-intro[hidden] {
  display: none;
}

/* 简介被两行截断时可以点开：虚线提示 + 手型光标，展开后不限行数，超高自己滚 */
.ed-paybar .pb-intro.can-expand {
  cursor: pointer;
}

.ed-paybar .pb-intro.can-expand:not(.is-open) {
  text-decoration: underline dotted rgba(255, 255, 255, 0.32);
  text-underline-offset: 3px;
}

.ed-paybar .pb-intro.is-open {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  max-height: 34vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/**
 * 购买按钮：照淘宝主按钮那套配色——橘黄起手、橘红收尾，从左往右压深，
 * 白字 + 胶囊形。纯红像报错、纯淡橙又发黄，这条橘红带是电商最不容易看错的。
 */
.ed-paybar .pb-btn {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff7a00 0%, #ff5100 30%, #ff3d00 70%, #f22e00 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 0;
  box-shadow: 0 3px 10px rgba(255, 90, 0, 0.26);
  cursor: pointer;
}

.ed-paybar .pb-btn:active {
  background: linear-gradient(90deg, #ef6d00 0%, #ef4800 30%, #ee3500 70%, #d92800 100%);
  box-shadow: 0 2px 6px rgba(255, 90, 0, 0.24);
}

/* ---------- 付费预览：盖住锁定内容的一整块毛玻璃 ---------- */

.ed-veil {
  position: absolute;
  z-index: 4;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.52);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
  /* 手势留给下面的节点：点到锁住的内容仍会弹「解锁」 */
  pointer-events: none;
}

/* ---------- 只读分享（复用解锁条的位置与排版，换成品牌蓝） ---------- */

.ed-sharebar .pb-btn {
  background: linear-gradient(135deg, #4a86dc, #1b4f8a);
  color: #fff;
}

/* 只读：没有「子节点 / 同级」那一排，也没有主题按钮 */
.editor.is-readonly .ed-actions {
  display: none;
}

.editor.is-readonly .ed-theme-fab {
  display: none;
}

/* 只读：标题不可点（没有重命名铅笔） */
.ed-title.is-static {
  pointer-events: none;
}

/* ---------- 弹层（样式 / 主题） ---------- */

.ed-sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.16);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ed-sheet-mask.is-on {
  opacity: 1;
  pointer-events: auto;
}

/* ============ 首次编辑的键位说明 ============ */

/**
 * 第一次开始编辑时弹一次，必须点「知道了」（或点卡片外面）才关。
 * 用卡片而不是 toast：键位说明要读两三行，3 秒根本看不完，手机上更看不清。
 */
.ed-guide {
  position: absolute;
  inset: 0;
  z-index: 33;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.3);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.ed-guide.is-on {
  opacity: 1;
}

.ed-guide-card {
  width: min(320px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.22);
  transform: translateY(6px) scale(0.98);
  transition: transform 0.18s ease;
}

.ed-guide.is-on .ed-guide-card {
  transform: none;
}

.ed-guide-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
}

.ed-guide-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ed-guide-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #475569;
}

.ed-guide-list kbd {
  flex: 0 0 auto;
  min-width: 56px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 7px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-bottom-width: 2px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.ed-guide-ok {
  margin-top: 16px;
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: #1b4f8a;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.ed-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 14px 18px calc(18px + var(--safe-b));
  /**
   * 收起位置按「自身高度 + 24px」算，不能只写 104%。
   *
   * 百分比是相对自身高度：弹层从没打开过时内容为空，高度只剩内边距（约 32px），
   * 推下去 33px 盖不住 bottom: 18px，屏幕底部会露出一条白色圆角边，
   * PC 端正好卡在工具栏卡片下面，看着就像多了一截。多推 24px 就彻底出屏了。
   */
  transform: translateY(calc(100% + 24px));
  pointer-events: none;
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 70%;
  overflow-y: auto;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.1);
}

.ed-sheet.is-on {
  transform: none;
  pointer-events: auto;
}

/* 弹层标题（主题色等）：居中一行，别让它是浏览器默认的左对齐裸文本 */
.sheet-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

/* 样式面板顶部：左两排 chips，右两块竖排胶囊（复刻小程序布局） */
.st-top {
  display: flex;
  gap: 12px;
}

.st-main {
  flex: 1;
  min-width: 0;
}

.st-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.st-row:last-child {
  margin-bottom: 0;
}

/**
 * chips：默认态用「白底 + 细边」而不是整块浅灰。
 * 样式面板里元素本来就多，一片 #f1f5f9 的灰块叠在白色弹层上会显得脏，
 * 白底加 1px 边反而更轻，选中态再用品牌色压住对比。
 */
.st-chip {
  flex: 1;
  height: 34px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-chip.is-on {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(27, 79, 138, 0.22);
}

.st-chip svg {
  width: 15px;
  height: 15px;
  margin-right: 4px;
  flex: 0 0 auto;
}

.st-side {
  flex: 0 0 76px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.st-pill {
  height: 34px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-pill.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.st-pill.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(27, 79, 138, 0.24);
}

.st-group {
  margin-top: 14px;
}

.st-group .k {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 700;
  margin-bottom: 8px;
}

/**
 * 组标题右侧的小胶囊（目前只有文字色的「自动」）。
 * 原先是色板里的第一个白格兼职「恢复默认」，看着像白色文字、点了却没反应；
 * 单独做成胶囊，「默认」和「白字」就各归各位了。
 */
.st-auto {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.st-auto.is-on {
  border-color: transparent;
  background: rgba(27, 79, 138, 0.1);
  color: var(--brand);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

/**
 * 样式面板里的色板：固定 6 列。
 * 每组 12 个（1 个「无」+ 11 个色），6 列正好两排、左右对齐，
 * 比之前 13 个挤成 7+6 的参差排法整齐得多。
 */
.ed-sheet .swatches {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

/**
 * 文件夹颜色（新建 / 重命名文件夹面板）：固定一行 8 个。
 * 之前是 flex 换行 + 34px 固定宽，360 这类窄屏刚好塞不下第 8 个，
 * 第二排就孤零零剩一个色；改成等分列，宽屏窄屏都是一整排。
 */
.sheet .swatches {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px;
}

.sheet .swatch {
  width: 100%;
  height: 26px;
}

/**
 * 色块：做成「缩小版节点」的圆角矩形，颜色铺满整块。
 *
 * 原来是小圆点 + 一圈 16% 灰边，填充色（#FEE2E2 这类浅色）被灰边一圈、
 * 又被白底一衬，看起来比导图上实际的节点淡很多；改成铺满的圆角块、
 * 只留 8% 的细边，感官上才和画布里的节点对得上。
 */
.swatch {
  width: 34px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
  position: relative;
  /* div 版的色块（文件夹编辑器）没有按钮默认手感，这里补上手型 */
  cursor: pointer;
  box-sizing: border-box;
  padding: 0;
}

/* 网格里的色块铺满格子，高度保持一致 */
.ed-sheet .swatch {
  width: 100%;
  height: 30px;
}

/**
 * 选中：对勾 + 一圈品牌蓝外描边。
 * 用白色垫一圈再描边，描边才和色块之间有空隙，不会糊成一块；
 * 不用黑色，浅色填充上黑边显脏。
 */
.swatch.is-on {
  border-color: transparent;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3.5px var(--brand),
    0 3px 8px rgba(27, 79, 138, 0.18);
}

.swatch.is-on::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/**
 * 填充色首格 = 「不填充」：白底 + 一条斜杠。
 * 以前就是一块纯白，和「白色填充」长得一模一样，用户会以为选了白色没生效。
 */
.swatch[data-fill=''] {
  background: #fff;
  overflow: hidden;
}

.swatch[data-fill='']::before {
  content: '';
  position: absolute;
  left: -14%;
  right: -14%;
  top: 50%;
  height: 1.5px;
  border-radius: 2px;
  background: #cbd5e1;
  transform: translateY(-50%) rotate(-45deg);
}

/* 白块上的对勾换成深色：白勾压在白底上等于没选中 */
.swatch[data-ink='#FFFFFF'].is-on::after,
.swatch[data-fill=''].is-on::after {
  color: #1f2937;
  text-shadow: none;
}

.theme-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-dot {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.16);
}

.theme-dot.is-on {
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px var(--brand);
}

/* ---------- 12 套主题变量（与 js/theme.js 对应） ---------- */

.theme-0 { --root-a: #6366f1; --root-b: #4f46e5; --root-glow: rgba(99, 102, 241, 0.3); --line-color: #9294F5; --l1-bg: #eef0ff; --l1-bd: #dfe3ff; --l1-fg: #4338ca; --sel: #6366f1; --sel-glow: rgba(99, 102, 241, 0.16); }
.theme-1 { --root-a: #0ea5e9; --root-b: #0369a1; --root-glow: rgba(14, 165, 233, 0.3); --line-color: #56C0F0; --l1-bg: #e8f6fe; --l1-bd: #c9e9fb; --l1-fg: #075985; --sel: #0ea5e9; --sel-glow: rgba(14, 165, 233, 0.16); }
.theme-2 { --root-a: #06b6d4; --root-b: #0e7490; --root-glow: rgba(6, 182, 212, 0.3); --line-color: #51CCE1; --l1-bg: #e6f9fd; --l1-bd: #c2eff7; --l1-fg: #0e7490; --sel: #06b6d4; --sel-glow: rgba(6, 182, 212, 0.16); }
.theme-3 { --root-a: #10b981; --root-b: #047857; --root-glow: rgba(16, 185, 129, 0.3); --line-color: #58CEA7; --l1-bg: #e7faf3; --l1-bd: #c5f2e3; --l1-fg: #047857; --sel: #10b981; --sel-glow: rgba(16, 185, 129, 0.16); }
.theme-4 { --root-a: #22c55e; --root-b: #15803d; --root-glow: rgba(34, 197, 94, 0.3); --line-color: #64D78E; --l1-bg: #eefcf3; --l1-bd: #d3f5e0; --l1-fg: #15803d; --sel: #22c55e; --sel-glow: rgba(34, 197, 94, 0.16); }
.theme-5 { --root-a: #84cc16; --root-b: #4d7c0f; --root-glow: rgba(132, 204, 22, 0.3); --line-color: #A9DB5C; --l1-bg: #f7fce8; --l1-bd: #e8f5c8; --l1-fg: #4d7c0f; --sel: #84cc16; --sel-glow: rgba(132, 204, 22, 0.16); }
.theme-6 { --root-a: #ca8a04; --root-b: #854d0e; --root-glow: rgba(202, 138, 4, 0.3); --line-color: #DAAD4F; --l1-bg: #fff9e6; --l1-bd: #fbeec2; --l1-fg: #854d0e; --sel: #ca8a04; --sel-glow: rgba(202, 138, 4, 0.16); }
.theme-7 { --root-a: #f97316; --root-b: #c2410c; --root-glow: rgba(249, 115, 22, 0.3); --line-color: #FB9D5C; --l1-bg: #fff5eb; --l1-bd: #ffe4cc; --l1-fg: #c2410c; --sel: #f97316; --sel-glow: rgba(249, 115, 22, 0.16); }
.theme-8 { --root-a: #ef4444; --root-b: #b91c1c; --root-glow: rgba(239, 68, 68, 0.3); --line-color: #F47C7C; --l1-bg: #fff1f2; --l1-bd: #ffe0e2; --l1-fg: #be123c; --sel: #ef4444; --sel-glow: rgba(239, 68, 68, 0.16); }
.theme-9 { --root-a: #ec4899; --root-b: #be185d; --root-glow: rgba(236, 72, 153, 0.3); --line-color: #F27FDB; --l1-bg: #fff0f7; --l1-bd: #ffdcec; --l1-fg: #be185d; --sel: #ec4899; --sel-glow: rgba(236, 72, 153, 0.16); }
.theme-10 { --root-a: #a855f7; --root-b: #7e22ce; --root-glow: rgba(168, 85, 247, 0.3); --line-color: #C288F9; --l1-bg: #f7efff; --l1-bd: #eeddff; --l1-fg: #7e22ce; --sel: #a855f7; --sel-glow: rgba(168, 85, 247, 0.16); }
.theme-11 { --root-a: #64748b; --root-b: #1e293b; --root-glow: rgba(100, 116, 139, 0.3); --line-color: #939EAE; --l1-bg: #f1f5f9; --l1-bd: #e2e8f0; --l1-fg: #334155; --sel: #64748b; --sel-glow: rgba(100, 116, 139, 0.16); }

/* ============================================================
   桌面端：工具条居中悬浮，画布留出呼吸感
   ============================================================ */

/**
 * 桌面布局：只给「有鼠标、能悬停」的设备。
 *
 * 手机横过来有 900+ 像素，光看宽度会把横屏手机判成电脑端 —— 底栏变 780px 悬浮条、
 * 「子节点 / 同级」整排消失，横屏反而更难编辑。所以这里加上指针类型条件。
 */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .ed-bar {
    height: calc(60px + var(--safe-t));
    padding-left: 24px;
    padding-right: 24px;
    border-bottom: 1px solid #f1f5f9;
  }

  .ed-bar-inner {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .ed-title {
    font-size: 17px;
  }

  .ed-theme-fab {
    left: 28px;
    top: 78px;
    width: 46px;
    height: 46px;
  }


  /**
   * 桌面底栏贴边：原来 bottom 18px + 卡片 6px = 距底 24px，看着悬在半空。
   * 现在 bottom 0，只剩卡片自己的 4px，「我的导图」和「精选导图」统一。
   */
  .ed-dock {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 780px;
    bottom: 0;
    padding-bottom: 0;
    background: transparent;
  }

  /**
   * 桌面贴边：卡片下边距 6 → 4（配合 .ed-dock 的 bottom:0，距视口底只剩 4px）。
   * 手机端不在这条媒体查询里，仍是上面那套 6px，位置完全没动。
   */
  .ed-dock-card {
    border-radius: 18px;
    border: 1px solid #eef2f7;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
    margin-bottom: 4px;
  }

  .ed-tools {
    height: 62px;
  }

  /* 桌面：编辑中收起底栏（手机端不收起，靠 --kb-h 停在输入法上方） */
  .editor.is-editing .ed-dock-card {
    display: none;
  }

  /**
   * 那条毛玻璃是为了盖住「卡片 ↔ 输入法」之间的缝，只有手机键盘才有。
   * 桌面卡片一收起就没有缝了，留着会在视口底部多一条 6px 白条。
   */
  .editor.is-editing .ed-dock::after {
    display: none;
  }

  /* 悬浮横栏跟着工具条一起下沉：工具条卡片顶从 86 变 66，横栏按同样 10px 间隙摆到 76 */
  .ed-paybar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 780px;
    bottom: 76px;
  }

  .editor.is-locked .ed-paybar {
    bottom: 6px;
  }

  /* 桌面只读：分享条和付费预览一样居中悬在工具条上方 */
  .editor.is-readonly .ed-sharebar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 780px;
  }

  /**
   * 精选导图（.is-compact-bar）专用：这一页底下只剩「折叠 / 复位」，
   * 按默认 62px 高度白占一大块画布，压到 46px。
   * 贴边位置和其它编辑页一致（都走上面 .ed-dock 的 bottom: 0），不另外覆盖。
   * 「我的导图」不带这个 class，只影响高度，不影响位置。
   */
  .editor.is-compact-bar .ed-tools {
    height: 46px;
  }

  .editor.is-compact-bar .ed-tool {
    gap: 1px;
    padding: 2px 10px;
    font-size: 11.5px;
  }

  .editor.is-compact-bar .ed-tool svg {
    width: 18px;
    height: 18px;
  }

  /* 紧凑底栏卡片顶 = 4 + 46 = 50，横栏照旧留 10px 间隙 */
  .editor.is-compact-bar .ed-sharebar {
    bottom: 60px;
  }

  .ed-sheet {
    left: 50%;
    right: auto;
    /* 收起位置要推得比 bottom 多一些（4px + 8px 余量），否则底部会露一条白边 */
    transform: translateX(-50%) translateY(calc(100% + 12px));
    width: 780px;
    border-radius: 20px;
    bottom: 4px;
    padding-bottom: 18px;
  }

  .ed-sheet.is-on {
    transform: translateX(-50%);
  }

  .ed-sheet-mask {
    background: rgba(15, 23, 42, 0.24);
  }

  /* PC 上有节点旁的 + 和拖拽，不再需要「子节点 / 同级」那一排。
     .is-on 的选择器权重更高，要一起压掉，否则选中节点时这排又会冒出来。 */
  .ed-actions,
  .ed-actions.is-on {
    display: none;
  }

  /* 桌面横向空间充足：图标下面补一行文字，更好认。
     10px 太细，远看只剩一团灰；加到 12px + 半粗，图标不动，只让字更好认。 */
  .ed-tool {
    flex-direction: column;
    width: auto;
    height: auto;
    gap: 3px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .ed-tool > span {
    display: block;
  }

  .ed-tool.only-pc {
    display: flex;
  }

  .ed-tool.only-touch {
    display: none;
  }

  /**
   * 选中节点后的三个 +：右中（加子节点）、上 / 下（加同级）。
   *
   * 不再画白底圆：圆框压在节点旁边会抢注意力，还挡连线。
   * 现在只是一个灰色「+」浮在框外，离三条边都是 2px（加上字符自身留白，看着约 5px），
   * 三处距离一致；悬停时变品牌色，其余不变。
   */
  .node-plus {
    display: flex;
    position: absolute;
    right: -16px;
    width: 14px;
    height: 14px;
    color: #475569;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    align-items: center;
    justify-content: center;
    /* 没有白底圆了，+ 会压在连线上：垫一层白描边保证任何底子上都认得出来 */
    text-shadow: 0 0 2px #fff, 0 0 4px #fff;
    background: none;
    border: 0;
    box-shadow: none;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.12s ease, color 0.12s ease;
  }

  .node-plus.plus-child {
    top: 50%;
    transform: translateY(-50%);
  }

  /* 上 / 下两颗要脱离基类的 right，否则 left + right 同时存在会被拉成满宽 */
  .node-plus.plus-up {
    right: auto;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
  }

  .node-plus.plus-down {
    right: auto;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
  }

  .node-plus:hover {
    color: var(--brand);
  }

  /* 只在选中时出现：鼠标扫过不弹出，避免误点；平时也不吃点击 */
  .node-plus {
    pointer-events: none;
  }

  .node.is-selected .node-plus {
    opacity: 1;
    pointer-events: auto;
  }

  /**
   * 编辑中右边的 + 被输入框压住（光标正好停在 + 上，看着像「+ 被盖住了」）。
   *
   * 原因：`.ed-input` 为了「最后一行不提前折行」，宽度给的是 `item.w + 10px` 且
   * `z-index: 10`；而 + 是 `right: -16px; width: 14px`，只探出框外 2~16px ——
   * 中间那 9px 正好落在输入框白底下面。节点本身 is-editing 时是 hidden，
   * 唯一能被看见的 + 就成了「半个字符 + 一根光标」。
   *
   * 所以编辑态把这一颗往右让 14px（左边缘到 `item.w + 14`，离输入框右沿 3px，
   * 也让开 3px 的高亮描边）。高度不变，进出编辑时只是横着挪一下，位置仍然好点。
   * 实测：改前 `+.left − 输入框.right = -9.0`，改后 `+3.0`；非编辑态仍是 1.0（没动）。
   */
  .node.is-editing .node-plus.plus-child {
    right: -28px;
  }

  /**
   * 右边缘的宽度手柄：不再画出来。
   *
   * 一个浮在节点边上的小胶囊太抢眼，但它解决的问题是真的（长标题要能拖宽、双击恢复），
   * 所以改成一条看不见的热区：鼠标移到节点右边缘，光标自己变成 ↔，按住左右拖就能改宽度。
   * 热区比节点右边探出去 5px，边缘也够得着；双击仍然是恢复自适应。
   */
  .node-resize {
    display: block;
    position: absolute;
    right: -5px;
    top: 0;
    bottom: 0;
    width: 14px;
    background: transparent;
    cursor: ew-resize;
    z-index: 7;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ============================================================
   移动模式（手机换分支）：选中节点 → 移动 → 点目标
   ============================================================ */

/* 源节点：实线；能落的位置：虚线呼吸，点一下就挂过去 */
.node.is-move-src {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  z-index: 3;
}

.node.is-move-dst {
  outline: 2px dashed rgba(27, 79, 138, 0.55);
  outline-offset: 3px;
  animation: moveBreath 1.5s ease-in-out infinite;
}

@keyframes moveBreath {
  0%, 100% { outline-color: rgba(27, 79, 138, 0.28); }
  50% { outline-color: rgba(27, 79, 138, 0.68); }
}

.editor.is-move-mode .node { cursor: crosshair; }

/* 顶部提示条：「点目标节点，移动到这里」+ 取消（不显示节点内容，长标题会截断成半句话） */
.move-tip {
  position: absolute;
  z-index: 30;
  left: 50%;
  transform: translateX(-50%);
  /**
   * 绝对定位 + left:50% + 自动宽度时，可用宽度只剩一半，
   * 文字必被 ellipsis 截掉（表现就是「点目标节点，移动到…」）。
   * 先按内容撑开，再用 max-width 兜住超长的情况。
   */
  width: max-content;
  top: calc(env(safe-area-inset-top, 0px) + 58px);
  /* 两行：第一行说「点目标 = 换分支」，第二行才是同级上移 / 下移 */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  max-width: calc(100% - 28px);
  padding: 9px 11px 9px 13px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: 12.5px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.28);
}

.move-tip-main {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.move-tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 「同级之间调序」这行小字：给上移/下移定性，别让人以为只能上下挪 */
.move-tip-hint {
  margin-right: auto;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

.move-tip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-tip button {
  flex: 0 0 auto;
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* 提示条上的「上移 / 下移」：到顶 / 到底置灰，点不动 */
.move-tip button:disabled {
  opacity: 0.38;
  pointer-events: none;
}

/* 窄屏（手机）：提示文字让位给三个按钮，别把「上移/下移」挤出屏幕 */
@media (max-width: 380px) {
  .move-tip {
    gap: 8px;
    padding-left: 11px;
    font-size: 12px;
  }

  .move-tip button {
    padding: 0 10px;
    font-size: 11.5px;
  }
}

/* ============================================================
   背诵模式：整图遮住 → 点一下揭示一节
   ------------------------------------------------------------
   · 只遮「显示」，不动文档：遮罩用 .is-mask，节点框和连线都还在，
     让用户先回忆「这一块讲什么」，再点开对答案；
   · 已掌握（.is-known）打勾变淡，标记待复习（.is-review）描一圈橙边；
   · 底部工具条换成背诵控制条，编辑类按钮和折叠钮全部收起。
   ============================================================ */

/* 进背诵就别再露编辑入口：折叠钮、+、拖宽手柄一律收掉 */
.editor.is-recite .ed-dock,
.editor.is-recite .node .toggle,
.editor.is-recite .node .node-plus,
.editor.is-recite .node .node-resize {
  display: none !important;
}

/* 未揭示的节点：文字隐去，留一条灰色骨架 —— 长度还在，方便「看出有几条」 */
.editor.is-recite .node.is-mask {
  background: #eef1f6;
  border-color: #e4e9f2;
}

.editor.is-recite .node.is-mask .label,
.editor.is-recite .node.is-mask .node-img,
.editor.is-recite .node.is-mask .node-link {
  opacity: 0;
}

.editor.is-recite .node.is-mask::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  top: 50%;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.5);
}

/* 揭示动画：文字淡进来，比直接闪现更容易看出「这块刚才是藏着的」 */
.editor.is-recite .node .label {
  transition: opacity 0.18s ease;
}

/* 已掌握：打勾 + 变淡，扫一眼就知道哪些不用再看了 */
.editor.is-recite .node.is-known {
  opacity: 0.5;
}

.editor.is-recite .node.is-known::before {
  content: '✓';
  position: absolute;
  right: -7px;
  top: -7px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  font-weight: 700;
}

/* 标记待复习：橙色内描边，和已掌握的绿勾区分开 */
.editor.is-recite .node.is-review {
  box-shadow: inset 0 0 0 2px #f59e0b;
}

/**
 * 提示过的节点：前三个字照原位置露出来，后面的字只留位置、被一条浅灰盖住。
 * 文字布局完全不动（不换内容、不改对齐），看起来就像原句被涂掉后半段。
 */
.editor.is-recite .node.is-tip {
  background: #f8fafc;
  border-color: #e6ebf4;
}

.editor.is-recite .node.is-tip .label {
  opacity: 1;
  color: #475569;
}

.editor.is-recite .node.is-tip .tip-rest {
  color: transparent;
  background: #dde3ee;
  border-radius: 4px;
}

.editor.is-recite .node.is-tip::after {
  display: none;
}

/**
 * 挖空模式：不再是整块遮住，而是「整句看得见、只把数字和公式挖掉」。
 * 所以这里要把 .is-mask 的灰底 / 骨架条 / 文字透明全部撤销，只留 JS 换过的 ▢ 文本。
 */
.editor.is-recite.recall-hole .node.is-mask {
  background: #fff;
  border-color: #e8ecf5;
}

.editor.is-recite.recall-hole .node.is-mask .label {
  opacity: 1;
}

.editor.is-recite.recall-hole .node.is-mask::after {
  display: none;
}

/**
 * 手电筒（桌面）：鼠标停在哪条就临时亮哪条，用来快速过一遍。
 *
 * 必须锁在 hover 设备里：手机上 tap 之后 :hover 会「粘」在那个元素上，
 * 表现就是「点开再点回去，文字还亮着，点了别的才收起」——很像点了没反应。
 * 手机端点手电筒本来也只给一句提示，不真的开启。
 */
@media (hover: hover) and (pointer: fine) {
  .editor.is-recite.recall-torch .node.is-mask:hover {
    background: #fff;
    border-color: #e8ecf5;
  }

  .editor.is-recite.recall-torch .node.is-mask:hover .label {
    opacity: 1;
  }

  .editor.is-recite.recall-torch .node.is-mask:hover::after {
    display: none;
  }
}

/* ---------- 控制条 ---------- */

.ed-recall {
  position: absolute;
  left: 50%;
  bottom: calc(8px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 780px;
  max-width: calc(100% - 24px);
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid #e8ecf5;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
  box-sizing: border-box;
}

.ed-recall[hidden] {
  display: none;
}

.rc-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rc-prog {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.rc-bar {
  flex: 1;
  min-width: 40px;
  height: 6px;
  border-radius: 3px;
  background: #eef2f7;
  overflow: hidden;
}

.rc-bar em {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: #4f7cf7;
  transition: width 0.2s ease;
}

.rc-known {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: #16a34a;
}

.rc-acts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.rc-acts::-webkit-scrollbar {
  display: none;
}

.rc-chip,
.rc-done {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f2;
  background: #f7f9fc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.rc-chip:active {
  background: #eef2f8;
}

/**
 * 手机端把 chip 收窄一点：8 个按钮减到 6 个之后，390 / 414 宽的屏刚好排得下，
 * 360 的老安卓只会横向滚十几像素。只动背诵控制条这套 chip，不影响其它地方。
 */
@media (max-width: 899px) {
  .rc-acts {
    gap: 6px;
  }

  .rc-chip {
    padding: 0 10px;
    font-size: 12.5px;
  }
}

/* 开关型 chip（挖空 / 手电筒 / 朗读）：开着是蓝底 */
.rc-chip.is-on {
  background: #eaf0ff;
  border-color: #c7d6ff;
  color: #2f5bd8;
}

.rc-done {
  background: #2f5bd8;
  border-color: #2f5bd8;
  color: #fff;
}

/**
 * 重置：整张图从头再背一遍，优先级最高的动作。
 * 放上排、红色描边，和「完成」并列 —— 跟 提示 / 挖空 这些日常开关分开放，
 * 一眼能看出「这不是普通的模式按钮」。
 */
.rc-chip.rc-reset {
  background: #fff5f5;
  border-color: #f8c9c9;
  color: #d93a40;
}

.rc-chip.rc-reset:active {
  background: #ffe8e8;
}

/* 手机：控制条贴边，chip 行横向可滑 */
@media (max-width: 899px) {
  .ed-recall {
    bottom: calc(6px + var(--safe-b));
    padding: 9px 10px;
  }
}

/* ============================================================
   右键菜单（PC）：编辑 / 加减节点 / 复制粘贴 / 上下移 / 样式 / 删除
   ============================================================ */

.ed-menu {
  position: absolute;
  z-index: 40;
  min-width: 152px;
  padding: 4px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #eef2f7;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18);
}

.ed-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.ed-menu button:hover {
  background: #f4f7fb;
}

.ed-menu button:active {
  background: #eef3f9;
}

.ed-menu button:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.ed-menu .arrow {
  font-style: normal;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-3);
}

/* 分组分隔线：动作变多了，不分组一眼扫过去太挤 */
.ed-menu .sep {
  display: block;
  height: 1px;
  margin: 4px 6px;
  background: #eef2f7;
}

/* 删除是危险动作，单独标红，别和「复制」长得一样 */
.ed-menu button.danger {
  color: #e5484d;
}

.ed-menu button.danger .arrow {
  color: #e5484d;
}

/* ============================================================
   双击节点图片：本页看大图（点任意位置 / Esc 回到导图）
   ============================================================ */

.ed-lightbox {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  background: rgba(8, 13, 20, 0.9);
  cursor: zoom-out;
  -webkit-tap-highlight-color: transparent;
  /* 手机上要自己处理双指缩放：不关掉浏览器手势，pointer 事件会被取消 */
  touch-action: none;
}

.ed-lightbox[hidden] {
  display: none;
}

.ed-lightbox img {
  max-width: min(1100px, 94vw);
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  background: #fff;
  /* 缩放锚点放左上角，JS 里的换算才对得上 */
  transform-origin: 0 0;
  will-change: transform;
  cursor: zoom-in;
  -webkit-user-drag: none;
  user-select: none;
}

/* 放大后：整块变成「抓手」，拖动看图 */
.ed-lightbox.is-zoom {
  cursor: grab;
}

.ed-lightbox.is-zoom:active,
.ed-lightbox.is-zoom img {
  cursor: grabbing;
}

/* 底部操作提示：PC 才显示，手机不加这版功能就不打扰 */
.ed-lightbox .lb-tip {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 820px) {
  .ed-lightbox .lb-tip {
    display: none;
  }
}

/* 导出图片的全屏预览：PC 给「下载图片」，手机只给长按提示 */
.img-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.img-tip {
  color: #fff;
  font-size: 12px;
  opacity: 0.82;
}

/* ============================================================
   手机横屏（触屏 + 矮窗口）
   ============================================================ */

/**
 * 横屏专用：手机横过来后高度只有 360~430px，顶部 52 + 底部两排 ~95 就把画布
 * 啃掉一大半。这里把导航、工具条各压一档（纯图标，字已经隐藏），
 * 主题按钮跟着缩，给导图尽量多留高度。
 *
 * 只认触屏（pointer: coarse）：电脑上开个又宽又扁的窗口不受影响。
 */
@media (orientation: landscape) and (max-height: 560px) and (pointer: coarse) {
  .ed-bar {
    height: calc(44px + var(--safe-t));
  }

  .ed-icon-btn {
    width: 34px;
    height: 34px;
  }

  .ed-title {
    height: 34px;
    font-size: 15px;
  }

  .ed-tools,
  .ed-actions {
    padding: 1px 6px;
  }

  .ed-tool,
  .ed-act {
    width: 42px;
    height: 32px;
  }

  .ed-tool svg {
    width: 18px;
    height: 18px;
  }

  .ed-act svg {
    width: 19px;
    height: 19px;
  }

  .ed-theme-fab {
    top: 52px;
    left: 14px;
    width: 34px;
    height: 34px;
  }

  .ed-theme-fab svg {
    width: 18px;
    height: 18px;
  }

  /* 横屏是手指操作，没有滚轮 / 双击这一套，大图提示条别出来挡图 */
  .ed-lightbox .lb-tip {
    display: none;
  }

  .ed-sheet {
    max-height: 92vh;
  }
}

/* 横屏时左右可能压着刘海 / 圆角：顶部栏和底部横条都让出安全区 */
@media (orientation: landscape) and (pointer: coarse) {
  .ed-bar {
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
  }

  .ed-paybar {
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
  }

  .ed-dock-card {
    margin-left: calc(12px + env(safe-area-inset-left, 0px));
    margin-right: calc(12px + env(safe-area-inset-right, 0px));
  }
}

