:root {
  --bg-page: #F4F7F5;
  --bg-card: #FFFFFF;
  --bg-subtle: #EFF4F1;
  --bg-mint-soft: #E8F7F1;
  --bg-mint-tint: #F2FAF6;

  --mint-primary: #26B682;
  --mint-deep: #1D966A;
  --mint-light: #BCEAD8;

  --tone-protein: #26B682;
  --tone-fat: #679B8E;
  --tone-carbs: #4F8EA6;
  --tone-fiber: #77A573;
  --tone-neutral: #84968F;

  --text-main: #1B2823;
  --text-secondary: #5A6D66;
  --text-muted: #8A9C95;

  --border-soft: rgba(27, 40, 35, 0.06);
  --border-medium: rgba(27, 40, 35, 0.11);
  --shadow-card: 0 4px 18px rgba(22, 46, 36, 0.04);
  --shadow-float: 0 10px 30px rgba(22, 46, 36, 0.10);

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: -0.015em;
}

.app-shell {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-top: calc(var(--safe-top) + 8px);
  padding-bottom: calc(var(--safe-bottom) + 94px);
  position: relative;
}

/* 顶部导航与周历 */
.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(244, 247, 245, 0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 6px 16px 10px;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.brand-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mint-primary);
  display: inline-block;
}

.date-Selector-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  position: relative;
}

.date-Selector-pill input[type="date"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
  background: var(--bg-subtle);
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.week-day-btn {
  border: none;
  background: transparent;
  padding: 6px 2px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background-color 0.18s ease, color 0.18s ease;
}

.week-day-btn .wd-name {
  font-size: 12px;
  color: var(--text-muted);
}

.week-day-btn .wd-num {
  font-size: 14px;
  font-weight: 600;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-day-btn.active .wd-num {
  background: var(--bg-mint-soft);
  color: var(--mint-deep);
}

.week-day-btn.has-log .wd-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mint-primary);
}

.week-day-btn:not(.has-log) .wd-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
}

/* 卡片容器 */
.main-content {
  padding: 4px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.subtle-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--mint-deep);
  background: var(--bg-mint-soft);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
}

/* 核心热量圆环与五大营养素卡片 */
.energy-ring-layout {
  display: grid;
  grid-template-columns: 1fr 146px 1fr;
  align-items: center;
  text-align: center;
  margin: 2px 0 14px;
}

.side-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.side-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.side-stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ring-box {
  position: relative;
  width: 146px;
  height: 146px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-svg {
  width: 146px;
  height: 146px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--bg-subtle);
  stroke-width: 10;
}

.ring-progress {
  fill: none;
  stroke: var(--mint-primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.ring-caption {
  font-size: 11px;
  color: var(--text-muted);
}

.ring-number {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.15;
  margin: 2px 0;
}

.ring-budget {
  font-size: 11px;
  color: var(--text-muted);
}

/* 营养素进度区（平和无红绿灯） */
.macros-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}

.macro-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.macro-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.macro-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.macro-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.macro-bar-wrap {
  position: relative;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 99px;
  overflow: hidden;
}

.macro-range-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(38, 182, 130, 0.14);
  border-radius: 99px;
}

.macro-tick {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 1.5px;
  background: rgba(27, 40, 35, 0.25);
  z-index: 2;
}

.macro-bar-fill {
  position: relative;
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s ease;
  z-index: 1;
}

.macro-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* 盐摄入纯展示条（不设考核进度条） */
.salt-display-row {
  margin-top: 11px;
  padding: 9px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.salt-left {
  color: var(--text-secondary);
  font-weight: 500;
}

.salt-right {
  color: var(--text-main);
  font-weight: 600;
}

.salt-right span {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* 苹果健康每日一键同步条 */
.health-sync-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  background: linear-gradient(135deg, #FFFFFF 0%, #F4FAF7 100%);
}

.sync-info {
  min-width: 0;
}

.sync-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.heart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #F0F5F3;
  color: var(--mint-deep);
  font-size: 12px;
}

.sync-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-primary-mint {
  border: none;
  background: var(--mint-primary);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn-primary-mint:active {
  transform: scale(0.96);
}

.btn-primary-mint:disabled {
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: default;
  transform: none;
}

/* 首页近7日趋势视图（热量均值 + 体重7日均值线） */
.trend-section-block + .trend-section-block {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--border-soft);
}

.trend-headline-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.trend-kicker {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.trend-big-num {
  font-size: 21px;
  font-weight: 700;
  color: var(--text-main);
}

.trend-big-num small {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 3px;
}

.trend-meta-right {
  text-align: right;
  font-size: 12px;
  color: var(--text-secondary);
}

.chart-canvas-wrap {
  width: 100%;
  height: 128px;
  position: relative;
}

.chart-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.weight-goal-strip {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 7px 11px;
  border-radius: 10px;
}

/* 餐次卡片 */
.meal-card {
  padding: 14px 16px;
}

.meal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meal-title-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.meal-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.meal-suggest {
  font-size: 12px;
  color: var(--text-muted);
}

.meal-kcal-total {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.meal-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip-action-btn {
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s ease;
}

.chip-action-btn:active {
  background: var(--bg-mint-soft);
  color: var(--mint-deep);
}

.chip-action-btn.mint-tint {
  background: var(--bg-mint-tint);
  color: var(--mint-deep);
  border-color: rgba(38, 182, 130, 0.18);
}

.food-log-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
}

.food-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border-soft);
  cursor: pointer;
}

.food-log-main {
  min-width: 0;
  flex: 1;
}

.food-log-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.synced-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 1px 7px;
  border-radius: 99px;
}

.food-log-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.food-log-right {
  text-align: right;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.food-log-kcal {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.meal-empty-hint {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 底部固定快捷添加栏（还原图2底部极简5键） */
.bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  padding-bottom: var(--safe-bottom);
}

.bottom-dock-inner {
  max-width: 460px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 7px 8px 8px;
}

.dock-btn {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px;
  cursor: pointer;
  color: var(--text-main);
}

.dock-btn:active {
  opacity: 0.65;
}

.dock-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--bg-mint-soft);
  color: var(--mint-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.dock-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* 底部弹出抽屉与模态框 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(18, 28, 24, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.sheet-panel {
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  background: var(--bg-card);
  border-radius: 24px 24px 0 0;
  padding: 16px 18px calc(var(--safe-bottom) + 20px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-float);
  animation: sheetUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheetUp {
  from {
    transform: translateY(36px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.sheet-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.sheet-close {
  border: none;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.sheet-body {
  overflow-y: auto;
  padding-top: 12px;
  flex: 1;
}

/* 搜索框与输入表单（16px防iOS自动放大） */
.search-input-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.text-input, .select-input {
  width: 100%;
  border: 1px solid var(--border-medium);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.text-input:focus, .select-input:focus {
  background: #FFFFFF;
  border-color: var(--mint-primary);
}

.cat-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 6px;
  scrollbar-width: none;
}

.cat-tabs::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  border: none;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  cursor: pointer;
}

.cat-tab.active {
  background: var(--mint-primary);
  color: #FFFFFF;
}

.food-picker-list {
  display: flex;
  flex-direction: column;
}

.food-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}

.food-picker-item:active {
  background: var(--bg-mint-tint);
}

.fp-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.fp-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.fp-kcal {
  font-size: 13px;
  font-weight: 600;
  color: var(--mint-deep);
  white-space: nowrap;
}

/* 食物分量与生熟换算表单 */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.seg-control {
  display: flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  gap: 3px;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
}

.seg-btn.active {
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.converter-box {
  background: var(--bg-mint-tint);
  border: 1px solid rgba(38, 182, 130, 0.2);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.preset-chip {
  border: 1px solid var(--border-medium);
  background: #FFFFFF;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 99px;
  cursor: pointer;
}

.preset-chip.active {
  border-color: var(--mint-primary);
  color: var(--mint-deep);
  background: var(--bg-mint-soft);
}

.live-calc-preview {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
  margin-bottom: 14px;
}

.lcp-item span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.lcp-item strong {
  font-size: 15px;
  color: var(--text-main);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-full {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.btn-outline {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.btn-danger-soft {
  background: #F3F5F4;
  color: #5C6B66;
  border: 1px solid var(--border-medium);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.notice-box {
  background: var(--bg-subtle);
  border-left: 3px solid var(--mint-primary);
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 14px;
}

/* 轻提示 Toast */
.toast-msg {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  transform: translateX(-50%) translateY(16px);
  background: rgba(27, 40, 35, 0.92);
  color: #FFFFFF;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 88vw;
  text-align: center;
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
