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

.hd-report {
  position: relative;
  z-index: 1;
  height: calc(100% - var(--hd-topbar-h));
  padding: 14px 22px 16px;
  display: grid;
  grid-template-columns: 3fr 2fr;
  grid-template-rows: auto 1fr auto;
  gap: 12px 14px;
  overflow: hidden;
}

/* head 跨整列(回合 + 標題 + 統計卡) */
.hd-report__head {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--hd-line);
  padding-bottom: 8px;
}
.hd-report__head-l { display: flex; align-items: baseline; gap: 16px; }
.hd-report__round {
  font-family: var(--hd-font-display);
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  color: var(--hd-ink);
  letter-spacing: -.02em;
}
.hd-report__round small {
  font-size: 17px;
  color: var(--hd-ink-muted);
  margin-left: 5px;
}
.hd-report__title-stack { display: flex; flex-direction: column; gap: 3px; }
.hd-report__kicker {
  font-size: 13px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--hd-ink-muted);
  font-weight: 700;
  white-space: nowrap;
}
.hd-report__title {
  font-family: var(--hd-font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--hd-ink);
  margin: 0;
}

.hd-report-summary { display: flex; gap: 10px; }
.hd-stat-card {
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius);
  padding: 9px 14px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 120px;
}
.hd-stat-card__lbl {
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hd-ink-muted);
  font-weight: 600;
}
.hd-stat-card__val {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--hd-ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hd-stat-card__delta { font-size: 13px; color: var(--hd-ink-soft); font-weight: 500; }
.hd-stat-card__delta--pos { color: var(--hd-success); }
.hd-stat-card__delta--neg { color: var(--hd-danger); }

/* ── 左 3/5 區:上/下兩排 ─────────────────────────────────── */
.hd-report__main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  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;
}
.hd-report-tab {
  --hd-habitat-color: var(--hd-ink-muted);
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: 9px;
  font-family: var(--hd-font-display);
  font-weight: 600;
  font-size: 13px;
  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__icon {
  display: inline-flex;
  width: 20px; height: 20px;
  align-items: center; justify-content: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--hd-habitat-color) 18%, transparent);
  color: var(--hd-habitat-color);
  flex-shrink: 0;
}
.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;
}
.hd-report-tab--active .hd-report-tab__icon {
  background: rgba(255, 255, 255, .22);
  color: white;
}

/* ── 族群變化清單 ────────────────────────────────────────── */
.hd-report-changes {
  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;
  overflow-y: auto;
  min-height: 0;
}
.hd-report-changes__head {
  display: flex; align-items: center; gap: 9px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--hd-line);
}
.hd-report-changes__icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--hd-habitat-color);
  color: white;
  display: grid; place-items: center;
}
.hd-report-changes__habitat {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--hd-ink);
}
.hd-report-changes__numline {
  margin-left: auto;
  font-family: var(--hd-font-mono);
  font-size: 13px;
  color: var(--hd-ink-soft);
}
.hd-report-changes__numline strong {
  color: var(--hd-ink);
  font-family: var(--hd-font-display);
  font-size: 16px;
  font-weight: 700;
  margin: 0 3px;
}

.hd-changes-list { display: flex; flex-direction: column; }
.hd-changes-empty {
  padding: 10px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--hd-ink-muted);
  font-style: italic;
}
.hd-change {
  display: grid;
  grid-template-columns: 30px 80px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hd-line-soft);
}
.hd-change:last-child { border-bottom: 0; }
.hd-change__icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--hd-paper);
  color: var(--hd-ink-soft);
  display: grid; place-items: center;
}
.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: 15px;
  color: var(--hd-ink);
}
.hd-change__detail { font-size: 13px; color: var(--hd-ink-muted); }
.hd-change__delta {
  font-family: var(--hd-font-mono);
  font-weight: 700;
  font-size: 15px;
  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: 4px;
  padding: 8px 12px;
  background: var(--hd-paper);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.hd-changes-final__lbl {
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hd-ink-muted);
  font-weight: 700;
}
.hd-changes-final__num {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--hd-font-display);
  font-weight: 700;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
}
.hd-changes-final__from {
  font-size: 14px;
  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: 13px; }
.hd-changes-final__to { font-size: 24px; }

/* ── 觸發事件 ────────────────────────────────────────────── */
.hd-event {
  background: var(--hd-mist);
  color: #E8E0CC;
  border-radius: var(--hd-radius-lg);
  padding: 12px 16px;
  display: flex; flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--hd-shadow-lg);
  min-height: 0;
}
.hd-event::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(195, 130, 200, .18) 0%, transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(120, 180, 220, .12) 0%, transparent 50%);
  pointer-events: none;
}
.hd-event__head {
  display: flex; align-items: center; gap: 8px; position: relative;
}
.hd-event__badge {
  font-size: 13px;
  letter-spacing: .18em;
  text-transform: uppercase;
  background: rgba(232, 224, 204, .12);
  border: 1px solid rgba(232, 224, 204, .25);
  padding: 4px 10px;
  border-radius: 999px;
  color: rgba(232, 224, 204, .85);
  font-weight: 600;
  flex-shrink: 0;
}
.hd-event__location {
  font-family: var(--hd-font-mono);
  font-size: 13px;
  color: rgba(232, 224, 204, .85);
  background: rgba(232, 224, 204, .08);
  padding: 3px 9px;
  border-radius: 6px;
  margin-left: auto;
}
.hd-event__title {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 18px;
  color: #FBF8F0;
  margin: 0;
  line-height: 1.2;
}
.hd-event__quote {
  font-family: var(--hd-font-display);
  font-size: 14px;
  font-style: italic;
  color: rgba(232, 224, 204, .92);
  line-height: 1.45;
  position: relative;
  padding-left: 12px;
  border-left: 2px solid rgba(232, 224, 204, .3);
}
.hd-event-effects {
  display: flex; flex-direction: column;
  gap: 4px; position: relative;
  overflow-y: auto;
  min-height: 0;
}
.hd-event-effect {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 9px;
  align-items: center;
  font-size: 14px;
  color: rgba(232, 224, 204, .92);
  padding: 6px 0;
  border-top: 1px solid rgba(232, 224, 204, .08);
}
.hd-event-effect:first-of-type { border-top: 0; }
.hd-event-effect__dot {
  width: 12px; height: 12px;
  border-radius: 999px;
}
.hd-event-effect__delta {
  font-family: var(--hd-font-mono);
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.hd-event-effect__delta--neg  { color: #E89579; }
.hd-event-effect__delta--buff { color: #B5D88E; }
.hd-event-effect__sub {
  color: rgba(232,224,204,.55);
  margin-left: 6px;
  font-size: 13px;
}

/* ── 偵查報告紀錄(左下)────────────────────────────────── */
.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: 17px;
  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: 3px;
  padding-right: 2px;
}
.hd-recon-list__item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  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: 20px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.hd-recon-list__item--active .hd-recon-list__id { color: var(--hd-accent); }
.hd-recon-list__lbl {
  font-family: var(--hd-font-display);
  font-weight: 600;
  font-size: 15px;
}
.hd-recon-list__round {
  font-family: var(--hd-font-mono);
  font-size: 13px;
  color: var(--hd-ink-muted);
}

/* ── 偵查報告內容(右下)────────────────────────────────── */
.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: 22px;
  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: 17px;
  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: 13px;
  color: var(--hd-ink-muted);
  background: var(--hd-card);
  padding: 3px 9px;
  border-radius: 6px;
  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: 15px;
  color: var(--hd-ink);
  line-height: 1.55;
}
.hd-recon-detail__line:last-child { margin-bottom: 0; }
.hd-recon-detail__foot {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  flex-shrink: 0;
}
.hd-recon-detail__foot-lbl {
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--hd-ink-muted);
  font-weight: 700;
}
.hd-recon-detail__foot-val {
  margin-left: auto;
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 16px;
}
.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: 16px;
  color: var(--hd-ink);
  font-weight: 600;
}
.hd-report-cta__text small {
  display: block;
  font-family: var(--hd-font-sans);
  font-size: 13px;
  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: 10px 22px;
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 16px;
  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); }
