/* ============================================================
   editor.css — 行程節點編輯器（重設計）
   signature：不斷的直立脊柱（連續鏈）
   語意色：粉=景點/停留 · 藍=交通/移動 · 綠=接上 · 琥珀=缺口
   全部 class 以 .tfx- 前綴，scope 在 .tfx-ed 下，避免和 theme.css / Tailwind 撞。
   ============================================================ */

.tfx-ed {
  /* ── tokens ── */
  --ink:        #1E293B;   /* 主文字 */
  --ink-soft:   #64748B;   /* 次要 */
  --ink-faint:  #94A3B8;   /* 提示 / 軸線 */
  --line:       #E9EDF2;   /* 細邊 */
  --line-soft:  #F1F5F9;   /* 更淡的分隔 */
  --surface:    #FFFFFF;
  --sunk:       #F8FAFC;   /* 下沉面板 */

  --place:      #C1654A;   /* 景點 / 停留 / 主要動作 */
  --place-wash: #F4E7DF;
  --place-deep: #A8523A;

  --move:       #1E6FB5;   /* 交通 / 移動 */
  --move-wash:  #E8F1FA;
  --move-deep:  #14507F;

  --ok:         #0F6E56;   /* 接上 */
  --ok-wash:    #E9F6F0;
  --ok-line:    #BFE3D2;

  --warn:       #9A5108;   /* 缺口 */
  --warn-wash:  #FEF4E2;
  --warn-line:  #F6D79A;

  --r-lg: 22px;  --r-md: 15px;  --r-sm: 11px;

  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  /* 桌面 modal 較寬（max-w-lg≈512px），編輯器內容收窄置中，維持手機般的緊湊 */
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

/* ────────────────────────────────────────────
   1) 接點外顯 — 把這個節點釘在鏈上
   ──────────────────────────────────────────── */
.tfx-seam {
  display: flex; align-items: stretch; gap: 0;
  background: var(--sunk); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 4px; margin-bottom: 14px;
}
.tfx-seam-node {
  flex: 1; min-width: 0; padding: 7px 11px; border-radius: 10px; background: transparent;
}
.tfx-seam-node .tfx-seam-cap {
  font-size: 9.5px; font-weight: 800; letter-spacing: .04em; color: var(--ink-faint);
  display: flex; align-items: center; gap: 4px; margin-bottom: 2px;
}
.tfx-seam-node .tfx-seam-name {
  font-size: 13px; font-weight: 800; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tfx-seam-node .tfx-seam-time { font-size: 10.5px; font-weight: 800; color: var(--place); }
.tfx-seam-mid {
  flex: 0 0 auto; display: flex; align-items: center; padding: 0 4px;
  color: var(--ink-faint); font-size: 14px;
}
.tfx-seam-node.is-empty .tfx-seam-name { color: var(--ink-faint); font-weight: 700; }

/* 接點外顯：上一站/下一站可點擊 → 開該節點的編輯器 */
.tfx-seam-link { cursor: pointer; transition: background .12s; }
.tfx-seam-link:hover { background: var(--surface); }
.tfx-seam-link:hover .tfx-seam-name { text-decoration: underline; text-decoration-color: var(--place); text-underline-offset: 2px; }

/* 次要燃料來源（與分頁清楚分隔，避免看起來像分頁子標籤）*/
.tfx-fuel-alt {
  display: flex; align-items: center; justify-content: center; gap: 9px; flex-wrap: wrap;
  margin: 6px 0 16px;
}
.tfx-fuel-alt .lbl { font-size: 10px; font-weight: 800; color: var(--ink-faint); letter-spacing: .03em; }
.tfx-fuel-alt button {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 11px; font-weight: 800; color: var(--ink-soft);
  background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  transition: border-color .12s, color .12s;
}
.tfx-fuel-alt button:hover { border-color: var(--place); color: var(--place); }

/* ────────────────────────────────────────────
   2) 類型選擇 — 4 類分頁
   ──────────────────────────────────────────── */
.tfx-types {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px;
}
.tfx-type {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 11px 4px 9px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer;
  transition: border-color .15s, background .15s, transform .08s;
}
.tfx-type i { font-size: 17px; color: var(--ink-faint); transition: color .15s; }
.tfx-type span { font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.tfx-type:active { transform: scale(.97); }
.tfx-type.is-active { border-color: var(--place); background: var(--place-wash); }
.tfx-type.is-active i, .tfx-type.is-active span { color: var(--place-deep); }
/* 交通分頁選中時走藍 */
.tfx-type.is-active[data-type="transport"] { border-color: var(--move); background: var(--move-wash); }
.tfx-type.is-active[data-type="transport"] i,
.tfx-type.is-active[data-type="transport"] span { color: var(--move-deep); }

/* ────────────────────────────────────────────
   3) 區段 / 欄位 — 一般內容
   ──────────────────────────────────────────── */
.tfx-sec { margin-bottom: 14px; }
.tfx-sec-h {
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em; color: var(--ink-faint);
  display: flex; align-items: center; gap: 6px; margin: 0 2px 8px;
}
.tfx-field { margin-bottom: 11px; }
.tfx-label {
  display: block; font-size: 11px; font-weight: 800; color: var(--ink-soft); margin: 0 0 5px 2px;
}
.tfx-input, .tfx-area {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; font-size: 14px; font-weight: 700; color: var(--ink);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.tfx-input:focus, .tfx-area:focus {
  border-color: var(--place); box-shadow: 0 0 0 3px var(--place-wash);
}
.tfx-area { resize: vertical; min-height: 76px; line-height: 1.6; }
.tfx-row { display: flex; gap: 9px; }
.tfx-row > * { flex: 1; min-width: 0; }

/* ────────────────────────────────────────────
   4) ★ signature：連續鏈（交通節點）★
   ──────────────────────────────────────────── */
.tfx-chain { position: relative; padding: 2px 0 2px 4px; }

/* 一個站（端點 / 中繼）＝ 軸 + 圓點 + 內容 */
.tfx-stop { position: relative; display: flex; gap: 13px; }
.tfx-stop .tfx-rail {
  position: relative; flex: 0 0 14px; display: flex; justify-content: center;
}
/* 脊柱：相鄰站之間那條不斷的線（畫在 rail 內，用 ::before 連到下一站） */
.tfx-stop .tfx-rail::before {
  content: ""; position: absolute; top: 18px; bottom: -2px; left: 50%;
  width: 3px; transform: translateX(-50%); background: var(--move); border-radius: 2px;
}
.tfx-stop.is-end .tfx-rail::before { display: none; }
.tfx-dot {
  position: relative; z-index: 1; margin-top: 5px;
  width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid var(--place); background: var(--surface);
}
.tfx-dot.is-mid { border-color: var(--move); background: var(--move); width: 11px; height: 11px; margin-top: 7px; }

.tfx-stop .tfx-stop-body { flex: 1; min-width: 0; padding-bottom: 14px; }
.tfx-endpt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tfx-role {
  font-size: 9.5px; font-weight: 800; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 6px; background: var(--place-wash); color: var(--place-deep);
}
.tfx-role.is-mid { background: var(--move-wash); color: var(--move-deep); }
.tfx-endpt-head .tfx-input { flex: 1 1 auto; min-width: 0; width: auto; }

/* 鎖 */
.tfx-lock {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.tfx-lock.is-locked { background: var(--line-soft); color: var(--ink-faint); }
.tfx-lock.is-open { background: var(--place-wash); border-color: #F2BFD0; color: var(--place); }
.tfx-lock-hint { font-size: 9px; font-weight: 700; color: var(--ink-faint); margin: -2px 0 0; }

/* 段：兩站之間的交通工具（掛在脊柱上） */
.tfx-seg {
  display: flex; align-items: center; gap: 9px; margin: 2px 0 4px;
}
.tfx-seg-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--move-wash); border: 1px solid #CFE3F4; color: var(--move-deep);
  font-size: 12px; font-weight: 800; cursor: pointer;
}
.tfx-seg-pill i:first-child { font-size: 13px; }
.tfx-seg-pill .tfx-seg-cnt { color: var(--move); }

/* 接縫狀態：接上 / 缺口 / 接駁 */
.tfx-seam-row { margin: 0 0 2px 27px; }
.tfx-ok {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 800; color: var(--ok); padding: 3px 0;
}
.tfx-gap {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: var(--warn-wash); border: 1px solid var(--warn-line);
  border-radius: 12px; padding: 9px 12px; margin-top: 4px;
}
.tfx-gap .tfx-gap-txt { flex: 1; min-width: 130px; font-size: 11px; font-weight: 800; color: var(--warn); }
.tfx-gap button {
  font-size: 10.5px; font-weight: 800; color: #fff; background: var(--place);
  border: none; border-radius: 999px; padding: 7px 13px; cursor: pointer;
}
.tfx-bridge {
  display: flex; align-items: center; gap: 9px;
  background: var(--ok-wash); border: 1px solid var(--ok-line);
  border-radius: 12px; padding: 8px 12px; margin: 4px 0;
}
.tfx-bridge .tfx-bridge-txt { flex: 1; font-size: 11.5px; font-weight: 800; color: var(--ok); }
.tfx-bridge .tfx-bridge-rm {
  background: none; border: none; cursor: pointer; color: #9FC4B5; font-size: 13px;
}

/* 加一段 */
.tfx-add {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px; border-radius: var(--r-md); cursor: pointer;
  border: 1.5px dashed #CFE3F4; background: transparent; color: var(--move-deep);
  font-size: 12px; font-weight: 800; transition: background .15s;
}
.tfx-add:hover { background: var(--move-wash); }

/* 轉乘策略雙閘（順向銜接 / 回歸大站） */
.tfx-strategy {
  display: flex; gap: 7px; background: var(--sunk); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 4px; margin-bottom: 12px;
}
.tfx-strategy .tfx-strat {
  flex: 1; text-align: center; padding: 9px 6px; border-radius: 10px; cursor: pointer;
  font-size: 11.5px; font-weight: 800; color: var(--ink-soft); border: 1px solid transparent;
}
.tfx-strategy .tfx-strat.is-active { background: var(--surface); color: var(--move-deep); border-color: #CFE3F4; box-shadow: 0 1px 4px rgba(15,23,42,.06); }

/* ────────────────────────────────────────────
   5) 視覺 / 原始燃料 切換
   ──────────────────────────────────────────── */
.tfx-mode {
  display: flex; gap: 5px; background: var(--sunk); border: 1px solid var(--line);
  border-radius: 13px; padding: 4px; margin-bottom: 16px;
}
.tfx-mode-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px; border-radius: 9px; cursor: pointer; border: none; background: transparent;
  font-size: 12px; font-weight: 800; color: var(--ink-soft); transition: all .12s;
}
.tfx-mode-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(15,23,42,.08); }
.tfx-raw {
  width: 100%; min-height: 150px; border: 1.5px solid var(--line); border-radius: var(--r-md);
  padding: 12px; font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.6; color: var(--ink); background: var(--sunk); outline: none; resize: vertical;
}
.tfx-raw:focus { border-color: var(--move); box-shadow: 0 0 0 3px var(--move-wash); }

/* ────────────────────────────────────────────
   6) 動作鈕
   ──────────────────────────────────────────── */
.tfx-actions { display: flex; gap: 9px; margin-top: 18px; }
.tfx-btn {
  flex: 1; padding: 13px; border-radius: 14px; cursor: pointer; border: none;
  font-size: 14px; font-weight: 800; font-family: inherit; transition: filter .15s, transform .08s;
}
.tfx-btn:active { transform: scale(.98); }
.tfx-btn-primary { background: var(--place); color: #fff; }
.tfx-btn-primary:hover { filter: brightness(1.05); }
.tfx-btn-ghost { background: var(--line-soft); color: var(--ink-soft); flex: 0 0 auto; padding-inline: 18px; }

/* 無障礙 */
.tfx-ed :focus-visible { outline: 2px solid var(--place); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .tfx-ed * { transition: none !important; }
}

/* ════════════════════════════════════════════════════════════
   完整交通編輯器（每段每站可直接編） — 全 .tfx- 前綴，scope 在 .tfx-ed
   ════════════════════════════════════════════════════════════ */
.tfx-rc{display:flex;flex-direction:column;gap:2px;}
.tfx-rc .tfx-sec-h{display:flex;align-items:center;gap:7px;font-size:12px;font-weight:900;color:var(--ink);margin:16px 0 9px;}
.tfx-rc .tfx-sec-h i{color:var(--move);font-size:12px;}
.tfx-rc .tfx-sec-h .hint{margin-left:auto;font-size:10px;font-weight:700;color:var(--ink-faint);}

/* 段落區塊 */
.tfx-seg-block{border:1.5px solid #CFE1F3;border-radius:16px;background:var(--move-wash);overflow:hidden;margin-bottom:11px;}
.tfx-seg-bhead{display:flex;align-items:center;gap:8px;padding:9px 11px;background:color-mix(in srgb,var(--move) 9%,#fff);border-bottom:1px solid #CFE1F3;}
.tfx-seg-chip{font-size:10px;font-weight:900;color:#fff;background:var(--move);border-radius:6px;padding:3px 7px;flex:0 0 auto;}
.tfx-seg-type{flex:0 0 auto;border:1px solid #CFE1F3;border-radius:8px;background:#fff;font-size:14px;color:var(--move);width:36px;height:30px;cursor:pointer;outline:none;text-align:center;}
.tfx-seg-title{flex:1;min-width:0;border:1px solid #CFE1F3;border-radius:9px;padding:7px 9px;font-size:12.5px;font-weight:800;color:var(--move-deep);background:#fff;outline:none;font-family:inherit;}
.tfx-seg-title:focus{border-color:var(--move);}
.tfx-seg-del{flex:0 0 auto;width:28px;height:28px;border:none;background:transparent;color:#9DBBD8;font-size:13px;cursor:pointer;}
.tfx-seg-costrow{display:flex;align-items:center;gap:7px;padding:8px 11px 3px;}
.tfx-seg-costrow .cl{font-size:10.5px;font-weight:800;color:var(--move-deep);}
.tfx-seg-cost{width:120px;border:1px solid #CFE1F3;border-radius:8px;padding:6px 9px;font-size:12px;font-weight:800;color:var(--move-deep);background:#fff;outline:none;font-variant-numeric:tabular-nums;font-family:inherit;}

/* 段內各站 */
.tfx-stops{padding:5px 11px 9px;}
.tfx-stoprow{position:relative;padding-left:22px;}
.tfx-stoprow::before{content:"";position:absolute;left:5px;top:13px;width:11px;height:11px;border-radius:50%;border:2.5px solid var(--move);background:#fff;z-index:2;}
.tfx-stoprow::after{content:"";position:absolute;left:9.5px;top:24px;bottom:-6px;width:2px;background:#BCD5EE;z-index:1;}
.tfx-stoprow:last-of-type::after{display:none;}
.tfx-stop-main{display:flex;gap:7px;align-items:center;padding-top:6px;}
.tfx-stop-time{flex:0 0 72px;border:1.5px solid var(--line);border-radius:9px;padding:7px 6px;font-size:12.5px;font-weight:800;color:var(--move-deep);outline:none;text-align:center;font-variant-numeric:tabular-nums;background:#fff;font-family:inherit;}
.tfx-stop-name{flex:1;min-width:0;border:1.5px solid var(--line);border-radius:9px;padding:7px 9px;font-size:13px;font-weight:800;color:var(--ink);outline:none;background:#fff;font-family:inherit;}
.tfx-stop-time:focus,.tfx-stop-name:focus{border-color:var(--move);}
.tfx-stop-del{flex:0 0 auto;width:24px;height:24px;border:none;background:transparent;color:#CBD5E1;font-size:12px;cursor:pointer;}
.tfx-note-toggle{display:inline-flex;align-items:center;gap:4px;margin:5px 0 2px;font-size:10.5px;font-weight:800;color:var(--move);cursor:pointer;background:none;border:none;padding:2px 0;}
.tfx-note-toggle i{font-size:8px;transition:transform .2s;}
.tfx-note-toggle.open i{transform:rotate(90deg);}
.tfx-note-box{display:none;margin-bottom:6px;}
.tfx-note-box.open{display:block;}
.tfx-note-area{width:100%;border:1.5px solid var(--line);border-radius:9px;padding:8px 10px;font-size:12px;font-weight:500;line-height:1.6;color:var(--ink);outline:none;background:var(--sunk);resize:vertical;font-family:inherit;}
.tfx-note-area:focus{border-color:var(--move);background:#fff;}

.tfx-seg-addstop{width:100%;margin-top:4px;padding:7px;border:1.5px dashed #BCD5EE;border-radius:10px;background:transparent;font-size:11px;font-weight:800;color:var(--move);cursor:pointer;}
.tfx-add-seg{width:100%;padding:11px;border:1.5px dashed #BCD5EE;border-radius:13px;background:var(--move-wash);font-size:12.5px;font-weight:900;color:var(--move-deep);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:7px;margin-top:2px;}

/* 注意事項 */
.tfx-arow{display:flex;gap:7px;align-items:flex-start;margin-bottom:7px;}
.tfx-arow .tfx-ai{flex:0 0 auto;color:var(--warn);font-size:13px;padding-top:9px;}
.tfx-alert-area{flex:1;border:1.5px solid var(--warn-line);border-radius:9px;padding:7px 9px;font-size:12px;font-weight:600;line-height:1.5;color:#5b3d12;background:var(--warn-wash);outline:none;resize:vertical;font-family:inherit;}
.tfx-add-alert{padding:6px 11px;border:1.5px dashed var(--warn-line);border-radius:9px;background:transparent;font-size:10.5px;font-weight:800;color:var(--warn);cursor:pointer;}

/* 原始燃料：兩顆鈕 + 即時鏡像 */
.tfx-fuel-wrap{border:1.5px solid var(--line);border-radius:14px;overflow:hidden;}
.tfx-fuel-bar{display:flex;gap:8px;padding:9px 11px;background:var(--sunk);border-bottom:1px solid var(--line);}
.tfx-fuel-btn{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:9px;border-radius:10px;border:none;font-size:12px;font-weight:800;cursor:pointer;}
.tfx-fuel-btn.copy{background:#1E293B;color:#fff;}
.tfx-fuel-btn.paste{background:#fff;border:1.5px solid var(--line);color:var(--ink);}
.tfx-fuel-json{width:100%;border:none;padding:11px;font-size:10.5px;line-height:1.55;color:var(--ink-soft);background:#fff;outline:none;resize:vertical;font-family:"SF Mono",Menlo,Consolas,monospace;min-height:110px;}
.tfx-killed{margin-top:9px;font-size:10.5px;font-weight:700;color:var(--ink-faint);text-align:center;line-height:1.6;}
