/* ═══════════════════════════════════════════════════════════════════════════
   public/css/weather-ai-brief.css — AI 解讀分頁（2026-11-14，weather 整體優化第 3 班，照定稿第 10、17 版）

   根 class 是 .wab，手機面板（底部面板）與桌機面板（左邊欄）用同一份，不綁哪一種面板：
   兩邊的底都是深色，所以顏色寫在 .wab 自己身上，不借 --msh-*（手機）或 --wx-*（桌機）那兩套。
   第 8 班把兩套顏色變數併成一套時，這裡跟著換。

   結構（標記在 pages/weather.html 的 #wab）：
     還沒讀／讀取中／結果／沒讀完／要登入  各一格（同一時間只出現一格，weather-ai-analysis.js 的 showState 切）
     最下面  這一趟之前的報告、全部的 AI 報告、那一句提醒

   「看完整解讀」裡面（總結＋逐日卡）照舊是淺色卡片（跟分享頁同一套），沒有改成深色——留到第 8 班。

   選擇器一律從 .wab 起頭（比頁內 <style> 的 .ai-state-empty 等舊規則多一層，不靠載入順序贏）。
   ═══════════════════════════════════════════════════════════════════════════ */

.wab {
  --wab-card: #2B3142;
  --wab-card-2: rgba(255, 255, 255, 0.03);
  --wab-line: rgba(174, 189, 212, 0.16);
  --wab-ink: #F5F1E8;
  --wab-ink-m: #AEBDD4;
  --wab-amber: #8A5636;          /* 主要動作的底（白字 6.1:1） */
  --wab-amber-ink: #F7D9B5;      /* 深底上的琥珀字 */
  --wab-amber-line: rgba(242, 195, 143, 0.5);
  --wab-warn: #F2B8A8;           /* 深底上的錯誤訊息（比 --pk-error 亮：那個是給淺底用的） */
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--wab-ink);
  font-size: 13.5px;
  line-height: 1.65;
  min-width: 0;
}
.wab [hidden] { display: none !important; }

/* ── 一張卡（還沒讀／沒讀完／要登入） ── */
.wab .wab-card,
.wab .wab-hero {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  gap: 0;
  padding: 14px;
  min-height: 0;
  border-radius: 14px;
  background: var(--wab-card);
  border: 1px solid var(--wab-line);
  color: var(--wab-ink);
}
.wab .wab-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; line-height: 1.4; color: var(--wab-ink); }
.wab .wab-desc { margin: 0 0 12px; font-size: 13.5px; line-height: 1.65; color: var(--wab-ink-m); }
.wab .wab-msg { margin: 0 0 10px; min-height: 0; font-size: 13px; line-height: 1.6; color: var(--wab-warn); }
.wab .wab-msg:empty { display: none; }
.wab .wab-bal { margin: 8px 0 0; font-size: 12.5px; color: var(--wab-ink-m); text-align: center; font-variant-numeric: tabular-nums; transition: color .4s ease; }
.wab .wab-bal.ai-empty-hint--success { color: #A8D5BA; }
.wab .wab-note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--wab-ink-m); }
.wab .wab-note a { color: inherit; }
.wab .wab-sp { flex: 1 1 auto; }

/* 主要動作（琥珀只給這一種） */
.wab .wab-cta {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--wab-amber);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: none;
  transform: none;
}
.wab .wab-cta > span { display: inline-flex; align-items: center; gap: 8px; }
.wab .wab-cta:hover:not([disabled]) { filter: brightness(1.08); transform: none; }
.wab .wab-cta[disabled] { background: #3A4052; color: var(--wab-ink-m); cursor: not-allowed; opacity: 1; }
.wab .wab-cta:focus-visible,
.wab .wab-obtn:focus-visible,
.wab .wab-cbtn:focus-visible,
.wab .wab-lnk:focus-visible,
.wab .wab-item:focus-visible,
.wab .wab-rowlink:focus-visible,
.wab .wab-full > summary:focus-visible { outline: 2px solid #E6B38A; outline-offset: 2px; }

/* 次要動作（繼續問、分享） */
.wab .wab-row2 { display: flex; gap: 8px; margin-top: 12px; }
.wab .wab-obtn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 12px;
  border: 1px solid var(--wab-line);
  background: var(--wab-card);
  color: var(--wab-ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.wab .wab-obtn > span:not(.ai-hero-banner__followup-dot) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wab .wab-obtn:hover:not([disabled]) { background: #323A4E; }
.wab .wab-obtn[disabled] { color: var(--wab-ink-m); cursor: not-allowed; opacity: .7; }
.wab .wab-obtn .ai-hero-banner__followup-dot { position: absolute; top: 8px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: #E6B38A; }

/* 文字連結（底線點線；可點範圍用 ::before 往外撐到 44） */
.wab .wab-more { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; }
.wab .wab-lnk {
  position: relative;
  border: 0;
  background: none;
  padding: 0;
  color: var(--wab-ink-m);
  font-family: inherit;
  font-weight: 600;
  font-size: 12.5px;
  line-height: 1.6;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
.wab .wab-lnk::before { content: ""; position: absolute; inset: -12px -8px; }
.wab .wab-lnk:hover { color: var(--wab-ink); }

/* 小顆的琥珀框鈕（重新解讀、移除） */
.wab .wab-cbtn {
  position: relative;
  flex: none;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid rgba(242, 195, 143, 0.6);
  background: none;
  color: var(--wab-amber-ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
}
.wab .wab-cbtn::before { content: ""; position: absolute; inset: -4px -2px; }
.wab .wab-cbtn[disabled] { opacity: .55; cursor: not-allowed; }

/* ── 讀取中 ── */
.wab .wab-loading {
  display: grid;
  gap: 10px;
  place-items: center;
  justify-content: stretch;
  padding: 28px 0;
  min-height: 0;
  text-align: center;
  color: var(--wab-ink-m);
  font-size: 13.5px;
  line-height: 1.6;
}
.wab .wab-loading__t { color: var(--wab-ink); font-size: 15px; }
.wab .wab-loading__m { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.wab .wab-loading__m:empty { display: none; }
/* 不知道還要多久的那種進度條：一小段來回跑。減少動態效果時停在中間。 */
.wab .wab-bar { width: 100%; max-width: 260px; height: 4px; border-radius: 2px; background: rgba(174, 189, 212, 0.18); overflow: hidden; }
.wab .wab-bar > i { display: block; width: 36%; height: 100%; border-radius: 2px; background: #E6B38A; animation: wab-ind 1.6s ease-in-out infinite; }
@keyframes wab-ind { 0% { transform: translateX(-110%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .wab .wab-bar > i { animation: none; margin: 0 auto; } }

/* ── 結果 ── */
.wab .ai-state-result { display: block; }
.wab .wab-hero { gap: 0; }
.wab .wab-rerun {
  display: grid;
  gap: 4px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(242, 195, 143, 0.1);
  border: 1px solid rgba(242, 195, 143, 0.35);
  color: var(--wab-amber-ink);
  font-size: 13px;
  line-height: 1.55;
}
.wab .wab-rerun > b { font-size: 13.5px; }
.wab .wab-rerun .wab-bar { max-width: none; margin: 2px 0; }
.wab .wab-rerun__m { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--wab-ink-m); }

.wab .wab-meta { margin: 0 0 8px; font-size: 12.5px; line-height: 1.55; color: var(--wab-ink-m); font-variant-numeric: tabular-nums; }
.wab .wab-other { display: flex; gap: 6px; align-items: flex-start; margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: rgba(174, 189, 212, 0.1); font-size: 13px; line-height: 1.55; color: var(--wab-ink); }
.wab .wab-other .pk-i { flex: none; margin-top: 3px; color: var(--wab-ink-m); }
/* 那一行右邊的「回到畫面上這一趟」：放不下就折到下一行、靠右 */
.wab .wab-other { flex-wrap: wrap; }
.wab .wab-other > span { flex: 1 1 200px; min-width: 0; }
.wab .wab-other > .wab-cbtn { margin-left: auto; }
.wab .wab-agree { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 2px; }
.wab .wab-agree__d { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: rgba(174, 189, 212, 0.14); font-size: 12.5px; color: var(--wab-ink-m); white-space: nowrap; }
.wab .wab-agree__d b { color: var(--wab-ink); font-weight: 700; }
.wab .wab-agree__d.is-low { background: rgba(242, 195, 143, 0.14); color: var(--wab-amber-ink); }
.wab .wab-agree__d.is-low b { color: var(--wab-amber-ink); }

.wab .wab-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.wab .wab-item {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--wab-line);
  background: var(--wab-card-2);
  color: var(--wab-ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-sizing: border-box;
}
.wab div.wab-item--static { cursor: default; }
.wab button.wab-item:hover { background: rgba(255, 255, 255, 0.07); }
.wab .wab-item > .pk-i { flex: none; color: var(--wab-ink-m); }
.wab .wab-item__tx { flex: 1 1 auto; min-width: 0; }
.wab .wab-item__tx small { display: block; margin-bottom: 2px; color: var(--wab-ink-m); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* 一條最多三行（AI 的一句話最長看過一百五十幾個字）；完整的在「看完整解讀」裡 */
.wab .wab-item__t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; }
.wab .wab-none { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--wab-line); color: var(--wab-ink-m); font-size: 13px; }

/* 看完整解讀：收合；裡面照舊是淺色卡片 */
.wab .wab-full { margin-top: 12px; border-top: 1px solid var(--wab-line); padding-top: 2px; }
.wab .wab-full > summary { min-height: 44px; display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; cursor: pointer; list-style: none; color: var(--wab-ink); }
.wab .wab-full > summary::-webkit-details-marker { display: none; }
.wab .wab-full > summary .pk-i { color: var(--wab-ink-m); }
.wab .wab-full[open] .wab-full__chev { transform: rotate(180deg); }
.wab .wab-full__body { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 6px; min-width: 0; }
.wab .wab-full__body .ai-meta { margin: 0; color: var(--wab-ink-m); }

/* 預報更新過／時間改過 */
.wab .wab-newer { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 6px 6px 10px; border-radius: 10px; background: rgba(242, 195, 143, 0.1); border: 1px solid rgba(242, 195, 143, 0.35); font-size: 13px; line-height: 1.5; color: var(--wab-amber-ink); }
.wab .wab-newer > .pk-i { flex: none; }
.wab .wab-newer__t { flex: 1 1 auto; min-width: 0; padding: 4px 0; }

/* 移除前再問一次 */
.wab .wab-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(174, 189, 212, 0.1); font-size: 13px; color: var(--wab-ink); }
.wab .wab-ask > span { flex: 1 1 180px; min-width: 0; }

/* 重新解讀的時候：底下那幾顆先不能按，報告本身照常看 */
.wab .ai-state-result.is-rerunning .wab-more { opacity: .6; pointer-events: none; }

/* ── 最下面：報告清單 ── */
.wab .wab-reports { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.wab .wab-sec > h5 { margin: 2px 0 6px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; color: var(--wab-ink-m); }
.wab .wab-allrep { margin: 0; }
.wab .wab-rowlink {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--wab-line);
  background: var(--wab-card);
  color: var(--wab-ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}
.wab .wab-rowlink[disabled] { cursor: default; color: var(--wab-ink-m); }
.wab .wab-rowlink > .pk-i,
.wab .wab-rowlink__chev { flex: none; color: var(--wab-ink-m); display: inline-flex; }
.wab .wab-rowlink small { font-weight: 500; font-size: 12.5px; color: var(--wab-ink-m); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wab .wab-rowlink[aria-expanded="true"] .wab-rowlink__chev { transform: rotate(90deg); }
.wab .wab-replist { display: grid; gap: 6px; }
.wab .wab-allrep .wab-replist { margin-top: 8px; max-height: none; }
.wab .wab-replist .report-card { margin: 0; }
.wab .wab-replist .report-card:hover { transform: none; }
.wab .wab-replist .report-card.is-current { border-color: rgba(230, 179, 138, 0.6); }
.wab .wab-replist .report-card__title { font-size: 13.5px; font-weight: 700; color: var(--wab-ink); }
.wab .wab-replist .report-card__meta { font-size: 12.5px; color: var(--wab-ink-m); font-variant-numeric: tabular-nums; }
.wab .wab-replist .report-card__delete { min-width: 36px; min-height: 36px; }
.wab .wab-replist .ai-history-empty { padding: 12px; border-radius: 12px; border: 1px dashed var(--wab-line); color: var(--wab-ink-m); font-size: 13px; text-align: left; }
.wab .wab-replist .ai-history-empty small { display: block; margin-top: 2px; font-size: 12.5px; }

.wab .wab-dis { margin: 2px 2px 0; font-size: 12.5px; line-height: 1.6; color: var(--wab-ink-m); }

/* 手機面板的「AI 報告」那一頁（開場點「AI 報告」）：平常只有清單；打開了一份才放出報告本身。
   （原本的規則在 weather-mobile-panel.css，認的是舊的排法；第 3 班起由這裡管。） */
@media (max-width: 768px) {
  #mobile-sheet.msh-on[data-mscreen="reports"]:not([data-mrep="1"]) #wab > :not(#wab-reports):not(.wab-dis) { display: none !important; }
  /* 🔴 新頁面可能配到瀏覽器快取裡舊的 weather-mobile-panel.css（同檔名、快取一小時）：那一份的規則是
     「#tab-main-ai-analysis > :not(#ai-history-bar) { display:none !important }」，會把整個 #wab 藏掉——這一頁就整頁空白。
     這一條比它多一個 id、同樣帶 !important，不管哪一份先載入都贏；這個檔是新檔名，新頁面拿到的一定是這一份（2026-11-14 審查）。 */
  #mobile-sheet.msh-on[data-mscreen="reports"]:not([data-mrep="1"]) #tab-main-ai-analysis > #wab:not(#ai-history-bar) { display: flex !important; }
  #mobile-sheet.msh-on[data-mscreen="reports"]:not([data-mrep="1"]) #wab-trip-reports { display: none !important; }
  /* 那一頁的清單一律攤開（不必再點一次那一列） */
  #mobile-sheet.msh-on[data-mscreen="reports"]:not([data-mrep="1"]) #ai-history-list { display: grid !important; }
  #mobile-sheet.msh-on[data-mscreen="reports"]:not([data-mrep="1"]) #ai-history-toggle .wab-rowlink__chev { display: none; }
  /* 手指：連結與小鈕的可點範圍 */
  .wab .wab-cbtn { min-height: 40px; }
}
