/* ============================================================
 * 排版整改 切片 G2（画布高阶 126-140）样式
 * 只复用既有 hex / CSS 变量；不改产品主色；覆盖 style.css
 * ============================================================ */

/* ---------- 通用：覆盖层世界容器（与 graphWorld 同变换） ---------- */
#g2WorldLayer {
  position: absolute; top: 0; left: 0; transform-origin: 0 0;
  z-index: 3; pointer-events: none;
}
#g2WorldLayer .g2-pe { pointer-events: auto; }

/* ---------- 129 顶部时间轴标尺 ---------- */
#g2Ruler {
  position: absolute; top: 0; left: 0; right: 0; height: 30px;
  background: var(--bg-soft, #171D29); border-bottom: 1px solid var(--border, #2A3242);
  z-index: 40; overflow: hidden; cursor: crosshair;
}
#g2RulerTrack {
  position: absolute; top: 0; left: 0; height: 100%; width: 1px;
  transform-origin: 0 0;
}
.g2-ruler-tick {
  position: absolute; bottom: 0; width: 1px; height: 8px;
  background: var(--text-muted, #909399);
}
.g2-ruler-lab {
  position: absolute; top: 2px; font-size: 12px; color: var(--text-muted, #909399);
  transform: translateX(-2px); white-space: nowrap; font-family: monospace;
}
.g2-ruler-shot {
  position: absolute; bottom: 0; height: 12px; background: rgba(56,189,248,0.28);
  border-top: 1px solid rgba(56,189,248,0.6);
}
#g2Cursor {
  position: absolute; top: 0; bottom: 0; width: 1px; background: #E06060; z-index: 5;
  display: none;
}
#g2Cursor::after {
  content: '◀'; position: absolute; top: -2px; left: -5px; font-size: 12px; color: #E06060;
}
#g2CursorLabel {
  position: absolute; top: 2px; left: 3px; font-size: 12px; color: #E06060; font-family: monospace;
  background: rgba(29,33,41,0.12); padding: 0 3px; border-radius: 4px; display: none; white-space: nowrap;
}
#g2RulerSel {
  position: absolute; top: 0; bottom: 0; background: rgba(56,189,248,0.18);
  border-left: 1px dashed #38BDF8; border-right: 1px dashed #38BDF8; display: none; z-index: 4;
}
#g2RulerNote {
  position: absolute; right: 8px; top: 6px; font-size: 12px; color: var(--text-muted, #909399);
  z-index: 6;
}

/* ---------- 131 时间锚点（BGM 卡点） ---------- */
.g2-anchor-line {
  position: absolute; top: 0; bottom: 0; width: 1px; background: #ff7d00;
  border-left: 1px dashed #ff7d00; opacity: 0.85;
}
.g2-anchor-pin {
  position: absolute; top: 2px; font-size: 12px; color: #ff7d00; white-space: nowrap;
  background: rgba(224,164,88,0.12); border: 1px solid rgba(224,164,88,0.4);
  border-radius: 4px; padding: 0 4px; cursor: pointer;
}
.g2-anchor-pin.locked { opacity: 0.55; }

/* ---------- 137 时间断点 ---------- */
.g2-break-line {
  position: absolute; top: 0; bottom: 0; width: 1px; background: #8aa2bc;
}
.g2-break-pin {
  position: absolute; top: 14px; font-size: 12px; color: #8aa2bc; white-space: nowrap;
  cursor: pointer; transform: translateX(-50%);
}

/* ---------- 126 子画布 ---------- */
.g2-sub-box {
  position: absolute; border: 1.5px dashed #38BDF8; border-radius: 12px;
  background: rgba(56,189,248,0.06); z-index: 1;
}
.g2-sub-cap {
  position: absolute; top: -10px; left: 10px; font-size: 12px; font-weight: 600;
  color: #38BDF8; background: var(--bg-soft, #171D29); border: 1px solid #38BDF8;
  border-radius: 12px; padding: 1px 8px; white-space: nowrap; cursor: pointer;
}
.g2-sub-thumb {
  position: absolute; right: 10px; bottom: 8px; font-size: 12px; color: var(--text-muted, #909399);
  background: rgba(0,0,0,0.25); border-radius: 4px; padding: 2px 6px; white-space: nowrap;
}
.g2-breadcrumb {
  position: absolute; top: 34px; left: 10px; z-index: 45; display: none; gap: 6px; align-items: center;
}
.g2-breadcrumb.show { display: flex; }
.g2-bc-item {
  font-size: 12px; padding: 2px 10px; border-radius: 12px; cursor: pointer;
  background: var(--card, #191E29); border: 1px solid var(--border, #2A3242); color: var(--text, #E6EAF2);
}
.g2-bc-item.now { border-color: #38BDF8; color: #38BDF8; }
.g2-bc-sep { color: var(--text-muted, #909399); }
body.g2-insub .graph-node:not(.g2-submember) { opacity: 0.18; }
body.g2-insub .g2-sub-box:not(.g2-sub-active) { opacity: 0.25; }

/* ---------- 128 连线标注 ---------- */
.g2-annot-pill {
  position: absolute; transform: translate(-50%, -50%); max-width: 160px;
  background: var(--card, #191E29); border: 1px solid #00b42a; border-radius: 8px;
  font-size: 12px; color: var(--text, #E6EAF2); padding: 2px 8px; cursor: pointer;
  z-index: 4; box-shadow: 0 2px 8px rgba(29,33,41,0.12);
}
.g2-annot-pill .g2a-del { margin-left: 6px; color: #E06060; cursor: pointer; }
.g2-annot-pill.collapsed { padding: 1px 6px; }
.g2-annot-pill.hidden-annot { display: none; }
.g2-annot-pill.flash { animation: g2flash 0.5s ease 3; border-color: #ff7d00; }
@keyframes g2flash { 50% { box-shadow: 0 0 0 3px rgba(224,164,88,0.6); } }

/* ---------- 132 链路冻结 ---------- */
.graph-node.g2-frozen { opacity: 0.5; filter: grayscale(0.5); }
.g2-freeze-cap {
  position: absolute; top: -10px; left: -6px; font-size: 12px; color: #ff7d00;
  background: rgba(224,164,88,0.15); border: 1px solid #ff7d00; border-radius: 8px; padding: 0 6px;
}

/* ---------- 135 旁路分支版本标签 ---------- */
.g2-ver-tag {
  position: absolute; top: -9px; right: -4px; font-size: 12px; color: #8aa2bc;
  background: rgba(56,189,248,0.10); border: 1px solid #B8D4F5; border-radius: 8px; padding: 0 5px;
}

/* ---------- 139 自由便签 ---------- */
.g2-note {
  position: absolute; width: 160px; min-height: 80px; padding: 8px; z-index: 6;
  border-radius: 8px; font-size: 12px; color: #303133; cursor: move;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
}
.g2-note.yellow { background: #FFF3C4; }
.g2-note.blue { background: #e6f4ff; }
.g2-note.green { background: #DDF3E0; }
.g2-note.pink { background: #FBDDE3; }
.g2-note .g2n-text { width: 100%; height: 100%; outline: none; white-space: pre-wrap; }
.g2-note .g2n-resize {
  position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; cursor: se-resize;
}
.g2-note .g2n-del { position: absolute; top: 2px; right: 4px; cursor: pointer; color: #ff7d00; font-size: 12px; }
.g2-note.selected { outline: 2px solid #38BDF8; }
.g2-note.flash { animation: g2flash 0.5s ease 3; }

/* ---------- 127 模板面板 ---------- */
#g2TplPanel {
  position: absolute; top: 40px; left: 10px; width: 200px; max-height: 70%; z-index: 46;
  background: var(--card, #191E29); border: 1px solid var(--border, #2A3242); border-radius: 8px;
  display: none; flex-direction: column; box-shadow: 0 6px 20px rgba(29,33,41,0.12);
}
#g2TplPanel.show { display: flex; }
#g2TplPanel .g2tp-head {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 10px;
  border-bottom: 1px solid var(--border, #2A3242); font-size: 13px; font-weight: 600;
}
#g2TplPanel .g2tp-body { overflow-y: auto; padding: 6px; }
.g2tp-cat { font-size: 12px; color: var(--text-muted, #909399); margin: 6px 2px 2px; }
.g2tp-item {
  padding: 6px 8px; border: 1px solid var(--border, #2A3242); border-radius: 8px; margin-bottom: 4px;
  font-size: 12px; cursor: grab; background: var(--bg-soft, #171D29);
}
.g2tp-item .g2tp-note { font-size: 12px; color: var(--text-muted, #909399); margin-top: 2px; }
.g2tp-item .g2tp-del { float: right; color: #E06060; cursor: pointer; }

/* ---------- 136 对比抽屉 ---------- */
#g2CmpDrawer {
  position: absolute; top: 40px; right: 10px; width: 300px; max-height: 76%; z-index: 47;
  background: var(--card, #191E29); border: 1px solid var(--border, #2A3242); border-radius: 8px;
  display: none; flex-direction: column; box-shadow: 0 6px 20px rgba(29,33,41,0.12);
}
#g2CmpDrawer.show { display: flex; }
#g2CmpDrawer .g2cd-head {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 10px;
  border-bottom: 1px solid var(--border, #2A3242); font-size: 13px; font-weight: 600;
}
#g2CmpDrawer .g2cd-body { overflow-y: auto; padding: 8px; font-size: 12px; }
.g2cd-row { display: flex; gap: 6px; padding: 4px 0; border-bottom: 1px dashed var(--border, #2A3242); }
.g2cd-row .g2cd-k { width: 56px; color: var(--text-muted, #909399); }
.g2cd-row .g2cd-a, .g2cd-b { flex: 1; }
.g2cd-row.diff .g2cd-a, .g2cd-row.diff .g2cd-b { color: #ff7d00; }
#g2CmpDrawer .g2cd-foot { padding: 8px; border-top: 1px solid var(--border, #2A3242); display: flex; gap: 6px; }

/* ---------- 140 搜索结果 ---------- */
#g2SearchPanel {
  position: absolute; top: 40px; left: 50%; transform: translateX(-50%); width: 460px; max-height: 60%;
  z-index: 48; background: var(--card, #191E29); border: 1px solid var(--border, #2A3242); border-radius: 8px;
  display: none; flex-direction: column; box-shadow: 0 6px 20px rgba(29,33,41,0.12);
}
#g2SearchPanel.show { display: flex; }
#g2SearchPanel .g2sp-head { padding: 8px 10px; border-bottom: 1px solid var(--border, #2A3242); font-size: 13px; font-weight: 600; }
#g2SearchPanel .g2sp-body { overflow-y: auto; padding: 6px; }
.g2sp-type { font-size: 12px; color: var(--text-muted, #909399); margin: 6px 2px 2px; }
.g2sp-item { padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.g2sp-item:hover { background: var(--primary-soft, #1C2A3D); }
.g2sp-item .g2sp-tag { display: inline-block; font-size: 12px; padding: 0 5px; border-radius: 8px; margin-right: 6px; }

/* ---------- 130 节点底部调速手柄 ---------- */
.g2-dur-handle {
  position: absolute; left: 0; right: 0; bottom: -4px; height: 8px; cursor: ns-resize;
  z-index: 5; display: none;
}
.graph-node:hover .g2-dur-handle, .graph-node.selected .g2-dur-handle { display: block; }
.g2-dur-tip {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: #0F141E; color: #38BDF8; font-size: 12px; padding: 2px 8px; border-radius: 4px;
  display: none; white-space: nowrap; z-index: 99;
}

/* ---------- 138 磁吸吸附辅助线 ---------- */
.g2-snap-line { position: absolute; background: #00b42a; z-index: 3; display: none; }

/* ---------- 136 对比高亮 / 弱化 ---------- */
body.g2-cmpmode .graph-node:not(.g2-cmp-a):not(.g2-cmp-b) { opacity: 0.15; }
.graph-node.g2-cmp-a { outline: 2px solid #38BDF8; }
.graph-node.g2-cmp-b { outline: 2px solid #8aa2bc; }

/* ---------- 133 粘贴 / 通用 toast 复用全局 ---------- */
.g2-hidden { display: none !important; }

/* ---------- G2 布局修复：画布全屏定位被祖先 transform 限制时强制铺满视口 ---------- */
#graphView.fullscreen {
  position: fixed !important;
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100vw !important; height: 100vh !important;
  display: flex !important; flex-direction: column !important;
}
#graphView.fullscreen .graph-stage { flex: 1 1 auto !important; height: auto !important; position: relative; overflow: hidden; }
