/* ===== Reptile Manager — Dark theme ===== */
:root {
  /* DeFi Saver 實際色票 (依面積取樣)：灰亮深青綠底 + 綠強調 */
  --green: #37b06f;
  --green-dark: #2f9760;
  --green-glow: rgba(55, 176, 111, 0.16);
  --bg-body: #181f25;      /* 主背景 (面積最大) */
  --bg-sidebar: #0f151a;   /* 側邊欄略深 */
  --bg-card: #1f272e;      /* 卡片比主背景微亮 */
  --bg-card-hover: #252f37;
  --bg-topbar: #151a1e;
  --border: #2c3a42;
  --text: #f5f7f7;
  --text-muted: #b2c1cc;
  --pink: #e879a6;
  --red: #e5484d;
}

body {
  background: var(--bg-body);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", Roboto, sans-serif;
}

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 1030;
}
.main-area { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 991.98px) {
  .main-area { margin-left: 0; }
}

/* Brand */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px; font-size: 1.25rem; font-weight: 700;
  color: var(--text); border-bottom: 1px solid var(--border);
}
.sidebar-brand i { color: var(--green); font-size: 1.5rem; }

/* Nav */
.sidebar-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--text-muted); text-decoration: none;
  font-weight: 500; transition: all .15s ease;
}
.nav-link-item i { font-size: 1.15rem; width: 22px; text-align: center; }
.nav-link-item:hover { background: var(--bg-card); color: var(--text); }
.nav-link-item.active {
  background: var(--green-glow); color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}
.sidebar-footer { padding: 16px 22px; border-top: 1px solid var(--border); }
.sidebar-offcanvas { background: var(--bg-sidebar); width: 260px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-size: 1.25rem; font-weight: 600; margin: 0; flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn-icon {
  background: transparent; border: none; color: var(--text);
  font-size: 1.4rem; padding: 2px 8px;
}

/* Content */
.content { padding: 24px; flex: 1; }
.flash-area { margin-bottom: 16px; }
@media (max-width: 575.98px) { .content { padding: 16px; } }

/* Cards */
.panel-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  background: transparent; border-bottom: 1px solid var(--border);
  font-weight: 600; padding: 14px 18px;
}
.card { background: var(--bg-card); border-color: var(--border); }

/* List groups */
.list-group-item {
  background: transparent; border-color: var(--border);
  color: var(--text); padding: 14px 18px;
}

/* Empty state */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; opacity: .4; display: block; margin-bottom: 10px; }
.empty-state.large { padding: 70px 20px; }
.empty-state.large i { font-size: 3.5rem; }
.empty-state p { margin-bottom: 14px; }

/* Badges */
.badge-type {
  background: var(--green-glow); color: var(--green);
  font-weight: 500; padding: 4px 8px; border-radius: 6px;
}

/* ===== Animal cards ===== */
.animal-card {
  border-radius: 14px; overflow: hidden;
  transition: transform .15s ease, border-color .15s;
  color: var(--text);
}
.animal-card:hover { transform: translateY(-3px); border-color: var(--green); }
.animal-photo {
  position: relative; aspect-ratio: 4/3; background: #14171a; overflow: hidden;
}
.animal-photo img { width: 100%; height: 100%; object-fit: contain; }
.photo-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: #3a4149; font-size: 2.5rem;
}
.animal-name { font-weight: 600; color: var(--text); }
.morph-tag {
  display: inline-block; margin-top: 6px; font-size: .72rem;
  background: var(--green-glow); color: var(--green);
  padding: 2px 8px; border-radius: 6px;
}
.text-pink { color: var(--pink) !important; }

/* Status pills */
.status-pill {
  font-size: .7rem; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  color: #fff;
}
.animal-photo .status-pill { position: absolute; top: 8px; right: 8px; }
.status-active { background: var(--green); }
.status-sold { background: #3498db; }
.status-deceased { background: #7f8c8d; }
.status-loaned { background: #f39c12; }

/* ===== Detail page ===== */
.detail-photo {
  aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #14171a;
}
/* contain: 完整顯示整張圖 (不裁切)，直式/橫式都能在框內完整呈現 */
.detail-photo img { width: 100%; height: 100%; object-fit: contain; }
.detail-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 18px;
  margin-top: 8px;
}
.detail-meta > div { display: flex; flex-direction: column; }
.meta-k { color: var(--text-muted); font-size: .72rem; }
.meta-v { font-weight: 500; }
.detail-notes {
  background: var(--bg-body); border-radius: 8px; padding: 10px 14px;
  color: var(--text-muted); font-size: .9rem;
}
.lineage { display: flex; gap: 20px; flex-wrap: wrap; }
.lineage-item { color: var(--text-muted); font-size: .9rem; }
.lineage-item a { color: var(--green); text-decoration: none; }
.lineage-item a:hover { text-decoration: underline; }

/* Form photo preview */
.form-photo-preview {
  aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #14171a;
  display: flex; align-items: center; justify-content: center;
}
.form-photo-preview img { width: 100%; height: 100%; object-fit: contain; }

/* Tabs */
.detail-tabs { border-bottom: none; margin-top: 4px; }
.detail-tabs .nav-link {
  color: var(--text-muted); border: 1px solid transparent;
  border-radius: 10px 10px 0 0; background: transparent;
}
.detail-tabs .nav-link:hover { color: var(--text); }
.detail-tabs .nav-link.active {
  color: var(--green); background: var(--bg-card);
  border-color: var(--border); border-bottom-color: var(--bg-card);
}
.border-top-0 { border-top-left-radius: 0; }

/* Tables */
.table-dark-custom { color: var(--text); margin: 0; }
.table-dark-custom thead th {
  background: var(--bg-body); color: var(--text-muted);
  border-color: var(--border); font-weight: 600; font-size: .82rem;
  text-transform: uppercase; letter-spacing: .3px;
}
.table-dark-custom td { border-color: var(--border); vertical-align: middle; }
.table-hover.table-dark-custom tbody tr:hover td { background: var(--bg-card-hover); }

/* Weight bars */
.weight-bar {
  height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, var(--green-dark), var(--green));
  min-width: 4px;
}

/* Offspring chips */
.offspring-chip {
  display: block; text-align: center; text-decoration: none;
  background: var(--bg-body); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 8px; color: var(--text);
  transition: all .15s;
}
.offspring-chip:hover { border-color: var(--green); color: var(--green); }
.offspring-chip i { color: var(--green); }

/* ===== Breeding ===== */
.breeding-card { transition: transform .15s ease, border-color .15s; }
.breeding-card:hover { transform: translateY(-2px); border-color: var(--green); }
.pairing-line {
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; padding: 6px 0; flex-wrap: wrap; gap: 4px;
}
.breeding-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
}
.breeding-stats > div { display: flex; flex-direction: column; }
.status-badge { font-size: .72rem; font-weight: 600; padding: 5px 10px; border-radius: 20px; color: #fff; }
.bstatus-paired { background: #3498db; }
.bstatus-gravid { background: #9b59b6; }
.bstatus-laid { background: #f39c12; }
.bstatus-incubating { background: #e67e22; }
.bstatus-hatched { background: var(--green); }
.bstatus-failed { background: #e74c3c; }

/* ===== Tasks ===== */
.task-done { opacity: .65; }
.btn-check-round {
  width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Forms */
.form-control, .form-select {
  background: var(--bg-body); border-color: var(--border); color: var(--text);
}
.form-control:focus, .form-select:focus {
  background: var(--bg-body); color: var(--text);
  border-color: var(--green); box-shadow: 0 0 0 .2rem var(--green-glow);
}
.form-control::placeholder { color: #5a626b; }
.form-label { color: var(--text-muted); font-weight: 500; }

/* Buttons */
.btn-success { background: var(--green); border-color: var(--green); font-weight: 500; }
.btn-success:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-outline-success { color: var(--green); border-color: var(--green); }
.btn-outline-success:hover { background: var(--green); border-color: var(--green); color: #fff; }

/* ===== Feeding ===== */
.feeding-card { transition: transform .15s ease, border-color .15s; }
.feeding-card:hover { transform: translateY(-2px); border-color: var(--green); }
.feed-badge-communal { background: #9b59b6; }

/* Animal / supplement checkbox grids */
.feed-animal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.feed-supp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.feed-supp-item {
  display: flex; flex-direction: column; gap: 4px;
}
.supp-qty-input {
  max-width: 100%;
}
.photo-card {
  position: relative;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.photo-thumb {
  width: 100%; aspect-ratio: 1/1; object-fit: contain; display: block;
  background: var(--bg-body);
}
.photo-cap { padding: 4px 6px; }
.photo-del { position: absolute; top: 4px; right: 4px; }
.brand-logo {
  width: 28px; height: 28px;
  flex: 0 0 28px;      /* flex 容器內鎖死尺寸,不被撐大 */
  object-fit: contain;
  vertical-align: middle;
}
.feed-animal-chk {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-body); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; cursor: pointer;
  font-weight: 500; transition: all .15s;
  min-width: 0;
}
.feed-animal-chk input { flex-shrink: 0; }
.feed-animal-chk span {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.feed-animal-chk small { font-size: .72rem; }
.feed-animal-chk:hover { border-color: var(--green); }
.feed-animal-chk input { accent-color: var(--green); width: 16px; height: 16px; }
.feed-animal-chk:has(input:checked) {
  border-color: var(--green); background: var(--green-glow); color: var(--green);
}

/* Dynamic food rows */
.food-rows { display: flex; flex-direction: column; gap: 8px; }
.food-row { display: flex; gap: 8px; align-items: center; }
.food-row .food-qty { max-width: 180px; }
.food-row .food-del { flex-shrink: 0; }
@media (max-width: 575.98px) {
  .food-row { flex-wrap: wrap; }
  .food-row .food-qty { max-width: none; flex: 1; }
}

/* Event card sections */
.feed-section { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.feed-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.feed-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; font-weight: 500; padding: 3px 9px;
  border-radius: 8px; background: var(--bg-body);
  border: 1px solid var(--border); color: var(--text);
}
.feed-chip i { font-size: .8rem; }
.feed-chip.food { color: #6db8e8; border-color: rgba(52,152,219,.35); }
.feed-chip.supp { color: var(--green); border-color: rgba(46,204,113,.35); }

/* Accepted status */
.feed-accept { font-size: .78rem; font-weight: 600; white-space: nowrap; }
.feed-accept.ok { color: var(--green); }
.feed-accept.no { color: #e74c3c; }
.feed-accept.none { color: var(--text-muted); }

/* ===== Pedigree / 族譜 ===== */
/* 性別配色 */
.ped-sex-male   { color: #3498db !important; }
.ped-sex-female { color: #e84393 !important; }
.ped-sex-unknown { color: var(--text-muted) !important; }

/* 聚焦動物摘要照片 */
.ped-focus-photo {
  width: 84px; height: 84px; border-radius: 12px; overflow: hidden;
  background: #14171a; flex-shrink: 0;
}
.ped-focus-photo img { width: 100%; height: 100%; object-fit: contain; }
.ped-focus-photo .photo-placeholder { font-size: 1.8rem; }

/* 節點卡片（共用於祖先與後代） */
.ped-node {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--bg-body); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 10px; padding: 9px 12px;
  text-decoration: none; color: var(--text);
  min-width: 140px; max-width: 180px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.ped-node:hover {
  border-color: var(--green);
  box-shadow: 0 0 0 .18rem var(--green-glow);
  transform: translateY(-1px);
}
.ped-node-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ped-node-morph { font-size: .72rem; color: var(--green); }
.ped-node-species { font-size: .7rem; color: var(--text-muted); }
.ped-node.ped-male   { border-left-color: #3498db; }
.ped-node.ped-female { border-left-color: #e84393; }
.ped-node.ped-unknown-node {
  border-style: dashed; opacity: .5; color: var(--text-muted);
  background: transparent;
}

/* 橫向家族樹佈局 */
.ped-tree-scroll { overflow-x: auto; padding-bottom: 6px; }
.ped-tree {
  display: flex; align-items: stretch; gap: 34px;
  min-width: min-content;
}
.ped-col {
  display: flex; flex-direction: column; justify-content: space-around;
  gap: 12px; position: relative;
}
.ped-slot {
  display: flex; align-items: center; flex: 1;
  position: relative;
}

/* 連接線：每個非第 0 代節點左側畫水平線連向前一代 */
.ped-branch::before {
  content: ""; position: absolute;
  left: -18px; top: 50%;
  width: 18px; height: 2px; background: var(--border);
}
/* 每一代欄位右側畫垂直匯流線（連接同一父母的兩個子節點）*/
.ped-branch::after {
  content: ""; position: absolute;
  left: -18px; top: 50%;
  width: 2px; background: var(--border);
}
/* 上分支：垂直線往下延伸；下分支：垂直線往上延伸 —— 以相鄰配對呈現分岔 */
.ped-slot:nth-child(odd).ped-branch::after  { height: 50%; top: 50%; }
.ped-slot:nth-child(even).ped-branch::after { height: 50%; top: 0; }

/* 直向後代樹 */
.desc-tree, .desc-children { list-style: none; margin: 0; padding: 0; }
.desc-tree { padding-left: 4px; }
.desc-item { position: relative; padding: 6px 0; }
.desc-card { display: inline-flex; flex-direction: column; }
.desc-children {
  padding-left: 28px; margin-top: 2px;
  border-left: 2px solid var(--border);
  margin-left: 10px;
}
.desc-children > .desc-item::before {
  content: ""; position: absolute;
  left: -18px; top: 22px;
  width: 16px; height: 2px; background: var(--border);
}

@media (max-width: 575.98px) {
  .ped-node { min-width: 120px; max-width: 150px; }
  .ped-tree { gap: 26px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #3a4149; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #4a525b; }

/* 同胎手足 */
.clutch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.clutch-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-body); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px; text-decoration: none;
  color: inherit; transition: all .15s;
}
.clutch-card:hover { border-color: var(--green); transform: translateY(-2px); }
.clutch-card.muted { opacity: .7; }
.clutch-photo {
  width: 48px; height: 48px; border-radius: 8px; flex-shrink: 0;
  background: var(--bg-card); display: flex; align-items: center;
  justify-content: center; overflow: hidden; color: var(--text-muted);
}
.clutch-photo img { width: 100%; height: 100%; object-fit: contain; }
.clutch-info { min-width: 0; }
.clutch-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.clutch-morph { font-size: .82rem; color: var(--green); }
.clutch-date { font-size: .75rem; }

/* 飲食 - 參與動物依物種分組 */
.feed-species-group { margin-bottom: 12px; }
.feed-species-group:last-child { margin-bottom: 0; }
.feed-species-title {
  font-size: .82rem; font-weight: 600; color: var(--green);
  margin-bottom: 6px; display: flex; align-items: center;
  justify-content: space-between; gap: 6px;
  border-left: 3px solid var(--green); padding-left: 8px;
}
.feed-species-title .text-muted { font-weight: 400; }
.feed-select-all {
  font-size: .75rem; font-weight: 500; color: var(--text-muted);
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  user-select: none; white-space: nowrap;
}
.feed-select-all input { accent-color: var(--green); cursor: pointer; }

/* 飲食—給水列 */
.feed-water-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.feed-water-row .feed-animal-chk { flex-shrink: 0; margin: 0; }
.feed-water-row .form-control { flex: 1; min-width: 180px; }
.feed-badge-water { background: #2b6cb0; color: #fff; }

/* 筆記本 */
.note-card { transition: all .15s; }
.note-card.note-pinned { border-color: var(--green); }
.note-title { font-weight: 600; word-break: break-word; }
.note-animal { font-size: .8rem; color: var(--green); }
.note-content {
  white-space: pre-wrap; word-break: break-word;
  color: var(--text-muted); font-size: .9rem; margin: 6px 0;
}
.note-date { font-size: .72rem; }

/* ===== DeFi Saver 風格對齊 Bootstrap 元件 ===== */
:root, [data-bs-theme="dark"] {
  --bs-body-bg: #181f25;
  --bs-body-color: #f5f7f7;
  --bs-success: #37b06f;
  --bs-success-rgb: 55, 176, 111;
  --bs-border-color: #2c3a42;
  --bs-danger: #e5484d;
  --bs-danger-rgb: 229, 72, 77;
}
.text-success { color: var(--green) !important; }
.bg-success { background-color: var(--green) !important; }
.text-danger { color: var(--red) !important; }
.btn-outline-success { color: var(--green); border-color: var(--green); }
.btn-outline-success:hover { background: var(--green); border-color: var(--green); color: #ffffff; }
.badge.bg-success { color: #ffffff; }
/* 卡片/面板底色微調更貼近 DeFi Saver */
.card, .panel-card { background: var(--bg-card); border-color: var(--border); }
/* 表單控件深色底 */
.form-control, .form-select {
  background-color: #151a1e; border-color: var(--border); color: var(--text);
}
.form-control:focus, .form-select:focus {
  background-color: #151a1e; border-color: var(--green);
  box-shadow: 0 0 0 .2rem var(--green-glow); color: var(--text);
}

/* 統一所有 muted 文字亮度 (跨頁一致) */
.text-muted, .sidebar-footer small {
  color: var(--text-muted) !important;
}
.sidebar-footer small { opacity: .85; }

/* TCG 卡片格線：固定寬度卡片不用 Bootstrap 百分比欄寬。
   舊做法的問題：欄寬随視窗變 (1440→566px、1600→646px、1920→537px)，
   卡片 480px 置中後左右留白跟著變 → 卡間間距 57～166px 忽寬忽窄。
   flex + 固定 gap：間距永遠是 --dex-gap。 */
.dex-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--dex-gap, 24px);
}
.dex-grid > .animal-cell {
  flex: 0 0 auto;
  width: var(--card-w, 480px);
  max-width: 100%;
}

/* ===== 動物卡片：圖鑑卡風 (v1.6.0) ===== */
/* 通用 TCG 骨架（固定卡比、金屬外框、圖＋名＋數值、下方條列）＋ ReptileKeep 自有視覺語言。
   刻意避開特定商品的識別特徵組合：
   - 卡面不用屬性色滿版底，改中性圖鑑紙 + 單一重點色
   - 標記用圓角方章，不用圓形能量球
   - 資訊列是三個獨立方塊，不是帶缺口的三分格帶
   - 頁尾不用 Illus./set 章/流水卡號/稀有度字母那一列
   字級一律 cqw（1cqw = 卡片寬度 1%），卡片縮放時文字等比跟隨。 */
.dex-card {
  container-type: inline-size;
  /* 卡面專用字體堆疊：Windows 落在微軟正黑體 (含真 Bold 字面)，Mac 落在蘋方。
     實體卡的卡名、HP、招式名都是重黑體，因此顯示級元素字重拉高；
     說明文字維持常規，避免整張卡都很重。 */
  font-family: "PingFang TC", "Hiragino Sans", "Noto Sans TC",
               "Microsoft JhengHei", "Segoe UI", -apple-system, sans-serif;
  position: relative;
  /* 高度由內容決定，不用 aspect-ratio 鎖死。
     舊寫法的兩難：aspect-ratio + overflow:hidden → 底部被裁；
     aspect-ratio + 無 overflow → 內框凸出卡片外。
     現在卡比改由 .dex-face 的 min-height (cqw) 維持，
     內容真的超過時整張卡一起長高，既不裁切也不溢出。 */
  /* 卡片寬度固定：卡面上所有尺寸 (外框 %、內框 %、字級 cqw、
     卡比 min-height cqw) 都是相對卡片寬度，所以鎖住寬度等於一次鎖住
     全部規格；也負責修掉「框厚隨視窗/縮放忕厚忕薄」的根本原因。
     max-width: 100% 是端點保险：欄位比 --card-w 窄時才縮。 */
  width: var(--card-w, 480px);      /* 基準 320px 的 1.5 倍 */
  max-width: 100%;
  margin: 0 auto;
  border-radius: 4.5% / 3.2%;
  /* 外框厚度用整數 px 而非百分比：
     2.2% × 320px = 7.040px 是小數，瀏覽器在不同縮放下的捨入方向不一致，
     外框與內框各自捨入到不同方向時中間就會露出一道縫。
     卡片寬度已固定 (320px)，百分比已無必要。 */
  padding: var(--dex-frame, 10px);  /* 金屬外框厚度 (7px ×1.5 = 10.5 取整)，可調 */
  overflow: hidden;
  background:
    linear-gradient(145deg, #eef0f2 0%, #c3c8cd 22%, #e6e9ec 42%,
                    #b0b6bc 62%, #dfe3e6 82%, #aeb4ba 100%);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .6);
  transition: transform .15s ease, box-shadow .15s ease;
}
.dex-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .62), inset 0 0 0 1px rgba(255, 255, 255, .75);
}
.dex-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  border-radius: 4.5% / 3.2%;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, .28) 50%, transparent 62%);
  opacity: 0; transition: opacity .2s ease;
}
.dex-card:hover::after { opacity: 1; }

/* 中性圖鑑紙卡面（所有物種同一張底，靠重點色區分） */
.dex-face {
  position: relative;
  /* 142cqw ≈ 實體卡 63:88 扇除外框後的內高。
     1cqw = .dex-card 內容盒寬度的 1%，所以這個值會跟著卡片縮放。
     內容較少 → 卡片維持卡牌比例；內容較多 → 卡片跟著長高。 */
  min-height: 142cqw;
  border-radius: 2%;
  padding: 14px 14px 9px;    /* 整數 px (9/9/6 ×1.5 = 13.5/13.5/9 取整)，避免捨入縫隕 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #1d2124;
  background:
    radial-gradient(ellipse at 50% 14%, rgba(255, 255, 255, .6) 0%, transparent 62%),
    linear-gradient(170deg, #f7f4ec 0%, #ece7da 58%, #ddd6c5 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .32);
}
/* 物種重點色（只用在方章與細線，不做滿版底色） */
.dex-type-snake  { --dex-accent: #6b5f8f; }
.dex-type-gecko  { --dex-accent: #a86a32; }
.dex-type-lizard { --dex-accent: #4d7c46; }
.dex-type-turtle { --dex-accent: #7d6440; }
.dex-type-frog   { --dex-accent: #2f7a74; }
.dex-type-croc   { --dex-accent: #3f6b4f; }
.dex-type-invert { --dex-accent: #8a5a5a; }
.dex-type-other  { --dex-accent: #5d666d; }

/* ---- 標題列 ---- */
.dex-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 1.6cqw;
  padding-bottom: 1.4cqw;
  border-bottom: 2px solid var(--dex-accent, #5d666d);
}
/* 生命階段銘牌：雙層金屬，右端斜切做出旗標感 */
.dex-stage {
  flex: 0 0 auto;
  display: inline-block;
  padding: 1px;
  border-radius: 1.2cqw;
  background: linear-gradient(180deg, #8f969d 0%, #5d646b 50%, #7b828a 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .45);
  clip-path: polygon(0 0, 100% 0, calc(100% - 1.6cqw) 100%, 0 100%);
}
.dex-stage > span {
  display: block;
  padding: 0.9cqw 2.6cqw 0.9cqw 1.8cqw;
  border-radius: 1cqw;
  font-size: 3.8cqw; font-weight: 700; line-height: 1; letter-spacing: .04em;
  color: #24282c;
  background:
    linear-gradient(180deg, #ffffff 0%, #e4e8ec 38%, #b9c0c7 52%, #d6dbe0 68%, #f2f5f7 100%);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .9);
  clip-path: polygon(0 0, 100% 0, calc(100% - 1.5cqw) 100%, 0 100%);
}
.dex-name {
  flex: 1; min-width: 0;
  font-weight: 800; font-size: 6.4cqw; line-height: 1.15; color: #14181b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-sex { font-size: 5cqw; margin-left: 1cqw; }
.dex-sex-male { color: #1d6fa5; }
.dex-sex-female { color: #b5497c; }
.dex-sex-unknown { color: #6b7278; }
.dex-weight {
  flex: 0 0 auto;
  font-weight: 800; font-size: 6.4cqw; line-height: 1; color: #14181b;
  font-variant-numeric: tabular-nums;
}
.dex-weight small {
  font-size: 3.4cqw; font-weight: 700; margin-left: .3cqw; color: #5b6268;
}
/* 物種方章（圓角方形，非圓形） */
.dex-type {
  flex: 0 0 auto; width: 9cqw; height: 9cqw; border-radius: 2cqw;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 4.2cqw; font-weight: 700; color: #fff;
  background: var(--dex-accent, #5d666d);
  box-shadow: inset 0 -1.5px 0 rgba(0, 0, 0, .28), 0 1px 2px rgba(0, 0, 0, .3);
}

/* ---- 圖 ---- */
/* 卡圖：用明確的 aspect-ratio 而非高度百分比，
   舊寫法 flex:0 0 36% 算出來是 1.87:1 (過寬)，直式照片被 cover 裁掉太多。
   要改比例只調 --dex-art-ratio：4/3 標準、3/2 稍寬、1/1 正方、3/4 直式。 */
.dex-art {
  position: relative;
  flex: 0 0 auto;
  aspect-ratio: var(--dex-art-ratio, 16 / 9);
  margin-top: 2cqw; overflow: hidden;
  border-radius: 1.5cqw;
  /* 圖框底色跟著圖鑑紙，不再用黑底；
     照片改用 contain 完整置入框内 (不裁切)，直式照不再被切頭切尾。 */
  background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
}
.dex-art img {
  width: 100%; height: 100%;
  object-fit: contain;          /* 完整顯示整張照片，餘白透出圖鑑紙底色 */
  object-position: center;
}
.dex-art-empty {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: #b3ab99; font-size: 14cqw;
}
.dex-art .status-pill {
  position: absolute; top: 1.5cqw; right: 1.5cqw;
  font-size: 3.4cqw; padding: .4cqw 2cqw; font-weight: 400;
}

/* ---- 圖鑑編號列 ---- */
/* 分類欄：上列 物種(學名)＋年齡，下列 血系/品系/地域 徽章 (v1.6.5) */
.dex-idbar {
  flex: 0 0 auto;
  display: flex; flex-direction: column; gap: .8cqw;
  margin-top: 1.8cqw;
  font-size: 3.6cqw; line-height: 1.5;
}
.dex-idrow {
  display: flex; align-items: baseline; gap: 1.6cqw; min-width: 0;
}
.dex-sci {
  font-style: italic; font-weight: 500; color: #5b6268;
  font-size: 3.1cqw; margin-left: .4cqw;
}
.dex-tags { gap: 1.2cqw; overflow: hidden; }
.dex-tag {
  flex: 0 1 auto; min-width: 0;
  padding: .2cqw 1.4cqw; border-radius: .8cqw;
  font-size: 3.2cqw; font-weight: 700; letter-spacing: .02em; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-tag-blood { background: #6b5f8f; }                     /* 血系 */
.dex-tag-morph { background: var(--dex-accent, #5d666d); }  /* 品系：跟物種重點色 */
.dex-tag-loc   { background: #4a6b7c; }                     /* 地域 */
.dex-tag-none  { background: transparent; color: #8a9299; padding-left: 0; }
.dex-species {
  flex: 1 1 auto; min-width: 0; color: #2c3135; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-age {
  flex: 0 0 auto; color: #5b6268; font-size: 3.4cqw; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- 飼養紀錄 ---- */
/* flex-basis 必須是 0：讓紀錄區只吃「剩下的空間」，而不是拿內容高度
   參與分配。舊寫法 flex: 1 1 auto 會讓紀錄區先以內容高度占位，
   總高超過卡面時底部的資訊方塊與頁尾會被擠出卡外被 overflow 裁掉。 */
.dex-logs {
  flex: 1 1 0; min-height: 0; overflow: hidden;
  margin-top: 1.4cqw;
  display: flex; flex-direction: column; gap: .8cqw;
}
.dex-log {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 1.8cqw;
  /* 上下內距由 1cqw 收為 0.6cqw，用以抵销事件名行盒放寬後的列高增加 */
  padding: 0.6cqw 1.4cqw;
  border-radius: 1cqw;
  background: rgba(255, 255, 255, .55);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  /* 4cqw = 18.40px (卡片 480px 時 1cqw = 4.60px)，行高 ×1.2 = 22.08px。
     此字級決定事件名；數值欄 .dex-log-val 已有自己的宣告。 */
  font-size: 4cqw; line-height: 1.2;
}
/* 紀錄類型方章 */
.dex-log-mark {
  flex: 0 0 auto; width: 6cqw; height: 6cqw; border-radius: 1.4cqw;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 3.2cqw; color: #fff; background: #5d666d;
}
.dex-m-feeding { background: #b5651d; }
.dex-m-shed    { background: #6b4aa0; }
.dex-m-water   { background: #1f6ea8; }
.dex-m-weight  { background: #3d7d4a; }
/* 事件名與日期上下疊，左切齊；數值單獨右對齊成一欄 */
.dex-log-body {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: .2cqw;
}
.dex-log-name {
  color: #14181b; font-weight: 700;
  /* 同數值欄的理由：line-height 1.2 的行盒 (22.08px) 小於 CJK 字體的
     ascent+descent (約 1.4em = 25.76px)，overflow: hidden 裁在內距盒邊緣
     → g、j、y 的伸部被削。放寬行盒再給下方內距。 */
  line-height: 1.4;
  padding-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-log-date {
  font-size: 3cqw; color: #7a8187; letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
/* 數值欄：food_qty 是自由文字 (TEXT)，填「3隻大蟋蟀」這種值時
   舊寫法 (flex:0 0 auto + nowrap、無 max-width/無截断) 會撐寬欄位並擠壓事件名。
   此處封頂寬度並以刪節號截断，完整內容放在 title 提示。 */
.dex-log-val {
  flex: 0 1 auto; min-width: 11cqw; max-width: 22cqw; text-align: center;
  color: #14181b; font-weight: 700; font-variant-numeric: tabular-nums;
  /* 字級不跟著 .dex-log 的 4.71cqw，回到 4cqw；
     line-height 也從 1.2 放寬到 1.35，否則英數字的上下伸部
     (g、j、9 等) 在 overflow: hidden 下會被削掉。 */
  font-size: 4cqw;
  /* overflow: hidden 是裁切到「內距盒」邊緣，所以下方給內距
     才是真正讓伸部 (g、j、y) 有容身之處；光加 line-height 不夠，
     因為 CJK 字體的 ascent+descent 常超過 1.35em。 */
  line-height: 1.5;
  padding: 2px .8cqw 4px;
  /* 固定單行：封頂寬度並以刪節號截断，完整內容放在 title 提示。
     不折行，所以紀錄列高度固定，三筆排版不會因內容而變動。 */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 1px solid rgba(0, 0, 0, .12);
}
.dex-log-empty { justify-content: center; color: #6a7177; font-style: italic; }

/* ---- 資訊方塊（三個獨立小卡） ---- */
.dex-facts {
  flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2cqw;
  margin-top: 1.4cqw;
  font-size: 3.4cqw; line-height: 1.3;
}
.dex-facts > div {
  font-weight: 700;
  padding: .8cqw 1cqw;
  border-radius: 1cqw;
  background: rgba(255, 255, 255, .5);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  text-align: center; color: #1d2124;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-facts small {
  display: block; font-size: 3cqw; font-weight: 500;
  color: #6a7177; letter-spacing: .04em;
}

/* ---- 頁尾 ---- */
.dex-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 1.6cqw;
  margin-top: 1.4cqw; padding-top: 1.2cqw;
  border-top: 1px solid rgba(0, 0, 0, .18);
  font-size: 3.2cqw; line-height: 1.35;
}
.dex-country {
  flex: 0 0 auto; padding: .2cqw 1.6cqw; border-radius: .8cqw;
  background: #3c4247; color: #fff; font-weight: 700; letter-spacing: .06em;
}
/* 個體來源徽章 (WC/CB/CBB)，緊鄰產地國碼 */
.dex-otype {
  flex: 0 0 auto; padding: .2cqw 1.4cqw; border-radius: .8cqw;
  font-size: 3cqw; font-weight: 700; letter-spacing: .04em; color: #fff;
  background: #5d666d;
}
.dex-otype-WC  { background: #8a6a3a; }
.dex-otype-CB  { background: #3f6b4f; }
.dex-otype-CBB { background: #2f6b86; }
/* 頁尾中欄：晶片編號 (v1.6.6)，左為產地/來源徽章、右為出生日期 */
.dex-chip {
  flex: 1 1 auto; min-width: 0; text-align: center;
  color: #5b6268; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-chip small {
  color: #8a9299; font-size: 2.8cqw; font-weight: 500;
  letter-spacing: .06em; margin-right: .8cqw;
}
/* 頁尾右側：出生日期 (原本是備註 flavor text) */
.dex-birth {
  flex: 0 0 auto; min-width: 0; color: #5b6268; text-align: right;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dex-birth small {
  color: #8a9299; font-size: 2.8cqw; font-weight: 500;
  letter-spacing: .04em; margin-right: 1cqw;
}

/* ===== 體重走勢圖 (v1.7.0) ===== */
.wt-panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.wt-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.wt-title { font-weight: 600; color: var(--text); }
.wt-xmode { display: flex; gap: 12px; font-size: .85rem; color: var(--text-muted); }
.wt-xmode label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

.wt-chart { width: 100%; }
.wt-svg { width: 100%; height: auto; display: block; }
.wt-grid { stroke: rgba(255, 255, 255, .10); stroke-width: 1; }
.wt-ytick { fill: #8fa0ac; font-size: 11px; text-anchor: end; }
.wt-xtick { fill: #8fa0ac; font-size: 11px; text-anchor: middle; }
.wt-axis  { fill: #6f7f8b; font-size: 10px; }
.wt-empty { color: var(--text-muted); font-size: .9rem; padding: 28px 8px; text-align: center; }

/* 同齡比較的個體清單 */
.wt-legend {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--text-muted);
}
.wt-legend-title { color: var(--text-muted); }
.wt-peer {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 14px;
  background: var(--bg-body); border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
}
.wt-peer:hover { border-color: var(--green); }
.wt-peer small { color: var(--text-muted); }
/* 圓點顏色需與 JS 的 WT_COLORS 對齊 */
.wt-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #8fa0ac; }
.wt-dot[data-i="0"] { background: #e0a33c; }
.wt-dot[data-i="1"] { background: #5aa9e6; }
.wt-dot[data-i="2"] { background: #7ec97e; }
.wt-dot[data-i="3"] { background: #c98bd9; }
.wt-dot[data-i="4"] { background: #e2756f; }
.wt-dot[data-i="5"] { background: #6fd0c4; }

/* 體重走勢圖：時間區間控制 (v1.7.2) */
.wt-range-quick { display: inline-flex; gap: 4px; margin-right: 6px; }
.wt-qbtn {
  background: var(--bg-body); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 12px;
  padding: 2px 10px; font-size: .78rem; cursor: pointer;
}
.wt-qbtn:hover { border-color: var(--green); color: var(--text); }
.wt-qbtn-on { background: var(--green-glow); border-color: var(--green); color: var(--green); }
.wt-range { display: inline-flex; align-items: center; gap: 4px; }
.wt-range input[type="date"] {
  background: #151a1e; border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 2px 6px; font-size: .78rem;
}
.wt-range input[type="date"]:focus { border-color: var(--green); outline: none; }

/* ===== 儀表板 (v1.8.0) ===== */
.min-w-0 { min-width: 0; }
/* 面板標題右側的計數徽章 */
.dash-count {
  display: inline-block; min-width: 22px; text-align: center;
  margin-left: 6px; padding: 1px 7px; border-radius: 11px;
  background: var(--bg-body); border: 1px solid var(--border);
  color: var(--text-muted); font-size: .78rem; font-weight: 600;
}
/* 「幾天沒做」的天數標記：越久越紅 */
.dash-days {
  flex: 0 0 auto; margin-left: 10px;
  padding: 2px 10px; border-radius: 12px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dash-days-warn  { background: rgba(243, 156, 18, .16); color: #f0a637; }
.dash-days-bad   { background: rgba(229, 72, 77, .16);  color: #ef6b70; }
.dash-days-never { background: rgba(229, 72, 77, .22);  color: #ff8a8f; }

.dash-badge-bad  { background: rgba(229, 72, 77, .18); color: #ef6b70; font-weight: 600; }
.dash-badge-warn { background: rgba(243, 156, 18, .18); color: #f0a637; font-weight: 600; }
}

/* 待辦任務：快速新增列 (v1.8.0) */
/* 快速新增 (v1.8.2 放大)：第一列標題獨佔整行，第二列 個體／日期／循環／新增 */
.dash-quickadd {
  display: grid; grid-template-columns: minmax(0, 1fr) 150px 96px auto; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .02);
}
.dash-quickadd .qa-title { grid-column: 1 / -1; }
.dash-quickadd .form-control, .dash-quickadd .form-select,
.dash-quickadd .btn { font-size: .95rem; min-height: 40px; }
.dash-quickadd .btn { white-space: nowrap; padding-inline: 16px; }
@media (max-width: 767.98px) {
  .dash-quickadd { grid-template-columns: 1fr 1fr; }
}
/* 近期紀錄：共食多隻名稱，每個都可點 */
.rec-names { display: inline-flex; flex-wrap: wrap; align-items: baseline; }

/* 近期紀錄：類型篩選 chip */
.rec-filter {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.rec-chip {
  background: var(--bg-body); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 12px;
  padding: 2px 12px; font-size: .78rem; cursor: pointer;
}
.rec-chip:hover { border-color: var(--green); color: var(--text); }
.rec-chip-on { background: var(--green-glow); border-color: var(--green); color: var(--green); }

/* 日期分隔列 */
.rec-daysep {
  background: var(--bg-body) !important;
  color: var(--text-muted); font-size: .76rem; font-weight: 600;
  letter-spacing: .05em; padding-top: 5px !important; padding-bottom: 5px !important;
}

/* 類型色點：與 TCG 卡面紀錄列的方章同一套配色 */
.rec-mark {
  flex: 0 0 auto; width: 9px; height: 9px; border-radius: 3px; background: #5d666d;
}
.rec-m-feeding    { background: #b5651d; }
.rec-m-shed       { background: #6b4aa0; }
.rec-m-water      { background: #1f6ea8; }
.rec-m-weight     { background: #3d7d4a; }
.rec-m-defecation { background: #8a6a3a; }
.rec-m-bath       { background: #2f7a9b; }
.rec-m-cleaning   { background: #4a6b7c; }
.rec-m-vet        { background: #a3474c; }
.rec-m-note       { background: #6b7278; }

/* 儀表板版面 (v1.8.4)：所有面板固定寬高（整數 px）；v1.8.13 起一排三格，
   v1.8.14 格寬依視窗分級（見下方 media query）；內容超出一律在卡片內捲動 */
:root {
  --dash-w: 520px;          /* 每格寬 */
  --dash-gap: 16px;
  --dash-h-alert: 400px;    /* 第一列：該餵食了／健康警示／逾期任務 */
  --dash-h-main: 560px;     /* 第二列：待辦任務／近期紀錄／已完成任務 */
}
.dash-grid {
  display: grid; gap: var(--dash-gap);
  grid-template-columns: repeat(auto-fill, var(--dash-w));
  justify-content: start;
}
.dash-cell { width: var(--dash-w); min-width: 0; }
.dash-h-alert { height: var(--dash-h-alert); }
.dash-h-main  { height: var(--dash-h-main); }
.dash-cell > .card { height: 100%; display: flex; flex-direction: column; margin: 0; }
.dash-cell > .card > .card-header { flex: 0 0 auto; }
.dash-cell > .card > .card-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column;
}
/* 待辦／近期／已完成：頂端表單與 chip 固定，只有清單區捲動 */
.dash-cell .dash-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.dash-cell .empty-state { margin: auto 0; }
.dash-cell > .card > .card-body,
.dash-scroll { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.dash-cell > .card > .card-body::-webkit-scrollbar,
.dash-scroll::-webkit-scrollbar { width: 8px; }
.dash-cell > .card > .card-body::-webkit-scrollbar-thumb,
.dash-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
/* 格寬分級 (v1.8.14)：依視窗寬度換一組固定寬度，讓常見螢幕都能一排三格。
   可用寬度 ≈ 視窗 − 側欄 240 − 內距 48 − 捲軸 17 = 視窗 − 305；三格需 3w + 32。
     ≥1897px → 520（1920 @100%）
     1657–1896 → 440
     1507–1656 → 390（1920 @125% = 1536）
     1357–1506 → 340（1366 筆電 @100%、1920 @150% 以上改走下一級）
     <1357 → 放不下三格，改 400 一排兩格；<576 手機滿版 */
@media (max-width: 1896.98px) { :root { --dash-w: 440px; } }
@media (max-width: 1656.98px) { :root { --dash-w: 390px; } }
@media (max-width: 1506.98px) { :root { --dash-w: 340px; } }
@media (max-width: 1356.98px) { :root { --dash-w: 400px; } }
/* 格寬 ≤440 時，快速新增與任務編輯改兩欄：標題整行 → 個體｜日期 → 循環｜按鈕 */
@media (max-width: 1896.98px) {
  .dash-quickadd { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash-quickadd .btn { width: 100%; }
  .task-edit-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .task-edit-form .form-control, .task-edit-form .form-select { min-width: 0; }
}
/* 手機：螢幕比一格還窄，寬度改滿版（高度仍固定） */
@media (max-width: 575.98px) {
  :root { --dash-w: 100%; }
  .dash-grid { grid-template-columns: 100%; }
}
/* 已完成任務：標題刪除線、整體淡化 */
.task-done .task-done-title { text-decoration: line-through; color: var(--text-muted); }

/* 血檢 (v1.8.7)：每欄「紅字」按鈕標記異常；表格中異常值紅字 */
.bw-field .form-control { min-width: 0; }
.bw-flag-btn {
  font-size: .85rem; padding: 0 8px; line-height: 1;
  color: #ef6b70; border: 1px solid rgba(229, 72, 77, .55); background: transparent;
  display: inline-flex; align-items: center;
}
.bw-flag-btn:hover { color: #ff8a8e; border-color: #ef6b70; background: rgba(229, 72, 77, .1); }
/* 紅點 (v1.8.10)：已標記時按鈕底色維持透明，只把圓點填成紅色，較低調 */
.btn-check:checked + .bw-flag-btn { color: #e5484d; background: rgba(229, 72, 77, .14); border-color: #e5484d; }
/* 圖示切換：未標記顯示空心圓，標記後換實心紅點 */
.bw-flag-btn .bw-flag-on { display: none; }
.btn-check:checked + .bw-flag-btn .bw-flag-off { display: none; }
.btn-check:checked + .bw-flag-btn .bw-flag-on { display: inline; }
.btn-check:focus-visible + .bw-flag-btn { box-shadow: 0 0 0 .2rem rgba(229, 72, 77, .35); }
.bw-field:has(.bw-flag-chk:checked) .form-control { color: #ef6b70; font-weight: 700; }
.bw-abn { color: #ef6b70 !important; font-weight: 700; }
.bw-editing-bar {
  margin-bottom: 10px; padding: 6px 12px; border-radius: 8px; font-size: .85rem;
  background: rgba(90, 169, 230, .12); border: 1px solid rgba(90, 169, 230, .4); color: #8cc4ef;
}

/* 飲食系統：動物依物種中文名折疊 (v1.8.7) */
.feed-sp-toggle {
  background: none; border: 0; padding: 0; color: inherit; font: inherit;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; text-align: left;
}
.feed-sp-caret { font-size: .75rem; transition: transform .15s; transform: rotate(90deg); }
.feed-species-group.is-collapsed .feed-sp-caret { transform: rotate(0deg); }
.feed-species-group.is-collapsed .feed-animal-grid { display: none; }
.feed-sp-picked {
  font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 10px;
  background: rgba(126, 201, 126, .18); color: var(--green);
}

/* 任務 (v1.8.10)：指定個體可點；行內編輯表單 */
a.task-animal { text-decoration: none; }
a.task-animal:hover { filter: brightness(1.25); text-decoration: underline; }
.task-edit-form {
  width: 100%; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
  display: grid; grid-template-columns: minmax(0, 1fr) 150px 96px; gap: 6px;
}
.task-edit-form[hidden] { display: none; }
.task-edit-form .te-title { grid-column: 1 / -1; }
.task-edit-form .te-actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }
