/* ============================================================
   生存報告 — 三區式版面(反思模式為唯一版面)
   左 3/5 區:上排=族群變化(+棲地分頁) | 觸發事件
              下排=偵查報告紀錄 | 新偵查報告內容
   右 2/5 區:AI 對話(縱向貫穿,自 head 下方到 CTA 上方)
   ============================================================ */

.hd-report {
  position: relative;
  z-index: 1;
  height: calc(100% - var(--hd-topbar-h));
  /* 2026-06-02:上下 padding 收小,讓每一塊(含 header)上下緻密 */
  padding: 1px 12px;
  display: grid;
  grid-template-columns: 3fr 2fr;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px 10px;
  overflow: hidden;
}

/* head 跨整列(標題 + 兩張統計卡;2026-06-02 去大回合數字/kicker) */
.hd-report__head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--hd-line);
  padding-bottom: 1px;
}
.hd-report__title {
  font-family: var(--hd-font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--hd-ink);
  margin: 0;
  white-space: nowrap;
}

.hd-report-summary { display: flex; gap: 10px; }
.hd-stat-card {
  background: var(--hd-card);
  border: 1.5px solid var(--hd-line-soft);
  border-radius: var(--hd-radius);
  padding: 6px 18px;
  display: flex; align-items: center; gap: 12px;
}
.hd-stat-card__lbl {
  font-family: var(--hd-font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--hd-ink-soft);
  white-space: nowrap;
}
.hd-stat-card__val {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 32px;
  color: var(--hd-ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: baseline; gap: 4px;
}
.hd-stat-card__val--pos { color: var(--hd-success); }
.hd-stat-card__val--neg { color: var(--hd-danger); }
.hd-stat-card__arrow { font-size: 22px; }
.hd-stat-card__sub {
  font-size: 20px;
  color: var(--hd-success);
  font-weight: 600;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 2px;
}

/* ── 左 3/5 區:上/下兩排 ─────────────────────────────────── */
/* 2026-06-02:下排(偵查列表)高度 −15%,空間讓給上排(結算 + 事件向下延伸) */
.hd-report__main {
  display: grid;
  grid-template-rows: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 8px;
  min-height: 0;
  min-width: 0;
}
.hd-report__top,
.hd-report__bot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}
/* 上排左:分頁 + 變化清單;為了讓分頁與卡分離成兩塊獨立元件,wrap 用 grid 把高度分配 */
.hd-report__changes-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
  min-width: 0;
}

/* ── 右 2/5 區:AI 對話(縱向貫穿 row 2)────────────────────── */
.hd-report__chat {
  display: flex;
  min-height: 0;
  min-width: 0;
}
.hd-report__chat .hd-chat { width: 100%; }

/* ── 棲地分頁 ────────────────────────────────────────────── */
.hd-report-tabs {
  display: flex;
  gap: 6px;
  align-items: stretch;
  overflow: hidden; /* 2026-06-03 最後防線:4 棲地分頁不溢出到事件區 */
}
.hd-report-tab {
  --hd-habitat-color: var(--hd-ink-muted);
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: 10px;
  font-family: var(--hd-font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--hd-ink-soft);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  min-width: 0;
}
.hd-report-tab:hover {
  background: var(--hd-paper);
  color: var(--hd-ink);
}
.hd-report-tab__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hd-report-tab--active {
  background: var(--hd-habitat-color);
  border-color: var(--hd-habitat-color);
  color: white;
}

/* ── 族群變化清單(結算;2026-06-02:上下 padding 1px 緻密、文字放大、name/detail 直疊)── */
.hd-report-changes {
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius-lg);
  padding: 1px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
}
.hd-report-changes__head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 1px 0;
  border-bottom: 1px dashed var(--hd-line);
}
.hd-report-changes__habitat {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 25px;
  color: var(--hd-ink);
}
.hd-report-changes__numline {
  margin-left: auto;
  font-size: 18px;
  color: var(--hd-ink-soft);
  white-space: nowrap;
}
.hd-report-changes__numline strong {
  color: var(--hd-ink);
  font-family: var(--hd-font-display);
  font-size: 21px;
  font-weight: 700;
  margin: 0 2px;
}

.hd-changes-list { display: flex; flex-direction: column; }
.hd-changes-empty {
  padding: 10px 8px;
  text-align: center;
  font-size: 16px;
  color: var(--hd-ink-muted);
  font-style: italic;
}
.hd-change {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 1px 0;
  border-bottom: 1px solid var(--hd-line-soft);
}
.hd-change:last-child { border-bottom: 0; }
.hd-change__icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--hd-paper);
  color: var(--hd-ink-soft);
  display: grid; place-items: center;
}
.hd-change__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hd-change--success  .hd-change__icon { background: rgba(91, 140, 63, .14);  color: var(--hd-success); }
.hd-change--negative .hd-change__icon { background: rgba(181, 60, 46, .14);  color: var(--hd-danger);  }
.hd-change--inflow   .hd-change__icon { background: rgba(74, 123, 166, .14); color: var(--hd-species-blue); }
/* v3:覓食「受阻」(勢均力敵失敗)— 黃 */
.hd-change--partial  .hd-change__icon { background: rgba(217, 164, 65, .18); color: #8a6a1e; }
.hd-change--partial  .hd-change__name { color: #8a6a1e; }
.hd-change__name {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 23px;
  color: var(--hd-ink);
}
.hd-change__detail { font-size: 18px; color: var(--hd-ink-muted); line-height: 1.25; }
.hd-change__delta {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 24px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hd-change__delta--pos     { color: var(--hd-success); }
.hd-change__delta--neg     { color: var(--hd-danger); }
.hd-change__delta--neutral { color: var(--hd-ink-muted); }

.hd-changes-final {
  margin-top: 2px;
  padding: 1px 14px;
  background: var(--hd-paper);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: space-between;
}
.hd-changes-final__lbl {
  font-family: var(--hd-font-display);
  font-size: 20px;
  color: var(--hd-ink-soft);
  font-weight: 700;
}
.hd-changes-final__num {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 28px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
}
.hd-changes-final__from {
  font-size: 20px;
  color: var(--hd-ink-muted);
  text-decoration: line-through;
  text-decoration-color: rgba(0,0,0,.2);
}
.hd-changes-final__arrow { color: var(--hd-ink-muted); font-size: 18px; }
.hd-changes-final__to { font-size: 28px; }

/* ── 觸發事件(2026-06-02:深色卡;去 A/B 分頁、事件堆疊;角落放大標籤;高對比內文)── */
.hd-event {
  position: relative;
  background: var(--hd-mist);
  color: #E8E0CC;
  border-radius: var(--hd-radius-lg);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 13px;
  overflow: hidden;   /* 事件完整顯示不捲動(靠上排加高容納) */
  box-shadow: var(--hd-shadow-lg);
  min-height: 0;
}
/* 「觸發事件」緊靠右上角 + 放大(角落標籤) */
.hd-event__badge {
  position: absolute; top: 0; right: 0; z-index: 2;
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .06em;
  background: rgba(232, 224, 204, .95);
  color: #2A2620;
  padding: 6px 16px;
  border-radius: 0 var(--hd-radius-lg) 0 12px;
  white-space: nowrap;
}
.hd-event__empty {
  font-size: 18px;
  color: rgba(232, 224, 204, .7);
  margin-top: 6px;
}
.hd-event__item { display: flex; flex-direction: column; gap: 6px; }
.hd-event__item:first-child .hd-event__top { padding-right: 128px; }   /* 讓出角落標籤位 */
.hd-event__item + .hd-event__item {
  padding-top: 12px;
  border-top: 1px solid rgba(232, 224, 204, .16);
}
.hd-event__top { display: flex; align-items: center; gap: 11px; }
.hd-event__name {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 24px;
  color: #FBF8F0;
  line-height: 1.15;
}
.hd-event__desc {
  font-size: 20px;
  line-height: 1.08;   /* 2026-06-05:壓低行距,事件 B 長文不被下方擋住 */
  color: #feedda;   /* 淺橘,高對比 */
}
.hd-event__impact {
  font-size: 18px;
  line-height: 1.32;
  color: #d6efff;   /* 淺藍,高對比 */
}

/* impact_desc 中的物種色圓點(純色 + 白框,內嵌文字流;renderImpactDesc 用) */
.hd-species-chip {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 999px;
  vertical-align: -2px;
  margin: 0 3px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

/* ── 偵查報告紀錄(左下)────────────────────────────────── */
.hd-recon-list {
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius-lg);
  padding: 10px 14px;
  display: flex; flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.hd-recon-list__title {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--hd-ink);
  margin: 0 0 2px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--hd-line);
}
.hd-recon-list__rows {
  flex: 1; min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}
.hd-recon-list__item {
  display: grid;
  /* 2026-06-02:對齊 mockup,代號 | 棲地短名 | 回合 三欄 */
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--hd-ink-soft);
  transition: background .15s, border-color .15s, color .15s;
}
.hd-recon-list__item:hover {
  background: var(--hd-paper);
  color: var(--hd-ink);
}
.hd-recon-list__item--active {
  background: rgba(232, 168, 117, .22);
  border-color: rgba(184, 92, 61, .35);
  color: var(--hd-ink);
}
.hd-recon-list__id {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hd-recon-list__item--active .hd-recon-list__id { color: var(--hd-accent); }
.hd-recon-list__name {
  font-family: var(--hd-font-display);
  font-weight: 600;
  font-size: 21px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hd-recon-list__round {
  font-family: var(--hd-font-mono);
  font-size: 17px;
  color: var(--hd-ink-muted);
  white-space: nowrap;
}

/* ── 偵查報告內容(右下)────────────────────────────────── */
.hd-recon-detail {
  background: var(--hd-card-soft);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius-lg);
  padding: 12px 16px;
  display: flex; flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.hd-recon-detail__head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--hd-line);
}
.hd-recon-detail__id {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--hd-accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.hd-recon-detail__title {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 23px;
  color: var(--hd-ink);
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hd-recon-detail__round {
  font-family: var(--hd-font-mono);
  font-size: 17px;
  color: var(--hd-ink-muted);
  background: var(--hd-card);
  padding: 3px 10px;
  border-radius: 7px;
  border: 1px solid var(--hd-line-soft);
  flex-shrink: 0;
}
.hd-recon-detail__body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.hd-recon-detail__line {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--hd-ink);
  line-height: 1.5;
}
.hd-recon-detail__line:last-child { margin-bottom: 0; }
.hd-recon-detail__foot {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border-radius: 9px;
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  flex-shrink: 0;
}
.hd-recon-detail__foot-lbl {
  font-family: var(--hd-font-display);
  font-size: 18px;
  color: var(--hd-ink-soft);
  font-weight: 700;
}
.hd-recon-detail__foot-val {
  margin-left: auto;
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 20px;
}
.hd-recon-detail__unlocked--has .hd-recon-detail__foot-val { color: var(--hd-success); }
.hd-recon-detail__unlocked--none .hd-recon-detail__foot-val { color: var(--hd-ink-muted); }

.hd-recon-detail--empty {
  align-items: center;
  justify-content: center;
}
.hd-recon-detail__placeholder {
  font-size: 14px;
  color: var(--hd-ink-muted);
  font-style: italic;
}

/* ── 底部 CTA(跨整列)────────────────────────────────── */
.hd-report-cta {
  grid-column: 1 / -1;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px;
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius);
}
.hd-report-cta__text {
  font-family: var(--hd-font-display);
  font-size: 20px;
  color: var(--hd-ink);
  font-weight: 600;
}
.hd-report-cta__text small {
  display: block;
  font-family: var(--hd-font-sans);
  font-size: 15px;
  color: var(--hd-ink-muted);
  margin-top: 2px;
  font-weight: 400;
}
.hd-report-cta__btn {
  background: var(--hd-accent);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 11px 24px;
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 20px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.hd-report-cta__btn:hover { background: #9F4A2E; transform: translateY(-1px); }
.hd-report-cta__btn--ghost {
  background: transparent;
  color: var(--hd-ink);
  border: 1px solid var(--hd-line);
}
.hd-report-cta__btn--ghost:hover { background: var(--hd-paper); }

/* ── 底部「棲地變化」列(跨整列;2026-06-03 取代 CTA bar)──────────
   左標題「棲地變化」+ 四棲地卡(各三指標 水源/植被/汙染 帶趨勢)+ 最右等待提示 */
.hd-habdelta {
  grid-column: 1 / -1;
  display: flex; align-items: stretch; gap: 10px;
  padding: 8px 14px;
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius);
}
/* 左側區段標題 */
.hd-habdelta__title {
  flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center;
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 30px;
  color: var(--hd-ink-soft);
  line-height: 1.1;
  padding-right: 6px;
  border-right: 1px solid var(--hd-line-soft);
}
/* 四張棲地卡平均分配 */
.hd-habdelta__cards {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.hd-habdelta__card {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 12px;
  background: var(--hd-card-soft);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius);
}
.hd-habdelta__name {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 44px;
  color: var(--hd-ink);
  white-space: nowrap; line-height: 1;
  flex-shrink: 0;
}
.hd-habdelta__metrics {
  display: flex; flex-direction: column; gap: 1px;
  flex: 1; min-width: 0;
}
.hd-habdelta__metric {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.hd-habdelta__metric-lbl {
  font-size: 16px; color: var(--hd-ink-soft); white-space: nowrap;
}
.hd-habdelta__arrow {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 20px; line-height: 1;
  width: 18px; text-align: center;
}
/* 依「對棲地是好是壞」上色(非依方向):
   水源/植被 ↑＝好(綠) ↓＝壞(紅);汙染 ↑＝壞(紅) ↓＝好(綠) */
.hd-habdelta__arrow--good { color: var(--hd-success); }
.hd-habdelta__arrow--bad  { color: var(--hd-danger); }
.hd-habdelta__arrow--flat { color: var(--hd-ink-muted); }
/* 最右等待提示 */
.hd-habdelta__wait {
  flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center; text-align: right;
  padding-left: 8px;
  border-left: 1px solid var(--hd-line-soft);
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 25px;
  color: var(--hd-ink-soft);
  line-height: 1.25;
}
.hd-habdelta__wait strong {
  display: block;
  font-size: 16px;
  color: var(--hd-accent);
  font-weight: 700;
  margin-bottom: 2px;
}
