/*
 * 策略實驗室（/backtest）專屬樣式。
 * 沿用 app.css 的 CSS 變數（--bg-*, --card-bg, --text*, --accent, --border...），
 * 這裡只放本頁獨有的版面，不重複定義全域 tokens。app.css 本身禁止修改
 * （另一棒施工中），本頁所有新元件（wizard/template card/tooltip/modal）都
 * 在本檔自帶一份等效樣式，不依賴尚未 commit 的 app.css 共用元件。
 */

/* ---------- HERO ---------- */

.bt-hero {
  margin: 4px 0 20px;
}

.bt-hero-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.bt-hero-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 640px;
}

.bt-intro h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--text);
}

.bt-intro p {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* .bt-paywall* 已於任務#123 退役：付費牆換裝為全域 .sv-paywall-card
   插畫解鎖卡（見 app.css 該 class 定義處、backtest.html #bt-paywall 用法），
   舊版純文字卡片 CSS 移除。 */

/* ---------- 三步驟導覽條 ---------- */

.bt-wizard-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  padding: 4px 0;
  overflow-x: auto;
}

.bt-wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px 8px 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: border-color 150ms var(--ease), background 150ms var(--ease), color 150ms var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
}

.bt-wizard-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.bt-wizard-step-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.25;
}

/* 任務#81 指揮官新增：燈號下方白話狀態文字（已選：xxx／參數已就緒／
   已有成績單…），不只靠顏色，直接把「這步驟目前狀態」寫出來。 */
.bt-wizard-step-status {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-faint);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bt-wizard-step-status:empty {
  display: none;
}

/* 「目前編輯中」：脈衝高亮，與 .done（完成度）是正交的兩個維度，同一顆燈
   可以同時是「目前在編輯」又「尚未完成」，或「已完成」但「不是目前焦點」。 */
.bt-wizard-step.active {
  border-color: var(--brand-blue);
  background: var(--accent-bg);
  color: var(--text);
  animation: bt-wizard-pulse 1.8s ease-in-out infinite;
}

.bt-wizard-step.active .bt-wizard-step-num {
  background: var(--brand-gradient);
  color: var(--on-accent);
}

@keyframes bt-wizard-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--brand-blue-rgb), 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(var(--brand-blue-rgb), 0); }
}

/* 完成度：刻意不用 --up/--down（漲跌語意只准用於行情事實），改用品牌色
   打勾，與「目前編輯中」的漸層底色區分開來。 */
.bt-wizard-step.done .bt-wizard-step-num {
  background: var(--brand-cyan);
/* theme-exempt: 缺 token --on-brand-deep —— #001428 是「品牌青/漸層底上的
   極深字」，語意上對應 --on-brand 但其值為 #06222b（不同值，換上去深色
   外觀會變）；待下一波補 --on-brand-deep 後收斂。 */
  color: #001428;
}

.bt-wizard-step.done .bt-wizard-step-status {
  color: var(--brand-cyan-text);
}

/* 執行中：用旋轉圈取代數字圈（比照全站既有 .spinner 慣例，縮小尺寸嵌進
   步驟燈圓圈）。 */
.bt-wizard-step.running .bt-wizard-step-num {
  background: transparent;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand-cyan);
  animation: bt-spin 700ms linear infinite;
}

@keyframes bt-spin {
  to { transform: rotate(360deg); }
}

.bt-wizard-connector {
  flex: 1 1 16px;
  min-width: 12px;
  max-width: 40px;
  height: 1px;
  background: var(--border-strong);
}

/* ---------- STEP 區塊 ---------- */

.bt-step {
  scroll-margin-top: 16px;
}

.bt-step-header {
  margin-bottom: 14px;
}

.bt-step-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand-cyan-text);
  background: rgba(var(--brand-cyan-rgb), 0.1);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 6px;
}

.bt-step-header h2 {
  margin: 0 0 4px;
  font-size: 19px;
  color: var(--text);
}

.bt-step-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.bt-step-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}

.bt-step-next,
.bt-step-prev {
  align-self: flex-start;
  margin-top: 4px;
}

/* ---------- 策略範本卡 ---------- */

.bt-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.bt-template-card {
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 150ms var(--ease), background 150ms var(--ease), transform 150ms var(--ease);
  color: inherit;
  font: inherit;
}

.bt-template-card:hover {
  border-color: var(--brand-blue);
  background: var(--card-bg-hover);
  transform: translateY(-1px);
}

.bt-template-card.selected {
  border-color: var(--brand-cyan);
  background: var(--accent-bg);
  box-shadow: var(--glow);
}

.bt-template-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bt-template-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand-cyan-text);
  background: rgba(var(--brand-cyan-rgb), 0.1);
  border-radius: 6px;
  padding: 1px 6px;
}

.bt-template-blurb {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.bt-template-rules {
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------- 白話 tooltip ---------- */

.bt-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  position: relative;
  padding: 0;
  vertical-align: middle;
  margin-left: 4px;
}

.bt-help:hover,
.bt-help:focus-visible,
.bt-help.bt-help-open {
  border-color: var(--brand-cyan);
  color: var(--brand-cyan-text);
  outline: none;
}

.bt-help::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 260px;
  /* 2026-08-01 對比修復：原本寫死 #05080f 蓋 theme-exempt 章（「無同值代幣」
     ——判準錯誤，見 app.css :root 區塊 (h)）。這是承字說明氣泡，改接
     --overlay-surface；深色從 #05080f 變 #0c101b，同屬近黑，肉眼難辨。 */
  background: var(--overlay-surface);
  color: var(--on-overlay);
  border: 1px solid var(--overlay-surface-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  box-shadow: var(--shadow-pop);
  display: none;
  z-index: 20;
  white-space: normal;
}

.bt-help:hover::after,
.bt-help:focus-visible::after,
.bt-help.bt-help-open::after {
  display: block;
}

/* ---------- 已儲存策略 ---------- */

.bt-saved-card h3 {
  margin-bottom: 4px;
}

.bt-save-row {
  display: flex;
  gap: 8px;
  margin: 10px 0 12px;
  flex-wrap: wrap;
}

.bt-save-row input[type="text"] {
  flex: 1 1 220px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}

.bt-saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bt-saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  flex-wrap: wrap;
}

.bt-saved-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.bt-saved-item-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: 8px;
}

.bt-saved-item-actions {
  display: flex;
  gap: 6px;
}

.bt-saved-item-actions button {
  padding: 5px 12px;
  font-size: 12px;
}

.bt-saved-empty {
  color: var(--text-faint);
  font-size: 12.5px;
}

/* ---------- 表單 ---------- */

.bt-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bt-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.bt-card h3 {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--text);
}

.bt-rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bt-rule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
}

.bt-rule-row.disabled {
  opacity: 0.55;
}

.bt-rule-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  flex: 1 1 200px;
}

.bt-rule-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.bt-rule-name {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
}

.bt-rule-desc {
  color: var(--text-muted);
  font-size: 12px;
  display: block;
  margin-top: 2px;
}

.bt-rule-example {
  color: var(--text-faint);
  font-size: 11.5px;
  display: block;
  margin-top: 2px;
  font-style: italic;
}

/* 任務#70：規則說明旁的「深入學習 →」連結（由 web/static/learn_links.js
   makeLearnLink() 產生，class="sv-learn-link"，這裡疊加 bt-rule-learn-link
   補版面與配色，比照全站既有 .sv-learn-link hover 慣例）。 */
.bt-rule-learn-link {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: none;
}

.bt-rule-learn-link:hover {
  color: var(--accent-text);
  text-decoration: underline;
}

.bt-rule-params {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.bt-rule-param {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bt-rule-param label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.bt-rule-param input {
  width: 84px;
}

.bt-lookahead-badge {
  font-size: 11px;
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}

.bt-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.bt-field-row label {
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
}

.bt-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.bt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bt-field label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.bt-form input[type="number"],
.bt-form input[type="date"] {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}

.bt-hint {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.6;
  margin: 12px 0 0;
}

.bt-run-btn {
  align-self: flex-start;
  background: var(--accent);
/* theme-exempt: 缺 token --on-brand-deep —— #001428 是「品牌青/漸層底上的
   極深字」，語意上對應 --on-brand 但其值為 #06222b（不同值，換上去深色
   外觀會變）；待下一波補 --on-brand-deep 後收斂。 */
  color: #001428;
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  cursor: pointer;
}

.bt-run-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bt-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  margin: 18px 0;
}

/* 回測 async job 化（2026-07-19）：輪詢期間顯示「第 X/Y 個訊號日」進度條，
   跟在 .bt-loading 下面，同一組 display:none/flex 顯示切換節奏。 */
.bt-progress-wrap {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin: -8px 0 18px;
}

.bt-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
}

.bt-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--brand-gradient);
  transition: width 300ms var(--ease);
}

.bt-progress-text {
  font-size: 12px;
  color: var(--text-muted);
}

.bt-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  margin: 18px 0;
}

.bt-result {
  margin-top: 8px;
}

/* ---------- KPI 主列 ---------- */

.bt-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.bt-kpi-box {
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 16px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.bt-kpi-box .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.bt-kpi-box .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

/* 任務#81 指揮官回饋：KPI 卡白話副標（不只靠 ? tooltip，直接可見） */
.bt-kpi-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.4;
}

/* 最大回檔：琥珀色警示語感（正值百分比但代表虧損，需要視覺上與漲跌紅綠區分） */
.bt-kpi-value-amber {
  color: var(--warn-fg) !important;
}

/* vs 大盤：策略/大盤雙值並列，取代單一差值（差值嚇人且難懂） */
.bt-kpi-value-dual {
  font-size: 15px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.bt-kpi-vs-sep {
  color: var(--text-faint);
  font-weight: 400;
}

.bt-kpi-vs-bench {
  color: var(--text-muted);
  font-weight: 700;
}

/* ---------- 進階指標（次要，摺疊） ---------- */

.bt-advanced-details summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bt-advanced-details summary::-webkit-details-marker {
  display: none;
}

.bt-advanced-details summary::before {
  content: "▸";
  color: var(--text-faint);
  transition: transform 150ms var(--ease);
}

.bt-advanced-details[open] summary::before {
  transform: rotate(90deg);
}

.bt-advanced-details .bt-stats-grid {
  margin-top: 14px;
}

.bt-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.bt-stat-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
}

.bt-stat-box .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.bt-stat-box .value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* .metric-row 是 stock.css 的既有慣例，本頁不載入 stock.css，故在此自帶一份
   同款樣式（避免改動 stock.css，也避免整頁多載一份不相干的樣式表）。 */
.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-row .label {
  color: var(--text-muted);
}

.metric-row .value {
  font-weight: 700;
  color: var(--text);
}

.bt-benchmark-def {
  font-size: 12px !important;
  color: var(--text-faint) !important;
  font-weight: 400 !important;
  text-align: right;
  max-width: 60%;
}

/* ---------- 權益曲線（雙線） ---------- */

.bt-chart-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.bt-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bt-legend-swatch {
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
}

.bt-legend-strategy {
  background: var(--brand-cyan);
}

.bt-legend-benchmark {
  background: var(--text-faint);
  background-image: repeating-linear-gradient(90deg, var(--text-muted) 0 5px, transparent 5px 9px);
}

.bt-chart-wrap {
  position: relative;
}

#bt-equity-canvas {
  width: 100%;
  height: 240px;
  display: block;
}

.bt-chart-tooltip {
  position: absolute;
  pointer-events: none;
  /* 2026-08-01 對比修復：同上 .bt-help::after，改接深色浮層承字面代幣族。 */
  background: var(--overlay-surface);
  border: 1px solid var(--overlay-surface-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--on-overlay);
  line-height: 1.6;
  box-shadow: var(--shadow-pop);
  z-index: 5;
  white-space: nowrap;
}

/* ---------- 逐筆交易表 ---------- */

.bt-trades-table-wrap,
.bt-preview-list-wrap {
  overflow-x: auto;
}

.bt-trades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.bt-trades-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.bt-trades-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

.bt-trades-table tbody tr:hover {
  background: var(--bg-2);
}

.bt-trades-table .up {
  color: var(--up);
  font-weight: 700;
}

.bt-trades-table .down {
  color: var(--down);
  font-weight: 700;
}

.bt-trades-table .flat {
  color: var(--text-muted);
}

.bt-trades-table a {
  color: var(--brand-cyan-text);
  text-decoration: none;
}

.bt-trades-table a:hover {
  text-decoration: underline;
}

/* 任務#81 指揮官回饋「逐筆交易表太薄弱像黑箱」新增：數字欄右對齊＋等寬
   數字，命中規則欄允許換行（主要資訊禁截斷，見 docs/design_system.md
   §7.5），其餘短欄位維持 nowrap（日期/天數本來就不需要換行）。 */
.bt-trades-table .bt-trades-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bt-trades-table td[data-label="命中規則"],
.bt-trades-table td[data-label="股票"] {
  white-space: normal;
}

.bt-trades-summary {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* 命中規則 chips */
.bt-rule-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 220px;
}

.bt-rule-chip {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand-cyan-text);
  background: rgba(var(--brand-cyan-rgb), 0.1);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* 產業類別籤（任務#92）：股票名旁的淡色小籤，特意用藍色（呼應全站既有
   .industry-badge 語意）而非命中規則的青色，兩種籤並排時一眼可辨。 */
.bt-trade-stock-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.bt-industry-chip {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand-blue);
  background: var(--accent-bg);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* 同窗大盤：贏/輸小圓點（中性藍/灰，不用紅綠——這是「贏過大盤與否」的
   結果分類，不是行情漲跌事實本身，比照全站語意色規則）。 */
.bt-bench-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 2px;
}

.bt-bench-dot.win {
  background: var(--brand-cyan);
}

.bt-bench-dot.lose {
  background: var(--text-faint);
}

/* 最佳/最差一筆：整列淡色高亮＋小標籤 */
.bt-trade-row-best {
  background: rgba(var(--brand-cyan-rgb), 0.06);
}

.bt-trade-row-worst {
  background: rgba(var(--watch-rgb), 0.06);
}

.bt-trade-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.bt-trade-tag-best {
  color: var(--brand-cyan-text);
  background: rgba(var(--brand-cyan-rgb), 0.14);
}

.bt-trade-tag-worst {
  color: var(--warn-fg);
  background: var(--warn-bg);
}

/* 任務#81：欄數多（11欄），窄螢幕降卡片式兩行制，取代水平硬擠／截斷，
   比照 docs/design_system.md §7 時間軸流列版式的響應式精神（欄位資訊改用
   垂直空間换取可讀性）。data-label 由 JS renderTradesTable() 寫在每個
   td 上，CSS 用 ::before 還原成欄名。 */
@media (max-width: 720px) {
  .bt-trades-table thead {
    display: none;
  }

  .bt-trades-table,
  .bt-trades-table tbody,
  .bt-trades-table tr,
  .bt-trades-table td {
    display: block;
    width: 100%;
  }

  .bt-trades-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px 10px;
  }

  .bt-trades-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    white-space: normal;
    text-align: right;
  }

  .bt-trades-table td:last-child {
    border-bottom: none;
  }

  .bt-trades-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    flex-shrink: 0;
    text-align: left;
  }

  .bt-rule-chips {
    justify-content: flex-end;
    max-width: none;
  }
}

/* ---------- 誠實聲明 ---------- */

.bt-disclosure-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bt-disclosure-list li {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

.bt-disclosure-list strong {
  color: var(--text);
  font-weight: 700;
  margin-right: 4px;
}

/* ---------- 底部操作列（接回選股） ---------- */

.bt-action-row {
  display: flex;
  justify-content: center;
  margin: 20px 0 8px;
}

/* ---------- 「看今日符合此策略」彈窗 ---------- */
/* 獨立殼（不複用 .info-modal-*：那是純靜態說明彈窗，語意不同，見 app.css
   該 class 旁的既有註解，本頁沿用相同分離原則）。 */

.bt-preview-overlay {
  position: fixed;
  inset: 0;
  /* theme-exempt: 缺 token --overlay-deep —— 遮罩基色 rgb(5,8,16) 與
     --scrim-rgb(11,15,26) 不同值，換上去深色外觀會變。 */
  background-color: rgba(5, 8, 16, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 220;
  animation: fadeIn 150ms var(--ease);
}

.bt-preview-overlay[hidden] {
  display: none !important;
}

.bt-preview-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 24px 26px;
  max-width: 620px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
}

.bt-preview-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--text);
}

.bt-preview-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.bt-preview-close:hover {
  color: var(--text);
}

.bt-preview-count {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.bt-preview-count strong {
  color: var(--brand-cyan-text);
  font-size: 16px;
}

/* ---------- 怎麼用導覽卡（任務#81 M3） ---------- */

.bt-tutorial-card {
  background: var(--accent-bg);
  border-color: var(--brand-blue);
}

.bt-tutorial-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.bt-tutorial-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.bt-tutorial-step-num {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 800;
}

.bt-tutorial-step-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.bt-tutorial-step-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.5;
}

.bt-tutorial-why-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.bt-tutorial-why-list {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

.bt-tutorial-why-list strong {
  color: var(--text);
}

.bt-tutorial-demo-btn {
  margin: 0;
}

.bt-demo-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-bg);
  border: 1px solid var(--brand-blue);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ---------- 範本卡策略示意小圖（任務#81 M3） ---------- */

.bt-template-icon {
  display: block;
  margin-bottom: 8px;
}

/* ---------- K線型態子集多選（任務#81 M2，比照 app.css .rule-pattern-* 既有樣式） ---------- */

.bt-rule-pattern-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  width: 100%;
  padding-left: 4px;
}

.bt-rule-pattern-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

/* ---------- 產業/主題篩選雙欄（任務#81 M2） ---------- */

.bt-field-grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* ---------- 持有天數快速對比（任務#81 M3 亮點①） ---------- */

#bt-compare-holding-btn {
  margin-bottom: 4px;
}

.bt-compare-holding-progress-text {
  white-space: normal;
}

/* ==========================================================================
   四格卡通說服卡（任務#88 M1；任務#116 換裝為品牌插畫）
   -------------------------------------------------------------------------
   桌機 4 欄、行動版 2×2（見下方 480px 媒體查詢）。圖改用品牌機器人插畫
   （ill_06~09.webp，900×672，4:3），容器裁切維持統一比例＋卡片圓角，
   載入用純 CSS fade-in（無 JS 開銷）。
   ========================================================================== */

.bt-persuade-section {
  margin: 24px 0 28px;
}

.bt-persuade-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.bt-persuade-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow-card);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
}

.bt-persuade-svg-wrap {
  margin: -16px -16px 10px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg-2);
}

.bt-persuade-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  animation: bt-img-fadein 0.5s ease forwards;
}

@keyframes bt-img-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bt-persuade-title {
  margin: 2px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.bt-persuade-quote {
  margin: 0 0 4px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

.bt-persuade-quote-a {
  color: var(--text-faint);
  font-style: italic;
}

.bt-persuade-quote-b {
  color: var(--text);
  font-weight: 600;
}

.bt-persuade-strong {
  font-size: 15px;
  font-weight: 800;
  margin: 0 4px;
}

.bt-persuade-legend {
  margin: 0 0 8px;
}

/* ==========================================================================
   證明區「回測回答了什麼」（任務#88 M2）
   ========================================================================== */

.bt-proof-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 24px;
}

.bt-proof-title {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text);
}

.bt-proof-lead {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 720px;
}

.bt-proof-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.bt-proof-card {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.bt-proof-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.bt-proof-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.bt-proof-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bt-proof-stat-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bt-proof-stat-label {
  font-size: 11px;
  color: var(--text-faint);
}

.bt-proof-vs {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-faint);
  text-align: center;
}

.bt-proof-conclusion {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 14px;
  line-height: 1.6;
}

.bt-proof-cta {
  margin: 0 0 12px;
}

.bt-proof-hint {
  margin: 0;
}

/* ==========================================================================
   一句話總評＋策略人格標籤（任務#88 M3①③）
   ========================================================================== */

.bt-verdict-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--accent-bg);
  border: 1px solid var(--brand-blue);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.bt-verdict-text {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  flex: 1;
}

.bt-persona-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
/* theme-exempt: 缺 token --on-brand-deep —— #001428 是「品牌青/漸層底上的
   極深字」，語意上對應 --on-brand 但其值為 #06222b（不同值，換上去深色
   外觀會變）；待下一波補 --on-brand-deep 後收斂。 */
  color: #001428;
  background: var(--brand-gradient);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

/* 已儲存策略清單項目上的人格徽章（存檔當下的判讀快照，比主徽章小一號） */
.bt-persona-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--brand-cyan-text);
  background: rgba(var(--brand-cyan-rgb), 0.1);
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  white-space: nowrap;
}

/* ==========================================================================
   最糟時點體感卡（任務#88 M3②）
   ========================================================================== */

.bt-worst-moment-text {
  margin: 0 0 4px;
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.6;
}

.bt-worst-moment-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---------- 響應式（行動版） ---------- */

@media (max-width: 480px) {
  .bt-wizard-step-label {
    display: none;
  }

  .bt-wizard-step {
    padding: 8px;
  }

  .bt-kpi-grid,
  .bt-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bt-step-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .bt-step-actions .bt-run-btn,
  .bt-step-actions .bt-step-prev {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* 四格卡通說服卡：行動版 2×2（任務#88 M1 規格明定） */
  .bt-persuade-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .bt-persuade-card {
    padding: 12px 12px 14px;
  }

  .bt-persuade-svg-wrap {
    margin: -12px -12px 8px;
  }

  /* 證明區兩張迷你成績單：窄版改上下堆疊，VS 徽章轉水平置中 */
  .bt-proof-grid {
    grid-template-columns: 1fr;
  }

  .bt-proof-vs {
    padding: 2px 0;
  }

  .bt-verdict-box {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* 證明區兩張迷你成績單：中寬（平板）也先改上下堆疊，避免每張卡被擠到過窄 */
@media (max-width: 720px) {
  .bt-proof-grid {
    grid-template-columns: 1fr;
  }

  .bt-proof-vs {
    padding: 2px 0;
  }
}
