:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-sub: #64748b;
  --text-faint: #94a3b8;
  --border: #e2e8f0;
  --radius: 18px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 800;
}
.app-logo { font-size: 22px; }
.app-header-date { font-size: 13px; color: var(--text-sub); }

/* ── Main ── */
.app-main {
  padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 24px);
  max-width: 520px;
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; animation: fadein 0.2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.empty-desc { font-size: 14px; color: var(--text-sub); line-height: 1.6; }

.settings-placeholder { font-size: 14px; color: var(--text-sub); }

/* ── 帳號卡片 ── */
.auth-hint { font-size: 14px; color: var(--text-sub); line-height: 1.6; margin-bottom: 12px; }
.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #34d399, var(--primary-dark));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: none;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.user-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.user-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--border); }
.user-name { font-size: 15px; font-weight: 700; }
.user-email { font-size: 13px; color: var(--text-sub); }

/* ── 開發者資訊 ── */
.dev-info-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.dev-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.dev-info-row:last-child { border-bottom: none; }
.dev-info-label { color: var(--text-sub); }
.dev-info-value { font-weight: 600; }
.dev-info-link { color: var(--primary-dark); text-decoration: none; font-weight: 600; }

/* ── 拍照記錄 ── */
.chip-row { display: flex; gap: 8px; margin-bottom: 14px; }
.chip {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.photo-slot {
  display: block;
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
  cursor: pointer;
  min-height: 120px;
}
.photo-slot img { display: block; width: 100%; }
.photo-slot-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 16px;
  color: var(--text-sub);
  font-size: 14px;
  text-align: center;
}
.photo-slot-icon { font-size: 30px; }
.photo-slot-sub { min-height: 72px; }
.photo-slot-sub .photo-slot-hint { padding: 16px; font-size: 13px; }
.photo-slot-sub .photo-slot-icon { font-size: 22px; }

.btn-primary:disabled { opacity: 0.45; cursor: default; }
#btn-analyze { margin-top: 4px; }

.analyze-spinner {
  width: 34px;
  height: 34px;
  margin: 8px auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.analyze-loading-text { text-align: center; font-size: 14px; color: var(--text-sub); }

.result-item-edit {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.result-item-row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.result-item-name-input {
  flex: 1.3;
  min-width: 0;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}
.result-item-amount-input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}
.result-item-remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
}
.result-item-row2 { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.result-item-row2 label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-sub);
}
.result-item-row2 input {
  width: 56px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 6px;
}
.result-item-row2 span { color: var(--text-faint); }
.result-item-estimating { font-size: 13px; color: var(--primary-dark); }
.btn-add-item { margin: 10px 0 4px; }

.result-ratio {
  margin-top: 12px;
  padding: 10px 12px;
  background: #ecfdf5;
  border-radius: 12px;
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 600;
}
.result-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px 0 4px;
  font-size: 15px;
  font-weight: 800;
}
.result-total .kcal-big { font-size: 22px; color: var(--primary-dark); }
.result-notes { font-size: 13px; color: var(--text-sub); line-height: 1.6; margin-bottom: 14px; }
#btn-save-meal { margin-bottom: 10px; }

/* ── AI 教練評語 ── */
.coach-bubble {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f0fdf4;
  border: 1px solid #d1fae5;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.coach-emoji { font-size: 24px; line-height: 1.2; }
.coach-name { font-size: 12px; font-weight: 700; color: var(--primary-dark); margin-bottom: 2px; }
.coach-text { font-size: 14px; color: var(--text); line-height: 1.55; }
.coach-style-row { flex-wrap: wrap; margin-bottom: 0; }

/* ── 養成夥伴（主畫面 Hero）── */
.companion-card {
  padding: 16px 18px 18px;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 72%);
  text-align: center;
}
.companion-head { display: flex; align-items: center; gap: 8px; }
.companion-name { font-size: 15px; font-weight: 800; color: var(--text); }
.companion-streak { font-size: 13px; font-weight: 700; color: #f59e0b; }
.companion-stage { padding: 10px 0 4px; animation: companion-idle 3.2s ease-in-out infinite; }
.companion-emoji { font-size: 96px; line-height: 1; }
@keyframes companion-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.03); }
}
.companion-bubble {
  position: relative;
  background: var(--bg);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 10px auto 12px;
  max-width: 340px;
  font-size: 14px; color: var(--text-sub); line-height: 1.55;
}
.companion-bubble::before {
  content: '';
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  border: 8px solid transparent; border-top: none;
  border-bottom: 8px solid var(--bg);
}
.companion-cta {
  display: block; width: 100%; max-width: 340px; margin: 0 auto 12px;
  border: none; border-radius: 14px; padding: 13px 16px;
  background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}
.companion-cta:active { transform: scale(0.97); }
.companion-signin-hint { font-size: 12px; color: var(--text-faint); }
.companion-dots-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.companion-dots-label { font-size: 11px; color: var(--text-faint); }
.companion-dots { display: flex; gap: 5px; }
.cdot { width: 9px; height: 9px; border-radius: 50%; }
.cdot-full { background: #10b981; }
.cdot-partial { background: #fbbf24; }
.cdot-none { background: var(--border); }

/* ── 功能說明 ── */
.guide-item { border-bottom: 1px solid var(--border); padding: 4px 0; }
.guide-item:last-child { border-bottom: none; }
.guide-item summary { cursor: pointer; font-size: 14px; font-weight: 600; padding: 8px 0; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.guide-item summary::-webkit-details-marker { display: none; }
.guide-item summary::after { content: '▾'; color: var(--text-faint); font-size: 12px; transition: transform .2s; }
.guide-item[open] summary::after { transform: rotate(180deg); }
.guide-body { font-size: 13px; color: var(--text-sub); line-height: 1.7; padding-bottom: 10px; }
.guide-body p { margin: 6px 0; }
.guide-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.guide-table td { padding: 5px 8px; border: 1px solid var(--border); }
.guide-table td:first-child { width: 84px; white-space: nowrap; }
.guide-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 2px; vertical-align: middle; }
.guide-dot-full { background: #10b981; }
.guide-dot-partial { background: #fbbf24; }
.guide-dot-none { background: var(--border); }

/* ── 小食栽互動 ── */
@keyframes companion-shake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  20% { transform: rotate(-10deg) scale(1.13); }
  40% { transform: rotate(10deg) scale(1.17); }
  60% { transform: rotate(-6deg) scale(1.1); }
  80% { transform: rotate(6deg) scale(1.06); }
}
.companion-shake { animation: companion-shake 0.48s ease; }
.companion-emoji { cursor: pointer; display: inline-block; transition: filter 0.6s ease, transform 0.6s ease; }

/* 枯萎前兆：傍晚還沒記錄，葉子垂下、褪色，停掉呼吸動畫 */
.companion-wilt { filter: grayscale(0.55) saturate(0.6) brightness(0.92); transform: rotate(14deg); }
.companion-stage:has(.companion-wilt) { animation-play-state: paused; }

/* 成長卡分享按鈕 */
.companion-share {
  margin-left: auto; border: none; background: #ecfdf5;
  border-radius: 12px; padding: 3px; font-size: 15px; cursor: pointer; line-height: 1;
}
.companion-share:active { transform: scale(0.92); }
.share-wreath-icon { width: 32px; height: 32px; display: block; }

/* 免登入體驗 banner */
.demo-banner {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 14px;
  padding: 12px 16px;
}

/* ── 場景/心情 ── */
.mood-row { margin: 8px 0 12px; }
.mood-label { font-size: 12px; color: var(--text-faint); display: block; margin-bottom: 6px; }
.mood-chip-row { flex-wrap: wrap; gap: 6px; }

/* ── 體重目標 / BMI ── */
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.goal-grid-item { display: flex; flex-direction: column; gap: 6px; }
.goal-label { font-size: 13px; color: var(--text-sub); }
.bmi-row { display: flex; align-items: center; gap: 20px; padding: 4px 0 8px; }
.bmi-main { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bmi-value { font-size: 38px; font-weight: 800; line-height: 1; }
.bmi-label { font-size: 14px; font-weight: 700; }
.bmi-detail { font-size: 13px; color: var(--text-sub); line-height: 1.7; }
.bmi-goal-text { font-size: 13px; font-weight: 600; margin-top: 4px; }
.meal-mood { font-size: 13px; margin-left: 3px; }

/* ── 日曆搜尋 ── */
.cal-search-card { padding-bottom: 8px; }
.cal-search-input { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px; background: var(--bg); color: var(--text); outline: none; }
.cal-search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px #10b98122; }
.cal-search-result-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.cal-search-result-item:last-child { border-bottom: none; }
.cal-search-date { font-size: 12px; color: var(--text-faint); white-space: nowrap; min-width: 38px; }
.cal-search-meal-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-search-kcal { font-size: 13px; font-weight: 700; color: var(--primary-dark); white-space: nowrap; }
.cal-empty { font-size: 14px; color: var(--text-faint); padding: 14px 0; text-align: center; }

/* ── 下一餐建議 ── */
#next-meal-result { margin-top: 14px; }
#next-meal-result .coach-bubble { margin-bottom: 10px; }
.suggest-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.suggest-item:last-child { margin-bottom: 0; }
.suggest-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.suggest-scene { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.suggest-kcal { font-size: 14px; font-weight: 800; color: var(--text); }
.suggest-combo { font-size: 14px; color: var(--text); line-height: 1.5; margin-bottom: 4px; }
.suggest-macros { font-size: 12px; color: var(--text-faint); }
.suggest-why { font-size: 13px; color: var(--text-sub); line-height: 1.5; margin-top: 6px; }
.suggest-accept {
  display: block; width: 100%; margin-top: 10px;
  border: 1.5px solid var(--primary); border-radius: 10px; padding: 9px 12px;
  background: #ecfdf5; color: var(--primary-dark);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.suggest-accept:disabled { opacity: 0.55; cursor: default; }
.suggest-accept:not(:disabled):active { transform: scale(0.97); }

/* ── 食栽任務卡 ── */
.mission-card {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1.5px solid #fcd34d;
}
.mission-card.mission-done {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-color: #6ee7b7;
}
.mission-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; font-weight: 800; color: #92400e; margin-bottom: 6px;
}
.mission-done .mission-head { color: var(--primary-dark); }
.mission-abandon {
  border: none; background: none; cursor: pointer;
  font-size: 14px; color: #b45309; padding: 2px 6px; line-height: 1;
}
.mission-combo { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.mission-week { font-size: 12px; color: var(--text-sub); }

/* ── 品種圖鑑＋徽章牆 ── */
.badge-section-head { font-size: 14px; font-weight: 700; color: var(--text); margin: 14px 0 8px; }
.badge-count { font-size: 12px; font-weight: 600; color: var(--text-sub); margin-left: 4px; }
.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge-cell {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 10px 4px 8px; border-radius: 12px;
  background: #ecfdf5; border: 1px solid #d1fae5;
}
.badge-emoji { font-size: 28px; line-height: 1.2; }
.badge-name { font-size: 12px; font-weight: 700; color: var(--primary-dark); margin-top: 4px; }
.badge-cond { font-size: 10px; color: var(--text-sub); margin-top: 2px; line-height: 1.3; }
.badge-locked { background: #f3f4f6; border-color: #e5e7eb; }
.badge-locked .badge-emoji { filter: grayscale(1); opacity: .45; }
.badge-locked .badge-name { color: #9ca3af; }

/* 每月主題挑戰 */
.theme-cur {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 14px;
  background: #fffbeb; border: 1px solid #fde68a;
}
.theme-cur.theme-got { background: #ecfdf5; border-color: #6ee7b7; }
.theme-cur-img { width: 64px; height: 64px; flex-shrink: 0; }
.theme-cur:not(.theme-got) .theme-cur-img { filter: grayscale(.7); opacity: .75; }
.theme-cur-info { flex: 1; min-width: 0; }
.theme-cur-title { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.theme-cur-sub { font-size: 12px; color: var(--text-sub); }
.theme-bar { height: 8px; border-radius: 4px; background: #fde68a; overflow: hidden; margin-bottom: 6px; }
.theme-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #34d399, var(--primary-dark)); transition: width .4s; }
.theme-cell-img { width: 44px; height: 44px; }
#badges-theme:not(:empty) { margin-top: 8px; }

/* ── 今日儀表板 ── */
.today-hero { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; }
.kcal-ring-wrap { position: relative; width: 130px; height: 130px; flex-shrink: 0; }
.kcal-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--border); }
.ring-fg {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
}
.ring-fg.over { stroke: #f59e0b; }
.kcal-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.kcal-eaten { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kcal-unit { font-size: 12px; color: var(--text-sub); }
.today-hero-side { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.hero-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
}
.hero-stat-label { font-size: 13px; color: var(--text-sub); font-weight: 600; }

.macro-row { display: flex; flex-direction: column; gap: 10px; }
.macro-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 600;
  margin-bottom: 4px;
}
.macro-bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.macro-fill { height: 100%; width: 0; border-radius: 999px; transition: width 0.5s ease; }
.fill-protein { background: #3b82f6; }
.fill-carbs { background: #f59e0b; }
.fill-fat { background: #ef4444; }

.meal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.meal-row:last-child { border-bottom: none; }
.meal-type-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  background: #ecfdf5;
  border-radius: 999px;
  padding: 3px 10px;
}
.meal-info { flex: 1; min-width: 0; }
.meal-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-macros { font-size: 12px; color: var(--text-faint); }
.meal-kcal { font-size: 14px; font-weight: 700; white-space: nowrap; }
.meal-ratio-badge { font-size: 11px; font-weight: 600; color: #0284c7; background: #e0f2fe; border-radius: 999px; padding: 1px 7px; margin-left: 5px; }
.meal-after {
  flex-shrink: 0;
  border: none;
  background: none;
  font-size: 16px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px;
}
.meal-after:hover { color: var(--primary); }
.after-mode-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.after-mode-label { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.meal-delete {
  flex-shrink: 0;
  border: none;
  background: none;
  font-size: 16px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 6px;
}
.today-empty-hint { font-size: 14px; color: var(--text-sub); text-align: center; padding: 12px 0; }

/* ── 目標設定 ── */
.goal-input-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.goal-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
}
.goal-label { width: 52px; font-size: 14px; font-weight: 600; color: var(--text-sub); white-space: nowrap; }
.goal-unit { font-size: 14px; color: var(--text-sub); white-space: nowrap; width: 32px; }
.goal-hint { font-size: 13px; color: var(--primary-dark); margin-top: 10px; min-height: 1em; }
.key-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  margin-bottom: 12px;
}

/* ── 體重趨勢 ── */
.trend-stats { display: flex; gap: 10px; margin-bottom: 14px; }
.trend-stat {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 12px;
  text-align: center;
}
.trend-stat-label { font-size: 12px; color: var(--text-sub); margin-bottom: 2px; }
.trend-stat-value { font-size: 17px; font-weight: 800; }
.trend-stat-value.down { color: var(--primary-dark); }
.trend-stat-value.up { color: #ef4444; }
#trend-chart { display: block; width: 100%; height: 160px; }

.weight-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.weight-row:last-child { border-bottom: none; }
.weight-date { color: var(--text-sub); }
.weight-value { font-weight: 700; }
.weight-delete {
  border: none;
  background: none;
  font-size: 15px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 6px;
}

/* ── 歷史日曆 ── */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font-size: 16px; font-weight: 800; }
.cal-nav {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: none;
  font-size: 20px;
  color: var(--text-sub);
  cursor: pointer;
  line-height: 1;
}
.cal-summary { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.cal-summary strong { font-size: 17px; color: var(--primary-dark); }

.cal-chart-card { padding-bottom: 10px; }
.cal-chart-title { font-size: 13px; font-weight: 700; color: var(--text-sub); margin-bottom: 8px; }
.cal-chart { display: block; width: 100%; height: 112px; }
.cal-bar-hit { cursor: pointer; }
.cal-bar.selected { stroke: var(--text); stroke-width: 1.5; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-faint);
  font-family: inherit;
}
.nav-item.active { color: var(--primary-dark); }
.nav-icon { font-size: 20px; filter: grayscale(1) opacity(0.55); }
.nav-item.active .nav-icon { filter: none; }
.nav-label { font-size: 11px; font-weight: 600; }

.nav-camera { position: relative; }
.nav-camera-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, var(--primary-dark));
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transform: translateY(-10px);
  transition: transform 0.15s ease;
}
.nav-camera:active .nav-camera-btn { transform: translateY(-10px) scale(0.92); }
.water-lens-icon { width: 27px; height: 27px; display: block; }
.nav-camera-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(52, 211, 153, 0.55);
  animation: camera-invite 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes camera-invite {
  0% { transform: scale(0.85); opacity: 0.9; }
  60% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}
