/* ============================================================
 * 訓練行事曆（/calendar/training）
 * 規劃 SSOT：docs/TRAINING_CALENDAR_PLAN.md
 * VI：主綠 #00AB7B 僅 action；資料數字深綠 #004533／ink；完成態淺綠底 #EBF4EB
 * 設計：週＝一塊看板（內部 hairline 分欄），數字是主角，chrome 退位
 * ============================================================ */

.tc-root {
    --rq-primary: #00AB7B;
    --rq-dark: #004533;
    --rq-pale: #EBF4EB;
    --rq-primary-soft: rgba(0, 171, 123, .08);
    --tc-ink: #1c1e21;
    --tc-secondary: #4a4f55;
    --tc-muted: #8a9199;
    --tc-border: #e8ebee;
    --tc-hairline: #eef1f3;
    --tc-panel: #f7f9f8;          /* 摘要欄第二層中性（微偏品牌綠） */
    --tc-gold: #f1c40f;
    /* 賽事標記卡三色（issue #1898）：自 DESIGN.md 功能紅 #e74c3c 衍生的同族色階
      （hue 6–7°），非 .tc-error 的 355° 家族——「紅＝比賽日」沿舊版 fc-event-danger
       語意、與錯誤列刻意分色。token 化讓卡片與跳窗 chip 由 CSS 保證同色 */
    --tc-event-bg: #fdedeb;
    --tc-event-border: #f6c3bc;
    --tc-event-border-hover: #efa79c;
    --tc-event-ink: #c0392b;
    /* ---------- 字級量表（#1405 可讀性改版）----------
       底線 12px，改版前各階（10.9／11.5／11.8／12.2／12.5／12.8／13.4／13.6／14.4／16.3px）
       整體約 ×1.10 等比放大後收斂成 6 階，階梯先後順序與改版前一致。
       **只有 icon** 不套 12px 底線（見 .tc-check、.tc-sport-ico）：它們是圖形不是閱讀文字，
       套底線會搶走卡片標題的視覺重量。badge 類（原 BETA 徽章，2026-08-20 已隨全面公開移除）
       是被讀的字，一律套底線（DESIGN.md Typography；letterspacing 不會讓一個字變成
       不用讀的圖形）——日後若再加任何徽章，照這條走。 */
    --tc-fs-xs: 12px;             /* 微標籤：星期、指標標籤、摘要表頭、紀錄時刻、推估標記 */
    --tc-fs-sm: 13px;             /* 次要內容：紀錄名、教練的話、展開鈕、週日期範圍、運動分組列 */
    --tc-fs-md: 14px;             /* 卡片本文、日期列、摘要面板基準 */
    --tc-fs-lg: 15px;             /* 資料數字：卡片三值、摘要表數值、載入鈕 */
    --tc-fs-xl: 16px;             /* 卡片標題、提示列、月初日期錨點、FAB */
    --tc-fs-2xl: 18px;            /* 週指標數值（體能／疲勞／狀況） */
    max-width: 1480px;
    margin: 0 auto;
    color: var(--tc-ink);
    /* 手動 getBoundingClientRect 校正是唯一補償來源——關閉瀏覽器原生
       scroll anchoring，避免 prepend 時雙重補償造成畫面跳動 */
    overflow-anchor: none;
}

/* ---------- 錯誤／提示列 ---------- */
.tc-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 10px 0;
    padding: 9px 12px;
    border: 1px solid #f1c9cd;
    background: #fdf5f5;
    color: #842029;
    border-radius: 6px;
    font-size: var(--tc-fs-md);
}
/* 「重試」鈕吃佈景主題的 .btn.btn-xs（.7rem＝11.2px），低於本頁 12px 底線。
   平時隱藏，但 AJAX 失敗時是使用者唯一的復原路徑，不該是全頁最小的字。
   必須寫成三層選擇器：theme.css／theme-elements.css 的 `.btn.btn-xs` 特異性
   同為 (0,0,2,0)，且載入順序在本檔之後——平手時後者勝，兩層選擇器蓋不掉。 */
.tc-root .tc-error .btn {
    font-size: var(--tc-fs-xs);
}
/* 未解鎖說明／升級引導的共用視覺語彙（淡黃底）。兩條各自獨立、可同時出現：
   #tcHistoryHint 講「能回捲多久」（JS 捲到 8 週下界才顯示）、
   #tcMetricsHint 講「三枚週指標」（對非白金 target 常駐，2026-08-20 新增）。
   共用 selector 是為了讓兩條同框時看起來是同一組提示，不是把它們當成同一件事。 */
.tc-history-hint,
.tc-metrics-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
    padding: 12px;
    background: #fffcf3;
    border: 1px solid #f0e6c8;
    border-radius: 6px;
    color: var(--tc-secondary);
    font-size: var(--tc-fs-xl);
}
/* 說明句在窄畫面會被 badge 與連結擠成單字換行，允許它獨佔一行 */
.tc-hint-desc {
    flex: 1 1 auto;
    min-width: 0;
}
@media (max-width: 575.98px) {
    .tc-history-hint,
    .tc-metrics-hint {
        flex-wrap: wrap;
        justify-content: flex-start;
        font-size: var(--tc-fs-md);
    }
    .tc-hint-desc {
        flex: 1 1 100%;
        order: 3;
    }
}
/* 升級連結：改版前**完全沒有規則**，吃 mainV2 預設的藍字底線，在週摘要欄裡比周圍
   12–14px 的灰數字更搶眼（XJack 2026-08-20 全面公開盤點時發現）。週摘要那數十枚已
   移除，但跳窗的白金鎖定態（_trainingCardDetail.php 的 .tc-track-lock）仍在用同一個
   class，故補上規則而非連 class 一起刪。
   兩條提示列裡的裸 <a> 一併納入：#tcHistoryHint 原本同樣是預設藍字，與緊鄰的
   #tcMetricsHint 一綠一藍會像兩套系統。
   主綠是 action 色（DESIGN.md 紅線：只用於按鈕／連結／focus），升級是 action，故適用；
   提示列本身是淡黃底，主綠對它的對比足夠。 */
/* 🔴 **底線必須保留**（Codex review 2026-08-20）：本規則初版加了 text-decoration:none，
   使這些連結**只靠顏色**與周圍文字區分，而主綠 #00AB7B 對相鄰的 #4a4f55 只有 2.80:1，
   未達 WCAG「非顏色以外無其他區分方式」所需的 3:1。底線是零成本的非顏色提示。
   ⚠️ 文字本身對淡黃底 #fffcf3 為 2.89:1（實算），未達一般文字 4.5:1 —— 這是站上「主綠
   只用於 action」慣例的既有限制（CLAUDE.md 明載「主綠對白 ≈3:1，禁用於內文／資料數字」），
   全站 action 色一致如此，不在本 PR 單獨改；要動是全站 VI 議題。 */
.tc-premium-link,
.tc-history-hint a,
.tc-metrics-hint a {
    color: var(--rq-primary);
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
}
.tc-premium-link:hover,
.tc-premium-link:focus,
.tc-history-hint a:hover,
.tc-history-hint a:focus,
.tc-metrics-hint a:hover,
.tc-metrics-hint a:focus {
    color: var(--rq-primary);
    text-decoration: underline;
}

/* ---------- 空狀態引導（2026-08-20，全面公開前置）----------
   刻意**不**用淡黃提示列的語彙：那組是「未解鎖／升級引導」，而空狀態既沒有東西被鎖、
   也不該讓新會員的第一印象是一則行銷訊息。用中性面板 ＋ 一顆主綠 CTA。
   週曆骨架仍留在上方（不隱藏），本區塊補在其下方說明「為什麼是空的、怎麼開始」。 */
.tc-empty-hint {
    margin: 16px 0 24px;
    padding: 28px 20px;
    text-align: center;
    background: var(--tc-panel);
    border: 1px solid var(--tc-border);
    border-radius: 8px;
}
.tc-empty-title {
    margin: 0 0 6px;
    color: var(--tc-ink);
    font-size: var(--tc-fs-xl);
    font-weight: 600;
}
.tc-empty-desc {
    margin: 0 auto 16px;
    max-width: 34em;
    color: var(--tc-secondary);
    font-size: var(--tc-fs-md);
    line-height: 1.6;
}
.tc-empty-cta {
    display: inline-block;
    padding: 9px 20px;
    background: var(--rq-primary);
    color: #fff;
    border-radius: 6px;
    font-size: var(--tc-fs-md);
    font-weight: 600;
    text-decoration: none;
}
.tc-empty-cta:hover,
.tc-empty-cta:focus {
    background: var(--rq-dark);
    color: #fff;
    text-decoration: none;
}
/* 中性資訊提示（#1405 批次 3A.1，用於 #tcStaleBar「已解除對應，請重新整理以更新畫面」）。
   刻意**不**沿用 .tc-error：那是粉紅底＋暗紅字，而 DESIGN.md 把紅色保留給 error states；
   解除對應本身是**成功**的（伺服器已生效），只是畫面沒跟上，用錯誤色會讓使用者誤以為
   操作失敗而重複點擊。也不沿用 .tc-history-hint 的淡黃——那條的語意是「未解鎖／升級引導」。 */
.tc-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 10px 0;
    padding: 9px 12px;
    border: 1px solid var(--tc-hairline);
    background: var(--tc-panel);
    color: var(--tc-secondary);
    border-radius: 6px;
    font-size: var(--tc-fs-md);
}
/* icon-only 時 tooltip 的可點／可長按範圍需 ≥24px（docs/RQ_APP_DESIGN.md §9-1）——
   單看 14px 的盾牌 icon 只有約 16px 高，觸控裝置觸發不到 */
.tc-premium-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    color: var(--tc-secondary);
    white-space: nowrap;
    font-weight: 600;
}
.tc-premium-badge .fa-shield-alt {
    color: var(--tc-gold);
}

/* ---------- 頁首列 ----------
   目前只承載學員快速切換；「回到目前版本」已於 2026-07-28 移除（站台選單本來就能回舊頁）。
   view 端在沒有學員時整條不渲染，故這裡不需處理空列。 */
.tc-topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    justify-content: flex-start;
    margin: 0 0 6px;
}

/* ---------- 學員快速切換（#1405 P2-10）----------
   VI：這是導航控制項不是主要動作，用中性描邊＋深綠字（DESIGN.md L62「正在檢視學員 XX」
   這類狀態脈絡即用深綠）；主綠只出現在 focus ring。 */
.tc-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    max-width: 100%;
    font-weight: 400; /* 蓋掉 Bootstrap 對 label 的 700 */
    cursor: pointer;
}
.tc-switch__icon {
    color: var(--tc-muted);
    font-size: var(--tc-fs-sm);
}
.tc-switch__select {
    max-width: 220px;
    padding: 3px 8px;
    border: 1px solid var(--tc-border);
    border-radius: 6px;
    background: #fff;
    color: var(--rq-dark);
    font-size: var(--tc-fs-sm);
    line-height: 1.5;
    /* 長學員名不得撐破頁首；原生 select 無 ellipsis，靠 max-width＋原生截斷 */
    text-overflow: ellipsis;
}
.tc-switch__select:hover {
    border-color: var(--tc-muted);
}
.tc-switch__select:focus-visible {
    outline: 2px solid var(--rq-primary);
    outline-offset: 1px;
}
@media (max-width: 575.98px) {
    /* 手機：切換器撐滿整列，換得大一點的點擊區 */
    .tc-switch {
        width: 100%;
    }
    .tc-switch__select {
        flex: 1 1 auto;
        max-width: none;
        /* flex item 的 min-width 預設是 auto＝min-content，而原生 select 的 min-content
           取決於「最長的那個 option」——長學員名會讓它撐破容器（實測 375px 視窗下
           容器 345px、select 卻 376px）。桌機靠 max-width:220px 夾住，行動版沒有上限，
           必須顯式 min-width:0 才收得回來。 */
        min-width: 0;
    }
}
/* ---------- 載入 ---------- */
.tc-load-btn {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 8px;
    border: 1px dashed #d4dade;
    background: transparent;
    color: var(--tc-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--tc-fs-lg);
    transition: color .15s cubic-bezier(.22, 1, .36, 1), border-color .15s cubic-bezier(.22, 1, .36, 1);
}
.tc-load-btn:hover,
.tc-load-btn:focus-visible {
    color: var(--rq-primary);
    border-color: var(--rq-primary);
    outline: none;
}
.tc-sentinel {
    height: 2px;
}
.tc-loading {
    display: flex;
    justify-content: center;
    padding: 10px;
}
.tc-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--tc-border);
    border-top-color: var(--rq-primary);
    border-radius: 50%;
    animation: tc-spin .8s linear infinite;
}
@keyframes tc-spin {
    to { transform: rotate(360deg); }
}

/* ---------- 週看板 ---------- */
.tc-week {
    margin: 14px 0 22px;
    /* 回今天 scrollIntoView 時預留 sticky bar 高度 */
    scroll-margin-top: 118px;
}
.tc-days {
    display: grid;
    /* 摘要欄 240px：字級改版後「訓練指數」中文標籤＋兩欄 15px 數值在 224px 下只剩約 14px 餘裕 */
    grid-template-columns: repeat(7, minmax(0, 1fr)) 240px;
    background: #fff;
    border: 1px solid var(--tc-border);
    border-radius: 8px;
    overflow: hidden;
}
.tc-day {
    display: flex;
    flex-direction: column;
    min-height: 140px;
    border-right: 1px solid var(--tc-hairline);
    min-width: 0;
}
/* 解除對應成功後整格由伺服器重新渲染置換（#1405 批次 3A.1）：舊節點連同焦點一起消失，
   JS 把焦點交給新日格（tabindex="-1"，ARIA APG）。程式化 focus 在滑鼠操作之後不會觸發
   :focus-visible，所以滑鼠使用者不會看到突兀的框；鍵盤操作時才顯示，ring 規格與本檔
   其餘 focus 樣式一致。 */
/* ⚠️ outline:none 必須包在 @supports 內。不支援 :focus-visible 的瀏覽器會套用
   `:focus { outline: none }` 卻忽略下面那條規則 → 程式化 focus() 完全沒有可見焦點
   指示（a11y regression，Copilot review 指出）。包起來後：支援的瀏覽器走 :focus-visible
   規則（滑鼠不顯示、鍵盤顯示），不支援的保留 UA 預設焦點框。
   註：同檔其餘 :focus-visible 用法都沒有搭配 outline:none，故不受此問題影響。 */
@supports selector(:focus-visible) {
    .tc-day[tabindex="-1"]:focus {
        outline: none;
    }
}
.tc-day[tabindex="-1"]:focus-visible {
    outline: 2px solid var(--rq-primary);
    outline-offset: 2px;
}
.tc-day-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
    padding: 7px 9px 5px;
    font-size: var(--tc-fs-md);
    color: var(--tc-muted);
}
.tc-day-date {
    font-weight: 600;
    color: var(--tc-secondary);
    font-variant-numeric: tabular-nums;
}
.tc-day-weekday {
    font-size: var(--tc-fs-xs);
}
.tc-day-body {
    padding: 0 7px 8px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1;
}
/* 月初：日期升級為月份錨點（深綠、放大——informational，非 action） */
.tc-month-start .tc-day-date {
    color: var(--rq-dark);
    font-weight: 700;
    font-size: var(--tc-fs-xl);
}
/* 今天：狀態高亮——淡綠 wash＋深綠日期（不用主綠實色） */
.tc-today {
    background: var(--rq-primary-soft);
    box-shadow: inset 0 2px 0 var(--rq-dark);
}
.tc-today .tc-day-date {
    color: var(--rq-dark);
    font-weight: 700;
}

/* ---------- 卡片 ---------- */
.tc-card {
    --tc-muted: var(--tc-secondary); /* 卡內次要文字仍須在各狀態底色達 AA 對比。 */
    border: 1px solid var(--tc-hairline);
    border-radius: 6px;
    background: #fff;
    padding: 7px 9px 8px;
    font-size: var(--tc-fs-md);
    line-height: 1.4;
    transition: border-color .15s cubic-bezier(.22, 1, .36, 1), box-shadow .15s cubic-bezier(.22, 1, .36, 1);
}
.tc-card:hover {
    border-color: #d8dde1;
    box-shadow: 0 1px 4px rgba(28, 30, 33, .06);
}
.tc-card-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.tc-sport-ico {
    color: var(--tc-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    font-size: 16px;
}
/* 運動／來源為同一組識別，完成標記獨立留在右側。 */
.tc-card-icons {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: 2px;
}
/* 計畫數據保持原有排列；來源移至標題列，不佔用數據空間。 */
.tc-plan-meta {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    min-width: 0;
}
.tc-plan-meta .tc-nums,
.tc-plan-meta .tc-nums-sub {
    min-width: 0;
}
.tc-source-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    cursor: help;
    color: #004533;
    line-height: 1;
}
.tc-source-ico img {
    display: block;
    width: 100%;
    height: 100%;
}
.tc-source-ico .tc-source-dark {
    display: none;
}
/* 沿用網站 html.dark 佈景開關，不依 OS 偏好把白底卡片單獨換成淺色 icon。 */
html.dark .tc-source-ico {
    color: #EBF4EB;
}
html.dark .tc-source-ico .tc-source-light {
    display: none;
}
html.dark .tc-source-ico .tc-source-dark {
    display: block;
}
/* 七日桌面格可能僅約 110px。極窄卡片的標題區分兩行，名稱仍有完整欄寬；
   以卡片寬度判斷，避免只看 viewport 而在桌面窄欄把名稱擠成直條。 */
.tc-card-planned,
.tc-card-completed {
    container-name: tc-workout-card;
    container-type: inline-size;
}
@container tc-workout-card (max-width: 170px) {
    .tc-card-head {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        row-gap: 4px;
    }
    .tc-card-head .tc-card-title {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    .tc-card-head .tc-card-icons {
        grid-column: 1;
        grid-row: 1;
        margin-top: 0;
    }
    .tc-card-head .tc-check {
        grid-column: 2;
        grid-row: 1;
        margin-top: 1px;
    }
}
.tc-source-ico::before {
    position: absolute;
    inset: -4px;
    content: '';
}
.tc-source-ico:focus-visible {
    outline: 2px solid var(--rq-primary);
    outline-offset: 2px;
}
/* Portal 到 body，避免 .tc-days 的 overflow:hidden 裁切；不依賴 tc-root token。
   無動畫，並允許游標移入提示（WCAG 1.4.13）。 */
.tc-source-tooltip {
    position: fixed;
    box-sizing: border-box;
    z-index: 1040;
    max-width: min(240px, calc(100vw - 16px));
    padding: 6px 10px;
    border-radius: 4px;
    background: #004533;
    color: #fff;
    font-family: "Noto Sans TC", "Open Sans", Arial, sans-serif;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.tc-source-tooltip[hidden] {
    display: none;
}
.tc-card-title {
    font-size: var(--tc-fs-xl);
    font-weight: 600;
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}
.tc-card .tc-card-title {
    color: var(--rq-dark);
}
.tc-card a.tc-card-title:hover,
.tc-card a.tc-card-title:focus-visible {
    text-decoration: underline;
    text-underline-offset: 2px;
}
.tc-card-title:focus-visible {
    /* theme.css 的 body a 全域以 !important 清除 outline，卡片鍵盤入口需明確恢復。 */
    outline: 2px solid var(--rq-primary) !important;
    outline-offset: 2px;
    border-radius: 2px;
}
/* 完成狀態的實心圓比線條圖示更醒目，縮為 16px／內勾 9px，避免放大時搶過標題。
   ✓ 為圖形標記，依 DESIGN.md 不套 12px 閱讀文字底線。 */
.tc-check {
    margin-left: auto;
    align-self: flex-start;
    margin-top: 3px;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--rq-dark);
    color: #fff;
    font-size: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* 時間／公里／訓練指數固定各佔一行（XJack 2026-07-27 裁決）。
   改版前是 flex-wrap 自動換行，換行點取決於數值字寬與當下欄寬——同一畫面上
   「31 分 5.4 公里 ／ 20 點」與「7 分 1.0 公里 2 點」並列，有的兩行有的一行，
   讀起來像資料格式不一致。欄寬最窄時（1280px→約 101px 內容寬）本來就塞不下
   三個值，一行方案在任何斷點都無法一致，故固定三行。
   代價：卡片平均高 124→147px（+19%），整頁約 +8%。 */
.tc-nums {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 4px;
    color: var(--rq-dark);
    font-weight: 600;
    font-size: var(--tc-fs-lg);
    line-height: 1.3;          /* 較卡片本文的 1.4 緊，抵回一部分增高 */
    font-variant-numeric: tabular-nums;
}
a.tc-nums {
    text-decoration: none;
}
a.tc-nums:hover .tc-num,
a.tc-nums:focus-visible .tc-num {
    color: var(--rq-primary);
}
a.tc-nums:focus-visible {
    outline: 2px solid var(--rq-primary);
    outline-offset: 2px;
    border-radius: 2px;
}
.tc-nums-sub {
    margin-top: 2px;
    color: var(--tc-muted);
    font-size: var(--tc-fs-sm);
}
/* 已完成卡內嵌的紀錄列（與僅實際卡同構：時刻＋紀錄名＋數據） */
.tc-rec-embed {
    display: block;
    margin-top: 5px;
    padding: 5px 7px 6px;
    background: rgba(255, 255, 255, .72);
    border: 1px dashed #cfe2d5;
    border-radius: 5px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s cubic-bezier(.22, 1, .36, 1);
}
.tc-rec-embed:hover {
    border-color: var(--rq-primary);
    text-decoration: none;
}
.tc-rec-embed:focus-visible {
    outline: 2px solid var(--rq-primary) !important;
    outline-offset: 2px;
    border-radius: 5px;
}
.tc-rec-embed-head {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    /* 紀錄名稱換到自己一行（XJack 2026-08-04 回報）：改版前時刻 badge 與名稱並排，
       名稱只分到「欄寬 − badge」約 130px，遇上裝置給的長名稱（例：「八德區 - 最大攝氧
       短間歇跑」）就折成 4 行細長條，把整張卡撐得又高又窄。時刻只有 5 個字元、是次要
       標籤，讓它獨佔第一行、名稱獨佔第二行，名稱就能用完整欄寬（同樣的字只需 2 行）。 */
    flex-wrap: wrap;
}
.tc-rec-name {
    font-size: var(--tc-fs-sm);
    font-weight: 500;
    color: var(--tc-secondary);
    min-width: 0;
    overflow-wrap: anywhere;
    /* ⚠️ 刻意**無條件**換行，不做「只有太長才換」的條件式。三種條件式寫法都不可靠：
       ① `min-width: max-content` ＋ `max-width: 100%` —— CSS 規定 min-width 勝過
          max-width，名稱比欄寬長時會直接溢出卡片；
       ② `flex-basis: max-content` —— 內建尺寸關鍵字當 flex-basis 的支援度不足；
       ③ 固定 em 門檻（如 `flex: 1 1 12em`）—— 門檻同時受欄寬、字級量表與語系字寬影響，
          改任一個就失準，正是 .tc-desc-toggle 當年踩過的那類「配著當時數字訂的門檻」。
       換行後短名稱（如「跑步」）會多佔一行，這是拿一致、可預測的版式換掉細長條。 */
    flex-basis: 100%;
}
.tc-rec-embed:hover .tc-rec-name,
.tc-rec-embed:focus-visible .tc-rec-name {
    text-decoration: underline;
    text-underline-offset: 2px;
}
.tc-rec-embed .tc-nums {
    margin-top: 2px;
}
/* 已完成：淺綠底＋深綠字 */
.tc-card-completed {
    background: var(--rq-pale);
    border-color: #d9e9de;
}
.tc-card-completed .tc-card-title {
    color: var(--rq-dark);
}
.tc-card-completed:hover {
    border-color: #c4ddcc;
    box-shadow: 0 1px 4px rgba(0, 69, 51, .08);
}
/* 週期化賽事標記卡（issue #1898）：紅色系一眼可辨，語意對齊舊版 fullcalendar 的
   fc-event-danger（比賽）——「紅＝比賽日」是全站既有語意，非 error。色票自 VI
   功能紅 #e74c3c 衍生成 tc 體系淡色卡，**刻意不沿用 .tc-error 的三色**（本檔
   :171 的裁決同理：與錯誤列同色會讓賽事卡被誤讀成「這天出錯了」，也稀釋真正
   錯誤列的警示力）。已完成態（比賽紀錄配對後）維持紅卡識別。非顏色線索由
   卡頭的旗幟 icon＋sr-only 文字承載（WCAG 1.4.1，見 _trainingCard.php）。 */
.tc-card-event,
.tc-card-event.tc-card-completed {
    background: var(--tc-event-bg);
    border-color: var(--tc-event-border);
}
.tc-card-event .tc-card-title,
.tc-card-event .tc-sport-ico {
    color: var(--tc-event-ink);
}
.tc-card-event:hover {
    border-color: var(--tc-event-border-hover);
    box-shadow: 0 1px 4px rgba(192, 57, 43, .08);
}
/* 過去未連結課表：虛線邊框＋強度圖灰階降彩，hover／鍵盤 focus 恢復全彩供回顧。
   不再降低整卡透明度，以免標題、來源、次要文字一起失去對比。
   注意：isPast 僅在「無匹配紀錄」時為真（TrainingCalendarService::buildWorkoutCard），
   故退場只作用於未執行的過去課表，永不牽連任何紀錄卡（#1405 P2-11）。 */
.tc-card-past {
    border-style: dashed;
}
.tc-card-past .tc-chart {
    filter: grayscale(1);
    opacity: .75;
    transition: filter .18s cubic-bezier(.22, 1, .36, 1), opacity .18s cubic-bezier(.22, 1, .36, 1);
}
.tc-card-past:hover .tc-chart,
.tc-card-past:focus-within .tc-chart {
    filter: none;
    opacity: 1;
}

/* 訂閱到期後被切點鎖住的週期化課表（spec §11 #13）：純鎖定卡——只有鎖頭與「課表已鎖定」，
   內容零外露。中性灰虛線降低視覺權重（主綠只用於 action，續訂鈕在課表頁），
   點擊進課表頁上鎖畫面。非顏色線索由鎖頭 icon 承載。 */
.tc-card-locked {
    background: #f3f4f6;
    border-style: dashed;
    border-color: #d5d9de;
}
.tc-card-locked .tc-card-title,
.tc-card-locked .tc-sport-ico {
    color: var(--tc-muted);
}
.tc-locked-note {
    font-size: var(--tc-fs-sm);
    color: var(--tc-muted);
    margin-top: 2px;
}

/* ---------- 僅實際（未規劃紀錄）----------
   #1405 P2-11：紀錄是「已發生的事實」，與已完成卡同一層級，未配對課表的紀錄同樣重要，
   不得降級。改版前的灰底＋虛線＋降字重讀起來像暫存草稿，故改為：
   白底＋左側深綠 accent 標示「這是紀錄」，數字與其他卡同級（深綠 600／--tc-fs-lg）。
   與課表卡的區隔改由「語意標記」承擔（accent bar ＋ 只有紀錄才有的開始時刻），
   而非由「變淡」承擔。深綠 accent 是資料語意用色，非 #1400 的限定功能標記。 */
.tc-card-actualonly {
    background: #fff;
    border-color: var(--tc-border);
    border-left: 3px solid var(--rq-dark);
}
.tc-card-actualonly .tc-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}
/* 紀錄名稱換到自己一行（XJack 2026-08-04 回報，與 .tc-rec-embed-head 同一個理由與寫法）。
   只作用在僅實際卡；課表卡改以 container query 決定標題是否獨佔一行。 */
.tc-card-actualonly .tc-card-head {
    flex-wrap: wrap;
}
.tc-card-actualonly .tc-card-title {
    font-weight: 600;
    color: var(--tc-ink);
    /* 長字串斷行不必在此重述：基底 .tc-card-title 已有 overflow-wrap: anywhere */
    flex-basis: 100%;
}
.tc-card-actualonly .tc-nums {
    font-weight: 600;
    color: var(--rq-dark);
}
.tc-card-actualonly:hover {
    border-color: #d8dde1;
    border-left-color: var(--rq-dark);
}
.tc-card-actualonly .tc-card-link:hover .tc-card-title,
.tc-card-actualonly .tc-card-link:focus-visible .tc-card-title {
    text-decoration: underline;
    text-underline-offset: 2px;
}
.tc-card-actualonly .tc-card-link:focus-visible {
    outline: 2px solid var(--rq-primary) !important;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- 卡片動作列（#1405 P2-01：卡片上直接解除紀錄↔課表對應）----------
   重用 views/calendar/_recordWorkoutUnlink.php（inline 二段式確認＋事件委派），
   置於內嵌紀錄列「之後」——該列是 <a>，互動元素不可巢狀於錨點內。 */
.tc-card-actions {
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px dashed #cfe2d5;
    font-size: var(--tc-fs-sm);
    line-height: 1.5;
}
/* 註：`.tc-card-unlinked .tc-check` 與 `.tc-rec-embed.tc-rec-detached`（連同其 hover 與
   .tc-rec-name 變體）已於 #1405 批次 3A.1 移除。那兩組 class 只有前端手工降級
   （training-calendar.js 舊 fallbackDegrade）會賦予，而解除對應後的畫面現在一律由
   伺服器重新渲染整個日格（伺服器直接輸出 .tc-card-planned 與 .tc-card-actualonly，
   不需要中間態 class）。留著即為打不到任何元素的死碼。 */

/* ---- 對比校正：共用 partial 的 inline 色是配著白底卡訂的，本頁第一次把它放進
   已完成卡的淺綠底（--rq-pale #EBF4EB）。實測 #808B96 → 3.09:1、#d9534f → 3.52:1，
   兩者都低於 WCAG AA 正文 4.5:1，而 #d9534f 還是破壞性動作的確認鍵。
   刻意「只在本頁覆蓋」而不改共用 partial——那支同時服務紀錄頁與課表頁，
   改它等於未經同意動到其他頁面的外觀。需要 !important 是因為原樣式是 inline style。 */
.tc-card-actions .rwl-unlink-confirm > span {
    color: var(--tc-secondary) !important;   /* 7.35:1 */
}
.tc-card-actions .rwl-unlink-yes {
    color: #b71c1c !important;               /* 5.84:1，同檔錯誤訊息已在用的深紅 */
}
/* 解除成功後共用 partial 注入的訊息（「已解除對應」＋說明）也帶 inline #808B96 →
   淺綠底 3.09:1，而上面兩條選擇器打不到它（它是回呼新建的節點，不在 .rwl-unlink-confirm
   內）。重取成功時它只存在幾百毫秒（整個日格隨即被伺服器版本置換），但**重取失敗時會
   留在畫面上直到使用者重整**——那正是最需要讀清楚的時候，故一併校正。
   `[data-rwl-block]` 就是該回呼唯一會置換 innerHTML 的節點，綁它最貼合契約。 */
.tc-card-actions[data-rwl-block] > div {
    color: var(--tc-secondary) !important;   /* 淺綠底 7.35:1 */
}
/* 共用 partial 的三顆 <a href="javascript:void(0)"> 沒有自帶 focus 樣式（其原生成頁面
   也沒有）。本頁其餘互動元素 focus-visible 覆蓋率 100%，這裡就地補齊，不動共用 partial。 */
.tc-card-actions .rwl-unlink-trigger:focus-visible,
.tc-card-actions .rwl-unlink-yes:focus-visible,
.tc-card-actions .rwl-unlink-cancel:focus-visible {
    outline: 2px solid var(--rq-dark);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- 迷你強度圖 ---------- */
.tc-chart {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 34px;
    margin-top: 6px;
    padding: 2px 2px 0;
    background: #f4f6f7;
    border-radius: 4px;
    overflow: hidden;
}
.tc-seg {
    display: block;
    height: var(--tc-seg-h, 25%);
    min-width: 1px;
    flex: 0 0 auto;
    border-radius: 1px 1px 0 0;
}
.tc-seg-unknown {
    opacity: .4;
}

/* ---------- 教練的話 ---------- */
.tc-desc {
    margin-top: 6px;
    color: var(--tc-secondary);
    font-size: var(--tc-fs-sm);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}
.tc-desc.tc-desc-open {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}
/* 教練的話內自動轉成的超連結：加底線（WCAG 1.4.1），長網址可斷行 */
.tc-desc a,
.tc-modal-desc a {
    text-decoration: underline;
    overflow-wrap: break-word;
    word-break: break-word;
}
.tc-desc-toggle {
    margin-top: 3px;
    border: 0;
    background: none;
    padding: 0;
    color: var(--rq-primary);
    cursor: pointer;
    font-size: var(--tc-fs-sm);
}
.tc-desc-toggle:focus-visible {
    outline: 2px solid var(--rq-primary);
    outline-offset: 2px;
    border-radius: 2px;
}
/* 顯式壓過佈景主題可能對 button 下的 display，確保 [hidden] 真的隱藏 */
.tc-desc-toggle[hidden] {
    display: none;
}

/* ---------- 週摘要面板 ---------- */
.tc-summary {
    background: var(--tc-panel);
    border-left: 1px solid var(--tc-border);
    padding: 10px 12px 12px;
    font-size: var(--tc-fs-md);
    display: flex;
    flex-direction: column;
}
.tc-summary-range {
    color: var(--tc-muted);
    font-size: var(--tc-fs-sm);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-bottom: 8px;
}
.tc-week-current .tc-summary-range {
    color: var(--rq-dark);
}
.tc-metrics {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 9px;
    margin-bottom: 9px;
    border-bottom: 1px solid var(--tc-border);
    position: relative;
}
.tc-metric {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.tc-metric-label {
    color: var(--tc-muted);
    font-size: var(--tc-fs-xs);
}
.tc-metric-val {
    color: var(--rq-dark);
    font-weight: 700;
    font-size: var(--tc-fs-2xl);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
/* 推估：次要色＋「推估」標記（不用斜體——數字可讀性優先） */
.tc-metrics-est .tc-metric-val {
    color: var(--tc-secondary);
}
.tc-est-badge {
    position: absolute;
    top: -2px;
    right: 0;
    background: var(--rq-pale);
    color: var(--rq-dark);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: var(--tc-fs-xs);
}
.tc-metrics-empty {
    color: var(--tc-muted);
    border-bottom: 1px solid var(--tc-border);
}
/* .tc-metrics-locked／.tc-premium-note 已於 2026-08-20 移除：週摘要在看不到週指標時
   整塊不渲染（連盾牌 icon 都不留），兩個 class 因此沒有任何輸出端。
   說明與升級出口集中在頁首 #tcMetricsHint —— 見 _trainingWeekSummary.php 的沿革註解。 */
.tc-summary-table {
    width: 100%;
    border-collapse: collapse;
}
.tc-summary-table th,
.tc-summary-table td {
    padding: 3px 0 3px 8px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.tc-summary-table th:first-child,
.tc-summary-table td:first-child {
    text-align: left;
    padding-left: 0;
    color: var(--tc-secondary);
    font-weight: 400;
}
.tc-summary-table thead th {
    color: var(--tc-muted);
    font-weight: 600;
    font-size: var(--tc-fs-xs);
    padding-bottom: 5px;
}
.tc-summary-table td {
    color: var(--rq-dark);
    font-weight: 700;
    font-size: var(--tc-fs-lg);
}
.tc-summary-group td {
    padding-top: 9px;
    padding-bottom: 2px;
    color: var(--tc-ink);
    font-weight: 700;
    text-align: left;
    font-size: var(--tc-fs-sm);
}

/* ---------- 週收合切換（#1405 P2-06）----------
   桌機恆隱藏：7 欄橫向排列本來就一屏一週，無捲動問題。 */
.tc-week-toggle {
    display: none;
}

/* ---------- 行動版（<1280px）：日堆疊＋摘要卡殿後 ----------
   斷點自 991.98px 提高到 1279.98px。實測每欄寬＝(viewport − 80 padding − 15 捲軸 − 240 摘要欄) / 7：
   1024px → 101px、1200px → 124px、1280px → 135px、1440px → 158px、1536px 以上 → 171px 起。
   字級改版後卡片本文 14px，欄內文字寬要到約 100px（≈7 字／行）才不會把 CJK 標題切碎，
   對應 viewport 約 1280px，故取 1279.98px。（真正「舒適」要到約 1366px＝147px／欄；
   若日後判定 1280～1365 仍太擠，把此值與 training-calendar.js 的 STACK_MQ 一併改為 1365.98px。）*/
@media (max-width: 1279.98px) {
    .tc-days {
        display: flex;
        flex-direction: column;
        border-radius: 8px;
    }
    .tc-day {
        min-height: 0;
        border-right: 0;
        border-bottom: 1px solid var(--tc-hairline);
        flex-direction: row;
        align-items: flex-start;
        /* 「回今天」堆疊時錨定的是「今天那一格」而非週頂端（#1384 項目 4），
           故單日也需預留固定頁首高度，與 .tc-week 同值 */
        scroll-margin-top: 100px;
    }
    /* 84px：字級改版後「12/31」＋「星期三」在 74px 下會擠壓換行 */
    .tc-day-head {
        flex: 0 0 84px;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 9px 8px;
    }
    .tc-day-body {
        padding: 8px 8px 8px 0;
        flex: 1;
    }
    .tc-day-body:empty {
        padding: 0;
        min-height: 34px;
    }
    /* 堆疊時「今天」只靠底層的 --rq-primary-soft 整列淡綠 wash ＋ 深綠粗體日期標示。
       原本的 inset 左側深綠條已移除：僅實際卡的身分標記也是左側 3px 深綠條
       （.tc-card-actualonly），兩條方向相同、粗細只差 1px 卻語意完全不同（「今天」vs
       「這是紀錄」）。整列 wash 的訊號本來就比 2px 線強，移除後反而更清楚。 */
    .tc-today {
        box-shadow: none;
    }
    .tc-summary {
        border-left: 0;
        border-top: 1px solid var(--tc-border);
    }
    .tc-week {
        margin: 10px 0 16px;
        scroll-margin-top: 100px;
    }
    .tc-fab-cluster {
        right: 16px;
        bottom: 20px;
    }
    .tc-fab {
        padding: 9px 15px;
    }
    /* 週收合：預設全展開，使用者可自行收起想快速翻過的週（只留週摘要） */
    .tc-week-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        margin-top: 10px;
        padding: 7px 10px;
        border: 1px solid var(--tc-border);
        border-radius: 6px;
        background: #fff;
        color: var(--tc-secondary);
        font-size: var(--tc-fs-sm);
        font-weight: 600;
        cursor: pointer;
    }
    .tc-week-toggle:hover {
        border-color: var(--rq-primary);
        color: var(--rq-primary);
    }
    .tc-week-toggle:focus-visible {
        outline: 2px solid var(--rq-primary);
        outline-offset: 2px;
    }
    .tc-week-collapsed .tc-day {
        display: none;
    }
    .tc-week-collapsed .tc-summary {
        border-top: 0;
    }
}

/* ---------- 固定控制組（fixed：不受 .inner-wrapper overflow:hidden 破壞 sticky 影響）----------
   承載「回今天」與「意見回饋」，捲到任何位置都可用。取代原本黏不住又會閃爍的頂部 sticky bar。
   （原註解寫「回今天與回到目前版本」有誤：FAB 群組從未放過「回到目前版本」，那枚是後來加在
   頁首、且已於 2026-07-28 移除。2026-07-28 一併更正。） */
/* ---------- 學員快速切換的固定停靠位（#1405 P2-10）----------
   頁首捲出畫面後，切換器搬進這裡，讓教練捲到任何位置都能換人。
   fixed 而非 sticky：.inner-wrapper 的 overflow:hidden 會破壞 position:sticky（同 FAB 群組）。
   靠左下，與右下 FAB 群組分開——右下第三枚在手機會疊成一座塔遮蔽內容。
   VI：這是導航控制項不是主要動作，用白底＋中性描邊，不與主綠 FAB 爭焦點。 */
.tc-switch-dock {
    position: fixed;
    left: 26px;
    bottom: 30px;
    z-index: 30;
    max-width: calc(100vw - 52px);
    padding: 6px 10px;
    border: 1px solid var(--tc-border);
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(0, 69, 51, .16);
}
.tc-switch-dock[hidden] {
    display: none;
}
/* 停靠時不需要 margin-right:auto（那是頁首 flex 版面用的） */
.tc-switch-dock .tc-switch {
    margin: 0;
}
@media (max-width: 767.98px) {
    /* 與 FAB 群組（right:16px）分居左右兩側：dock 佔左半、FAB 佔右半，不重疊。
       55vw 是實測留給「回今天」FAB 的安全寬度——375px 下 dock 佔 16～222px、
       FAB 群組約自 245px 起。 */
    .tc-switch-dock {
        left: 16px;
        bottom: 20px;
        max-width: 55vw;
        padding: 5px 9px;
    }
}

.tc-fab-cluster {
    position: fixed;
    right: 26px;
    bottom: 30px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.tc-fab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--rq-primary);
    color: #fff;
    font-size: var(--tc-fs-xl);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(0, 69, 51, .28);
    transition: background-color .15s cubic-bezier(.22, 1, .36, 1), box-shadow .15s cubic-bezier(.22, 1, .36, 1);
}
.tc-fab:hover {
    background: #009569;
    box-shadow: 0 4px 16px rgba(0, 69, 51, .34);
    color: #fff;
}
.tc-fab:focus-visible {
    outline: 2px solid var(--rq-dark);
    outline-offset: 2px;
}
/* 頁首 BETA 標記樣式（.page-header h2 small）已於 2026-08-20 全面公開時整段移除。
   它只服務 params['subtitle'] 那一枚 BETA 徽章，而本頁的 subtitle 自始只設過 BETA；
   徽章拿掉後此規則沒有任何輸出端。
   ⚠️ 這個選擇器落在 .tc-root 之外（針對 layout），移除前已確認全站其他 .page-header h2
   規則（theme.css / default.css / rqdefault.css / cntheme.css）都沒有 small 子選擇器，
   故移除不影響任何其他頁面。 */

/* 次級 FAB（意見回饋）：白底中性外框，刻意不搶「回今天」的主綠。
   主綠僅限主要 action（VI 紅線），一個控制組內只留一枚實心綠。 */
.tc-fab--ghost {
    background: #fff;
    color: var(--rq-dark);
    border: 1px solid rgba(0, 69, 51, .18);
    font-weight: 500;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 69, 51, .14);
}
.tc-fab--ghost:hover,
.tc-fab--ghost:focus {
    background: var(--rq-pale);
    color: var(--rq-dark);
    text-decoration: none;
    box-shadow: 0 3px 12px rgba(0, 69, 51, .2);
}

/* ---------- 紀錄開始時刻（紀錄有時刻、課表沒有——計畫 vs 事實一眼區分） ---------- */
.tc-rec-time {
    flex: 0 0 auto;
    background: #eef1f3;
    color: var(--tc-secondary);
    border-radius: 3px;
    padding: 0 5px;
    font-size: var(--tc-fs-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
}
.tc-card-completed .tc-rec-time {
    background: rgba(0, 69, 51, .1);
    color: var(--rq-dark);
}
.tc-card-actualonly .tc-rec-time {
    background: rgba(0, 69, 51, .1);
    color: var(--rq-dark);
}

/* ============================================================
 * 卡片跳窗整合檢視（#1405 P2-02，計畫 §九 批次 3A）
 *
 * 定位＝量測儀器讀數，不是「把紀錄頁塞進框裡」，也不是卡片＋陰影＋icon 圓圈那種
 * 「讓 modal 看起來有設計」的反射答案（違反 PRODUCT.md 的 anti-references）。
 *
 * 兩個關鍵決定（2026-07-30 改版）：
 * 1. **跳窗有自己的 rem 字級級距 --tcm-fs-***，不沿用 48 週網格的 --tc-fs-*（12px 起）。
 *    網格需要那個密度，閱讀型跳窗不需要；本文 1rem=16px 才符合可讀性底線。
 *    用 rem 而非 px 的三個實得好處：尊重使用者瀏覽器字級、200% 縮放正確 reflow、
 *    且不受 cntheme.css 把 body 設成 14px 影響（rem 錨在 html，兩語系一致）。
 *    ⚠️ body 有 `line-height: 22px`（固定 px）會被繼承——放大字級後每一處都必須
 *    明確給 line-height，否則行距會擠在一起。
 * 2. 節奏靠留白與字重，**不靠「細線＋每節一個小灰標題」**。只有真的需要命名的三塊
 *    （逐段強度／教練的話／分段）有標題，且是真標題（19px/700/ink）不是小號 kicker。
 *
 * VI：主綠只出現在出口按鈕（唯一 action）；資料數字用深綠／ink；強度七區用官方功能色。
 * ============================================================ */
.tc-modal {
    /* 跳窗自己的字級級距（1.2 ratio，錨在 1rem = 16px；product register 要求固定 rem 級距） */
    /* 12px 附註（唯一低於 14px 的級距）。決策 #13 說跳窗不沿用 48 週網格的 12px 系統，
       指的是「本文與資料不可掉到 12px」；此級距只給次級附註（如缺值原因）當細字使用，
       不得用於本文、資料值或欄位標題。 */
    --tcm-fs-xs: 0.75rem;
    --tcm-fs-sm: 0.875rem;      /* 14px 欄位標題、表格、meta */
    --tcm-fs-base: 1rem;        /* 16px 本文（教練的話）、表格數值 */
    --tcm-fs-md: 1.1875rem;     /* 19px 區塊標題 */
    --tcm-fs-title: 1.5rem;     /* 24px 跳窗標題 */
    --tcm-fs-data: 1.75rem;     /* 28px 實際值（數字是主角，刻意大於標題） */
    --tcm-fs-data-sub: 1.25rem; /* 20px 計畫值（明顯次於實際） */
    /* 跳窗專用的次要文字色。**不可改回 --tc-muted（#8a9199）**：那個值對白底只有
       3.19:1，WCAG 2.1 AA 對一般文字（<18.66px 粗體／<24px 常規）要求 4.5:1，跳窗內
       8 處灰字全部不達標——其中 .tc-read-note（12px 缺值原因）是使用者唯一能讀到
       「為什麼算不出來」的管道，讀不清等於決策 #21 白做。#6b7280 實算 4.83:1 ✓。
       層級改由字級與字重承擔，不靠「灰到看不清」（2026-07-31 review 第 2 輪）。
       ⚠️ 48 週網格仍用 --tc-muted，同樣不達標但屬 #1354 既有範圍，本 PR 不動。
       例外：.tc-spinner 的 border-top-color 仍用 --tc-muted——它是圖形不是文字，
       走 WCAG 1.4.11 非文字對比的 3:1 門檻，3.19:1 通過。 */
    --tcm-muted: #6b7280;
    /* 間距節奏（8px 基準的 1.5 倍階，避免每塊都一樣寬） */
    --tcm-gap: 12px;
    --tcm-sec-gap: 28px;
}

/* ---------- 外框 ---------- */
.tc-modal .modal-content {
    border: 0;
    border-radius: 10px;
    box-shadow: 0 18px 50px rgba(28, 30, 33, .2);
}
.tc-modal .modal-header {
    align-items: flex-start;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--tc-border);
}
.tc-modal-ident {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}
/* icon 是圖形不是閱讀文字，故不套字級底線；跟著標題等比縮放 */
.tc-modal-ico {
    flex: 0 0 auto;
    color: var(--rq-dark);
    font-size: 1.15rem;
    line-height: 1;
}
/* 賽事標記卡的跳窗旗幟同走賽事 ink（issue #1898）——日格旗、chip、跳窗旗三處
   同族色；缺這條時跳窗旗幟吃上面的深綠，緊鄰紅 chip 視覺打架 */
.tc-modal-ico.fa-flag-checkered {
    color: var(--tc-event-ink);
}
.tc-modal-title {
    margin: 0;
    color: var(--tc-ink);
    font-size: var(--tcm-fs-title);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    /* CJK 長課表名在窄框內要能斷行，不可溢出 */
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
    text-wrap: balance;
}
.tc-modal-close {
    flex: 0 0 auto;
    /* 觸控目標 ≥44px（BS4 的 .close 只有字級大小） */
    width: 44px;
    height: 44px;
    margin: -8px -10px 0 0;
    font-size: 1.75rem;
    line-height: 1;
    opacity: .5;
    transition: opacity 160ms cubic-bezier(.22, 1, .36, 1);
}
.tc-modal-close:hover,
.tc-modal-close:focus {
    opacity: 1;
}
.tc-modal .modal-body {
    padding: 4px 24px 24px;
}
/* 桌機：內容過長時只捲 body，標題與關閉鈕留在原位（BS4 4.1 無 .modal-dialog-scrollable）。
   3.5rem 恰為 BS4 .modal-dialog 在 ≥576px 的上下 margin 合計，數學上不會超出視窗。 */
@media (min-width: 768px) {
    .tc-modal .modal-content {
        max-height: calc(100vh - 3.5rem);
    }
    .tc-modal .modal-body {
        overflow-y: auto;
    }
}

.tc-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
}
.tc-modal-errorbar {
    margin: 16px 0;
}
/* 空狀態／就地錯誤說明（無分段資料、第二段請求失敗） */
.tc-modal-note {
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-base);
    line-height: 1.6;
}

/* ---------- 區塊骨架 ----------
   分隔靠 margin，不靠每塊一條細線；標題是真標題不是 kicker。 */
.tc-modal-sec {
    margin-top: var(--tcm-sec-gap);
}
.tc-modal-h {
    margin: 0 0 var(--tcm-gap);
    color: var(--tc-ink);
    font-size: var(--tcm-fs-md);
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -0.005em;
}

/* ---------- meta 列（狀態／日期／時刻／紀錄名）---------- */
.tc-modal-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding-top: 16px;
    color: var(--tc-secondary);
    font-size: var(--tcm-fs-sm);
    line-height: 1.5;
}
.tc-modal-state {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 12px;
    background: var(--tc-panel);
    color: var(--tc-secondary);
    font-weight: 700;
}
/* 完成態沿用卡片的淺綠底＋深綠字（同一語彙，不另發明狀態色） */
.tc-modal-state--completed {
    background: var(--rq-pale);
    color: var(--rq-dark);
}
/* 賽事 chip（issue #1898）：既有 modifier 慣例，只覆寫顏色、幾何全繼承
   .tc-modal-state——色票走 --tc-event-* token，與 .tc-card-event 由 CSS 保證同色 */
.tc-modal-state--event {
    background: var(--tc-event-bg);
    color: var(--tc-event-ink);
}
.tc-modal-date {
    font-variant-numeric: tabular-nums;
}
.tc-modal-time {
    background: rgba(0, 69, 51, .1);
    color: var(--rq-dark);
    border-radius: 4px;
    padding: 1px 7px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.tc-modal-recname {
    color: var(--tcm-muted);
}
/* 紀錄屬性（類型／吃力程度）。桌機一行放得下不換行；行動版整組換行（見 767.98px 區塊） */
.tc-modal-attrs {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 10px;
}
/* 標籤＋值成對，標籤退到 muted 讓值讀得出來 */
.tc-modal-attr {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
}
.tc-modal-attr-k {
    color: var(--tcm-muted);
}
.tc-modal-attr-v {
    color: var(--tc-secondary);
    font-weight: 600;
}

/* ---------- 計畫 vs 實際配對讀數 ----------
   用真正的 table：跨列共用欄寬是表格佈局的天生行為。改版初版用「每列一個 grid」，
   `auto` 欄（標籤欄、差值欄）因此逐列各自解析——標籤字數不同（時間 2 字 vs 訓練指數 4 字）
   加上差值 pill 寬度不同（實測 51/45/41px），把中間兩欄推歪，計畫欄右邊界差 21px。
   差值讓使用者不必心算，這是整個跳窗最有用的一個數字；欄位對齊是它可讀的前提。 */
.tc-cmp {
    width: 100%;
    margin-top: 18px;
    border-collapse: collapse;
    /* 標籤欄與差值欄縮到內容寬，兩個數值欄分掉剩餘空間 */
    table-layout: auto;
}
.tc-cmp th,
.tc-cmp td {
    /* 欄距走 padding-left（border-collapse 下 border-spacing 無效）；首欄另外歸零 */
    padding: 12px 0 12px 16px;
    text-align: right;
    vertical-align: baseline;
    white-space: nowrap;
    border-bottom: 1px solid var(--tc-hairline);
}
.tc-cmp thead th {
    padding-top: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--tc-border);
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-sm);
    font-weight: 700;
    line-height: 1.4;
}
.tc-cmp tbody tr:last-child th,
.tc-cmp tbody tr:last-child td {
    border-bottom: 0;
}
/* 列標題（時間／公里／訓練指數）：靠左、可換行（en 的 "Training Point" 較長） */
.tc-cmp .tc-cmp-label {
    padding-left: 0;
    text-align: left;
    white-space: normal;
    color: var(--tc-secondary);
    font-size: var(--tcm-fs-base);
    font-weight: 500;
    line-height: 1.5;
}
.tc-cmp thead th:first-child {
    padding-left: 0;
}
.tc-cmp-val {
    font-variant-numeric: tabular-nums;
}
/* 計畫＝意圖：中性、次級 */
.tc-cmp-val--plan {
    color: var(--tc-secondary);
    font-size: var(--tcm-fs-data-sub);
    font-weight: 600;
    line-height: 1.2;
}
/* 實際＝已發生的事實：深綠、最大（PRODUCT.md「數字是主角」；非 action 故不用主綠） */
.tc-cmp-val--act {
    color: var(--rq-dark);
    font-size: var(--tcm-fs-data);
    font-weight: 700;
    line-height: 1.15;
}
/* 單側時該欄就是主角，用實際的視覺重量 */
.tc-cmp--planned .tc-cmp-val--plan {
    color: var(--rq-dark);
    font-size: var(--tcm-fs-data);
    font-weight: 700;
    line-height: 1.15;
}
/* 刻意不上色：做多不等於做好，一上色就變成價值判斷；也不可用主綠（VI 紅線） */
.tc-cmp-deltapill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 11px;
    background: var(--tc-panel);
    color: var(--tc-secondary);
    font-size: var(--tcm-fs-sm);
    font-weight: 700;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

/* ---------- 三枚代表性讀數（即時跑力／平均配速／平均心率） ----------
   回答的是「這次跑得多好、多快、多喘」，與上方「計畫 vs 實際」是不同的問題，故獨立成一列
   而不是硬塞進對照表（課表無法預先計畫跑力／配速，那些列的計畫欄只會是永遠的破折號）。

   用 grid 而不是 inline flex：三枚字級不一（28 / 20 / 20），inline 換行後兩個不同字級的值
   會落在同一行做 baseline 對齊，行高被 28px 撐開、20px 那枚浮著。每格獨立就沒有這個問題，
   也讓「值下方掛一行原因小字」不會推歪隔壁格。

   auto-fit + minmax：欄數由可用寬度自己決定，不需要 media query。
   128px 這個下限的實測結果（2026-07-31 用 getComputedStyle 量測，非計算推導）：
   桌機 body 737px → 3 欄（各 235.0px）；375px body 339px → 2 欄（各 161.6px）；
   320px body 284px → 2 欄（各 134.0px）。三個斷點皆無橫向捲動，最長的原因字串單行不斷行。
   ⚠️ 320px 是 2 欄不是 1 欄——modal body 實際有 284px 而非紙上推算的 256px，
   兩欄需 2×128+16=272px 剛好放得下。要改成 1 欄，下限得 **≥135px**
   （2×135+16=286 > 284；134px 是 2 欄成立的邊界值），但實機看 2 欄並無問題，故維持。
   **改動這個值前務必實機重量，不要用算的。** */
.tc-reads {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 14px 16px;
    align-items: start;
    margin-top: 18px;
}
.tc-read {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.tc-read-k {
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-sm);
    font-weight: 700;
    line-height: 1.4;
}
/* 資料數字用深綠，不可用主綠（VI 紅線：主綠只給 action） */
.tc-read-v {
    color: var(--rq-dark);
    font-size: var(--tcm-fs-data-sub);
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
/* 即時跑力是 RQ 專屬核心指標，用字級保持主位——層級靠字級，不另加線或底色 */
.tc-read-v--lead {
    font-size: var(--tcm-fs-data);
}
/* 算不出來（無 recordDetail／無心率／無速度）：轉 muted，讀成「沒有資料」而非一個數值。
   即時跑力那枚同時降回 20px——28px 深綠的破折號會讀成一個設計元素而不是缺值。 */
.tc-read-v--empty {
    color: var(--tcm-muted);
    font-weight: 600;
}
.tc-read-v--lead.tc-read-v--empty {
    font-size: var(--tcm-fs-data-sub);
}
/* 無法計算即時跑力的原因（5～9 字）。常駐小字而非 tooltip：原生 title 在手機上幾乎觸發不到。
   走 --tcm-fs-xs（12px）：它是附註不是資料，14px 時視覺重量與上方的欄位標題打平，
   讀起來像第二個標籤而不是註解（XJack 2026-07-31）。
   word-break 讓最長的「與當前跑力差異過大」在 128px 欄寬內能斷行而不撐破格線。 */
.tc-read-note {
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-xs);
    font-weight: 400;
    line-height: 1.4;
    word-break: break-word;
}

/* ---------- 逐段強度雙軌 ---------- */
.tc-track + .tc-track {
    margin-top: 20px;
}
.tc-track-label {
    display: block;
    margin-bottom: 6px;
    color: var(--tc-ink);
    font-size: var(--tcm-fs-sm);
    font-weight: 700;
    line-height: 1.4;
}
/* 沿用 .tc-chart 的容器語彙（同底色、同圓角、同 1px 間隙），高度加到可讀出區間差異。
   卡片上 34px 的迷你圖在跳窗裡讀不出起伏，那正是雙軌對照的全部價值。 */
.tc-track-bars {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 76px;
    padding: 3px 3px 0;
    background: #f4f6f7;
    border-radius: 5px;
    overflow: hidden;
}
/* 白金鎖定態的實際軌（#1405 批次 3A.1 決策 3A.1-3）。刻意做成「與長條圖同一個容器
   語彙」的空槽（同底色、同圓角、同高度），而不是一行灰字：使用者一眼就看得出「這裡
   本來有一張圖」，那才是分層要傳達的資訊。內容置中，不模擬假的長條（不做模糊的假圖——
   那等於用視覺暗示謊稱資料長什麼樣）。 */
.tc-track--locked .tc-track-lock {
    /* 三段垂直堆疊：白金標記 → 這一塊是什麼 → 升級入口。
       改版初版是水平一行（只有 badge ＋ 連結），實機看下來是一格空白面板、讀不出鎖住
       什麼（XJack 2026-08-04 回報），故改為堆疊並補上說明句。 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 76px;                /* 與 .tc-track-bars 等高，鎖定前後版面不跳動 */
    padding: 16px 12px;
    background: #f4f6f7;
    border-radius: 5px;
    font-size: var(--tcm-fs-sm);
    line-height: 1.5;
    text-align: center;
}
/* 說明句：14px secondary（對 #f4f6f7 為 7.62:1）。限寬避免在寬螢幕拉成一條長線，
   讀起來會像 footer 而不是說明。 */
.tc-track--locked .tc-track-lock-desc {
    max-width: 30em;
    color: var(--tc-secondary);
}

/* 區間彙總 chip：色塊與長條同色（zoneColor 單一來源），互相印證。
   取代改版前那行逗號串起來的灰字——「哪一區練了多久」是這張圖要回答的問題。 */
.tc-zonelist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}
.tc-zonechip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 12px;
    background: var(--tc-panel);
    font-size: var(--tcm-fs-sm);
    line-height: 1.5;
}
.tc-zonechip-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex: 0 0 auto;
}
.tc-zonechip-name {
    color: var(--tc-secondary);
    font-weight: 600;
}
.tc-zonechip-min {
    color: var(--tc-ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- 教練的話全文 ---------- */
.tc-modal-desc {
    color: var(--tc-ink);
    font-size: var(--tcm-fs-base);
    line-height: 1.8;
    /* 本文行長上限（DESIGN.md：65–75ch） */
    max-width: 70ch;
    white-space: normal;
    overflow-wrap: break-word;
    text-wrap: pretty;
}

/* ---------- 四欄分段表 ----------
   刻意**不**給表格自己的垂直捲動區：那會在跳窗內生出第二條垂直捲軸，與 .modal-body
   的捲軸並排（實機截圖確認很難操作）。垂直捲動統一交給單一容器（桌機＝.modal-body、
   行動版＝.modal），thead 的 sticky 也才有對的 scrollport 可貼。
   水平退路見下方 767.98px 區塊。 */
.tc-laps {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
.tc-laps th,
.tc-laps td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--tc-hairline);
    text-align: right;
    white-space: nowrap;
    line-height: 1.5;
}
.tc-laps thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
    border-bottom: 1px solid var(--tc-border);
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-sm);
    font-weight: 700;
}
.tc-laps tbody td {
    color: var(--tc-ink);
    font-size: var(--tcm-fs-base);
}
.tc-laps tbody tr:last-child th,
.tc-laps tbody tr:last-child td {
    border-bottom: 0;
}
/* 圈序欄：強度區圓點 ＋ 圈號。圓點不是第五個資料欄，是把上方強度軌與這張表
   綁在一起的視覺索引（看到圖上那段橘色，往下就能找到是哪一圈）。 */
/* 圈序欄夾窄：5 欄平均分配時它會白佔 1/5，把數字欄擠得沒有呼吸空間（實機看出來的） */
.tc-laps-idx {
    width: 62px;
    text-align: left;
}
.tc-laps thead th.tc-laps-idx {
    text-align: left;
}
.tc-laps tbody th.tc-laps-idx {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tc-secondary);
    font-size: var(--tcm-fs-sm);
    font-weight: 600;
}
.tc-laps-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex: 0 0 auto;
}
.tc-laps-no {
    font-variant-numeric: tabular-nums;
}

/* ---------- 出口 ----------
   有邊框的 ghost 按鈕而非裸連結：觸控目標才夠大，也讀得出是可點的出口。
   出口是 action → 主綠（本跳窗唯一用主綠的地方）。 */
.tc-modal-exits {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: var(--tcm-sec-gap);
    padding-top: 20px;
    border-top: 1px solid var(--tc-border);
}
.tc-modal-exit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--tc-border);
    border-radius: 8px;
    color: var(--rq-primary);
    font-size: var(--tcm-fs-base);
    font-weight: 600;
    line-height: 1.4;
    transition: border-color 160ms cubic-bezier(.22, 1, .36, 1), background-color 160ms cubic-bezier(.22, 1, .36, 1);
}
.tc-modal-exit:hover,
.tc-modal-exit:focus {
    border-color: var(--rq-primary);
    background: var(--rq-primary-soft);
    color: var(--rq-primary);
    text-decoration: none;
}
.tc-modal-exit .fa-external-link-alt {
    font-size: .8em;
}

/* ---------- 行動版全螢幕（決策 #3）----------
   375px 放不下「計畫 vs 實際」並排對照，跳窗會被壓成難讀的窄框。
   斷點沿用本檔既有的 767.98px（同 .tc-switch-dock），不另立一條。 */
@media (max-width: 767.98px) {
    .tc-modal .modal-dialog {
        width: 100%;
        max-width: none;
        margin: 0;
    }
    .tc-modal .modal-content {
        min-height: 100vh;
        border-radius: 0;
    }
    .tc-modal .modal-header {
        padding: 16px 18px 14px;
    }
    .tc-modal .modal-body {
        padding: 4px 18px 32px;
    }
    .tc-modal {
        /* 窄螢幕縮一階，讓四欄表與三欄對照都塞得下，但本文仍守住 16px */
        --tcm-fs-title: 1.375rem;   /* 22px */
        --tcm-fs-data: 1.5rem;      /* 24px */
        --tcm-fs-data-sub: 1.125rem;/* 18px */
        --tcm-fs-md: 1.125rem;      /* 18px */
        --tcm-sec-gap: 24px;
    }
    /* 窄螢幕收窄欄距（table 的欄距走 padding-left） */
    .tc-cmp th,
    .tc-cmp td {
        padding-left: 10px;
    }
    .tc-cmp .tc-cmp-label,
    .tc-cmp thead th:first-child {
        padding-left: 0;
    }
    /* 類型與吃力程度整組換行，上一行留給「狀態＋日期＋時刻＋紀錄名」
       （XJack 2026-07-31：手機版要讓紀錄日期跟時間在同一行）。
       flex-basis:100% 讓這個 flex item 自己占滿一列，後面的內容被推到下一行。 */
    .tc-modal-attrs {
        flex: 0 0 100%;
    }
    .tc-laps th,
    .tc-laps td {
        padding: 9px 6px;
    }
    /* 分段表的水平退路。BS4 開窗時 .modal 是硬性 overflow-x: hidden，表格若因使用者把
       字級／頁面縮放調大而變寬，超出的欄位會被裁切且**捲不到**——那是 WCAG 2.1 AA
       1.4.10 Reflow 的內容遺失（DESIGN.md 訂 AA 為目標）。
       只在此斷點加：桌機放大到 200% 後 CSS 視寬也會落到 768px 以下，一併涵蓋。
       副作用是本斷點下 thead 的 sticky 會失效（wrapper 自己成為 scrollport）——
       「表頭不固定」遠優於「看不到欄位」，刻意如此取捨。 */
    .tc-laps-wrap {
        overflow-x: auto;
    }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .tc-spinner {
        animation: none;
        border-top-color: var(--tc-muted);
    }
    .tc-root *,
    .tc-root *::before,
    .tc-root *::after {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* ===========================================================================
 * 跳窗留言區（#1405 批次 3B-a）
 *
 * 設計取向與跳窗其他區塊一致：靠留白與字重分層，不畫框線盒子。氣泡只用極淡的
 * 底色區分「誰說的」，不用主綠 —— DESIGN.md 紅線把 #00AB7B 保留給 action，此處
 * 唯一的 action 是送出鈕。
 *
 * ⚠️ 對比度：本區所有次要文字走 --tcm-muted（跳窗專用 token，#6b7280＝對白底
 * 4.83:1 ✓，宣告與完整論證見本檔 :994），不用 --tc-muted（3.19:1 不達 AA）。
 * 氣泡底色刻意選極淡值，讓 --tc-ink 正文在其上仍遠高於 4.5:1。
 * =========================================================================== */
.tcm-comments .tcm-error {
    color: #b23c17;             /* 對白底 5.91:1 ✓ */
    margin: 0 0 .5rem;
}

.tcm-thread + .tcm-thread {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--tc-line, #e4e6e8);
}

.tcm-thread-peer {
    margin: 0 0 .5rem;
    font-size: var(--tcm-fs-sm);
    font-weight: 700;
    color: var(--tc-ink);
}

.tcm-msgs {
    list-style: none;
    margin: 0 0 .75rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.tcm-daysep {
    align-self: center;
    font-size: var(--tcm-fs-xs);
    color: var(--tcm-muted);
}

.tcm-msg {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
    max-width: 88%;
}

.tcm-msg--mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.tcm-msg-bubble {
    padding: .5rem .75rem;
    border-radius: 12px;
    background: #f1f3f5;
    color: var(--tc-ink);
    font-size: var(--tcm-fs-base);
    line-height: 1.5;           /* body 的固定 line-height:22px 會被繼承，必須明確覆蓋 */
    word-break: break-word;
}

/* 自己的訊息用極淡綠底（同已完成卡的語彙），不是主綠 */
.tcm-msg--mine .tcm-msg-bubble {
    background: #ebf4eb;
}

/* 留言內自動轉成的超連結：只靠連結色無法與內文區分（WCAG 1.4.1），一律加底線 */
.tcm-msg-bubble a {
    text-decoration: underline;
}

.tcm-msg-avatar {
    flex: 0 0 auto;
    line-height: 0;
}

.tcm-msg-meta {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .25rem;
    font-size: var(--tcm-fs-xs);
    color: var(--tcm-muted);
    white-space: nowrap;
}

.tcm-msg-time {
    font-size: inherit;
    color: inherit;
}

.tcm-msg-del {
    border: 0;
    background: none;
    padding: .25rem;
    color: var(--tcm-muted);
    cursor: pointer;
    line-height: 1;
    /* 觸控目標：視覺很小但可點範圍撐到 24px，避免手機誤觸隔壁 */
    min-width: 24px;
    min-height: 24px;
}

.tcm-msg-del:hover,
.tcm-msg-del:focus {
    color: #b23c17;
}

.tcm-form {
    display: flex;
    align-items: flex-end;
    gap: .5rem;
}

.tcm-input {
    flex: 1 1 auto;
    width: 100%;
    padding: .5rem .625rem;
    border: 1px solid var(--tc-line, #e4e6e8);
    border-radius: 8px;
    font-size: var(--tcm-fs-base);
    line-height: 1.5;
    color: var(--tc-ink);
    resize: vertical;
}

.tcm-input:focus {
    outline: 2px solid var(--rq-primary);   /* focus 屬 action 語彙，主綠正確 */
    outline-offset: 1px;
    border-color: var(--rq-primary);
}

.tcm-send {
    flex: 0 0 auto;
    min-width: 44px;
    /* 本站觸控門檻是 24px（docs/RQ_APP_DESIGN.md:240「網站 ≥ 24px、APP ≥ 44×44pt」）。
       送出鈕是本區唯一主要動作，刻意做到 44px＝比門檻寬裕，非規範要求。
       （DESIGN.md／PRODUCT.md 都沒有觸控尺寸條文，勿再引用它們。） */
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--rq-primary);
    color: #fff;
    cursor: pointer;
}

.tcm-send:disabled {
    opacity: .55;
    cursor: default;
}

@media (max-width: 767.98px) {
    .tcm-msg {
        max-width: 100%;
    }
}

/* ============================================================
   雙軌口徑標示 ＋ 配速／心率切換（#1405 批次 3B-d／3B-13）
   ============================================================
   GRACE 2026-08-05 教練團會議：「我實際跑的都有在心率範圍內，為什麼會顯示不同區。」
   成因是兩軌各用各的尺、而畫面上都沒有標示。標示是本批的最小交付；切換是進一步的能力。 */

/* 口徑標示緊貼軌道名稱，讀起來是「實際・配速區間」而不是另一個欄位。
   用 --tcm-fs-xs（12px 附註級距）＋ muted：它是限定詞不是標題，搶了層級反而蓋掉軌道名。 */
.tc-track-metric {
    margin-left: 6px;
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-xs);
    font-weight: 400;
    letter-spacing: 0;
}

/* 切換鍵：兩枚原生 button ＋ aria-pressed（不自刻 radiogroup，見 _trainingCardDetail.php）。
   放在實際軌上方、右對齊——它只作用於實際軌，貼著它才讀得出從屬關係。 */
.tc-metric-switch {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 16px 0 8px;
}
.tc-metric-switch-label {
    margin-right: 2px;
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-xs);
}
/* 指標不可用的原因。可見文字而非只靠 disabled 按鈕的 title（Codex review 第 2 輪）——
   disabled 天生不可 focus，鍵盤與觸控使用者讀不到 tooltip。用中性次要色，不用主綠
   （主綠只保留給 action，見 DESIGN.md）。 */
.tc-metric-reason {
    margin: 0 0 8px;
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-xs);
    line-height: 1.5;
}
.tc-metric-btn {
    min-height: 32px;          /* 本站觸控門檻 24px（docs/RQ_APP_DESIGN.md:240），此處寬裕 */
    padding: 0 12px;
    border: 1px solid var(--tc-border);
    border-radius: 999px;
    background: #fff;
    color: var(--tc-secondary);  /* 白底 7.35:1 */
    font-size: var(--tcm-fs-xs);
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 160ms cubic-bezier(.22, 1, .36, 1), background-color 160ms cubic-bezier(.22, 1, .36, 1);
}
/* 選中態用深綠底白字：aria-pressed 是唯一的狀態來源，樣式跟著它走而不是另立 class
   ——兩份狀態必然漂移，而漂移的症狀是「看起來選中、AT 卻說沒有」。 */
.tc-metric-btn[aria-pressed="true"] {
    border-color: var(--rq-dark);
    background: var(--rq-dark);
    color: #fff;
}
.tc-metric-btn:disabled {
    opacity: .5;
    cursor: default;
}
.tc-metric-btn:focus-visible {
    outline: 2px solid var(--rq-primary);   /* focus 屬 action 語彙，主綠正確 */
    outline-offset: 2px;
}

/* 兩條實際軌一次帶回、切換只 toggle 顯示。`hidden` 必須真的隱藏——.tc-track 沒有自己的
   display 宣告，但明寫一條免得日後有人給它 flex／grid 而讓 hidden 失效。 */
.tc-track[hidden] {
    display: none;
}

/* 分段表每列的雙圓點：由容器的 data-tc-metric 擇一顯示。
   ⚠️ **色值仍由 PHP 的 zoneColor() 出**（inline style），這裡只管顯示哪一枚——
   把七區色表複製進 CSS 會讓區間配色出現第二個 source of truth。
   ⚠️ 同一組選擇器同時作用在 sr-only 的區名上（兩者共用 [data-tc-zone]），
   確保螢幕閱讀器每列只讀到一個區名（另有 JS 同步的 aria-hidden 當第二道）。 */
.tc-laps-wrap[data-tc-metric="pace"] [data-tc-zone="hr"],
.tc-laps-wrap[data-tc-metric="hr"] [data-tc-zone="pace"] {
    display: none;
}
.tc-laps-zone {
    display: inline-flex;
    flex: 0 0 auto;
}

/* ============================================================
   跳窗配對動作列（#1405 批次 3B-b／3B-c／3B-14）
   ============================================================
   位置＝分段表之後、出口連結之前（決策 3B-7）：破壞性動作落在所有閱讀內容結束之後。
   ⚠️ 刻意**不**沿用 _recordWorkoutUnlink.php 那組 inline 色——它們是配著白底卡訂的，
   而且那支同時服務紀錄頁與課表頁，改它等於動到其他頁面。本區自己一套，跑跳窗的
   --tcm-fs-* 級距與 4.5:1 以上的對比。 */
.tc-match-state {
    margin: 0 0 10px;
    color: var(--tc-secondary);      /* 白底 7.35:1 */
    font-size: var(--tcm-fs-sm);
    line-height: 1.5;
}
.tc-match-state .fa-lock {
    margin-right: 4px;
    color: var(--tcm-muted);
}
.tc-match-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.tc-match-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--tc-border);
    border-radius: 8px;
    background: #fff;
    color: var(--rq-dark);           /* 白底 11.6:1；主綠留給出口（本跳窗唯一 action 綠） */
    font-size: var(--tcm-fs-sm);
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 160ms cubic-bezier(.22, 1, .36, 1), background-color 160ms cubic-bezier(.22, 1, .36, 1);
}
.tc-match-btn:hover:not(:disabled) {
    border-color: var(--rq-dark);
    background: var(--rq-pale);
}
.tc-match-btn:disabled {
    opacity: .5;
    cursor: default;
}
.tc-match-btn:focus-visible {
    outline: 2px solid var(--rq-primary);
    outline-offset: 2px;
}
/* 破壞性動作：白底實測 #b71c1c 為 7.4:1（同檔錯誤訊息已在用的深紅）。
   刻意**不用** _recordWorkoutUnlink.php 的 #d9534f——那個值在淺綠底只有 3.52:1，
   而它還是破壞性動作的確認鍵。 */
.tc-match-btn--danger {
    color: #b71c1c;
}
.tc-match-btn--danger:hover:not(:disabled) {
    border-color: #b71c1c;
    background: #fdf0f0;
}
.tc-match-btn--ghost {
    color: var(--tc-secondary);
}
.tc-match-unlink {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.tc-match-confirm {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.tc-match-confirm[hidden],
.tc-match-btn[hidden],
.tc-match-cands[hidden] {
    display: none;
}
.tc-match-hint {
    margin: 8px 0 0;
    color: var(--tc-secondary);
    font-size: var(--tcm-fs-xs);
    line-height: 1.5;
}
.tc-match-confirm .tc-match-hint {
    margin: 0;
    max-width: 32em;
}
.tc-match-error,
.tc-match-notice {
    margin: 10px 0 0;
    font-size: var(--tcm-fs-sm);
}
.tc-match-error {
    color: #b71c1c;
}
.tc-match-error[hidden],
.tc-match-notice[hidden] {
    display: none;
}
.tc-match-cands {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--tc-border);
}
.tc-match-cands-h {
    margin: 0 0 8px;
    color: var(--tcm-muted);
    font-size: var(--tcm-fs-xs);
}
.tc-match-cand-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.tc-match-cand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.tc-match-cand-sum {
    color: var(--tc-secondary);
    font-size: var(--tcm-fs-xs);
    line-height: 1.5;
}

@media (max-width: 767.98px) {
    /* 候選一行放不下課表名＋菜色摘要，摘要獨佔一行（同 .tc-rec-name 的既有處理） */
    .tc-match-cand-sum {
        flex-basis: 100%;
    }
}

/* 跳窗外殼的中性提示列（#1405 批次 3B）。放在標題與內容之間：它講的是「畫面剛被更正」，
   讀者需要在看內容之前先知道。.tc-modal-note 已定義色與字級，這裡只補間距。 */
.tc-modal-notice {
    margin: 12px 0 0;
}
.tc-modal-notice[hidden] {
    display: none;
}
