/* ========== 温柔米杏色板 ========== */
:root {
  --bg: #f5ecd9;             /* 米杏色温柔背景 */
  --bg-card: #fdf6e6;        /* 节点和卡片更浅米杏 */
  --bg-hover: #ebe0c5;       /* hover 加深 */
  --bg-soft: #f0e6d0;

  --text: #4a3d2a;           /* 暖深棕主文字 */
  --text-soft: #8a7861;      /* 中度灰咖 */
  --text-faint: #b5a288;     /* 浅灰咖（次要） */

  --border: #d8c8a8;         /* 浅米杏边线 */
  --border-strong: #b8a37c;  /* 深一点的边线 */

  --accent: #c97b4a;         /* 温柔暖橙强调 */
  --accent-soft: #e8b994;
  --accent-bg: #f7dfc5;
  --accent-deep: #a25e30;

  --node-size: clamp(72px, 8vw, 90px);
  --node-size-root: clamp(86px, 9.5vw, 104px);
  --card-w: clamp(280px, 28vw, 360px);
  --notebook-w: clamp(260px, 23vw, 320px);

  --font:
    -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "HarmonyOS Sans SC",
    system-ui, sans-serif;

  --ease-out: cubic-bezier(0.34, 1.4, 0.64, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== 顶部 brand + 重置按钮 ========== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(14px, 1.6vw, 22px) clamp(18px, 2vw, 28px);
  z-index: 50;
  pointer-events: none;
}
.header > * { pointer-events: auto; }

.brand h1 {
  font-size: clamp(15px, 1.4vw, 17px);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.brand p {
  font-size: clamp(10.5px, 1vw, 12px);
  color: var(--text-soft);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.reset-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: clamp(11.5px, 1.1vw, 13px);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.reset-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.reset-btn:active { background: var(--border); }

/* ========== 画布 ========== */
#canvas-wrapper {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
#canvas-wrapper.dragging { cursor: grabbing; }
#link-layer {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}
#node-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* ========== 节点 ========== */
.node {
  position: absolute;
  width: var(--node-size);
  height: var(--node-size);
  margin-left: calc(var(--node-size) / -2);
  margin-top: calc(var(--node-size) / -2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transform: scale(0.5);
  opacity: 0;
  transition:
    left 0.5s var(--ease-out),
    top 0.5s var(--ease-out),
    transform 0.4s var(--ease-out),
    opacity 0.3s var(--ease-soft);
}
.node.visible { transform: scale(1); opacity: 1; }
.node.root {
  width: var(--node-size-root);
  height: var(--node-size-root);
  margin-left: calc(var(--node-size-root) / -2);
  margin-top: calc(var(--node-size-root) / -2);
}

/* 从灯泡选项 spawn 出来的节点：跟正常节点一样大，只是 disc 用虚线边表示「这是支线分支」*/
.node.from-lightbulb .node-disc {
  border-style: dashed;
}
.node.from-lightbulb.visited .node-disc {
  border-style: solid;  /* visited 后变实线，融入主路径 */
}

/* 节点角标：💡 新可点 / ! 还有路没走完 —— 贴在右上角小圆 */
.node-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  z-index: 3;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.22s var(--ease-soft), transform 0.22s var(--ease-out), background 0.18s;
  pointer-events: none;
  font-weight: 700;
  color: var(--accent-deep);
  box-shadow: 0 1px 3px rgba(74, 61, 42, 0.12);
}
.node-badge.show {
  opacity: 1;
  transform: scale(1);
}
.node-badge.badge-lightbulb {
  background: var(--accent-bg);
  border-color: var(--accent-soft);
  font-size: 12px;
  animation: badge-bulb-pulse 2s ease-in-out infinite;
}
.node-badge.badge-exclaim {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--bg-card);
  font-size: 14px;
}
@keyframes badge-bulb-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 1px 3px rgba(74, 61, 42, 0.12); }
  50% { transform: scale(1.12); box-shadow: 0 2px 6px rgba(201, 123, 74, 0.35); }
}
/* root 的角标位置稍微调整（root 节点更大） */
.node.root .node-badge {
  top: 4px;
  right: 4px;
}

.node-disc {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  transition: all 0.18s var(--ease-soft);
}
.node:hover .node-disc {
  border-color: var(--border-strong);
  background: var(--bg-soft);
}
.node.visited .node-disc {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.node.active .node-disc {
  border-color: var(--accent);
  border-width: 1.5px;
  box-shadow: 0 0 0 4px rgba(201, 123, 74, 0.18);
}
.node.root .node-disc {
  background: var(--text);
  border-color: var(--text);
}
.node.root.visited .node-disc {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.node-emoji {
  font-size: calc(var(--node-size) * 0.4);
  line-height: 1;
  margin-bottom: 3px;
  z-index: 1;
  pointer-events: none;
  position: relative;
}
.node.root .node-emoji { font-size: calc(var(--node-size-root) * 0.4); }

.node-title {
  position: relative;
  font-size: clamp(11px, 1.1vw, 12.5px);
  color: var(--text);
  text-align: center;
  line-height: 1.2;
  padding: 0 4px;
  z-index: 1;
  pointer-events: none;
  max-width: 92%;
  font-weight: 500;
}
.node.root .node-title {
  color: var(--bg-card);
  font-size: clamp(11.5px, 1.2vw, 13px);
  font-weight: 500;
}

/* ========== 连线 ========== */
.link-path {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.4s var(--ease-soft), stroke 0.3s, stroke-width 0.3s;
}
.link-path.visible { opacity: 1; }
.link-path.gold {
  stroke: var(--accent);
  stroke-width: 1.6;
}
/* 直流连线：父只有 1 个子节点时，连线终点画箭头标记 = 视觉表示"这是直流，不分叉" */
.link-path.arrow-direct {
  marker-end: url(#arrow-direct);
}
.link-path.arrow-direct.gold {
  marker-end: url(#arrow-direct-gold);
}

/* ========== 详情卡片 ========== */
#card-root { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

.card {
  position: absolute;
  width: var(--card-w);
  max-width: calc(100vw - 24px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.18s var(--ease-soft), transform 0.22s var(--ease-out);
  box-shadow:
    0 8px 24px rgba(74, 61, 42, 0.1),
    0 2px 6px rgba(74, 61, 42, 0.06);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  /* 高度由 JS positionCard 设置 max-height 防止上下出画。当 max-height 触发：
     header / footer 固定高，body 弹性占剩余空间内"可见内容尽量多"——但宝宝禁止可滚动框
     所以 body 用 overflow: hidden 兜底（视觉切掉而不是滚动）；同时分 page 让内容不至于超长 */
  overflow: hidden;
}
.card.show { opacity: 1; transform: translateY(0) scale(1); }

.card-tail {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  transform: rotate(45deg);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.card-emoji { font-size: 22px; line-height: 1; flex-shrink: 0; }
.card-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  flex: 1;
}
.card-close {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  width: 24px; height: 24px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease-soft);
}
.card-close:hover { color: var(--text); background: var(--bg-hover); }

.card-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  min-height: 0;
  flex: 1 1 auto;  /* 弹性占据剩余空间 */
  overflow-y: auto;
  overscroll-behavior: contain;  /* 滚到顶/底不会带动外层 body */
  -webkit-overflow-scrolling: touch;  /* iOS 旧版本平滑滚动 */
  position: relative;
  /* 自定义滚动条：暖色板细窄不抢戏 */
  scrollbar-width: thin;
  scrollbar-color: var(--accent-soft) transparent;
}
.card-body::-webkit-scrollbar { width: 6px; }
.card-body::-webkit-scrollbar-track { background: transparent; }
.card-body::-webkit-scrollbar-thumb {
  background: var(--accent-soft);
  border-radius: 3px;
}
.card-body::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* 内容可继续下滑时，底部一道渐隐 + 一个小箭头暗示"还有内容" */
.card-body.cut::after {
  content: '⌄';
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--accent);
  line-height: 36px;
  background: linear-gradient(to bottom, rgba(253, 246, 230, 0), var(--bg-card) 65%);
  pointer-events: none;
  animation: scroll-hint-bob 1.8s ease-in-out infinite;
}
@keyframes scroll-hint-bob {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(2px); opacity: 1; }
}
.card-body p { margin: 0 0 4px; }
.card-body ul { margin: 3px 0; padding-left: 18px; }
.card-body li { margin: 1px 0; }
.card-body p:last-child { margin-bottom: 0; }
.card-body strong { color: var(--accent-deep); font-weight: 600; }
.card-body em {
  font-style: normal;
  font-weight: 600;
  color: var(--text);
}
.card-body em.term-clickable {
  cursor: pointer;
  border-bottom: 1px dotted var(--accent);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}
.card-body em.term-clickable:hover {
  color: var(--accent-deep);
  border-bottom-color: var(--accent-deep);
}
.card-body .term {
  border-bottom: 1.5px solid var(--accent);
  padding: 0 1px;
  font-weight: 500;
}

/* 术语解释 tooltip（点击 em 弹出） */
.term-tooltip {
  position: fixed;
  z-index: 200;
  background: var(--text);
  color: var(--bg-card);
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 12px;
  max-width: 260px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s var(--ease-soft), transform 0.18s var(--ease-soft);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  pointer-events: auto;
}
.term-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}
.term-tooltip .term-tip-name {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--accent-soft);
  font-family: var(--font);
}
.term-tooltip .term-tip-desc {
  line-height: 1.55;
  color: var(--bg-card);
}
.card-body code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent-deep);
}

/* 卡片里的"图示"区——拟人 emoji + 简单关系图，让用户一眼看懂 */
.card-body .page-illust {
  margin: 10px 0;
  padding: 12px 10px;
  background: var(--bg-soft);
  border-radius: 6px;
  border: 1px dashed var(--border);
}
.card-body .illust-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 3px 0;
}
.card-body .illust-icon {
  font-size: 22px;
  line-height: 1;
}
.card-body .illust-arrow {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
}
.card-body .illust-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text);
}
.card-body .illust-pill.good {
  border-color: var(--accent-soft);
  background: var(--accent-bg);
  color: var(--accent-deep);
}
.card-body .illust-pill.bad {
  border-color: var(--border-strong);
  color: var(--text-soft);
  text-decoration: line-through;
}
.card-body .illust-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--text);
  max-width: 60%;
}
.card-body .illust-cap {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.4;
}
.card-body .illust-cap-inline {
  font-size: 11px;
  color: var(--text-soft);
  line-height: 1.4;
}

/* ========== 卡片内小流程：元素按顺序 fade-in 亮起来 ========== */
.card-body .mini-flow {
  margin: 12px 0;
  padding: 12px 6px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.card-body .mini-flow > * {
  opacity: 0;
  animation: mini-flow-in 0.45s var(--ease-out) forwards;
}
.card-body .mini-flow > *:nth-child(1) { animation-delay: 0.10s; }
.card-body .mini-flow > *:nth-child(2) { animation-delay: 0.35s; }
.card-body .mini-flow > *:nth-child(3) { animation-delay: 0.60s; }
.card-body .mini-flow > *:nth-child(4) { animation-delay: 0.85s; }
.card-body .mini-flow > *:nth-child(5) { animation-delay: 1.10s; }
.card-body .mini-flow > *:nth-child(6) { animation-delay: 1.35s; }
.card-body .mini-flow > *:nth-child(7) { animation-delay: 1.60s; }
.card-body .mini-flow > *:nth-child(8) { animation-delay: 1.85s; }
@keyframes mini-flow-in {
  from { opacity: 0; transform: translateY(8px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card-body .flow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 50px;
  flex-shrink: 0;
}
.card-body .flow-emoji { font-size: 22px; line-height: 1.1; }
.card-body .flow-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.card-body .flow-role {
  font-size: 10px;
  color: var(--text-soft);
}
.card-body .flow-op {
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  align-self: center;
  flex-shrink: 0;
}
.card-body .flow-result {
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-deep);
  margin: 6px 0 10px;
  opacity: 0;
  animation: mini-flow-in 0.45s var(--ease-out) forwards;
  animation-delay: 1.6s;
}

/* 循环流程（传感器→代码→执行器，loop 高亮） */
.card-body .loop-flow {
  margin: 12px 0;
  padding: 12px 6px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.card-body .loop-flow .flow-step {
  position: relative;
  padding: 4px 6px;
  border-radius: 6px;
  animation: loop-highlight 4.5s ease-in-out infinite;
}
.card-body .loop-flow .flow-step:nth-child(1) { animation-delay: 0s; }
.card-body .loop-flow .flow-step:nth-child(3) { animation-delay: 1.5s; }
.card-body .loop-flow .flow-step:nth-child(5) { animation-delay: 3.0s; }
.card-body .loop-flow .flow-op { animation: loop-arrow 4.5s ease-in-out infinite; }
.card-body .loop-flow .flow-op:nth-child(2) { animation-delay: 0.75s; }
.card-body .loop-flow .flow-op:nth-child(4) { animation-delay: 2.25s; }
@keyframes loop-highlight {
  0%, 80%, 100% { background: transparent; transform: scale(1); }
  10%, 25% { background: var(--accent-bg); transform: scale(1.08); }
}
@keyframes loop-arrow {
  0%, 80%, 100% { color: var(--text-faint); }
  10%, 25% { color: var(--accent); }
}

/* ========== 互动 widget：前后端传消息（自动循环动画） ========== */
.card-body .fe-be-game {
  margin: 12px 0;
  padding: 16px 12px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-body .fe-be-game .actor {
  flex: 0 0 auto;
  text-align: center;
  min-width: 56px;
}
.card-body .fe-be-game .actor-emoji { font-size: 28px; line-height: 1.1; }
.card-body .fe-be-game .actor-label {
  font-size: 10.5px;
  color: var(--text-soft);
  margin-top: 2px;
}
.card-body .fe-be-game .msg-track {
  flex: 1;
  position: relative;
  height: 60px;
  overflow: hidden;
}
.card-body .fe-be-game .msg {
  position: absolute;
  top: 50%;
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10.5px;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
}
.card-body .fe-be-game .msg-req {
  left: 0;
  transform: translateY(-50%);
  animation: msg-req-fly 3.6s ease-in-out infinite;
}
.card-body .fe-be-game .msg-res {
  right: 0;
  transform: translateY(-50%);
  animation: msg-res-fly 3.6s ease-in-out infinite;
  background: var(--accent-bg);
  border-color: var(--accent-soft);
  color: var(--accent-deep);
}
@keyframes msg-req-fly {
  0%       { left: 0;    opacity: 0; }
  10%      { left: 5%;   opacity: 1; }
  40%      { left: 70%;  opacity: 1; }
  45%      { opacity: 0; left: 75%; }
  100%     { opacity: 0; left: 75%; }
}
@keyframes msg-res-fly {
  0%, 50%  { right: 0;   opacity: 0; }
  55%      { right: 5%;  opacity: 1; }
  90%      { right: 70%; opacity: 1; }
  95%, 100%{ right: 75%; opacity: 0; }
}

/* ========== 互动 widget：HTML/CSS/JS 三件套层叠演示（小网页 mock） ========== */
.card-body .web-stack-game {
  margin: 12px 0;
  padding: 14px 12px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 6px;
}
.card-body .web-stack-game .stack-mock {
  margin: 0 auto;
  width: 180px;
  height: 100px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  position: relative;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10.5px;
  overflow: hidden;
}
.card-body .web-stack-game .stack-layer {
  opacity: 0;
  animation: stack-fade-in 4.5s ease-in-out infinite;
}
.card-body .web-stack-game .stack-layer.html { animation-delay: 0s; }
.card-body .web-stack-game .stack-layer.css  { animation-delay: 1.2s; }
.card-body .web-stack-game .stack-layer.js   { animation-delay: 2.4s; }
@keyframes stack-fade-in {
  0%, 5%   { opacity: 0; }
  15%, 75% { opacity: 1; }
  85%, 100%{ opacity: 1; }
}
.card-body .web-stack-game .mock-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: #333;
}
.card-body .web-stack-game .mock-title.styled {
  color: #c97b4a;
  font-size: 12px;
}
.card-body .web-stack-game .mock-btn {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  color: #333;
}
.card-body .web-stack-game .mock-btn.styled {
  background: #c97b4a;
  color: white;
  border-radius: 4px;
}
.card-body .web-stack-game .stack-labels {
  display: flex;
  justify-content: space-around;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-soft);
}
.card-body .web-stack-game .stack-labels span {
  opacity: 0;
  animation: stack-label-in 4.5s ease-in-out infinite;
}
.card-body .web-stack-game .stack-labels span:nth-child(1) { animation-delay: 0s; }
.card-body .web-stack-game .stack-labels span:nth-child(2) { animation-delay: 1.2s; }
.card-body .web-stack-game .stack-labels span:nth-child(3) { animation-delay: 2.4s; }
@keyframes stack-label-in {
  0%, 5%   { opacity: 0; color: var(--text-faint); }
  15%, 75% { opacity: 1; color: var(--accent-deep); }
  85%, 100%{ opacity: 0.5; color: var(--text-soft); }
}

/* ========== 通用 emoji 关系图 illust ========== */
.card-body .emoji-illust {
  margin: 12px 0;
  padding: 12px 8px;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text);
}
.card-body .emoji-illust .ei-emoji {
  font-size: 24px;
  line-height: 1.1;
}
.card-body .emoji-illust .ei-label {
  font-size: 11px;
  color: var(--text-soft);
}
.card-body .emoji-illust .ei-arrow {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

/* 卡片选项列表（用户选「下一步走哪」） */
.card-options {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.options-label {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}
.options-end {
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
  padding: 6px 0;
}
.option {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  text-align: left;
  transition: all 0.15s var(--ease-soft);
  width: 100%;
}
.option:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.option:active { transform: scale(0.985); }
.option.visited {
  background: var(--accent-bg);
  border-color: var(--accent-soft);
  color: var(--accent-deep);
}
.option.visited:hover { background: var(--accent-bg); }
.option .opt-icon {
  font-size: 15px;
  line-height: 1;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.option .opt-label { flex: 1; line-height: 1.35; }
.option .opt-hint {
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}
.option.lightbulb {
  border-style: dashed;
}
.option.lightbulb .opt-icon {
  animation: lightbulb-pulse 2.4s ease-in-out infinite;
}
.option.lightbulb:hover { border-style: solid; }

@keyframes lightbulb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* 跳转选项（仅 root 有）：视觉上跟主选项 / 灯泡支线都不同——表示"绕过中间直接跳过去" */
.option.jump {
  border-color: var(--accent-soft);
  background: linear-gradient(to right, var(--bg-card), var(--accent-bg) 200%);
  position: relative;
}
.option.jump::before {
  content: '⤴';
  position: absolute;
  left: -3px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--accent);
  background: var(--bg-card);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-soft);
}
.option.jump:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.option.jump .opt-hint {
  background: var(--accent-bg);
  color: var(--accent);
}

/* ========== 笔记本搜索框 ========== */
.notebook-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.notebook-search-icon {
  font-size: 13px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.notebook-search-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}
.notebook-search-input::placeholder { color: var(--text-faint); }
.notebook-search-input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}
.notebook-search-clear {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.notebook-search-clear:hover { color: var(--text); background: var(--bg-hover); }

.notebook-list mark {
  background: var(--accent-bg);
  color: var(--accent-deep);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

/* ========== 互动小游戏 widget ========== */

/* example 第二张并行卡片：跟主卡片同款样式，放在主卡片旁边（不是中心遮罩弹窗）
   修弹窗"乱动一下"：用 opacity fade，不用 transform 平移（避免位置先错后纠正） */
.card.example-card-popup {
  z-index: 70;  /* 比主卡片 60 略高，但不像 modal 那样盖一切 */
  cursor: default;
  transform: none !important;
  opacity: 0;
  transition: opacity 0.2s var(--ease-soft), box-shadow 0.18s var(--ease-soft);
}
.card.example-card-popup.show {
  opacity: 1;
  transform: none !important;
}
.card.example-card-popup.dragging {
  box-shadow:
    0 16px 40px rgba(74, 61, 42, 0.22),
    0 4px 10px rgba(74, 61, 42, 0.12);
  user-select: none;
}
.card.example-card-popup .card-header {
  background: var(--accent-bg);
  margin: -10px -12px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--accent-soft);
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
/* 拖动小提示：header 左上角小图标 */
.card.example-card-popup .card-header::after {
  content: '⋮⋮';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-soft);
  font-size: 13px;
  letter-spacing: -1.5px;
  pointer-events: none;
  opacity: 0.7;
}
.card.example-card-popup .card-emoji {
  margin-left: 14px;  /* 给拖拽提示让位 */
}
.card.example-card-popup .card-title {
  color: var(--accent-deep);
}
.card.example-card-popup .card-close {
  cursor: pointer;
}
.example-popup-body {
  font-size: 13px;
  line-height: 1.7;
}

/* (0) example-card 在主卡片里只显示按钮（内容由 modal 接管） */
.example-card {
  margin: 10px 0;
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent-bg) 0%, var(--bg-card) 100%);
  overflow: hidden;
}
.example-toggle {
  width: 100%;
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--accent-deep);
  cursor: pointer;
  text-align: left;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s;
}
.example-toggle:hover {
  background: rgba(201, 123, 74, 0.08);
}
.example-card.opened .example-toggle {
  border-bottom: 1px solid var(--accent-soft);
}
.example-content {
  padding: 10px 12px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  animation: example-slide 0.35s var(--ease-soft);
}
.example-content[hidden] { display: none; }
@keyframes example-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* example 三段结构：原理类比 / 实际场景 / 好处帮助
   (selector 同时适用主卡片内的 .example-content 和并行弹卡片 .example-popup-body) */
.example-content .ex-section,
.example-popup-body .ex-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--accent-soft);
}
.example-content .ex-section:first-child,
.example-popup-body .ex-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.example-content .ex-section-title,
.example-popup-body .ex-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-deep);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
}
.example-content .ex-section-title .ex-section-icon,
.example-popup-body .ex-section-title .ex-section-icon {
  font-size: 15px;
}

/* example 三种内容形式 */
/* (a) ex-story 拟人化故事场景：用 emoji + 短句模拟现实场景 */
.example-content .ex-story {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}
.example-content .ex-story .ex-line,
.example-popup-body .ex-story .ex-line {
  display: block;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 8px;
  word-break: break-word;
  overflow-wrap: break-word;
}
.example-content .ex-story .ex-line:last-child,
.example-popup-body .ex-story .ex-line:last-child { margin-bottom: 0; }
.example-content .ex-story .ex-emoji,
.example-popup-body .ex-story .ex-emoji {
  display: inline-block;
  font-size: 16px;
  width: 22px;
  text-align: center;
  vertical-align: -2px;
  margin-right: 6px;
}
.example-popup-body .ex-story .ex-caption {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-soft);
  font-style: italic;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-radius: 6px;
  border-left: 2px solid var(--accent-soft);
}
.example-content .ex-story .ex-arrow {
  color: var(--accent);
  font-weight: 600;
  margin: 0 2px;
}
.example-content .ex-story .ex-caption {
  color: var(--text-soft);
  font-size: 11px;
  font-style: italic;
  margin-top: 4px;
  padding-left: 32px;
}

/* (b) ex-code 真实代码片段 + 大白话注释 */
.example-content .ex-code {
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}
.example-content .ex-code .ex-comment {
  color: var(--text-faint);
  font-style: italic;
  font-family: var(--font);
  font-size: 10.5px;
}
.example-content .ex-code .ex-keyword {
  color: var(--accent-deep);
  font-weight: 600;
}
.example-content .ex-code .ex-string {
  color: #6b8e23;  /* 暖橄榄绿避免抢戏 */
}

/* (c) ex-flow 步骤流程：1→2→3→4 用户视角的事件链 */
.example-content .ex-flow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
  counter-reset: ex-step;
}
.example-content .ex-flow .ex-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
}
.example-content .ex-flow .ex-step::before {
  counter-increment: ex-step;
  content: counter(ex-step);
  background: var(--accent);
  color: var(--bg-card);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.example-content .ex-flow .ex-step-emoji {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  margin-top: -1px;
}
.example-content .ex-flow .ex-step-text {
  flex: 1;
  color: var(--text);
}
.example-content .ex-flow .ex-step-text strong {
  color: var(--accent-deep);
}

/* (1) 点击揭晓 reveal-card —— 用户点了才看到答案 */
/* 未揭晓时：问题 + 按钮 同一行 flex 紧凑；揭晓后：变竖排显示答案 */
.reveal-card {
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 6px 10px;
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.reveal-card.revealed {
  display: block;
  position: relative;
  padding-right: 56px;  /* 给右上角的收起按钮留位置 */
}
.reveal-q {
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.4;
  flex: 1;
}
.reveal-card.revealed .reveal-q {
  margin-bottom: 4px;
}
.reveal-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 11px;
  flex-shrink: 0;
  color: var(--accent);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s var(--ease-soft);
}
.reveal-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
/* 揭晓后按钮变「收起 ←」，挪到右上角不挡内容；JS 改文本即可 toggle */
.reveal-card.revealed .reveal-btn {
  position: absolute;
  top: 6px;
  right: 6px;
}
.reveal-a {
  font-size: 11px;
  color: var(--text);
  line-height: 1.4;
  margin-top: 6px;
  animation: reveal-in 0.35s var(--ease-soft);
}
.reveal-a > p {
  margin: 3px 0;
}
@keyframes reveal-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* (2) 连连看 matching-game —— 两列，左右配对 */
.matching-game {
  margin: 6px 0 4px;
  padding: 7px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.match-hint {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-bottom: 5px;
  text-align: center;
}
.match-rows {
  display: flex;
  gap: 8px;
}
.match-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.match-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  transition: all 0.15s var(--ease-soft);
  user-select: none;
}
.match-item:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.match-item.selected {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.match-item.matched {
  background: var(--accent-bg);
  border-color: var(--accent-soft);
  color: var(--accent-deep);
  cursor: default;
  opacity: 0.72;
}
.match-item.wrong {
  animation: match-shake 0.3s;
  background: #f3d4c5;
  border-color: #d68768;
}
@keyframes match-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.match-done {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--accent-deep);
  text-align: center;
  font-weight: 500;
  display: none;
}
.matching-game.done .match-done { display: block; }

/* (3) 场景选择题 quiz-card —— 多个候选答案，给反馈 */
.quiz-card {
  margin: 6px 0;
  padding: 7px 10px;
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
}
.quiz-q {
  font-size: 11.5px;
  color: var(--text);
  margin-bottom: 5px;
  line-height: 1.45;
}
.quiz-opts {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.quiz-opt {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 11px;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s var(--ease-soft);
}
.quiz-opt:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.quiz-card.answered .quiz-opt { cursor: default; }
.quiz-opt.correct {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-deep);
}
.quiz-opt.wrong {
  background: #f3d4c5;
  border-color: #d68768;
  color: #6b3a2a;
}
.quiz-result {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.5;
  display: none;
  animation: reveal-in 0.35s var(--ease-soft);
}
.quiz-card.answered .quiz-result { display: block; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
}
.card-pager { display: flex; align-items: center; gap: 4px; }
.card-pager button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  width: 26px; height: 22px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: all 0.15s var(--ease-soft);
}
.card-pager button:disabled { opacity: 0.32; cursor: not-allowed; }
.card-pager button:not(:disabled):hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.card-pager .page-indicator { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }

/* ========== 笔记本（右侧抽屉） ========== */
.notebook {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  z-index: 80;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
}

.notebook-toggle {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right: none;
  padding: 14px 10px;
  margin-top: clamp(72px, 8vw, 90px);
  cursor: pointer;
  border-radius: 10px 0 0 10px;
  font-family: inherit;
  font-size: 11px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s var(--ease-soft);
  position: relative;
  z-index: 2;
}
.notebook-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.notebook-icon { font-size: 20px; line-height: 1; }
.notebook-label {
  writing-mode: vertical-rl;
  letter-spacing: 0.18em;
  font-size: 11px;
}
.notebook-count {
  background: var(--accent);
  color: var(--bg-card);
  border-radius: 9px;
  padding: 1px 6px;
  font-size: 10.5px;
  min-width: 18px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.notebook-count.empty { visibility: hidden; }

.notebook-panel {
  pointer-events: auto;
  width: var(--notebook-w);
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 18px rgba(74, 61, 42, 0.08);
  transform: translateX(100%);
  transition: transform 0.32s var(--ease-soft);
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  right: 0;
}
.notebook.open .notebook-panel {
  transform: translateX(0);
}
.notebook.open .notebook-toggle {
  transform: translateX(calc(-1 * var(--notebook-w)));
}

.notebook-head {
  padding: 22px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.notebook-head h2 {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}
.notebook-head p {
  font-size: 11.5px;
  color: var(--text-soft);
  margin-top: 4px;
  line-height: 1.5;
}

.notebook-list {
  flex: 1;
  list-style: none;
  overflow-y: auto;
  padding: 6px 0;
}
.notebook-list li {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.notebook-list li:last-child { border-bottom: none; }
.notebook-list .concept-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.notebook-list .concept-explain {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-soft);
}
.notebook-list .empty-hint {
  padding: 36px 20px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-faint);
}

/* ========== 解锁 toast：新节点 spawn 时弹一下提示"解锁了 X" ========== */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--accent-deep);
  color: var(--bg-card);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(74, 61, 42, 0.25);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.28s var(--ease-soft), transform 0.32s var(--ease-out);
  pointer-events: auto;
  cursor: default;
  white-space: nowrap;
  max-width: min(80vw, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast .toast-emoji { margin-right: 6px; }

/* ========== 全局搜索：浮动按钮 + 搜索卡片 + 跳转结果浮按钮 ========== */
.search-toggle {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 80;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px 16px 8px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(74, 61, 42, 0.12);
  transition: all 0.18s var(--ease-soft);
}
.search-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.search-toggle-icon { font-size: 14px; }

.search-card {
  position: fixed;
  left: 18px;
  bottom: 72px;  /* search-toggle 上方 */
  width: min(380px, calc(100vw - 36px));
  max-height: min(70vh, 540px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow:
    0 12px 36px rgba(74, 61, 42, 0.18),
    0 4px 10px rgba(74, 61, 42, 0.08);
  z-index: 90;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  overflow: hidden;
  animation: search-card-in 0.18s var(--ease-out);
}
.search-card[hidden] { display: none; }
@keyframes search-card-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-bg);
  flex-shrink: 0;
}
.search-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent-deep);
}
.search-card-close {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 18px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease-soft);
}
.search-card-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.5); }

.search-card-input-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  box-sizing: border-box;
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-card);
}

.search-results {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-soft) transparent;
  min-height: 0;
}
.search-results::-webkit-scrollbar { width: 6px; }
.search-results::-webkit-scrollbar-thumb { background: var(--accent-soft); border-radius: 3px; }

.search-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.search-result:hover { background: var(--bg-hover); }
.search-result:last-child { border-bottom: none; }
.search-result-emoji {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  margin-top: 1px;
}
.search-result-body { flex: 1; min-width: 0; }
.search-result-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.search-result-path {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-snippet {
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result mark {
  background: var(--accent-bg);
  color: var(--accent-deep);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

.search-results-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}
.search-results-hint {
  padding: 10px 14px;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* 跳到结果后浮按钮：上一个 / 下一个（避开右下笔记本侧栏，放左下偏中） */
.search-nav {
  position: fixed;
  left: 18px;
  bottom: 64px;  /* search-toggle 正上方 */
  z-index: 75;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(74, 61, 42, 0.12);
  font-family: inherit;
}
.search-nav[hidden] { display: none; }
.search-nav button {
  background: transparent;
  border: none;
  color: var(--accent-deep);
  font-size: 18px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease-soft);
}
.search-nav button:hover { background: var(--accent-bg); }
.search-nav button:disabled { color: var(--text-faint); cursor: not-allowed; opacity: 0.5; }
.search-nav-info {
  font-size: 11.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
}
.search-nav-close { font-size: 14px !important; color: var(--text-faint) !important; }

/* 移动端微调 */
@media (max-width: 720px) {
  .search-toggle-text { display: none; }
  .search-toggle { padding: 8px 10px; left: 12px; bottom: 12px; }
  .search-card {
    width: calc(100vw - 24px);
    left: 12px;
    bottom: 64px;
    max-height: 70vh;
  }
  .search-nav { left: 12px; bottom: 56px; }
}

/* ========== 移动端 ========== */
@media (max-width: 720px) {
  :root {
    --node-size: clamp(58px, 16vw, 76px);
    --node-size-root: clamp(70px, 19vw, 88px);
    --card-w: min(90vw, 340px);
    --notebook-w: min(86vw, 320px);
  }
  .header { padding: 14px 18px; }
  .brand h1 { font-size: 14px; }
  .brand p { font-size: 10.5px; }
  .reset-btn { font-size: 12px; padding: 5px 11px; }
  /* 移动端字号反而增大：屏幕小、阅读距离近、不能再压小 */
  .card { padding: 12px 14px; }
  .card-title { font-size: 15px; }
  .card-body { font-size: 14px; line-height: 1.55; }
  .card-body p { margin: 0 0 6px; }
  .card-body code { font-size: 13px; }
  .card-body em { font-size: inherit; }
  .card-body .term-tooltip { font-size: 13px; max-width: 80vw; }
  .options-label { font-size: 12px; }
  .option { font-size: 13.5px; padding: 7px 12px; }
  .option .opt-icon { font-size: 16px; }
  .option .opt-hint { font-size: 11.5px; }
  .card-body .flow-emoji { font-size: 24px; }
  .card-body .flow-name { font-size: 12.5px; }
  .card-body .flow-role { font-size: 11px; }
  .card-body .emoji-illust .ei-emoji { font-size: 22px; }
  .card-body .emoji-illust .ei-label { font-size: 12.5px; }
  .reveal-q, .reveal-a, .reveal-btn { font-size: 13px; }
  .match-item { font-size: 12.5px; padding: 5px 8px; }
  .quiz-opt { font-size: 13px; }
  .notebook-toggle { margin-top: 64px; padding: 12px 8px; }
  .notebook-list .concept-name { font-size: 14.5px; }
  .notebook-list .concept-explain { font-size: 13px; }
  .notebook-search-input { font-size: 13.5px; }
}

/* ========== 减少动画偏好 ========== */
@media (prefers-reduced-motion: reduce) {
  .node, .card, .link-path, .notebook-panel { transition-duration: 0.15s; }
}
