/* ============================================================
   行動階段 — 平板兩欄式骨架(原始尺寸,小字最低 13px,不爆版)
   左 .hd-main  : 上=地圖, 下=底列三張卡(棲地詳情 / 族群分布+性狀 / AI 對話)
   右 .hd-side  : 行動選擇 4 張卡 + 已選擇佇列 + 展開行動
   ============================================================ */

.hd-shell {
  position: relative;
  z-index: 1;
  height: calc(100% - var(--hd-topbar-h));
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 14px;
  padding: 14px 18px 18px;
  overflow: hidden;
}

/* ---------- 左大欄 ---------- */
.hd-main {
  display: grid;
  /* 把底列拉到 1.4/1 的比例,讓左卡可以塞下「資源 + 族群分佈 2 欄」 */
  grid-template-rows: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  min-width: 0;
}

/* 底列 — 三張卡(左:資源+族群分佈 / 中:我的狀態 / 右:AI 對話) */
.hd-botrow {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 1.5fr;
  gap: 14px;
  min-height: 0;
  min-width: 0;
}
.hd-card {
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.hd-botrow > .hd-chat { padding: 0; }

/* ── 棲地詳情卡 ── */
.hd-detail__head { display: flex; align-items: center; gap: 10px; }
.hd-detail__icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--hd-habitat-color, var(--hd-color-wetland));
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.hd-detail__name {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 21px;
  color: var(--hd-ink); line-height: 1.05;
  white-space: nowrap;
}
.hd-detail__capacity {
  font-size: 13px; color: var(--hd-ink-muted);
  margin-top: 3px; white-space: nowrap;
}
.hd-detail__capacity strong {
  font-family: var(--hd-font-display);
  font-size: 16px; font-weight: 700;
  color: var(--hd-ink-soft);
  margin: 0 2px;
}

/* 資源條 */
.hd-resources { display: flex; flex-direction: column; gap: 5px; }
.hd-resource { display: flex; flex-direction: column; gap: 3px; }
.hd-resource__head { display: flex; align-items: center; justify-content: space-between; }
.hd-resource__label {
  display: flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 500;
  color: var(--hd-ink-soft);
}
.hd-resource__icon {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  color: var(--hd-ink-soft);
}
.hd-resource__pct {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 19px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
}
.hd-resource__pct small {
  font-size: 13px; color: var(--hd-ink-muted);
  font-weight: 500; margin-left: 2px;
}
.hd-resource__bar {
  height: 6px;
  background: var(--hd-paper-dark);
  border-radius: 3px;
  overflow: hidden;
}
.hd-resource__bar-fill {
  height: 100%; border-radius: 3px;
  transition: width .4s ease;
}
.hd-resource--low  .hd-resource__bar-fill { background: var(--hd-danger); }
.hd-resource--mid  .hd-resource__bar-fill { background: var(--hd-warning); }
.hd-resource--high .hd-resource__bar-fill { background: var(--hd-success); }

/* ── 族群分佈(底列左卡內) ── */
.hd-section-title {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 18px;
  color: var(--hd-ink); margin: 0;
}
.hd-popmini {
  display: flex; flex-direction: column;
  gap: 3px;
  padding-top: 6px;
  border-top: 1px dashed var(--hd-line);
}
.hd-popmini__title {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 14px;
  color: var(--hd-ink); margin: 0;
}
.hd-popmini__rows { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
/* 2 欄版(底列左卡用):列以 grid 平均填兩欄,自動換行 */
.hd-popmini__rows--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  row-gap: 1px;
}
.hd-popmini__row {
  display: grid;
  grid-template-columns: 11px 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  min-width: 0;
}
.hd-popmini__dot { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }
.hd-popmini__name {
  font-size: 13px; color: var(--hd-ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hd-popmini__num {
  font-family: var(--hd-font-mono);
  font-weight: 600; font-size: 14px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
}

/* ── 我的狀態卡(底列中卡) ── */
.hd-mystatus__rows {
  display: flex; flex-direction: column;
  gap: 2px;
}
.hd-mystatus__row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 5px 2px;
  border-bottom: 1px dashed var(--hd-line-soft);
}
.hd-mystatus__row:last-child { border-bottom: 0; }
.hd-mystatus__lbl {
  font-family: var(--hd-font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--hd-ink-soft);
  letter-spacing: .04em;
}
.hd-mystatus__val {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hd-mystatus__val--text {
  font-size: 17px;
  color: var(--hd-success);
}

.hd-traits__divider {
  border-top: 1px dashed var(--hd-line);
  padding-top: 7px;
  margin-top: auto;
}
.hd-traits__divider .hd-section-label {
  font-size: 13px; letter-spacing: .14em;
  color: var(--hd-ink-muted); font-weight: 700;
  margin: 0 0 5px; padding: 0;
}
.hd-traits__list {
  display: flex; gap: 5px; flex-wrap: wrap;
}
.hd-trait {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 8px;
  background: var(--hd-card-soft);
  border: 1px solid var(--hd-line);
  border-radius: 999px;
  font-size: 13px; color: var(--hd-ink-soft);
  white-space: nowrap;
}
.hd-trait__dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--hd-success);
}
.hd-trait--locked { opacity: .45; border-style: dashed; }
.hd-trait--locked .hd-trait__dot { background: var(--hd-ink-muted); }

/* ============================================================
   右側欄 — 行動選擇 + 佇列
   ============================================================ */
.hd-side {
  display: flex; flex-direction: column;
  gap: 14px;
  min-height: 0;
}

/* 行動選擇區(label + 4 張卡垂直堆疊) */
.hd-actbar {
  display: flex; flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.hd-actbar__head { padding: 0 4px; }
.hd-actbar__lbl {
  font-size: 13px;
  letter-spacing: .14em;
  color: var(--hd-ink-muted);
  font-weight: 700;
}
.hd-actbar__row {
  display: flex; flex-direction: column;
  gap: 8px;
}

/* 單張行動卡 */
.hd-action {
  background: var(--hd-card);
  border: 1.5px solid var(--hd-line-soft);
  border-radius: var(--hd-radius);
  padding: 11px 16px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  column-gap: 14px; row-gap: 8px;
  align-items: center;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color .18s, background .18s, transform .15s;
  position: relative;
  min-width: 0;
}
.hd-action:hover { border-color: var(--hd-ink-muted); transform: translateY(-1px); }
.hd-action--disabled { opacity: .4; cursor: not-allowed; }
.hd-action--disabled:hover { transform: none; border-color: var(--hd-line-soft); }
.hd-action__icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--hd-paper);
  color: var(--hd-ink);
  display: grid; place-items: center;
}
.hd-action__body {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.hd-action__name {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 19px;
  color: var(--hd-ink); line-height: 1.1;
  white-space: nowrap;
}
.hd-action__desc {
  font-size: 13px;
  color: var(--hd-ink-muted);
  line-height: 1.35;
}
.hd-action__cost {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 22px;
  color: var(--hd-ink-soft);
  display: flex; flex-direction: column; align-items: center;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hd-action__cost small {
  font-size: 13px;
  letter-spacing: .12em;
  color: var(--hd-ink-muted);
  font-weight: 700;
  margin-top: 3px;
}

/* 遷移卡 */
.hd-action--migrate { cursor: default; }
.hd-action--migrate:hover { transform: none; border-color: var(--hd-line-soft); }
.hd-action__subs {
  grid-column: 2 / 4;
  display: flex; gap: 8px;
  margin-top: 2px;
}
.hd-action__sub {
  flex: 1;
  background: var(--hd-paper);
  border: 1px solid var(--hd-line);
  border-radius: 9px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--hd-ink);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .15s;
}
.hd-action__sub:hover:not(:disabled) {
  background: var(--hd-ink); color: var(--hd-paper);
  border-color: var(--hd-ink);
  transform: translateY(-1px);
}
.hd-action__sub:disabled { opacity: .4; cursor: not-allowed; }
.hd-action__sub-arrow { font-weight: 700; color: var(--hd-ink-muted); }
.hd-action__sub:hover:not(:disabled) .hd-action__sub-arrow { color: var(--hd-paper); }
.hd-action__sub-name { font-family: var(--hd-font-display); font-weight: 700; }

/* ── 已選擇佇列 ── */
.hd-queue {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.hd-queue__head {
  background: var(--hd-card);
  border: 1.5px solid var(--hd-line);
  border-radius: var(--hd-radius);
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 4px;
  flex-shrink: 0;
}
.hd-queue__title {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 19px;
  color: var(--hd-ink);
}
.hd-queue__meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--hd-ink-muted);
}
.hd-queue__count {
  font-family: var(--hd-font-mono);
  font-weight: 700; color: var(--hd-ink-soft);
  font-size: 15px;
}
.hd-queue__count::after {
  content: " 項";
  font-family: var(--hd-font-sans);
  font-weight: 400; margin-left: 1px;
}
.hd-queue__cost {
  font-family: var(--hd-font-mono);
  font-size: 14px;
}

.hd-queue__list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding-right: 2px;
}
.hd-queue__empty {
  background: var(--hd-card);
  border: 1px dashed var(--hd-line);
  border-radius: var(--hd-radius);
  padding: 18px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--hd-ink-muted);
  line-height: 1.6;
}
.hd-queue__item {
  background: var(--hd-card);
  border: 1.5px solid var(--hd-line-soft);
  border-radius: var(--hd-radius);
  padding: 0 14px;
  height: 44px;
  display: grid;
  grid-template-columns: 24px 1fr auto 18px;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.hd-queue__item:hover {
  border-color: var(--hd-danger);
  background: rgba(181, 60, 46, .05);
}
.hd-queue__item:hover .hd-queue__x { color: var(--hd-danger); opacity: 1; }
.hd-queue__idx {
  font-family: var(--hd-font-mono);
  font-size: 13px; font-weight: 700;
  color: var(--hd-ink-muted);
  text-align: center;
}
.hd-queue__text {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 16px;
  color: var(--hd-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hd-queue__item--migrate .hd-queue__text { color: var(--hd-color-port, var(--hd-ink-soft)); }
.hd-queue__ap {
  font-family: var(--hd-font-mono);
  font-size: 13px; font-weight: 600;
  color: var(--hd-ink-muted);
  font-variant-numeric: tabular-nums;
}
.hd-queue__x {
  font-size: 20px; line-height: 1;
  color: var(--hd-ink-muted);
  opacity: .5;
  transition: color .15s, opacity .15s;
  text-align: center;
}

.hd-queue__remain {
  font-size: 13px;
  color: var(--hd-ink-soft);
  text-align: center;
  padding: 4px 0;
  flex-shrink: 0;
}
.hd-queue__remain strong {
  font-family: var(--hd-font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--hd-ink);
  margin: 0 2px;
}

.hd-execute {
  background: var(--hd-ink);
  color: var(--hd-paper);
  border: 0;
  border-radius: var(--hd-radius);
  padding: 16px 20px;
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 22px;
  cursor: pointer;
  letter-spacing: .04em;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-shrink: 0;
  transition: transform .18s, background .18s;
}
.hd-execute:hover:not(:disabled) { transform: translateY(-1px); background: #16120c; }
.hd-execute:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.hd-execute__cost {
  font-family: var(--hd-font-mono);
  font-size: 14px; font-weight: 600;
  background: rgba(255,255,255,.14);
  padding: 5px 11px;
  border-radius: 7px;
}
