/* ============================================================
   最终版式（最后加载）：稳定三栏 + 无限画布铺满
   覆盖之前所有布局实验残留
   ============================================================ */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- 工具栏 ---- */
.ribbon {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  gap: 0;
  height: 54px;
  background: #f0f0f0;
  border-bottom: 1px solid #d9d9d9;
  padding: 0 6px;
}
.ribbon-group {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 10px 2px;
  border-right: 1px solid #e2e2e2;
  min-width: 0;
}
.ribbon-group.grow { margin-left: auto; border-right: none; }
.rg-body { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.rg-label { font-size: 9px; color: #8c8c8c; text-align: center; padding-top: 1px; }
.rbtn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 11px;
  color: #262626;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.rbtn:hover { background: #e8f1fb; border-color: #c9dff2; }
.rbtn.primary { background: #1a73c9; border-color: #1a73c9; color: #fff; }
.rbtn.primary:hover { background: #155ea6; }
.rselect, .rinput {
  height: 22px;
  border: 1px solid #bfbfbf;
  background: #fff;
  color: #262626;
  font-size: 10.5px;
  border-radius: 2px;
  padding: 0 5px;
}
.rfield { display: flex; align-items: center; gap: 4px; font-size: 10px; color: #595959; }
.rinput { width: 96px; }

/* ---- 三栏：铺满、各自滚动 ---- */
.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 300px;
  gap: 8px;
  padding: 8px;
  background: #e6e6e6;
}
.palette, .inspector, .workspace {
  min-width: 0;
  min-height: 0;
  position: static !important;
  inset: auto !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  width: auto !important;
  height: auto !important;
}
.palette, .inspector { display: flex; flex-direction: column; overflow: hidden; }
.palette-list, .inspector-body { flex: 1; min-height: 0; overflow-y: auto; }
.workspace { display: flex !important; flex-direction: column; overflow: hidden; }
.theme-visio .workspace > #canvas { display: block !important; }
.theme-visio .workspace > .statusbar { display: flex !important; }

/* 画布：无限画布铺满中间区域 */
.canvas {
  flex: 1;
  min-height: 0;
  position: relative !important;
  margin: 0 !important;
  overflow: hidden;
}
.statusbar {
  flex-shrink: 0;
  height: 28px;
  position: static !important;
  width: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
}

/* ---- 其他主题的工具栏配色 ---- */
.theme-cosmic .ribbon {
  background: rgba(28, 19, 52, 0.9);
  border-bottom-color: rgba(150, 120, 255, 0.25);
}
.theme-cosmic .ribbon-group { border-right-color: rgba(150, 120, 255, 0.18); }
.theme-cosmic .rbtn { color: #d9d0f5; }
.theme-cosmic .rbtn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(198, 249, 106, 0.5); }
.theme-cosmic .rbtn.primary { background: #c6f96a; color: #1c2410; border-color: #c6f96a; }
.theme-cosmic .rselect, .theme-cosmic .rinput { background: #1a1233; border-color: rgba(150, 120, 255, 0.3); color: #ece7ff; }
.theme-cosmic .rg-label { color: #8d7fbd; }
.theme-cosmic .rfield { color: #9d90c7; }
.theme-cosmic .main { background: #0d0819; }

.theme-light .ribbon { background: rgba(255, 255, 255, 0.86); border-bottom-color: #e6e2f5; }
.theme-light .ribbon-group { border-right-color: #ece8f9; }
.theme-light .rbtn { color: #4b4768; }
.theme-light .rbtn:hover { background: #f2edff; border-color: #d5cdf5; }
.theme-light .rbtn.primary { background: linear-gradient(135deg, #ff9ed8, #9a8bff); color: #fff; border: none; }
.theme-light .rselect, .theme-light .rinput { background: #fff; border-color: #e2def2; color: #2c2846; }
.theme-light .rg-label { color: #9a94bb; }
.theme-light .main { background: transparent; }

/* 训练设置分组 */
.settings-sub { font-size: 11px; color: #8c8c8c; margin-bottom: 10px; }
.settings-section {
  border: 1px solid #e2e6ec;
  border-radius: 8px;
  padding: 10px 12px 4px;
  margin-bottom: 10px;
  background: #fbfcfd;
}
.settings-section-title { font-size: 11.5px; font-weight: 700; color: #404040; margin-bottom: 8px; }
.settings-hint { font-size: 10.5px; color: #8c8c8c; margin: 2px 0 8px; line-height: 1.5; }
.check-row { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 4px 0; color: #404040; }
.theme-cosmic .settings-section { background: rgba(255,255,255,.04); border-color: rgba(150,120,255,.25); }
.theme-cosmic .settings-section-title { color: #e5ddff; }
.theme-cosmic .settings-sub, .theme-cosmic .settings-hint { color: #8d7fbd; }
.theme-cosmic .check-row { color: #d9d0f5; }

/* 弹窗必须完全不透明并盖住画布 */
.modal-mask { z-index: 9999 !important; background: rgba(0, 0, 0, 0.45) !important; }
.modal { position: relative; z-index: 10000; background: #ffffff !important; }
.theme-cosmic .modal { background: #241a44 !important; }
.modal-body { background: inherit; }

/* 弹窗不做淡入（避免弱环境/截图捕捉到半透明状态） */
.modal-mask { animation: none !important; opacity: 1 !important; backdrop-filter: none !important; }
.modal { animation: none !important; }

/* 浅色小字改成中文，并稍微加深一点 */
.tile .tile-short, .node-type { font-family: inherit !important; letter-spacing: 0.2px; }
.theme-visio .tile .tile-short { color: #7a7a7a; font-size: 10px; }
.theme-visio .node-type { color: #6f6f6f; font-size: 9.5px; }
.tile .tile-short { color: #7a7590; }

/* ================= 深色模式（黑） ================= */
.theme-dark body, .theme-dark #app { background: #0b0d12 !important; }
.theme-dark .main { background: #0b0d12 !important; }
.theme-dark .ribbon {
  background: #17181d;
  border-bottom: 1px solid #2a2c33;
}
.theme-dark .ribbon-group { border-right-color: #262830; }
.theme-dark .rg-label { color: #6f737e; }
.theme-dark .rbtn { color: #d2d5dc; }
.theme-dark .rbtn:hover { background: #232630; border-color: #3a3f4d; }
.theme-dark .rbtn.primary { background: #2a6fdb; color: #fff; border-color: #2a6fdb; }
.theme-dark .rselect, .theme-dark .rinput {
  background: #101116; border-color: #2a2c33; color: #e6e8ee;
}
.theme-dark .rfield { color: #9aa0ad; }
.theme-dark .palette, .theme-dark .inspector {
  background: #17181d !important;
  border-color: #2a2c33 !important;
}
.theme-dark .palette-head, .theme-dark .inspector-head {
  background: #1d1f25 !important; color: #d8dbe2 !important; border-color: #2a2c33 !important;
}
.theme-dark .palette-search { background: #101116; border-color: #2a2c33; color: #e6e8ee; }
.theme-dark .palette-group-title { color: #9aa0ad; }
.theme-dark .tile { background: #1d1f25; border-color: #2a2c33; }
.theme-dark .tile:hover { background: #252832; border-color: #3a3f4d; }
.theme-dark .tile-name { color: #e2e4ea; }
.theme-dark .tile-short { color: #8b90a0; }
.theme-dark .palette-tip { background: #17181d; border-color: #2a2c33; color: #7f8494; }
.theme-dark .canvas {
  background: #14161c;
  border-color: #2a2c33;
}
.theme-dark .statusbar { background: #17181d; border-color: #2a2c33; color: #9aa0ad; }
.theme-dark .inspector-empty, .theme-dark .insp-sub { color: #8b90a0; }
.theme-dark .insp-title { color: #e8eaf0; }
.theme-dark .field-row label { color: #b9bec9; }
.theme-dark .field-row input, .theme-dark .field-row select { background: #101116; border-color: #2a2c33; color: #e6e8ee; }
.theme-dark .settings-section { background: #1d1f25; border-color: #2a2c33; }
.theme-dark .settings-section-title { color: #e2e4ea; }
.theme-dark .modal { background: #17181d !important; }
.theme-dark .modal-head, .theme-dark .modal-foot { background: #1d1f25; border-color: #2a2c33; color: #e2e4ea; }


/* ============================================================
   设计细节：等宽数字 / 平衡换行 / 同心圆角 / 柔和阴影
   来源：DESIGN.md
   ============================================================ */
:root {
  --num-font: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --radius-card: 10px;
  --radius-inner: 7px;
  --shadow-card: 0 1px 2px rgba(20, 24, 32, 0.05), 0 3px 10px rgba(20, 24, 32, 0.05);
  --shadow-hover: 0 2px 4px rgba(20, 24, 32, 0.08), 0 8px 22px rgba(20, 24, 32, 0.10);
}

/* 数字等宽：数值变化时不左右抖动 */
.statusbar, .statusbar *, .node, .node *, .ribbon, .ribbon *,
.modal, .modal *, .inspector, .insp * {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
input[type="number"], .modal-field input[type="number"], .num {
  font-family: var(--num-font);
  font-variant-numeric: tabular-nums;
}

/* 平衡换行：标题/提示避免最后一行孤字 */
.modal-head, .settings-section-title, .insp-title, .palette-tip,
.modal-field > label, .settings-sub, .empty-hint {
  text-wrap: balance;
}
.settings-hint, .insp-empty, .statusbar { text-wrap: pretty; }

/* 同心圆角：内层 = 外层 - 内边距 */
.node, .tile, .settings-section, .block-card { border-radius: var(--radius-card); }
.node .shape-chip, .node .node-badge, .tile .tile-icon,
.settings-hint, .palette-tip { border-radius: var(--radius-inner); }
.modal { border-radius: 14px; }

/* 柔和多层阴影（浅色）替代硬边框 */
.theme-visio .node {
  border-color: rgba(16, 22, 32, 0.12);
  box-shadow: var(--shadow-card);
}
.theme-visio .node:hover {
  box-shadow: var(--shadow-hover);
}
.theme-visio .tile { box-shadow: 0 1px 2px rgba(20, 24, 32, 0.04); }

/* 柔和阴影（深色） */
.theme-dark .node {
  border-color: rgba(255, 255, 255, 0.13);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.theme-dark .tile { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

/* 动效 150~250ms；尊重"减少动效"系统设置 */
.rbtn, .tile, .node, .settings-section { transition-duration: 180ms; }
@media (prefers-reduced-motion: reduce) {
  .node, .tile, .rbtn, .modal { transition: none !important; animation: none !important; }
}


/* ---------- 细节统一 v2：按钮/输入/代码预览/空态 ---------- */
:root {
  --radius-btn: 8px;
  --focus-ring: 0 0 0 3px rgba(31, 111, 235, 0.22);
}

/* 按钮：8px 圆角 + 160ms 过渡 + 键盘聚焦环 */
.rbtn, .btn, .icon-btn, .shape-option {
  border-radius: var(--radius-btn);
  transition: background-color 160ms cubic-bezier(.2,.8,.2,1),
              border-color 160ms cubic-bezier(.2,.8,.2,1),
              box-shadow 160ms cubic-bezier(.2,.8,.2,1),
              color 160ms cubic-bezier(.2,.8,.2,1);
}
.rbtn:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .shape-option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* 输入框 / 下拉：统一半径与聚焦环 */
.input, .rselect, .rinput, .modal input:not([type="checkbox"]), .modal select, #paletteSearch {
  border-radius: var(--radius-btn);
  transition: border-color 160ms cubic-bezier(.2,.8,.2,1),
              box-shadow 160ms cubic-bezier(.2,.8,.2,1);
}
.input:focus-visible, .rselect:focus-visible, .rinput:focus-visible,
.modal input:not([type="checkbox"]):focus-visible, .modal select:focus-visible, #paletteSearch:focus-visible {
  outline: none;
  border-color: #1f6feb;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}

/* 标题平衡换行 + 字距 */
#modalTitle { text-wrap: balance; letter-spacing: 0.2px; }
.settings-sub { letter-spacing: 0.15px; }

/* 缩放数字：等宽、定宽，切换时不抖动 */
#zoomText { font-family: var(--num-font); min-width: 46px; text-align: center; }

/* 代码预览：统一等宽字体、行高、圆角和浅底 */
.code-view {
  font-family: var(--num-font) !important;
  font-size: 11.5px;
  line-height: 1.65;
  tab-size: 4;
  letter-spacing: 0;
}
.theme-visio .code-view {
  background: #fbfcfd;
  border: 1px solid rgba(16, 22, 32, 0.10);
  border-radius: var(--radius-inner);
  padding: 10px 12px;
}
.theme-dark .code-view {
  background: #0f1116;
  border: 1px solid #262a33;
  border-radius: var(--radius-inner);
  padding: 10px 12px;
}
#exportResult .insp-sub { font-variant-numeric: tabular-nums; }

/* 弹窗柔和多层阴影 */
.modal { box-shadow: 0 16px 48px rgba(16, 22, 32, 0.20), 0 2px 8px rgba(16, 22, 32, 0.08); }
.theme-dark .modal { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.60); }

/* 空态 / 提示排版 */
.insp-empty, .settings-hint, .palette-tip { line-height: 1.65; }


/* 节点卡片：形状 + 参数量一行 */
.node-shape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.node-params {
  font-family: var(--num-font);
  font-variant-numeric: tabular-nums;
  font-size: 9.5px;
  color: #6b7684;
  white-space: nowrap;
}
.theme-dark .node-params { color: #9aa2b1; }


/* ================= 底部代码面板（多文件工程） ================= */
.code-drawer {
  flex-shrink: 0;
  height: 290px;
  display: flex;
  flex-direction: column;
  background: #fbfbfc;
  border-top: 1px solid rgba(16, 22, 32, 0.12);
  min-height: 160px;
}
.code-drawer[hidden] { display: none !important; }
.cd-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #f3f4f6;
  border-bottom: 1px solid rgba(16, 22, 32, 0.08);
}
.cd-title { font-size: 11px; font-weight: 700; color: #5f6673; white-space: nowrap; }
.cd-tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; }
.cd-tab {
  border: 0; background: transparent; padding: 4px 10px; border-radius: 6px;
  font-size: 11px; color: #6b7280; cursor: pointer; white-space: nowrap;
  transition: background 150ms, color 150ms;
}
.cd-tab:hover { background: rgba(16, 22, 32, 0.05); }
.cd-tab.active {
  background: #ffffff; color: #1f2328; font-weight: 700;
  box-shadow: 0 1px 2px rgba(20, 24, 32, 0.08);
}
.cd-actions { display: flex; gap: 6px; margin-left: auto; }
.cd-btn {
  border: 1px solid rgba(16, 22, 32, 0.12); background: #ffffff; color: #3b4250;
  padding: 3px 9px; border-radius: 7px; font-size: 11px; cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.cd-btn:hover { background: #eef2f7; border-color: rgba(31, 111, 235, 0.35); }
.cd-code {
  flex: 1; min-height: 0; margin: 0; padding: 10px 14px; overflow: auto;
  background: #fbfcfd; color: #24292f;
  font-family: var(--num-font); font-size: 11.5px; line-height: 1.6;
  tab-size: 4; white-space: pre;
}
/* Python 语法高亮（轻量） */
.tok-kw { color: #cf222e; font-weight: 600; }
.tok-self { color: #8250df; }
.tok-str { color: #0a3069; }
.tok-com { color: #6e7781; font-style: italic; }
.tok-num { color: #953800; }

/* 深色模式 */
.theme-dark .code-drawer { background: #14161c; border-top-color: #2a2c33; }
.theme-dark .cd-head { background: #1d1f25; border-bottom-color: #2a2c33; }
.theme-dark .cd-title { color: #9aa0ad; }
.theme-dark .cd-tab { color: #8b90a0; }
.theme-dark .cd-tab:hover { background: rgba(255, 255, 255, 0.06); }
.theme-dark .cd-tab.active { background: #252832; color: #e6e8ee; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.theme-dark .cd-btn { background: #1d1f25; border-color: #2a2c33; color: #d2d5dc; }
.theme-dark .cd-btn:hover { background: #252832; border-color: #3a3f4d; }
.theme-dark .cd-code { background: #0f1116; color: #d7dae0; }
.theme-dark .tok-kw { color: #ff7b72; }
.theme-dark .tok-self { color: #d2a8ff; }
.theme-dark .tok-str { color: #a5d6ff; }
.theme-dark .tok-com { color: #8b949e; }
.theme-dark .tok-num { color: #ffa657; }


/* ============================================================
   节点卡片：中性底 + 细色条（克制 / 高级感）
   参考：黑白系产品设计 —— 大面积留白，仅用细线和小色点做分类
   ============================================================ */
.theme-visio .node {
  background: #ffffff;
  border: 1px solid rgba(16, 22, 32, 0.10);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 22, 32, 0.05), 0 6px 16px rgba(16, 22, 32, 0.055);
  padding: 9px 12px 10px;
  gap: 3px;
}
.theme-visio .node {
  background-color: #ffffff;
  background-image: linear-gradient(var(--node-color, #93a4bd), var(--node-color, #93a4bd));
  background-size: 100% 3px;
  background-position: top left;
  background-repeat: no-repeat;
}
.theme-visio .node::before { display: none; }
.theme-visio .node:hover {
  border-color: rgba(26, 115, 201, 0.35);
  box-shadow: 0 2px 4px rgba(16, 22, 32, 0.06), 0 10px 24px rgba(16, 22, 32, 0.08);
}
.theme-visio .node.selected {
  border-color: #1a73c9;
  box-shadow: 0 0 0 3px rgba(26, 115, 201, 0.14), 0 8px 20px rgba(16, 22, 32, 0.10);
}
.theme-visio .node.has-error {
  border-color: #d64545;
  background-color: #fffdfd;
  box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.10);
}
.theme-visio .node.has-error::before { background: #d64545; }
.theme-visio .node-title {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.1px;
  color: #1f2328;
}
.theme-visio .node-type { top: 9px; right: 10px; font-size: 9px; color: #8b93a1; }
.theme-visio .node-summary {
  font-size: 10.5px;
  color: #5f6673;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.theme-visio .node-shape {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding: 2px 7px;
  border: 0;
  border-radius: 6px;
  background: #f4f6f8;
  color: #5b6470;
  font-size: 9px;
  line-height: 1.5;
}
.theme-visio .node-params { color: #8a919c; font-size: 8.5px; }
.theme-visio .port {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid rgba(31, 35, 40, 0.35);
  background: #ffffff;
  opacity: 0.4;
}
.theme-visio .node:hover .port { opacity: 0.9; border-color: rgba(26, 115, 201, 0.65); }
.theme-visio .port:hover { background: #1a73c9; border-color: #1a73c9; opacity: 1; }
.theme-visio .port[data-port="in"], .theme-visio .port[data-port="out"] { margin-top: -5px; }
.theme-visio .port[data-port="top"], .theme-visio .port[data-port="bottom"] { margin-left: -5px; }

/* 深色：同一套中性卡片 */
.theme-dark .node {
  background: #1d1f25;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.32);
  padding: 9px 12px 10px;
  gap: 3px;
  color: #e6e8ee;
}
.theme-dark .node {
  background-color: #1d1f25;
  background-image: linear-gradient(var(--node-color, #6b7686), var(--node-color, #6b7686));
  background-size: 100% 3px;
  background-position: top left;
  background-repeat: no-repeat;
}
.theme-dark .node::before { display: none; }
.theme-dark .node:hover {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 10px 26px rgba(0,0,0,0.45);
}
.theme-dark .node.selected {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22), 0 8px 22px rgba(0, 0, 0, 0.45);
}
.theme-dark .node.has-error { border-color: #e05252; }
.theme-dark .node.has-error::before { background: #e05252; }
.theme-dark .node-title { color: #e8eaf0; font-size: 12.5px; font-weight: 650; }
.theme-dark .node-type { color: #8b90a0; font-size: 9px; }
.theme-dark .node-summary { color: #a8aebb; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.theme-dark .node-shape {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #c3c8d4;
  font-size: 9px;
}
.theme-dark .node-params { color: #9aa0ad; font-size: 8.5px; }
.theme-dark .port {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: #14161c; opacity: 0.55;
}
.theme-dark .node:hover .port { opacity: 1; border-color: rgba(59, 130, 246, 0.75); }
.theme-dark .port:hover { background: #3b82f6; border-color: #3b82f6; }
.theme-dark .port[data-port="in"], .theme-dark .port[data-port="out"] { margin-top: -5px; }
.theme-dark .port[data-port="top"], .theme-dark .port[data-port="bottom"] { margin-left: -5px; }


/* 覆盖 Visio 主题的分类色块：只保留左侧细色条 */
.theme-visio .node[data-category] {
  background-color: #ffffff;
  border-color: rgba(16, 22, 32, 0.10);
}
.theme-visio .node[data-category="input"] { background-color: #fcfcfd; }
.theme-visio .node[data-category] .node-shape {
  background: #f4f6f8;
  border: 0;
  color: #5b6470;
}
.theme-visio .node[data-category]:hover {
  border-color: rgba(26, 115, 201, 0.35);
}
.theme-visio .node[data-category].selected {
  border-color: #1a73c9;
}
.theme-visio .node[data-category].has-error {
  border-color: #d64545;
  background-color: #fffdfd;
  background-image: linear-gradient(#d64545, #d64545);
}


/* ============================================================
   Apple 风浅色细节（参考：白卡 + 灰底 + 黑色主按钮 + 细线）
   只作用于浅色主题；深色保持黑底白字
   ============================================================ */
:root {
  --apple-bg: #f2f2f4;
  --apple-surface: #ffffff;
  --apple-hairline: rgba(0, 0, 0, 0.075);
  --apple-text: #1d1d1f;
  --apple-text-2: #6e6e73;
  --apple-text-3: #8e8e93;
  --apple-fill: #f5f5f7;
  --apple-radius: 12px;
}

.theme-visio body, .theme-visio #app { background: var(--apple-bg) !important; }
.theme-visio .main { background: var(--apple-bg) !important; gap: 0; }

/* 顶栏：白底、细线、黑色主按钮 */
.theme-visio .ribbon {
  background: var(--apple-surface) !important;
  border-bottom: 1px solid var(--apple-hairline) !important;
}
.theme-visio .ribbon-group { border-right-color: var(--apple-hairline) !important; }
.theme-visio .rg-label { color: var(--apple-text-3); font-size: 10px; letter-spacing: 0.3px; }
.theme-visio .rbtn {
  color: var(--apple-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 11.5px;
  padding: 5px 10px;
}
.theme-visio .rbtn:hover { background: var(--apple-fill); border-color: transparent; }
.theme-visio .rbtn.primary {
  background: #1d1d1f;
  color: #fff;
  border-color: #1d1d1f;
  font-weight: 600;
}
.theme-visio .rbtn.primary:hover { background: #333336; border-color: #333336; }
.theme-visio .rinput, .theme-visio .rselect {
  background: var(--apple-fill);
  border: 1px solid transparent;
  color: var(--apple-text);
  border-radius: 8px;
}
.theme-visio .rfield { color: var(--apple-text-3); }

/* 三栏：白面板 + 极细分割线 */
.theme-visio .palette, .theme-visio .inspector {
  background: var(--apple-surface) !important;
  border-color: var(--apple-hairline) !important;
}
.theme-visio .palette-head, .theme-visio .inspector-head {
  background: var(--apple-surface) !important;
  border-bottom: 1px solid var(--apple-hairline) !important;
  color: var(--apple-text);
  font-weight: 600;
}
.theme-visio .palette-search {
  background: var(--apple-fill);
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--apple-text);
}
.theme-visio .palette-group-title { color: var(--apple-text-3); font-size: 10.5px; }
.theme-visio .palette-group-title .count { color: #b0b0b7; }
.theme-visio .tile {
  background: var(--apple-surface);
  border: 1px solid var(--apple-hairline);
  border-radius: 12px;
  box-shadow: none;
}
.theme-visio .tile:hover {
  background: #fafafc;
  border-color: rgba(0, 0, 0, 0.14);
  transform: none;
}
.theme-visio .tile .tile-name { color: var(--apple-text); font-weight: 600; font-size: 12px; }
.theme-visio .tile .tile-short { color: var(--apple-text-3); font-size: 10px; }
.theme-visio .palette-tip { background: var(--apple-surface); border-color: var(--apple-hairline); color: var(--apple-text-3); }

/* 画布：纯白 + 极细边框，减少"工具感" */
.theme-visio .canvas {
  background-color: #ffffff !important;
  border: 1px solid var(--apple-hairline) !important;
  margin: 10px !important;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.theme-visio .canvas::after { display: none; }
.theme-visio .canvas-title { color: #d2d2d7; font-size: 10px; }

/* 状态栏：白底细线，信息弱化 */
.theme-visio .statusbar {
  background: var(--apple-surface);
  border-top: 1px solid var(--apple-hairline);
  color: var(--apple-text-3);
  font-size: 10.5px;
}
.theme-visio .status-config, .theme-visio .ide-status-item { color: var(--apple-text-3); }
.theme-visio .icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--apple-text-2);
  border-radius: 7px;
}
.theme-visio .icon-btn:hover { background: var(--apple-fill); border-color: transparent; }

/* 节点卡片：更圆、更轻、黑色选中态 */
.theme-visio .node {
  border-radius: 12px;
  border-color: var(--apple-hairline);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 18px rgba(0, 0, 0, 0.04);
}
.theme-visio .node:hover { border-color: rgba(0, 0, 0, 0.16); box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 10px 24px rgba(0,0,0,.06); }
.theme-visio .node.selected {
  border-color: #1d1d1f;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06), 0 8px 22px rgba(0, 0, 0, 0.08);
}
.theme-visio .node.selected::before { opacity: 1; }
.theme-visio .node-title { font-size: 13px; font-weight: 600; color: #1d1d1f; }
.theme-visio .node-type { color: var(--apple-text-3); font-size: 9px; }
.theme-visio .node-summary { color: var(--apple-text-2); font-size: 10.5px; }
.theme-visio .node-shape { background: var(--apple-fill); color: var(--apple-text-2); border-radius: 7px; }
.theme-visio .node-params { color: #a1a1a6; }

/* 代码面板：白底，选中 tab 用黑色胶囊 */
.theme-visio .code-drawer { background: var(--apple-surface); border-top: 1px solid var(--apple-hairline); }
.theme-visio .cd-head { background: var(--apple-surface); border-bottom: 1px solid var(--apple-hairline); }
.theme-visio .cd-title { color: var(--apple-text-3); font-weight: 500; }
.theme-visio .cd-tab { color: var(--apple-text-2); border-radius: 8px; }
.theme-visio .cd-tab:hover { background: var(--apple-fill); }
.theme-visio .cd-tab.active {
  background: #1d1d1f;
  color: #fff;
  font-weight: 500;
  box-shadow: none;
}
.theme-visio .cd-btn {
  background: var(--apple-surface);
  border: 1px solid var(--apple-hairline);
  border-radius: 8px;
  color: var(--apple-text);
}
.theme-visio .cd-btn:hover { background: var(--apple-fill); border-color: transparent; }
.theme-visio .cd-code { background: #fafafa; color: #1d1d1f; }

/* 弹窗：更圆、更软、无硬边 */
.theme-visio .modal {
  border-radius: 18px !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.theme-visio .modal-head { background: var(--apple-surface); border-bottom: 1px solid var(--apple-hairline); }
.theme-visio .settings-section { background: #fafafa; border-color: transparent; border-radius: 14px; }
.theme-visio .settings-section-title { color: var(--apple-text); font-weight: 600; }
.theme-visio .settings-sub { color: var(--apple-text-3); }
.theme-visio .modal .input, .theme-visio .modal select {
  background: var(--apple-fill);
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--apple-text);
}
.theme-visio .modal .input:focus-visible, .theme-visio .modal select:focus-visible {
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}
.theme-visio .btn { border-radius: 9px; }
.theme-visio .btn.primary { background: #1d1d1f; border-color: #1d1d1f; }
.theme-visio .btn.primary:hover { background: #333336; border-color: #333336; }
.theme-visio .btn:not(.primary) { background: var(--apple-surface); border: 1px solid var(--apple-hairline); color: var(--apple-text); }
.theme-visio .btn:not(.primary):hover { background: var(--apple-fill); }


/* 端口：默认隐藏，hover 节点 / 拖连线时出现；已连接端口常显 */
.port { opacity: 0 !important; transition: opacity 130ms ease, background-color 130ms ease, border-color 130ms ease; }
.node:hover .port, body.linking .port, .port.port-connected { opacity: 1 !important; }
.port.port-connected {
  background: var(--node-color, #1a73c9);
  border-color: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.theme-visio .node:hover .port { background: #ffffff; border-color: rgba(26, 115, 201, 0.7); }
.theme-visio .port.port-connected { background: var(--node-color, #1a73c9); border-color: #ffffff; }
.theme-dark .node:hover .port { background: #14161c; border-color: rgba(59, 130, 246, 0.8); }
.theme-dark .port.port-connected { background: var(--node-color, #6b7686); border-color: #1d1f25; box-shadow: 0 0 0 1px rgba(255,255,255,.18); }
body.linking .node { cursor: crosshair; }


/* 封装块不用顶部色条（块本身已有淡色渐变） */
.theme-visio .node.block::before, .theme-dark .node.block::before { display: none !important; }


/* 错误节点：顶部色条变红 */
.theme-visio .node.has-error:not(.block) {
  background-image: linear-gradient(#d64545, #d64545) !important;
}
.theme-dark .node.has-error:not(.block) {
  background-image: linear-gradient(#e05252, #e05252) !important;
}


/* 顶部色条：最后声明，确保不被其它主题规则覆盖 */
.theme-visio .node:not(.block) {
  background-image: linear-gradient(var(--node-color, #93a4bd), var(--node-color, #93a4bd)) !important;
  background-size: 100% 3px !important;
  background-position: top left !important;
  background-repeat: no-repeat !important;
}
.theme-dark .node:not(.block) {
  background-image: linear-gradient(var(--node-color, #6b7686), var(--node-color, #6b7686)) !important;
  background-size: 100% 3px !important;
  background-position: top left !important;
  background-repeat: no-repeat !important;
}
.theme-visio .node.has-error {
  background-image: linear-gradient(#d64545, #d64545) !important;
}
.theme-dark .node.has-error {
  background-image: linear-gradient(#e05252, #e05252) !important;
}



/* 连线：稍微加粗；端口 margin 归零，保证线端与圆点中心重合 */
.theme-visio .port, .theme-dark .port { margin: 0 !important; }
.theme-visio .edge-path { stroke-width: 2.2 !important; }
.theme-visio .edge-path.edge-skip { stroke-width: 2.6 !important; }
.theme-visio .edge-path.edge-selected { stroke-width: 2.8 !important; }
.theme-visio .edge-g:hover .edge-path:not(.edge-skip) { stroke-width: 2.5 !important; }
.theme-dark .edge-path { stroke-width: 2.4 !important; }
.theme-dark .edge-path.edge-skip { stroke-width: 2.8 !important; }
.theme-dark .edge-path.edge-selected { stroke-width: 3 !important; }


/* ================= 右键拖动笔势（圆环 / 空心中心） ================= */
.gesture-wheel {
  position: fixed;
  z-index: 9800;
  width: 300px;
  height: 300px;
  pointer-events: none;
}
.gesture-wheel[hidden] { display: none !important; }
.gw-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 18px 42px rgba(0, 0, 0, 0.16));
}
.gw-rim { fill: none; stroke: rgba(0, 0, 0, 0.06); stroke-width: 1; }
.gw-rim-inner { fill: none; stroke: rgba(0, 0, 0, 0.06); stroke-width: 1; }
.gw-donut { fill: none; stroke: #ffffff; stroke-width: 64; }
.gw-sector {
  fill: none;
  stroke: #1d1d1f;
  stroke-width: 64;
  opacity: 0;
  transition: opacity 120ms ease;
}
.gesture-wheel[data-active="nw"] .gw-sector[data-sector="nw"],
.gesture-wheel[data-active="ne"] .gw-sector[data-sector="ne"],
.gesture-wheel[data-active="sw"] .gw-sector[data-sector="sw"],
.gesture-wheel[data-active="se"] .gw-sector[data-sector="se"] { opacity: 1; }

.gw-cell {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #1d1d1f;
  transition: color 120ms ease;
  white-space: nowrap;
}
.gw-cell.active { color: #ffffff; }
.gw-icon svg { width: 24px; height: 17px; display: block; }
.gw-icon svg path { stroke: #1d1d1f; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gw-skip svg path { stroke: #d97706; }
.gw-cell.active .gw-icon svg path { stroke: #ffffff; }
.gw-name { font-size: 10.5px; font-weight: 600; line-height: 1.2; }
.gw-sub { font-size: 8.5px; opacity: 0.62; line-height: 1.2; }

/* 深色主题 */
.theme-dark .gw-svg { filter: drop-shadow(0 18px 42px rgba(0, 0, 0, 0.55)); }
.theme-dark .gw-rim, .theme-dark .gw-rim-inner { stroke: rgba(255, 255, 255, 0.10); }
.theme-dark .gw-donut { stroke: #1d1f25; }
.theme-dark .gw-sector { stroke: #ffffff; }
.theme-dark .gw-cell { color: #e6e8ee; }
.theme-dark .gw-icon svg path { stroke: #e6e8ee; }
.theme-dark .gw-cell.active { color: #1d1d1f; }
.theme-dark .gw-cell.active .gw-icon svg path { stroke: #1d1d1f; }
