/* ═══════════════════════════════════════════
   D3.js 流程圖編輯器樣式
   ═══════════════════════════════════════════ */

/* --- 主容器 --- */
.d3fc-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: "Microsoft JhengHei", "微軟正黑體", sans-serif;
}

/* --- 元件面板 --- */
.d3fc-palette {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8f9fa 0%, #f0f1f3 100%);
  overflow: hidden;
}
.d3fc-palette-title {
  display: none;
}

/* --- 頁籤列 --- */
.d3fc-tab-bar {
  display: flex;
  border-bottom: 1px solid #ddd;
  background: #eef0f2;
}
.d3fc-tab {
  padding: 6px 18px;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  border-right: 1px solid #ddd;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.d3fc-tab:last-child { border-right: none; }
.d3fc-tab:hover {
  background: #dfe3e8;
  color: #333;
}
.d3fc-tab-active {
  background: #fff !important;
  color: #2980B9 !important;
  font-weight: bold;
  border-bottom: 2px solid #2980B9;
  margin-bottom: -1px;
}

/* --- 檔案面板 --- */
.d3fc-file-panel {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  padding: 6px;
}

/* --- PNG 面板 --- */
.d3fc-png-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 6px;
}
.d3fc-insert-tab-bar {
  display: flex;
  border-bottom: 1px solid #ddd;
  background: #fff;
  margin-bottom: 6px;
  padding: 0 4px;
}
.d3fc-insert-tab {
  padding: 7px 10px 6px;
  cursor: pointer;
  font-size: 12px;
  color: #333;
  border-right: none;
  user-select: none;
  transition: color 0.15s, border-color 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  min-width: 28px;
  text-align: center;
}
.d3fc-insert-tab-icon {
  font-size: 15px;
  line-height: 1;
  display: inline-block;
}
.d3fc-insert-tab:last-child {
  border-right: none;
}
.d3fc-insert-tab:hover {
  color: #1f5fa8;
}
.d3fc-insert-tab-active {
  background: transparent !important;
  color: #1565c0 !important;
  font-weight: bold;
  border-bottom: 2px solid #1565c0;
}
.d3fc-insert-panel-wrap {
  display: block;
}
.d3fc-insert-tab-panel {
  display: none;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}
.d3fc-insert-empty {
  color: #888;
  font-size: 12px;
  padding: 8px 4px;
}
.d3fc-aitools-tab-bar {
  display: flex;
  border-bottom: 1px solid #ddd;
  background: #fff;
  margin-bottom: 6px;
  padding: 0 2px;
  flex-wrap: wrap;
  width: 100%;
}
.d3fc-aitools-main-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}
.d3fc-aitools-tab {
  padding: 6px 9px 5px;
  cursor: pointer;
  font-size: 12px;
  color: #444;
  user-select: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.d3fc-aitools-tab:hover {
  color: #1f5fa8;
}
.d3fc-aitools-tab-active {
  color: #1565c0 !important;
  font-weight: bold;
  border-bottom: 2px solid #1565c0;
}
.d3fc-aitools-panel-wrap {
  display: block;
}
.d3fc-aitools-tab-panel {
  display: none;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}
.d3fc-aiagent-tab-bar {
  display: flex;
  border-bottom: 1px solid #ddd;
  background: #fff;
  margin-bottom: 6px;
  padding: 0 2px;
  flex-wrap: wrap;
  width: 100%;
}
.d3fc-aiagent-main-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
}
.d3fc-aiagent-tab {
  padding: 6px 9px 5px;
  cursor: pointer;
  font-size: 12px;
  color: #444;
  user-select: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.d3fc-aiagent-tab:hover {
  color: #1f5fa8;
}
.d3fc-aiagent-tab-active {
  color: #1565c0 !important;
  font-weight: bold;
  border-bottom: 2px solid #1565c0;
}
.d3fc-aiagent-panel-wrap {
  display: block;
  width: 100%;
}
.d3fc-aiagent-tab-panel {
  display: none;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}
.d3fc-aiagent-role-section {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.d3fc-aiagent-role-title {
  display: none;
}
.d3fc-aiagent-role-items {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}
.d3fc-png-action-btn {
  cursor: pointer;
  padding: 4px 6px 3px;
  border-radius: 6px;
  text-align: center;
  border: 1px solid #e8e8e8;
  background: #fff;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}
.d3fc-png-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  border-color: #b0c4de;
}
.d3fc-png-action-btn:active {
  transform: translateY(0);
}
.d3fc-png-icon {
  display: block;
  font-size: 32px;
  line-height: 48px;
  width: 130px;
  height: 48px;
  text-align: center;
  pointer-events: none;
}
.d3fc-png-label {
  display: block;
  font-size: 10px;
  color: #888;
  margin-top: 1px;
  line-height: 1.2;
}

/* --- 畫板面板 --- */
.d3fc-board-panel {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  padding: 6px;
}
.d3fc-board-item {
  cursor: pointer;
  padding: 4px 6px 3px;
  border-radius: 6px;
  text-align: center;
  border: 2px solid #e8e8e8;
  background: #fff;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  overflow: hidden;
}
.d3fc-board-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  border-color: #b0c4de;
}
.d3fc-board-item:active {
  transform: translateY(0);
}
.d3fc-board-item-active {
  border-color: #2980B9;
  box-shadow: 0 0 0 2px rgba(41,128,185,0.25);
}
.d3fc-board-icon {
  display: block;
  margin: 0 auto;
  pointer-events: none;
  flex-shrink: 0;
  overflow: hidden;
}
.d3fc-board-label {
  display: block;
  font-size: 10px;
  color: #888;
  margin-top: 1px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.d3fc-lane-input {
  font-size: 13px;
  font-family: "Microsoft JhengHei", sans-serif;
  color: #1565c0;
  text-align: center;
  border: 2px solid #2980B9;
  border-radius: 3px;
  background: #fff;
  padding: 2px 4px;
  box-sizing: border-box;
  outline: none;
}

/* --- 頁籤內容面板 --- */
.d3fc-tab-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
}

/* --- 範本面板 --- */
.d3fc-template-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
}
.d3fc-template-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.d3fc-template-tool-btn {
  border: 1px solid #d6dce3;
  background: #fff;
  color: #37506a;
  border-radius: 4px;
  width: 26px;
  height: 24px;
  line-height: 22px;
  text-align: center;
  padding: 0;
  font-size: 14px;
  cursor: pointer;
}
.d3fc-template-tool-btn:hover {
  background: #f0f6ff;
  border-color: #9db4d1;
}
.d3fc-template-dropzone {
  border: none;
  border-radius: 8px;
  background: #f7fbff;
  padding: 10px 12px;
  min-height: 56px;
}
.d3fc-template-dropzone-active {
  background: #e8f2ff;
  box-shadow: inset 0 0 0 1px rgba(25, 118, 210, 0.18);
}
.d3fc-template-drop-title {
  color: #1e4f86;
  font-size: 13px;
  font-weight: bold;
}
.d3fc-template-drop-hint {
  margin-top: 2px;
  color: #607d9b;
  font-size: 11px;
}
.d3fc-template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.d3fc-template-empty {
  color: #8a97a6;
  font-size: 12px;
  padding: 6px 2px;
}
.d3fc-template-item {
  position: relative;
  min-width: 96px;
  max-width: 126px;
  border: 1px solid #d6e0ea;
  border-radius: 6px;
  background: #fff;
  padding: 7px 46px 7px 58px;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.d3fc-template-item-thumb {
  position: absolute;
  left: 8px;
  top: 7px;
  width: 46px;
  height: 30px;
  border-radius: 4px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #9fb6ce;
  box-shadow: 0 1px 3px rgba(23, 55, 89, 0.25);
}
.d3fc-template-item-thumb svg {
  display: block;
}
.d3fc-template-item:hover {
  transform: translateY(-1px);
  border-color: #9fbddd;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}
.d3fc-template-item-title {
  color: #234;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.d3fc-template-item-meta {
  margin-top: 3px;
  color: #7a8896;
  font-size: 11px;
}
.d3fc-template-item-del {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  border: 1px solid #d8d8d8;
  border-radius: 50%;
  background: #fff;
  color: #c05d5d;
  cursor: pointer;
  padding: 0;
}
.d3fc-template-item-ren {
  position: absolute;
  right: 28px;
  top: 6px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  border: 1px solid #d8d8d8;
  border-radius: 50%;
  background: #fff;
  color: #627487;
  cursor: pointer;
  padding: 0;
}
.d3fc-template-item-del:hover {
  background: #fff3f3;
  border-color: #e6b9b9;
}
.d3fc-template-item-ren:hover {
  background: #f2f7ff;
  border-color: #b9cce6;
}
.d3fc-template-ghost {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  display: none;
  background: rgba(25, 118, 210, 0.92);
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: "Microsoft JhengHei", sans-serif;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

/* --- 本機範本庫管理視窗 --- */
.d3fc-lib-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(13, 26, 39, 0.35);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.d3fc-lib-modal {
  width: min(760px, 92vw);
  max-height: 84vh;
  background: #fff;
  border: 1px solid #c8d5e2;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
}
.d3fc-lib-head {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: bold;
  color: #203547;
  border-bottom: 1px solid #e2e8ef;
  background: #f6f9fc;
}
.d3fc-lib-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #edf1f5;
}
.d3fc-lib-btn {
  border: 1px solid #cdd8e3;
  background: #fff;
  color: #2c4358;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.d3fc-lib-btn:hover {
  background: #eef5fc;
  border-color: #9db8d2;
}
.d3fc-lib-body {
  padding: 8px 10px;
  overflow: auto;
  min-height: 120px;
  max-height: 46vh;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.d3fc-lib-row {
  display: grid;
  grid-template-columns: 16px 40px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 6px;
  align-items: start;
  padding: 6px;
  border: 1px solid #e8edf3;
  border-radius: 6px;
  background: #fff;
  min-height: 54px;
}
.d3fc-lib-row:hover {
  background: #f9fbfe;
  border-color: #d7e3ef;
}
.d3fc-lib-cb {
  margin: 0;
  grid-column: 1 / 2;
  grid-row: 1 / 3;
  align-self: center;
}
.d3fc-lib-thumb {
  width: 46px;
  height: 30px;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #9fb6ce;
}
.d3fc-lib-thumb svg {
  display: block;
}
.d3fc-lib-name {
  font-size: 12px;
  color: #22384c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  grid-column: 3 / 4;
  grid-row: 1 / 2;
  padding-right: 18px;
}
.d3fc-lib-meta {
  font-size: 11px;
  color: #6a7f92;
  grid-column: 3 / 4;
  grid-row: 2 / 3;
}
.d3fc-lib-dup {
  font-size: 10px;
  color: #a15c00;
  background: #fff1dc;
  border: 1px solid #f0c27a;
  border-radius: 10px;
  padding: 1px 6px;
  grid-column: 3 / 4;
  grid-row: 1 / 2;
  justify-self: end;
}
.d3fc-lib-empty {
  color: #6f8193;
  font-size: 12px;
  padding: 12px 4px;
  grid-column: 1 / -1;
}
.d3fc-lib-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid #edf1f5;
  background: #fbfdff;
}
.d3fc-lib-status {
  font-size: 12px;
  color: #607488;
}

@media (max-width: 1200px) {
  .d3fc-lib-body {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 960px) {
  .d3fc-lib-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .d3fc-lib-body {
    grid-template-columns: 1fr;
  }
}

/* --- 操作說明面板 --- */
.d3fc-help-panel {
  display: none;
  flex-direction: column;
  gap: 0;
  padding: 0;
  font-size: 12px;
  color: #555;
  line-height: 1.6;
}
/* 類別導航列 */
.d3fc-help-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  border-bottom: 2px solid #e0e0e0;
  background: #fafafa;
  padding: 4px 4px 0;
  position: sticky;
  top: 0;
  z-index: 1;
  overflow-x: auto;
}
.d3fc-help-cat {
  padding: 4px 8px;
  font-size: 11px;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}
.d3fc-help-cat:hover {
  color: #1976D2;
}
.d3fc-help-cat.active {
  color: #1565C0;
  border-bottom-color: #1976D2;
  font-weight: bold;
}
/* 內容區域 */
.d3fc-help-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.d3fc-help-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #f8f9fa;
  border: 1px solid #eee;
}
.d3fc-help-row:hover {
  background: #e8f0fe;
  border-color: #c2d7f2;
}
.d3fc-help-icon {
  color: #2980B9;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}
.d3fc-help-txt {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.d3fc-help-txt b {
  color: #333;
  font-size: 12px;
  white-space: nowrap;
}
.d3fc-help-txt span {
  color: #777;
  font-size: 11px;
  line-height: 1.5;
}

/* --- 備註面板 --- */
.d3fc-memo-panel {
  display: none;
  flex-direction: column;
  padding: 8px 10px;
}
.d3fc-memo-panel .richText {
  width: 100% !important;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-height: 120px;
}
.d3fc-memo-panel .richText-editor {
  min-height: 100px;
  font-size: 13px;
  padding: 8px;
}
.d3fc-memo-editor {
  width: 100%;
  min-height: 120px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  font-size: 13px;
  font-family: inherit;
}
/* 畫布隱藏時，說明/幫助面板展開 */
.d3fc-canvas-hidden .d3fc-memo-panel .richText {
  min-height: 420px;
}
.d3fc-canvas-hidden .d3fc-memo-panel .richText-editor {
  min-height: 380px;
}
.d3fc-canvas-hidden .d3fc-memo-editor {
  min-height: 420px;
}
.d3fc-canvas-hidden .d3fc-help-panel {
  min-height: 500px;
}
.d3fc-canvas-hidden .d3fc-help-body {
  min-height: 420px;
  resize: vertical;
}
.d3fc-palette-item {
  cursor: pointer;
  padding: 4px 6px 3px;
  border-radius: 6px;
  text-align: center;
  border: 1px solid #e8e8e8;
  background: #fff;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}
.d3fc-palette-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  border-color: #b0c4de;
}
.d3fc-palette-item:active {
  transform: translateY(0);
}
.d3fc-pi-svg {
  display: block;
  margin: 0 auto;
  pointer-events: none;
}
.d3fc-pi-desc {
  display: block;
  font-size: 10px;
  color: #888;
  margin-top: 1px;
  line-height: 1.2;
}

/* --- 畫布區域 --- */
/* 透明圖紙時顯示棋盤格背景，方便辨識透明區域 */
.d3fc-board-transparent .d3fc-svg {
  background-color: #f0f0f0;
  background-image: linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.d3fc-canvas-wrap {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.d3fc-watermark {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: #ccc;
  font-family: "Microsoft JhengHei", "微軟正黑體", sans-serif;
  white-space: nowrap;
  z-index: 10;
}
/* 全螢幕模式（CSS 模擬，不使用 Fullscreen API 以避免中斷系統錄影） */
.d3fc-wrap.d3fc-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  border-radius: 0;
  border: none;
  max-height: none;
  background: #fff;
  gap: 0;
}
.d3fc-wrap.d3fc-fullscreen .d3fc-canvas-wrap {
  border-radius: 0;
  border: none;
  flex: 1;
  min-height: 0;
}
/* 保留原生 Fullscreen API 樣式（向下相容） */
.d3fc-wrap:fullscreen,
.d3fc-wrap:-webkit-full-screen,
.d3fc-wrap:-ms-fullscreen,
.d3fc-wrap:-moz-full-screen {
  border-radius: 0;
  border: none;
  max-height: none;
  width: 100%;
  height: 100%;
  background: #fff;
  gap: 0;
  position: relative;
}
.d3fc-wrap:fullscreen .d3fc-canvas-wrap,
.d3fc-wrap:-webkit-full-screen .d3fc-canvas-wrap,
.d3fc-wrap:-ms-fullscreen .d3fc-canvas-wrap,
.d3fc-wrap:-moz-full-screen .d3fc-canvas-wrap {
  border-radius: 0;
  border: none;
  flex: 1;
  min-height: 0;
}
.d3fc-svg {
  display: block;
  background: #fafbfc;
  cursor: grab;
}
.d3fc-svg:active {
  cursor: grabbing;
}

/* --- 工具列 --- */
.d3fc-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: #fafafa;
}
.d3fc-toolbar button {
  padding: 4px 10px;
  cursor: pointer;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  transition: background 0.15s;
  font-family: inherit;
}
.d3fc-toolbar button:hover {
  background: #f0f0f0;
}
.d3fc-tb-del {
  color: #c0392b !important;
}
.d3fc-tb-clear {
  color: #e67e22 !important;
}
.d3fc-tb-sep {
  color: #ddd;
  margin: 0 2px;
}
.d3fc-tb-zoom {
  font-size: 12px;
  color: #666;
  min-width: 40px;
  text-align: center;
}
.d3fc-tb-hint {
  font-size: 11px;
  color: #aaa;
  margin-left: auto;
}
.d3fc-tb-toggle {
  font-size: 12px;
  color: #2980B9 !important;
  border-color: #2980B9 !important;
}
.d3fc-tb-submit {
  background: #4A90D9 !important;
  color: #fff !important;
  border-color: #3a7bc8 !important;
  font-weight: bold;
  padding: 5px 16px !important;
  font-size: 13px;
  margin-left: 6px;
}
.d3fc-tb-submit:hover {
  background: #3a7bc8 !important;
}

/* ═══════════════════════════════════════════
   節點
   ═══════════════════════════════════════════ */
.d3fc-node {
  cursor: move;
}
.d3fc-node-shape {
  transition: filter 0.15s;
}
.d3fc-node:hover > .d3fc-node-shape {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.18));
}
/* 選取狀態 */
.d3fc-node-sel > .d3fc-node-shape {
  stroke: #2980B9 !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 8px rgba(41,128,185,0.5));
}
/* 連線目標高亮 */
.d3fc-drop-target > .d3fc-node-shape {
  stroke: #2980B9 !important;
  stroke-width: 3px !important;
  stroke-dasharray: 4,2 !important;
  filter: drop-shadow(0 0 6px rgba(41,128,185,0.4));
}

/* ═══════════════════════════════════════════
   線條 Resize Handle
   ═══════════════════════════════════════════ */
.d3fc-line-handle {
  fill: #fff;
  stroke: #888;
  stroke-width: 1.5;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity 0.15s;
}
.d3fc-line-handle-v {
  cursor: ns-resize;
}
.d3fc-line-handle-diag {
  cursor: nwse-resize;
}
.d3fc-node:hover .d3fc-line-handle,
.d3fc-node-sel .d3fc-line-handle {
  opacity: 1;
}
.d3fc-line-handle:hover {
  fill: #4A90D9;
  stroke: #2471A3;
}

/* ═══════════════════════════════════════════
   圖形 Resize Handle（四角）
   ═══════════════════════════════════════════ */
.d3fc-shape-handle {
  fill: #fff;
  stroke: #888;
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 0.15s;
}
.d3fc-shape-handle-nw { cursor: nw-resize; }
.d3fc-shape-handle-ne { cursor: ne-resize; }
.d3fc-shape-handle-se { cursor: se-resize; }
.d3fc-shape-handle-sw { cursor: sw-resize; }
.d3fc-node:hover .d3fc-shape-handle,
.d3fc-node-sel .d3fc-shape-handle {
  opacity: 1;
}
.d3fc-shape-handle:hover {
  fill: #4A90D9;
  stroke: #2471A3;
}

/* Call Out 尾巴控點 */
.d3fc-callout-handle {
  fill: #ccc;
  stroke: #aaa;
  stroke-width: 1;
  opacity: 0;
  cursor: grab;
  pointer-events: all;
  transition: opacity 0.15s;
}
.d3fc-node:hover .d3fc-callout-handle,
.d3fc-node-sel .d3fc-callout-handle {
  opacity: 0.7;
}
.d3fc-callout-handle:hover {
  fill: #999;
  stroke: #777;
  opacity: 1;
}

/* 線條選取樣式 */
.d3fc-node-sel .d3fc-line-vis {
  stroke: #2980B9 !important;
}

/* ═══════════════════════════════════════════
   連接點（Port）
   ═══════════════════════════════════════════ */
.d3fc-port {
  fill: #fff;
  stroke: #4A90D9;
  stroke-width: 2;
  cursor: crosshair;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, fill 0.1s;
}
.d3fc-node:hover .d3fc-port {
  opacity: 1;
  pointer-events: all;
}
.d3fc-port:hover {
  fill: #4A90D9;
  stroke: #2471A3;
}

/* ═══════════════════════════════════════════
   邊（連線）
   ═══════════════════════════════════════════ */
.d3fc-edge {
  cursor: pointer;
}
.d3fc-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
}
.d3fc-edge-line {
  fill: none;
  transition: stroke 0.15s, stroke-width 0.15s;
}

/* ═══════════════════════════════════════════
   拖曳幽靈元素
   ═══════════════════════════════════════════ */
.d3fc-ghost {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  opacity: 0.88;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
  font-family: "Microsoft JhengHei", sans-serif;
}
.d3fc-ghost svg {
  display: block;
}

/* ═══════════════════════════════════════════
   文字元件（textbox）
   ═══════════════════════════════════════════ */
.d3fc-node-sel[data-type="textbox"] > .d3fc-node-shape,
.d3fc-node.d3fc-node-sel .d3fc-node-shape[d=""] {
  stroke: #aaa !important;
  stroke-width: 1px !important;
  stroke-dasharray: 3,2 !important;
  fill: rgba(255,255,255,0.5) !important;
}

/* ═══════════════════════════════════════════
   唯讀模式
   ═══════════════════════════════════════════ */
.d3fc-readonly .d3fc-node {
  cursor: default;
}
.d3fc-readonly .d3fc-svg {
  cursor: default;
}
.d3fc-readonly .d3fc-svg:active {
  cursor: default;
}
