/* ============================================================
   專案進度追蹤 — 樣式
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #cdd3da;
  --text: #14181d;
  --text-2: #5b6673;
  --text-3: #8b95a1;

  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eef0fe;

  --todo: #94a3b8;
  --doing: #2f6fed;
  --blocked: #e0812b;
  --done: #12a06a;
  --danger: #d64545;

  --todo-soft: #eef1f5;
  --doing-soft: #e7f0ff;
  --blocked-soft: #fdf1e2;
  --done-soft: #e3f6ee;
  --danger-soft: #fdeceb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-2: 0 8px 28px rgba(16, 24, 40, 0.12);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

/* 深色模式的顏色由主題檔（theme-flowmind.css / theme-pastel.css）的
   [data-theme-mode="dark"] 決定，這裡不再跟著系統深色模式自動切換，
   以免使用者的系統設定跟主題選擇打架，明明選了亮色主題卻看到暗色畫面。 */

/* 沒宣告 color-scheme 的話，瀏覽器原生控制項（捲軸、checkbox…）會照使用者作業系統的
   深色/淺色設定去畫，跟我們畫面本身選的主題完全脫勾——常見症狀就是明明是亮色主題，
   捲軸卻跑出一條突兀的黑色。這裡跟著站內的主題切換走，不是跟著系統設定走 */
:root { color-scheme: light; }
:root[data-theme-mode="dark"] { color-scheme: dark; }

/* 自訂捲軸樣式（Firefox 用 scrollbar-width/-color，Chrome/Safari/Edge 用 ::-webkit-scrollbar）：
   細長、貼合主題色，取代前面那個突兀的原生黑色捲軸。目前只有問題清單這個側欄列表夠長
   會出現捲軸，先只套用在這裡 */
.issue-list-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.issue-list-scroll::-webkit-scrollbar { width: 8px; }
.issue-list-scroll::-webkit-scrollbar-track { background: transparent; }
.issue-list-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.issue-list-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

* { box-sizing: border-box; }

/* 背景漸層只能設在 html 或 body 其中一個，兩個都設的話等於各自獨立畫一份漸層——
   html 的框只到一個螢幕高度，body 卻是整頁內容的高度，兩份漸層對不齊，頁面拉長時
   就會在第一個螢幕高度的地方看到一條硬接縫、顏色突然跳掉。只留 body 一份就不會有這問題。 */
html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body {
  background: var(--bg);
  min-height: 100vh;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }

.app-loading {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--text-3);
}

/* ---------------- 通用元件 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand-dark);
  color: var(--brand-ink);
  box-shadow: 0 2px 0 var(--brand-dark);
}
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 0 0 var(--brand-dark); }

/* 已結案按鈕：輕輕浮動像氣泡，暗示「這是可以按的東西」，但幅度要小不要晃很兇；
   滑鼠移上去就停在懸浮的頂點，按下去照樣走原本 .btn-primary:active 的按壓效果 */
@keyframes issue-close-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
[data-act="close-issue"] {
  animation: issue-close-float 2.4s ease-in-out infinite;
}
[data-act="close-issue"]:hover { animation-play-state: paused; transform: translateY(-3px); }
[data-act="close-issue"]:active { animation-play-state: paused; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  color: var(--danger); border-color: var(--danger); background: var(--danger-soft);
  box-shadow: 0 2px 0 var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; box-shadow: 0 2px 0 var(--danger-dark); }
.btn-danger:active { transform: translateY(2px); box-shadow: 0 0 0 var(--danger-dark); }
.btn-danger svg { flex: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.input, .textarea, .select {
  width: 100%;
  max-width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.textarea { resize: vertical; min-height: 76px; }

/* 原生 <select> 樣式跟平台其他元件（字卡風格）落差很大，各瀏覽器長得也不一樣，
   自己畫箭頭統一樣式；另外原生 select 預設會撐到最長 option 的寬度，塞進 flex/grid
   排版時常常跑版，這裡強制它乖乖聽父層排版（min-width:0 讓 flex 容許縮小） */
.select, .mini-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 0;
  cursor: pointer;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238791b0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.mini-select { padding-right: 22px; background-position: right 7px center; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }

/* 自己畫的下拉清單（取代 <datalist>——那是瀏覽器原生彈出選單，完全沒辦法套樣式，
   各瀏覽器長得也不一樣，還會整個蓋出 modal 外面跑版） */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5;
  max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 var(--border-strong);
  padding: 4px;
}
.combo-option {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left;
  padding: 8px 10px; border: none; border-radius: 6px;
  background: transparent; cursor: pointer; font-size: 13px;
}
.combo-option:hover { background: var(--surface-2); }
.combo-option-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 自己畫的月曆（取代 <input type=date>——各瀏覽器彈出的月曆長得不一樣，樣式也套不進去） */
.date-field { position: relative; }
.date-display {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238791b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 9h18M8 3v4M16 3v4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
}
.cal-panel-wrap { position: absolute; left: 0; top: calc(100% + 4px); z-index: 6; }
.cal-panel {
  width: 240px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 var(--border-strong);
  padding: 10px;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-nav {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-nav:hover { background: var(--surface-2); border-color: var(--brand); }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-weekdays span { text-align: center; font-size: 10.5px; color: var(--text-3); padding-bottom: 4px; }
.cal-grid { gap: 2px; }
.cal-day {
  border: none; background: transparent; border-radius: 6px;
  height: 26px; font-size: 12px; cursor: pointer; color: var(--text);
}
.cal-day:hover { background: var(--surface-2); }
.cal-day.today { font-weight: 700; color: var(--brand); }
.cal-day.sel { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.cal-foot { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; }
.field > label { font-size: 12px; font-weight: 400; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* ---------------- 版面 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 68px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-mark {
  height: 58px;
  width: auto;
  display: block;
}
.theme-switcher { display: flex; align-items: center; gap: 6px; margin-right: 4px; }
.theme-dot {
  width: 18px; height: 18px; border-radius: 999px; flex: none;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
  cursor: pointer; padding: 0;
}
.theme-dot.on { box-shadow: 0 0 0 2px var(--brand-dark); }
.who {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2);
  border: none; background: transparent; padding: 4px 6px; border-radius: var(--radius-sm); cursor: pointer;
}
.who:hover { background: var(--surface-2); }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }

/* ---------------- 未讀紅點（小鈴鐺、問題清單共用） ---------------- */

.unread-dot {
  display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: transparent; vertical-align: middle;
}
.unread-dot.on { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.notif-item .unread-dot { margin-top: 5px; }

/* 小圖示卡：方塊字卡的感覺（圓角方形、細框、底部一條實色陰影，像被輕輕壓下去的卡片） */
.icon-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: 22px; height: 20px; padding: 0 5px;
  border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2);
  font-size: 10.5px; font-weight: 700; line-height: 1;
  box-shadow: 0 2px 0 var(--border-strong);
}
.icon-chip-btn {
  cursor: pointer;
  background: var(--danger-soft); border-color: var(--danger); color: var(--danger);
  box-shadow: 0 2px 0 var(--danger);
}
.icon-chip-btn:hover {
  background: var(--danger); color: #fff;
  box-shadow: 0 2px 0 var(--danger-dark);
}
.icon-chip-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--danger-dark);
}

/* ---------------- 小鈴鐺通知 ---------------- */

.notif-wrap { position: relative; }
.notif-bell {
  position: relative; width: 32px; height: 32px;
  padding: 0; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: 0 2px 0 var(--border-strong);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, color .12s, border-color .12s;
}
.notif-bell:hover { color: var(--brand); border-color: var(--brand); box-shadow: 0 2px 0 var(--brand); }
.notif-bell:active { transform: translateY(2px); box-shadow: 0 0 0 var(--border-strong); }
.notif-bell svg { flex: none; }
.notif-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 3px;
  border: 2px solid var(--surface);
}
.notif-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 45;
  width: 340px; max-height: 420px; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-2);
  animation: fade .12s ease;
}
.notif-panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.notif-panel-head h3 { margin: 0; font-size: 14px; }
.notif-list { display: flex; flex-direction: column; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item-body { min-width: 0; flex: 1; }
.notif-item-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.notif-title { font-size: 12.5px; font-weight: 600; }
.notif-body { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.notif-time { flex: none; font-size: 11px; color: var(--text-3); }

/* ---------------- 問題清單 ---------------- */

/* 問題清單像對話清單（LINE 那種）：一則一張字卡，點進去才看得到完整內容跟回覆。
 *  名字跟狀態同一列（右上角），名字太長用「…」截斷讓出空間給狀態，不會搶位置也不會跑版；
 *  待處理用品牌色卡強調（一眼就看到還沒處理），已結案整張卡反灰淡出（不用特別注意）；
 *  回覆數／刪除這兩個小圖示跟預覽文字同一行、靠右，內容太長就用「…」截斷 */
.issue-row {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 30px 12px 12px;
  margin-bottom: 12px;
  border-radius: 16px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  box-shadow: 0 3px 0 var(--border-strong);
  cursor: pointer;
  transition: transform .1s cubic-bezier(.34,1.56,.64,1), box-shadow .1s ease, opacity .15s ease, filter .15s ease;
}
.issue-row:last-child { margin-bottom: 0; }
.issue-row:hover { transform: translateY(-2px); }
.issue-row:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--border-strong); }

.issue-row.is-open {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 3px 0 var(--brand);
}
.issue-row.is-open:active { box-shadow: 0 1px 0 var(--brand); }
.issue-row.is-closed {
  opacity: .6;
  filter: grayscale(.5);
  box-shadow: 0 3px 0 var(--border);
}
.issue-row.is-closed:hover { opacity: .85; transform: translateY(-2px); }

.issue-row-body { min-width: 0; flex: 1; }
.issue-row-head { display: flex; align-items: center; gap: 8px; }
.issue-row-name {
  min-width: 0; flex: 1;
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.issue-row-head .pill { flex: none; font-size: 10px; padding: 1px 7px; }
.issue-row-time { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.issue-row-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.issue-row-preview {
  min-width: 0; flex: 1;
  font-size: 12.5px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.issue-row-icons { flex: none; display: flex; gap: 4px; }
.unread-dot.corner { position: absolute; top: 12px; right: 12px; }

.project-layout { display: flex; align-items: flex-start; gap: 20px; }
.project-main { flex: 1; min-width: 0; }

.issue-panel {
  flex: none; width: 320px;
  position: sticky; top: 76px;
  max-height: calc(100vh - 96px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.issue-panel-head { margin-bottom: 12px; }
.issue-panel-head h3 { margin: 0; font-size: 14px; }

/* 問題清單／卡片留言兩個頁籤，跟卡片視圖上方的 view chip 是同一套切換邏輯，
   樣式改成分段式（底線切換），因為這裡佔的橫向空間比較窄，chip 並排會太擠 */
.issue-panel-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.issue-panel-tab {
  flex: 1; padding: 8px 4px; border: none; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.issue-panel-tab:hover { color: var(--text-2); }
.issue-panel-tab.on { color: var(--brand); border-bottom-color: var(--brand); }
/* 沒有未讀時保留版位但不佔視覺重量，不然有未讀/沒未讀時分頁籤文字位置會跳動 */
.issue-panel-tab .unread-dot:not(.on) { visibility: hidden; }
.issue-quick-add { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.issue-quick-add .input { flex: 1; }
.issue-quick-add > button { align-self: flex-end; }

/* 問題清單的搜尋＋排序：跟卡片區的 .toolbar 是同一組欄位（.input.search / .select.sort），
   側欄比較窄，排成上下兩排比左右塞在一起可讀 */
.issue-list-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.issue-list-toolbar .search { flex: 1; min-width: 0; }
.issue-list-toolbar .sort { flex: none; width: 128px; }
.issue-sort-toggle { flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.issue-bug-btn {
  width: 100%; margin-bottom: 12px;
  background: var(--danger-soft); border-color: transparent;
  font-weight: 700; font-size: 13px; padding: 9px 14px;
}
.issue-bug-btn:hover { background: var(--danger-soft); border-color: var(--danger); }
.issue-list-scroll { overflow-y: auto; flex: 1; min-height: 0; }

/* 內容裡可能有圖片（貼截圖／上傳）——縮圖顯示，不要一放大就佔滿整個對話串，
   點一下用燈箱（.img-lightbox）看原始大小 */
.rte-content img {
  max-width: 160px; max-height: 160px; width: auto; height: auto;
  border-radius: 6px; margin: 4px 0; display: block;
  border: 1px solid var(--border-strong); cursor: zoom-in;
  transition: transform .12s ease;
}
.rte-content img:hover { transform: scale(1.03); }

/* 圖片燈箱：點縮圖之後蓋一層全螢幕深色背景秀原圖，再點一下（或按 Esc）關掉 */
.img-lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 18, 30, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 32px; cursor: zoom-out;
  animation: fade .12s ease;
}
.img-lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 0 rgba(0, 0, 0, .35);
}

/* ---------------- 簡易文字編輯器（回報 Bug 的說明欄） ---------------- */

.rte { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.rte-toolbar {
  display: flex; align-items: center; gap: 4px; padding: 6px 8px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.rte-btn {
  border: none; background: transparent; border-radius: 6px;
  padding: 5px 8px; font-size: 12px; cursor: pointer; color: var(--text-2);
}
.rte-btn:hover { background: var(--surface-3, var(--border)); color: var(--text); }
.rte-body {
  min-height: 110px; max-height: 260px; overflow-y: auto;
  padding: 10px 12px; font-size: 13px; line-height: 1.6; outline: none;
}
.rte-body:empty::before { content: attr(data-placeholder); color: var(--text-3); }
/* 送出中暫時鎖住編輯器，避免重複送出或送出途中還能改內容 */
.rte-body[contenteditable="false"] { opacity: .55; cursor: not-allowed; }

/* 問題清單最上面的「快速新增」：預設看起來像一般的單行輸入框，點下去（focus）
   才展開出完整的格式工具列跟多行編輯區，不然平常會佔太多版面 */
.rte-collapsible .rte-toolbar { display: none; }
.rte-collapsible .rte-body {
  min-height: 20px; max-height: 46px; transition: min-height .12s ease;
  white-space: nowrap; overflow: hidden;
}
/* 收起來的狀態下，佔位文字不管多長都不能換行——不然文字撐到兩行，看起來像跑版 */
.rte-collapsible .rte-body:empty::before {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* :focus-within 只在「還focus著」的時候展開；.rte-expanded 是 JS 加的，只要有內容
   就維持展開，即使點到旁邊失焦也不會縮回去（不然使用者會覺得剛打的字不見了） */
.rte-collapsible:focus-within .rte-toolbar, .rte-collapsible.rte-expanded .rte-toolbar { display: flex; }
.rte-collapsible:focus-within .rte-body, .rte-collapsible.rte-expanded .rte-body {
  min-height: 90px; max-height: 220px; white-space: normal;
}
.rte-body img { max-width: 100%; border-radius: 6px; margin: 6px 0; display: block; }
.rte-body ul { margin: 4px 0; padding-left: 20px; }

/* @標記自動完成：打「@」時跳出的成員清單，樣式比照小鈴噹通知面板。
   用 position:fixed 直接掛在 <body> 下、座標用 JS 算，不用 absolute 掛在輸入框裡面——
   輸入框（.rte）本身設了 overflow:hidden 讓圓角乾淨，掛在裡面的清單會被裁掉看不到。
   往上或往下開由 JS 依當下視窗剩餘空間決定（避免在抽屜最下面的留言框被切掉看不到）。 */
.mention-menu {
  position: fixed; z-index: 90;
  max-height: 220px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
  animation: fade .12s ease;
}
.mention-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; cursor: pointer; font-size: 13px;
}
.mention-menu-item .avatar { width: 22px; height: 22px; font-size: 10px; flex: none; }
.mention-menu-item span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-menu-role { flex: none; font-size: 11px; color: var(--text-3); }
.mention-menu-item.active, .mention-menu-item:hover { background: var(--surface-2); }

/* 留言/說明裡的「@姓名」標記——照全站「陰影台階」語言做成一顆實心小標籤（微型元件，
   全圓角），不是單純加粗改色，跟旁邊一般文字要有明顯的「這是一個標籤」的實體感 */
.mention-tag {
  display: inline-flex; align-items: center;
  color: var(--brand-ink);
  background: var(--brand);
  border: 1.5px solid var(--brand-dark);
  box-shadow: 0 2px 0 var(--brand-dark);
  font-weight: 700;
  padding: 0 7px;
  /* 上下留白抵掉邊框＋硬邊陰影的實際高度——不然斷行後連續兩顆標籤會疊在一起，
     邊框/陰影互相蓋住看不清楚（inline-flex 的 margin 會被算進行高，可以撐開行距） */
  margin: 3px 1px;
  border-radius: 999px;
  font-size: 0.92em;
  line-height: 1.6;
}

/* 留言/說明裡的「#任務單」引用標籤——跟 .mention-tag 同一套陰影台階語言，
   但换一個語意色（--done，全部主題都跟 --brand 拉得開），一眼就能分辨「這是引用任務單」
   還是「這是標記某個人」。可以點擊導去那張任務單，所以額外給 cursor:pointer + hover 回饋 */
.task-ref-tag {
  display: inline-flex; align-items: center;
  color: var(--brand-ink);
  background: var(--done);
  border: 1.5px solid var(--done-dark);
  box-shadow: 0 2px 0 var(--done-dark);
  font-weight: 700;
  padding: 0 7px;
  margin: 3px 1px;
  border-radius: 999px;
  font-size: 0.92em;
  line-height: 1.6;
  max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  cursor: pointer;
  transition: transform .12s ease;
}
.task-ref-tag:hover { transform: translateY(-1px); }
/* 引用的任務單被刪掉、或不在目前這個專案裡（點了打不開）——用灰階示意「連結失效」，
   還是看得到當初引用的標題文字，只是不再是可點的活動連結 */
.task-ref-tag.is-broken {
  background: var(--surface-3); color: var(--text-3);
  border-color: var(--border-strong); box-shadow: 0 2px 0 var(--border-strong);
  cursor: default;
}
.task-ref-tag.is-broken:hover { transform: none; }

@media (max-width: 900px) {
  .project-layout { flex-direction: column; }
  .issue-panel { width: 100%; position: static; max-height: none; }
}

.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { margin: 3px 0 0; color: var(--text-2); font-size: 12px; }

/* ---------------- 登入 / 初始化 ---------------- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 28px;
  box-shadow: var(--shadow-2);
}
.auth-card h1 { margin: 0 0 4px; font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.auth-card .page-sub { margin-bottom: 22px; }
.auth-logo { width: 40px; height: 40px; border-radius: 11px; background: var(--brand); display: grid; place-items: center; color: #fff; font-weight: 800; margin-bottom: 16px; }

/* ---------------- 統計磚 ---------------- */

/* 固定寬度（不用 1fr 撐滿）的話，格子一多，多出來的空間會整塊堆在整排最後面，
   看起來像沒排滿、跑版；改成剛好 4 欄等寬撐滿整排，並在每格加一個色塊圖示墊位子，
   格子變寬也不會只剩文字孤零零擠在左上角 */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-width: 0;
}
.stat-icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-3);
}
.stat.accent .stat-icon { background: color-mix(in srgb, var(--blocked) 16%, transparent); color: var(--blocked); }
.stat.danger .stat-icon { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 500; white-space: nowrap; }
.stat-value { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin-top: 1px; font-variant-numeric: tabular-nums; }
.stat.accent .stat-value { color: var(--blocked); }
.stat.danger .stat-value { color: var(--danger); }

/* ---------------- 專案卡 ---------------- */

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.project-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.project-card h3 { margin: 0 0 3px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.project-card .client { font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.project-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--text-2); }

/* ---------------- 進度條 ---------------- */

.bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--todo-soft);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--doing);
  transition: width .25s ease;
}
.bar.s-todo > i { background: var(--todo); }
.bar.s-doing > i { background: var(--doing); }
.bar.s-blocked > i { background: var(--blocked); }
.bar.s-done > i { background: var(--done); }
.bar-lg { height: 10px; }

/* 不知道確切進度時（例如呼叫外部 API），用滑動色塊表示「正在動作」 */
.bar-indeterminate { background: var(--brand-soft); }
.bar-indeterminate > i {
  position: absolute;
  width: 40%;
  background: var(--brand);
  animation: bar-indeterminate 1.1s ease-in-out infinite;
}
@keyframes bar-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.bar-line { display: flex; align-items: center; gap: 10px; }
.bar-line .bar { flex: 1; }
.bar-pct { font-size: 12px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }

/* 可拖曳的進度條（我方成員） */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: ew-resize;
  margin: 0;
  display: block;
}
.range::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right, var(--fill) 0 var(--pct), var(--todo-soft) var(--pct) 100%);
}
.range::-moz-range-track { height: 8px; border-radius: 999px; background: var(--todo-soft); }
.range::-moz-range-progress { height: 8px; border-radius: 999px; background: var(--fill); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--fill);
  margin-top: -4px;
  box-shadow: var(--shadow-1);
}
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--fill);
  box-shadow: var(--shadow-1);
}

/* ---------------- 標籤 ---------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.todo { background: var(--todo-soft); color: var(--text-2); }
.pill.doing { background: var(--doing-soft); color: var(--doing); }
.pill.blocked { background: var(--blocked-soft); color: var(--blocked); }
.pill.done { background: var(--done-soft); color: var(--done); }
.pill.await { background: var(--blocked-soft); color: var(--blocked); }
.pill.overdue { background: var(--danger-soft); color: var(--danger); }
.pill.role-admin { background: var(--brand-soft); color: var(--brand); }
.pill.pending-review { background: var(--blocked-soft); color: var(--blocked); }
.pill.rejected { background: var(--danger-soft); color: var(--danger); }
.pill.replied { background: var(--done-soft); color: var(--done); }
.pill.closed { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.pill.role-client { background: var(--done-soft); color: var(--done); }
/* Bug 標籤本來沒有專屬顏色，會落到跟「已逾期」/「高優先」共用的紅色（.pill.overdue），
   卡片上兩顆紅色標籤擠在一起很難一眼分辨是「逾期/高優先」還是「這是一張 Bug」。
   改用品牌色試過一次，但「棉花糖」主題的品牌色剛好也是粉紅，跟那個主題的危險色一樣
   撞色——四個主題的語意色（brand/danger/doing/blocked/done）沒有一個顏色能保證在
   全部主題都跟危險色拉得開，乾脆比照 .pill.closed 用中性灰階（不分主題都不是任何
   語意色的色相），保證在四個主題底下都不會跟任何一顆彩色標籤混在一起 */
.pill.bug { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border-strong); }
/* 高優先跟逾期本來共用同一個 .pill.overdue class，顏色完全相同分不出來——
   拆成獨立的 priority-* class，並靠圖示（旗子 vs 警示三角）＋外框做形狀區隔，
   而不是硬找一個「夠重要又不撞色」的第五種語意色（四個主題的色盤已經很滿了） */
.pill.priority-high { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.pill.priority-medium { background: var(--blocked-soft); color: var(--blocked); border: 1px solid var(--blocked); }
.pill.priority-low { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------- 篩選列 ---------------- */

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.chip .n { opacity: .7; margin-left: 3px; font-variant-numeric: tabular-nums; }
.search { max-width: 220px; }
.sort { max-width: 160px; }
.sort-dir { max-width: 120px; }
.toolbar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }

/* 甘特圖顆粒縮放：+/- 各一顆，中間顯示目前顆粒，取代原本四顆各佔一格的按鈕 */
.gantt-zoom { display: flex; align-items: center; gap: 8px; }
.gantt-zoom-btn {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); cursor: pointer; font-size: 15px; line-height: 1; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-2);
}
.gantt-zoom-btn:hover { background: var(--surface-2); border-color: var(--brand); color: var(--text); }
.gantt-zoom-btn:disabled { opacity: .35; cursor: not-allowed; }
.gantt-zoom-label { font-size: 13px; color: var(--text-2); min-width: 28px; text-align: center; font-weight: 600; }

/* ---------------- 階段與任務 ---------------- */

.phase { margin-bottom: 20px; }
.phase-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.phase-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.phase-head .bar { width: 120px; }
.phase-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.task-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; align-items: start; }
.task {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--todo);
  border-radius: var(--radius);
  padding: 14px 15px;
  cursor: pointer;
  transition: border-color .12s, background-color .12s, box-shadow .12s, transform .12s;
}
.task:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.task.s-doing { border-left-color: var(--doing); background: color-mix(in srgb, var(--doing-soft) 40%, var(--surface)); }
.task.s-blocked { border-left-color: var(--blocked); background: color-mix(in srgb, var(--blocked-soft) 40%, var(--surface)); }
.task.s-done { border-left-color: var(--done); background: color-mix(in srgb, var(--done-soft) 30%, var(--surface)); }
.task.is-await { background: color-mix(in srgb, var(--blocked-soft) 55%, var(--surface)); }
.pending-bug-card { border-style: dashed; }
.rejected-history { margin-bottom: 20px; }
.rejected-history summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-3);
  padding: 6px 0; list-style: none;
}
.rejected-history summary::-webkit-details-marker { display: none; }
.rejected-history summary::before { content: '▸ '; }
.rejected-history[open] summary::before { content: '▾ '; }
.rejected-history .task-list { margin-top: 10px; opacity: .75; }
.task.task-sub { padding-top: 11px; padding-bottom: 11px; }
.task-sub-arrow { color: var(--text-3); font-weight: 400; }

.task-top { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.task-title { font-weight: 700; font-size: 14.5px; letter-spacing: -0.005em; line-height: 1.35; }
.task.s-done .task-title { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.task-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.task-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: auto; padding-top: 10px; font-size: 12px; color: var(--text-2);
}
.task-meta .m { display: inline-flex; align-items: center; gap: 5px; }
.task-meta .m.late { color: var(--danger); font-weight: 600; }
.task-meta .quick { gap: 6px; }

.mini-select {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background-color: var(--surface-2);
  padding: 2px 20px 2px 6px;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mini-select:hover { border-color: var(--brand); }
.icon { width: 13px; height: 13px; flex: none; opacity: .75; }

.empty {
  text-align: center; padding: 32px 20px; color: var(--text-3);
  font-size: 13px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
}

/* ---------------- 甘特圖 ---------------- */
/* 字卡感：外框 + 實色偏移陰影，跟 .panel/.icon-chip 同一套語言，不是純線框表格 */

/* 2026-08 修正：只設 overflow-x 的話，CSS 有個規則會把沒設的 overflow-y 自動
   一起變成 auto（兩個只要有一個不是 visible，另一個就不能維持 visible）——這個框
   會在使用者沒發現的情況下，自己變成一個「垂直也會捲」的容器。下面 .gantt-header-row
   的 sticky top 原本是設計成跟著整個網頁捲動固定，一旦這裡意外多了一層垂直捲動，
   sticky 就會改成跟著「這個框自己」固定，位置全部跑掉，滑下去的時候舊的列會跟新的
   內容疊在一起、卡住不消失。與其硬凹讓 overflow-y 維持 visible（規格上不允許），
   乾脆讓它就是一個獨立、有明確高度上限的捲動框（跟旁邊 .issue-panel 同一套做法），
   sticky 頭固定在「這個框」的最上面，行為才會穩定、看得懂。 */
.gantt-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 3px 0 var(--border-strong);
}
.gantt-inner { position: relative; min-width: 100%; }

/* align-items 一定要 stretch，不能用 center——不然像表頭那種內容是空的 .gantt-label，
   高度只會跟著文字內容縮到只剩十幾 px，遠比整列矮，蓋不滿整列，讓「今天」紅線的日期
   標籤從底下露出一截變成奇怪的形狀（sticky 欄位本來要整列都不透光蓋住底下滑過去的內容）*/
.gantt-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.gantt-row:last-child { border-bottom: none; }
.gantt-row:hover .gantt-label { background: var(--surface-2); }

.gantt-label {
  position: sticky; left: 0; z-index: 4;
  width: 180px; flex: none;
  display: flex; align-items: center;
  padding: 6px 10px;
  background: var(--surface);
  border-right: 1px solid var(--border-strong);
  font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}

.gantt-phase-row { background: var(--surface-2); font-weight: 700; font-size: 12px; color: var(--brand-dark); cursor: default; }
.gantt-phase-row .gantt-label { background: var(--surface-2); font-weight: 700; border-right-color: var(--border-strong); }
.gantt-phase-row:hover .gantt-label { background: var(--surface-2); }

.gantt-track { position: relative; height: 36px; flex: none; }
.gantt-header-row .gantt-track { height: 28px; }
.gantt-header-row .gantt-label { background: var(--surface); }

/* 日期刻度往下滑要固定在最上面，不然拉長的甘特圖往下滑幾排就對不到日期是哪一天了。
   .gantt-scroll 現在是有明確高度上限、自己會捲動的框，這裡固定的是「框的最上面」
   （top:0），不是整個網頁——跟 .gantt-scroll 那邊的說明是同一件事。
   背景要蓋在整排（不能只設在 .gantt-label），不然 .gantt-track 那半邊是透明的，
   下面滑過去的任務條會直接透出來，蓋不住 */
.gantt-header-row { position: sticky; top: 0; z-index: 6; background: var(--surface); }

.gantt-month {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px dashed var(--border-strong);
  padding-left: 4px;
  font-size: 11px; font-weight: 600; color: var(--text-3); white-space: nowrap;
}

.gantt-bar {
  position: absolute; top: 6px; height: 22px; min-width: 8px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 2px 0 var(--border-strong);
  cursor: pointer;
  display: flex; align-items: center;
  overflow: visible;
  transition: transform .08s ease;
}
.gantt-bar:hover { transform: translateY(-1px); }
.gantt-bar.s-todo { background: var(--todo-soft); border-color: var(--todo-dark); box-shadow: 0 2px 0 var(--todo-dark); }
.gantt-bar.s-doing { background: var(--doing-soft); border-color: var(--doing-dark); box-shadow: 0 2px 0 var(--doing-dark); }
.gantt-bar.s-blocked { background: var(--blocked-soft); border-color: var(--blocked-dark); box-shadow: 0 2px 0 var(--blocked-dark); }
.gantt-bar.s-done { background: var(--done-soft); border-color: var(--done-dark); box-shadow: 0 2px 0 var(--done-dark); }

.gantt-bar > i {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 6px 0 0 6px;
  opacity: .55;
}
.gantt-bar.s-todo > i { background: var(--todo); }
.gantt-bar.s-doing > i { background: var(--doing); }
.gantt-bar.s-blocked > i { background: var(--blocked); }
.gantt-bar.s-done > i { background: var(--done); }

.gantt-bar-date {
  position: relative; z-index: 1;
  font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gantt-bar-date.in { width: 100%; text-align: center; color: var(--text); }
.gantt-bar-date.out {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: var(--text-2);
}

.gantt-today-line {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--danger); z-index: 3; pointer-events: none;
}
.gantt-today-line span {
  position: absolute; top: 2px; left: 4px;
  font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap;
  background: var(--danger); padding: 1px 6px; border-radius: 999px;
}

/* ---------------- 抽屜 ---------------- */

.scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .42); z-index: 40; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--bg);
  z-index: 50;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-2);
  animation: slide .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes slide { from { transform: translateX(24px); opacity: .4 } to { transform: none; opacity: 1 } }

.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.drawer-head h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot { border-top: 1px solid var(--border); padding: 12px 18px; background: var(--surface); }

.panel {
  /* 字卡感：實色偏移陰影（不是模糊的那種），跟小圖示卡（.icon-chip）同一套語言 */
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
  box-shadow: 0 3px 0 var(--border-strong);
}
.panel h4 { margin: 0 0 11px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }

/* AI 助理回的結案摘要目前是原樣文字（含 mermaid 語法），先保留換行，還沒接圖表渲染 */
/* .panel 只有 margin-bottom，.thread 內部間距靠 grid gap，兩個都沒有處理「跟前一個
   區塊的間距」，AI 摘要卡緊接在對話串後面就會直接貼在最後一句泡泡下面，看起來黏住 */
.ai-summary-panel { margin-top: 14px; border-color: var(--brand); }
.ai-summary-text { word-break: break-word; font-size: 13px; line-height: 1.6; }
.ai-summary-text > *:first-child { margin-top: 0; }
.ai-summary-text > *:last-child { margin-bottom: 0; }
.ai-summary-text p { margin: 6px 0; }
.ai-summary-text h5 { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--brand-dark); }
.ai-summary-text ul, .ai-summary-text ol { margin: 6px 0; padding-left: 20px; }
.ai-summary-text li > ul, .ai-summary-text li > ol { margin: 2px 0; }
.ai-summary-text li { margin: 2px 0; }
.ai-summary-text hr { border: none; border-top: 1px dashed var(--border-strong); margin: 12px 0; }
.ai-summary-text code { background: var(--surface-2); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.ai-summary-text .ai-code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0;
  font-size: 11.5px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap; word-break: break-word; overflow-x: auto;
}

/* 客戶意思整理：只有我方看得到，故意用虛線框＋跟 .panel 不同色調，一眼就能跟其他公開內容區分 */
.panel-internal {
  background: color-mix(in srgb, var(--brand) 6%, var(--surface));
  border: 1px dashed var(--brand);
  box-shadow: none;
}
.panel-internal h4 { color: var(--brand); }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

/* ---------------- 留言串 ---------------- */

/* 像聊天 app 一樣左右分邊：自己的訊息（.mine）整排靠右，大頭貼、泡泡跟著換邊 */
.thread { display: grid; gap: 12px; }
.msg { display: flex; gap: 10px; }
.msg.mine { flex-direction: row-reverse; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff;
  background: var(--brand);
  object-fit: cover;
}
.msg.client .avatar { background: var(--done); }
.msg-body { flex: 1; min-width: 0; }
.msg.mine .msg-body {
  flex: none; max-width: 78%;
  /* .msg-body 本身寬度是內容撐出來的（通常是名字那排比較寬），
     裡面的泡泡沒有明講要靠右的話會貼著左邊，跟名字那排對不齊——
     用 flex column + align-items:flex-end 讓兩個子元素都靠右 */
  display: flex; flex-direction: column; align-items: flex-end;
}
.msg-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 2px; flex-wrap: wrap; }
.msg.mine .msg-head { flex-direction: row-reverse; }
.msg-name { font-weight: 600; font-size: 13px; }
.msg-time { font-size: 11px; color: var(--text-3); }
.msg-text {
  /* inline-block 讓泡泡寬度跟著文字內容縮，不然 .msg-body 是 flex:1 撐滿一整排，
     文字很短的時候外框還是會被拉到跟整排一樣寬。陰影跟 .panel/.icon-chip 同一套
     字卡語言：實色偏移，不是模糊漸層 */
  display: inline-block; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 4px 10px 10px 10px; padding: 9px 12px;
  white-space: pre-wrap; word-break: break-word; font-size: 13px;
  box-shadow: 0 2px 0 var(--border-strong);
}
.msg.mine .msg-text {
  background: var(--brand-soft); border-color: var(--brand);
  border-radius: 10px 4px 10px 10px;
  box-shadow: 0 2px 0 var(--brand);
}
.msg-sys {
  font-size: 12px; color: var(--text-3);
  padding: 3px 0 3px 12px; border-left: 2px solid var(--border-strong);
  white-space: pre-wrap;
}

.composer { position: relative; display: grid; gap: 8px; }
.composer .row { justify-content: flex-end; }

/* ---------------- 對話框 ---------------- */

.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 14, 20, .42);
}
.modal-card {
  width: 100%; max-width: 500px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2);
  padding: 22px 24px;
}
.modal-card h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------------- Asana 同步確認畫面 ---------------- */

.asana-review-scrim {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 14, 20, .42);
}
.asana-review {
  width: 100%; max-width: 640px; max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2);
}
.asana-review-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.asana-review-head h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.asana-review-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.asana-review-body h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.asana-review-body h4:first-of-type { margin-top: 0; }
.asana-review-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); }

.asana-row {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: 0 2px 0 var(--border-strong);
  padding: 12px; margin-bottom: 10px;
  transition: opacity .15s ease, filter .15s ease;
}
.asana-row input[type="checkbox"] { margin-top: 3px; flex: none; }
.asana-row-body { flex: 1; min-width: 0; }
.asana-row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asana-row.off { opacity: .5; filter: grayscale(.4); }
.asana-row.off .asana-row-body input, .asana-row.off .asana-row-body select { pointer-events: none; }

/* ---------------- 表格 ---------------- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: none; }

/* ---------------- 同步遮罩 ---------------- */

.sync-overlay {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  background: rgba(10, 14, 20, .42);
  animation: fade .15s ease;
}
.sync-overlay[hidden] { display: none; }
.sync-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2);
  padding: 32px 40px; text-align: center;
}
/* 載入中／同步中：用公司 logo 上下跳動代替制式圓圈 spinner，品牌感更強 */
.brand-loading {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.brand-loading p, .sync-card p { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.brand-loading-mark {
  width: 44px; height: auto;
  animation: brand-bounce 1s ease-in-out infinite;
}
@keyframes brand-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.06); }
}
.spinner-sm {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  opacity: .8; vertical-align: -2px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* AI 摘要還在跑的時候先放一個佔位卡片，讓人知道「還在處理」而不是卡住 */
.ai-summary-loading { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.ai-thinking-dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.ai-thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .3;
  animation: ai-dot-pulse 1.2s ease-in-out infinite;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: .2s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-dot-pulse { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #14181d; color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 100; box-shadow: var(--shadow-2);
  animation: fade .15s ease;
}
.toast.err { background: var(--danger); }

/* ---------------- 品牌滑鼠游標（跟著滑鼠跑的跳動 logo） ---------------- */
/* 只有偵測到「有滑鼠」的裝置才會啟用（app.js 判斷），啟用時才幫 html 加這個 class，
   避免觸控裝置沒有滑鼠事件、卻把原生游標藏起來導致什麼都點不到 */
/* 用 !important＋* 蓋掉全站一堆各自宣告的 cursor:pointer，不然那些元件會把原生游標蓋回來 */
html.brand-cursor-on, html.brand-cursor-on * { cursor: none !important; }
/* 文字輸入的地方還是要看得到原生的文字游標，不然打字選字沒有視覺回饋 */
html.brand-cursor-on input, html.brand-cursor-on textarea, html.brand-cursor-on [contenteditable] {
  cursor: text !important;
}
.brand-cursor {
  position: fixed; top: 0; left: 0; width: 22px; height: 22px;
  pointer-events: none; z-index: 9999;
  transform: translate(-50%, -50%);
  will-change: transform;
}
.brand-cursor[hidden] { display: none; }
.brand-cursor img {
  width: 100%; height: 100%; display: block;
  animation: brand-cursor-bounce .6s ease-in-out infinite;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.25));
}
/* 滑到可以點的東西上面，跳動幅度變大一點，當作「這裡可以點」的回饋 */
.brand-cursor.is-pointer img { animation: brand-cursor-bounce-active .4s ease-in-out infinite; }
@keyframes brand-cursor-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.05); }
}
@keyframes brand-cursor-bounce-active {
  0%, 100% { transform: translateY(0) scale(1.1) rotate(-4deg); }
  50% { transform: translateY(-5px) scale(1.22) rotate(4deg); }
}

/* ---------------- 響應式 ---------------- */

@media (max-width: 640px) {
  .container { padding: 18px 14px 70px; }
  .topbar-inner { padding: 0 14px; }
  .field-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 84px 1fr; }
  .brand span.full { display: none; }
  .search { max-width: none; flex: 1; }
}

@media print {
  .topbar, .toolbar, .btn, .drawer, .scrim { display: none !important; }
  .task, .project-card, .stat { break-inside: avoid; }
  body { background: #fff; }
}
