/* law685 team-formation v1.0 — 組織圖依編隊呈現（見 team-formation.js） */
.ltf-on [class*="_chartArea_"] { display: none !important; }

.ltf-root, .ltf-dw-wrap, .ltf-toast {
  --ltf-line: var(--border-default, #cbd5e1);
  --ltf-graph: var(--text-subtle, #94a3b8); /* 1.0.5：組織圖連線用較深的顏色，邊框色太淡看不清楚 */
  --ltf-acc: var(--accent, #5b5bd6);
  --ltf-acc-t: var(--accent-tint, rgba(91, 91, 214, .1));
  --ltf-gate: #c2410c;
  --ltf-gate-t: rgba(234, 88, 12, .1);
  --ltf-syn: #0f766e;
  --ltf-syn-t: rgba(13, 148, 136, .12);
}
.ltf-root {
  flex-shrink: 0;
  padding: 18px 24px 8px;
  min-width: 0;
}

/* ---------- 編隊列 ---------- */
.ltf-bar {
  border: 1px solid var(--border-card, #e5e7eb);
  background: var(--surface-card, #fff);
  border-radius: var(--radius-lg, 12px);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm, none);
}
.ltf-bar-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ltf-bar-k { font-size: 12px; color: var(--text-muted, #64748b); }
.ltf-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px; border-radius: 999px;
  background: var(--ltf-acc-t); color: var(--ltf-acc); font-size: 13px;
}
.ltf-pill b { font-weight: 600; }
.ltf-pill svg { width: 18px; height: 18px; }
.ltf-bar-meta { font-size: 12px; color: var(--text-subtle, #94a3b8); }
.ltf-bar-sp { flex: 1; }
.ltf-sug {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--text-secondary, #475569); padding: 3px 4px 3px 8px;
  border: 1px dashed var(--ltf-line); border-radius: 999px;
}
.ltf-sug svg { width: 16px; height: 16px; color: var(--ltf-acc); }
.ltf-bar-desc { margin-top: 6px; font-size: 13px; color: var(--text-secondary, #475569); line-height: 1.6; }
.ltf-chat { display: block; color: var(--text-subtle, #94a3b8); font-size: 12px; }
.ltf-warn { margin-top: 8px; font-size: 12px; color: var(--ltf-gate); }

.ltf-btn {
  border: 1px solid var(--border-default, #cbd5e1); background: var(--surface-card, #fff);
  color: var(--text-primary, #0f172a); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.ltf-btn:hover { background: var(--surface-hover, #f1f5f9); }
.ltf-btn.primary { background: var(--ltf-acc); border-color: var(--ltf-acc); color: #fff; }
.ltf-btn.primary:hover { filter: brightness(1.06); }
.ltf-btn:disabled { opacity: .55; cursor: not-allowed; }
.ltf-link { border: 0; background: var(--ltf-acc-t); color: var(--ltf-acc); border-radius: 999px; padding: 3px 9px; font-size: 12px; cursor: pointer; }

/* ---------- 畫布 ---------- */
.ltf-canvas { position: relative; margin-top: 16px; overflow-x: auto; padding-bottom: 8px; }
.ltf-empty { display: flex; align-items: center; gap: 8px; padding: 32px 4px; color: var(--text-muted, #64748b); font-size: 13px; }
.ltf-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ltf-line); border-top-color: var(--ltf-acc); animation: ltf-spin .8s linear infinite; }
@keyframes ltf-spin { to { transform: rotate(360deg); } }

/* 節點卡片 */
.ltf-node {
  position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left;
  width: 100%; min-width: 0; padding: 12px; cursor: pointer;
  border: 1px solid var(--border-card, #e5e7eb); border-radius: var(--radius-2xl, 16px);
  background: var(--surface-card, #fff); box-shadow: var(--shadow-sm, none);
  color: inherit; font: inherit;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.ltf-node:hover { border-color: var(--accent-border, var(--ltf-acc)); box-shadow: var(--shadow-card, 0 4px 14px rgba(0,0,0,.08)); transform: translateY(-1px); }
.ltf-node.is-lead { border-color: var(--accent-border, var(--ltf-acc)); box-shadow: 0 0 0 3px var(--ltf-acc-t); }
.ltf-node.is-gate { border-color: rgba(234, 88, 12, .45); }
.ltf-node.is-synth { border-color: rgba(13, 148, 136, .5); }
.ltf-node.is-compact { padding: 10px; gap: 6px; }
.ltf-nhead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ltf-av {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.ltf-av.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.is-compact .ltf-av { width: 30px; height: 30px; }
.ltf-nmeta { display: flex; flex-direction: column; min-width: 0; }
.ltf-nm { font-size: 14px; font-weight: 600; color: var(--text-strong, #0f172a); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltf-job { font-size: 12px; color: var(--text-muted, #64748b); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltf-st { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted, #64748b); }
.ltf-st i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-subtle, #94a3b8); }
.ltf-st i.on { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.ltf-st b { margin-left: auto; font-weight: 500; color: var(--ltf-acc); background: var(--ltf-acc-t); padding: 1px 7px; border-radius: 999px; }
.ltf-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.ltf-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-muted, #f1f5f9); color: var(--text-secondary, #475569); }
.ltf-tag.is-lead { background: var(--ltf-acc-t); color: var(--ltf-acc); }
.ltf-tag.is-gate { background: var(--ltf-gate-t); color: var(--ltf-gate); }
.ltf-tag.is-synth { background: var(--ltf-syn-t); color: var(--ltf-syn); }
.ltf-badge {
  position: absolute; top: -9px; left: 12px; font-size: 11px; font-weight: 600;
  background: var(--ltf-acc); color: #fff; padding: 1px 8px; border-radius: 999px;
}
.ltf-node.is-gate .ltf-badge { background: var(--ltf-gate); }
.ltf-pseudo {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 16px;
  border: 1px dashed var(--ltf-line); border-radius: var(--radius-2xl, 16px);
  background: var(--surface-muted, #f8fafc); font-size: 13px; color: var(--text-secondary, #475569);
}
.ltf-pseudo span { font-size: 12px; color: var(--text-subtle, #94a3b8); }
.ltf-hint { font-size: 13px; color: var(--text-muted, #64748b); padding: 8px 12px; border: 1px dashed var(--ltf-line); border-radius: 10px; }

/* 成員面板（階層／專家池／候補） */
.ltf-panel { border: 1px solid var(--border-line, #e5e7eb); border-radius: var(--radius-2xl, 16px); padding: 12px; background: var(--surface-app, transparent); }
.ltf-panel.is-pool { border-style: dashed; }
.ltf-panel.is-bench { margin-top: 18px; opacity: .85; }
.ltf-panel-h { font-size: 12px; color: var(--text-muted, #64748b); margin: 0 2px 10px; }
.ltf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }

/* 階層式 */
.ltf-h { display: flex; flex-direction: column; align-items: center; }
.ltf-h-top { width: 240px; max-width: 100%; display: flex; justify-content: center; }
.ltf-vline { width: 2px; height: 22px; background: var(--ltf-graph); }
.ltf-h > .ltf-panel { align-self: stretch; }

/* 流水線 */
.ltf-pipe { display: flex; flex-direction: column; }
.ltf-src { width: 220px; display: flex; flex-direction: column; align-items: center; }
.ltf-src-arrow { width: 2px; height: 22px; background: var(--ltf-graph); position: relative; }
.ltf-src-arrow::after { content: ''; position: absolute; left: -4px; bottom: -2px; border: 5px solid transparent; border-top-color: var(--ltf-graph); border-bottom: 0; }
.ltf-flow { list-style: none; margin: 6px 0 0; padding: 12px 0 0; display: flex; flex-wrap: wrap; gap: 22px 40px; }
.ltf-step { position: relative; width: 196px; }
.ltf-step:not(:last-child)::after {
  content: ''; position: absolute; top: 50%; right: -32px; width: 24px; height: 2px; background: var(--ltf-acc);
}
.ltf-step:not(:last-child)::before {
  content: ''; position: absolute; top: calc(50% - 4px); right: -34px; border: 5px solid transparent; border-left-color: var(--ltf-acc); border-right: 0;
}
.ltf-step.is-wrap::after, .ltf-step.is-wrap::before { display: none; }
.ltf-step-end { width: auto; display: flex; align-items: center; }
.ltf-out { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 6px 10px; border-radius: 8px; background: var(--ltf-syn-t); color: var(--ltf-syn); }

/* 平行會診 */
.ltf-fan { position: relative; display: flex; flex-direction: column; align-items: center; min-width: fit-content; }
.ltf-fan > .ltf-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.ltf-tier { position: relative; display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.ltf-tier > .ltf-node { width: 196px; }
.ltf-tier-mid { max-width: 100%; }
.ltf-tier-label { font-size: 11px; color: var(--text-subtle, #94a3b8); margin: 22px 0; position: relative; background: var(--surface-app, #fff); padding: 0 6px; }
.ltf-fan > .ltf-panel { align-self: stretch; }
.ltf-edge { fill: none; stroke: var(--ltf-graph); stroke-width: 1.8; }
.ltf-edge.is-in { stroke-dasharray: 6 4; }
.ltf-arrhead { fill: var(--ltf-graph); }

/* 圓桌 */
.ltf-rt-wrap { overflow-x: auto; display: flex; }
.ltf-rt { position: relative; margin: 0 auto; flex-shrink: 0; }
.ltf-rt > .ltf-svg { position: absolute; inset: 0; pointer-events: none; }
.ltf-ring { fill: none; stroke: var(--ltf-graph); stroke-width: 1.6; stroke-dasharray: 4 5; opacity: .75; }
.ltf-spoke { stroke: var(--ltf-graph); stroke-width: 1.6; stroke-dasharray: 6 4; }
.ltf-rt-host { position: absolute; width: 158px; }
.ltf-node.is-rt { padding: 8px 10px; gap: 4px; }
.ltf-node.is-rt .ltf-av { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }
.ltf-node.is-rt .ltf-nm { font-size: 13px; }

/* 左側團隊清單的編隊標籤 */
.ltf-rowtag {
  flex-shrink: 0; font-size: 10.5px; line-height: 16px; padding: 0 6px; margin-left: 6px; border-radius: 999px;
  background: var(--accent-tint, rgba(91, 91, 214, .1)); color: var(--accent, #5b5bd6); white-space: nowrap;
}

/* ---------- 右側設定面板 ---------- */
.ltf-dw-wrap { position: fixed; inset: 0; z-index: 1200; pointer-events: none; }
.ltf-dw-back { position: absolute; inset: 0; background: rgba(15, 23, 42, .18); pointer-events: auto; }
.ltf-dw {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); pointer-events: auto;
  display: flex; flex-direction: column; background: var(--surface-card, #fff); color: var(--text-primary, #0f172a);
  box-shadow: var(--shadow-lg, -8px 0 30px rgba(0,0,0,.15)); border-left: 1px solid var(--border-card, #e5e7eb);
  animation: ltf-in .18s ease-out;
}
@keyframes ltf-in { from { transform: translateX(24px); opacity: 0; } }
.ltf-dw-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border-line, #e5e7eb); }
.ltf-dw-h div { display: flex; flex-direction: column; gap: 2px; }
.ltf-dw-h b { font-size: 16px; }
.ltf-dw-h span { font-size: 12px; color: var(--text-muted, #64748b); }
.ltf-x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-muted, #64748b); padding: 4px 8px; border-radius: 8px; }
.ltf-x:hover { background: var(--surface-hover, #f1f5f9); }
.ltf-dw-body { flex: 1; overflow-y: auto; padding: 6px 18px 18px; }
.ltf-dw-body section { margin-top: 16px; }
.ltf-dw-body h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--text-strong, #0f172a); }
.ltf-help { margin: 0 0 8px; font-size: 12px; color: var(--text-muted, #64748b); line-height: 1.6; }
.ltf-types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ltf-type {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; row-gap: 2px;
  text-align: left; padding: 10px; border-radius: 12px; cursor: pointer; font: inherit; color: inherit;
  border: 1px solid var(--border-card, #e5e7eb); background: var(--surface-card, #fff);
}
.ltf-type:hover:not(:disabled) { border-color: var(--accent-border, var(--ltf-acc, #5b5bd6)); }
.ltf-type.on { border-color: var(--accent, #5b5bd6); box-shadow: 0 0 0 3px var(--accent-tint, rgba(91, 91, 214, .12)); }
.ltf-type:disabled { opacity: .5; cursor: not-allowed; }
.ltf-type-ic { grid-row: span 2; color: var(--accent, #5b5bd6); display: flex; align-items: flex-start; padding-top: 1px; }
.ltf-type b { font-size: 13px; }
.ltf-type span:last-child { font-size: 11.5px; line-height: 1.5; color: var(--text-muted, #64748b); }
.ltf-rows { display: flex; flex-direction: column; gap: 6px; }
.ltf-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border-line, #e5e7eb); border-radius: 10px; }
.ltf-row.is-off { opacity: .55; }
.ltf-row .ltf-nm { font-size: 13px; }
.ltf-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ltf-chk input { width: 16px; height: 16px; accent-color: var(--accent, #5b5bd6); cursor: pointer; }
.ltf-no { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; background: var(--accent, #5b5bd6); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.ltf-in {
  width: 100%; box-sizing: border-box; border: 1px solid var(--border-default, #cbd5e1); border-radius: 7px;
  padding: 4px 8px; font: inherit; font-size: 12px; background: var(--surface-card, #fff); color: inherit;
}
.ltf-in:focus { outline: 2px solid var(--accent-tint, rgba(91, 91, 214, .25)); border-color: var(--accent, #5b5bd6); }
.ltf-note { font-size: 13px; resize: vertical; }
.ltf-tg { flex-shrink: 0; font-size: 11px; padding: 3px 8px; border-radius: 999px; cursor: pointer; border: 1px solid var(--border-default, #cbd5e1); background: none; color: var(--text-muted, #64748b); }
.ltf-tg.on { border-color: #c2410c; background: rgba(234, 88, 12, .1); color: #c2410c; }
.ltf-mv { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.ltf-mv button { border: 0; background: none; font-size: 9px; line-height: 12px; padding: 1px 4px; cursor: pointer; color: var(--text-muted, #64748b); border-radius: 4px; }
.ltf-mv button:hover:not(:disabled) { background: var(--surface-hover, #f1f5f9); }
.ltf-mv button:disabled { opacity: .3; cursor: default; }
.ltf-opts { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.ltf-opts label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary, #475569); }
.ltf-opts select { font: inherit; font-size: 12px; padding: 4px 6px; border-radius: 7px; border: 1px solid var(--border-default, #cbd5e1); background: var(--surface-card, #fff); color: inherit; }
.ltf-pre {
  margin: 0 0 8px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-muted, #f8fafc); color: var(--text-body, #334155); border: 1px solid var(--border-line, #e5e7eb);
}
.ltf-dw-f { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border-line, #e5e7eb); }
.ltf-dw-f > span { flex: 1; }
.ltf-err { font-size: 12px; color: #dc2626; }

.ltf-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); z-index: 1300; opacity: 0; pointer-events: none;
  background: var(--text-strong, #0f172a); color: #fff; font-size: 13px; padding: 10px 16px; border-radius: 10px; transition: .2s;
  max-width: calc(100vw - 32px);
}
.ltf-toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .ltf-root { padding: 12px 12px 4px; }
  .ltf-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ltf-step, .ltf-tier > .ltf-node { width: 160px; }
  .ltf-types { grid-template-columns: 1fr; }
}

/* v1.0.6 團隊名稱大標題 */
.ltf-title { margin: 0 0 14px; }
.ltf-title h2 { margin: 0; font-size: 24px; line-height: 1.3; font-weight: 700; color: var(--text, #0f172a); }
.ltf-title p { margin: 6px 0 0; font-size: 14px; line-height: 1.6; color: var(--text-muted, #64748b); }

/* v1.0.7 團隊改名 */
.ltf-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ltf-rn-btn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border, #e2e8f0); border-radius: 8px; background: var(--surface, #fff); color: var(--text-muted, #64748b); font-size: 13px; cursor: pointer; }
.ltf-rn-btn svg { width: 15px; height: 15px; }
.ltf-rn-btn:hover { color: var(--primary, #4f46e5); border-color: var(--primary, #4f46e5); }
.ltf-title.is-edit { display: grid; gap: 10px; max-width: 640px; padding: 14px 16px; border: 1px solid var(--border, #e2e8f0); border-radius: 12px; background: var(--surface, #fff); }
.ltf-rn-l { display: grid; gap: 4px; font-size: 13px; color: var(--text-muted, #64748b); }
.ltf-rn-name, .ltf-rn-desc { font: inherit; font-size: 15px; color: var(--text, #0f172a); padding: 8px 10px; border: 1px solid var(--border, #cbd5e1); border-radius: 8px; background: var(--surface, #fff); }
.ltf-rn-name { font-size: 18px; font-weight: 600; }
.ltf-rn-desc { resize: vertical; }
.ltf-rn-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ltf-rn-err { color: var(--danger, #dc2626); font-size: 13px; }

/* ---------- 1.1.0 刪除團隊 ---------- */
.ltf-btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.ltf-btn.danger:hover { filter: brightness(1.06); }
.ltf-btn.ghost { background: transparent; }
.ltf-rn-acts .ltf-del-open { margin-left: auto; background: transparent; color: #dc2626; border-color: rgba(220, 38, 38, .45); }
.ltf-rn-acts .ltf-del-open:hover { background: rgba(220, 38, 38, .08); filter: none; }
.ltf-del-wrap {
  position: fixed; inset: 0; z-index: 2147483000; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ltf-del {
  width: min(560px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--surface-card, #fff); color: var(--text-primary, #0f172a);
  border-radius: var(--radius-lg, 12px); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); overflow: hidden;
}
.ltf-del header, .ltf-del footer { display: flex; align-items: center; gap: 8px; padding: 14px 18px; }
.ltf-del header { border-bottom: 1px solid var(--border-card, #e5e7eb); }
.ltf-del header h3 { margin: 0; font-size: 16px; flex: 1; }
.ltf-del footer { justify-content: flex-end; border-top: 1px solid var(--border-card, #e5e7eb); }
.ltf-del-x { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-muted, #64748b); }
.ltf-del-body { padding: 6px 18px 14px; overflow: auto; font-size: 13px; }
.ltf-del-body section { padding: 10px 0; border-bottom: 1px dashed var(--border-card, #e5e7eb); }
.ltf-del-body h4 { margin: 0 0 6px; font-size: 13px; color: var(--text-secondary, #475569); }
.ltf-del-list { margin: 0 0 8px; padding: 0; list-style: none; display: grid; gap: 4px; }
.ltf-del-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ltf-del-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--ltf-acc-t, rgba(91,91,214,.1)); color: var(--ltf-acc, #5b5bd6); }
.ltf-del-tag.warn { background: rgba(234, 88, 12, .1); color: #c2410c; }
.ltf-del-sub { font-size: 12px; color: var(--text-muted, #64748b); margin: 0; }
.ltf-del-opt { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.ltf-del-opt span { display: grid; gap: 2px; }
.ltf-del-opt small { color: var(--text-muted, #64748b); font-size: 12px; line-height: 1.5; }
.ltf-del-type { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; }
.ltf-del-type input { border: 1px solid var(--border-default, #cbd5e1); border-radius: 8px; padding: 7px 10px; font-size: 14px; background: var(--surface-card, #fff); color: inherit; }
.ltf-del-err { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(220, 38, 38, .08); color: #b91c1c; font-size: 12px; }
