/* ==========================================================================
   营养配餐系统 — Complete Stylesheet
   Based on DESIGN.md specification
   ========================================================================== */

/* ==========================================================================
   1. CSS Custom Properties (Design Tokens)
   ========================================================================== */
:root {
  /* --- Brand Colors --- */
  --color-primary: #16A34A;
  --color-primary-light: #4ADE80;
  --color-primary-lighter: #BBF7D0;
  --color-primary-lightest: #F0FDF4;
  --color-primary-dark: #15803D;
  --color-primary-darker: #166534;

  /* --- Accent Colors --- */
  --color-accent: #F97316;
  --color-accent-light: #FDBA74;
  --color-accent-lightest: #FFF7ED;

  /* --- Semantic Colors --- */
  --color-success: #22C55E;
  --color-success-bg: #F0FDF4;
  --color-warning: #F59E0B;
  --color-warning-bg: #FFFBEB;
  --color-danger: #EF4444;
  --color-danger-bg: #FEF2F2;
  --color-info: #3B82F6;
  --color-info-bg: #EFF6FF;

  /* --- Pyramid Layer Colors (bottom → top) --- */
  --pyramid-grain: #D97706;
  --pyramid-grain-bg: #FEF3C7;
  --pyramid-vegetable: #16A34A;
  --pyramid-vegetable-bg: #DCFCE7;
  --pyramid-fruit: #EA580C;
  --pyramid-fruit-bg: #FED7AA;
  --pyramid-meat: #DC2626;
  --pyramid-meat-bg: #FEE2E2;
  --pyramid-fish: #0891B2;
  --pyramid-fish-bg: #CFFAFE;
  --pyramid-egg: #CA8A04;
  --pyramid-egg-bg: #FEF9C3;
  --pyramid-dairy: #9333EA;
  --pyramid-dairy-bg: #F3E8FF;
  --pyramid-oil: #6B7280;
  --pyramid-oil-bg: #F3F4F6;

  /* --- Neutral Colors --- */
  --color-bg: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-surface-2: #F1F5F9;
  --color-text-primary: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-tertiary: #94A3B8;
  --color-text-inverse: #FFFFFF;
  --color-border: #E2E8F0;
  --color-border-light: #F1F5F9;
  --color-divider: #E2E8F0;
  --color-shadow: rgba(0, 0, 0, 0.06);
  --color-overlay: rgba(0, 0, 0, 0.4);

  /* --- Typography --- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Roboto Mono", "Courier New", monospace;

  --text-display: 2rem;       /* 32px */
  --text-h1: 1.5rem;          /* 24px */
  --text-h2: 1.25rem;         /* 20px */
  --text-h3: 1.125rem;        /* 18px */
  --text-body: 1rem;          /* 16px */
  --text-body-sm: 0.875rem;   /* 14px */
  --text-caption: 0.75rem;    /* 12px */
  --text-overline: 0.6875rem; /* 11px */

  /* --- Spacing (4px base) --- */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* --- Border Radius --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* --- Container --- */
  --container-max: 480px;
  --container-padding: 16px;
  --tab-bar-height: 60px;
  --header-height: 56px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.10);

  /* --- Transitions --- */
  --transition-fast: 150ms ease-out;
  --transition-normal: 250ms ease-out;
  --transition-slow: 400ms ease-in-out;
}

/* ==========================================================================
   2. Reset & Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--color-text-primary);
  background: #E2E8F0;
  min-height: 100vh;
}

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

ul, ol { list-style: none; }

/* ==========================================================================
   3. App Shell Layout
   ========================================================================== */
.app-shell {
  max-width: var(--container-max);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-lg);
}

/* Page container — one visible at a time */
.page {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.page.active {
  display: flex;
}

/* Page header */
.page-header {
  height: var(--header-height);
  padding: 0 var(--container-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.page-header h1 {
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--color-text-primary);
}

/* Page content — scrollable */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--tab-bar-height) + var(--space-4) + var(--safe-area-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   4. Typography Utilities
   ========================================================================== */
.text-display { font-size: var(--text-display); font-weight: 700; line-height: 1.2; }
.text-h1 { font-size: var(--text-h1); font-weight: 700; line-height: 1.3; }
.text-h2 { font-size: var(--text-h2); font-weight: 600; line-height: 1.3; }
.text-h3 { font-size: var(--text-h3); font-weight: 600; line-height: 1.4; }
.text-body { font-size: var(--text-body); font-weight: 400; line-height: 1.5; }
.text-body-sm { font-size: var(--text-body-sm); font-weight: 400; line-height: 1.5; }
.text-caption { font-size: var(--text-caption); font-weight: 400; line-height: 1.4; }
.text-overline {
  font-size: var(--text-overline);
  font-weight: 600;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-inverse { color: var(--color-text-inverse); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Numeric — tabular figures for aligned data display */
.numeric {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ==========================================================================
   5. Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-body);
  font-weight: 600;
  transition: background var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

/* Primary */
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.btn-primary:active {
  background: var(--color-primary-dark);
}

/* Secondary */
.btn-secondary {
  background: var(--color-primary-lightest);
  color: var(--color-primary);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
}
.btn-ghost:active {
  background: var(--color-primary-lightest);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}

/* Full width */
.btn-block {
  width: 100%;
}

/* Small */
.btn-sm {
  height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-body-sm);
}

/* Icon button */
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast);
}
.btn-icon:active {
  background: var(--color-surface-2);
}

/* ==========================================================================
   6. Card (Base)
   ========================================================================== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.card-tappable {
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.card-tappable:active {
  background: var(--color-surface-2);
}

/* ==========================================================================
   7. Calorie Ring (Circular Progress)
   ========================================================================== */
.calorie-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
}

.calorie-ring__svg {
  position: relative;
  width: 160px;
  height: 160px;
}

.calorie-ring__svg svg {
  transform: rotate(-90deg);
}

.calorie-ring__bg {
  fill: none;
  stroke: var(--color-surface-2);
  stroke-width: 12;
}

.calorie-ring__fg {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-slow);
}

/* Status color variants */
.calorie-ring--warning .calorie-ring__fg { stroke: var(--color-warning); }
.calorie-ring--danger .calorie-ring__fg { stroke: var(--color-danger); }

.calorie-ring__center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.calorie-ring__value {
  font-size: var(--text-display);
  font-weight: 700;
  line-height: 1;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.calorie-ring__unit {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.calorie-ring__target {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Macro nutrient mini bars under ring */
.macro-mini {
  display: flex;
  gap: var(--space-6);
  justify-content: center;
}

.macro-mini__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.macro-mini__label {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.macro-mini__value {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.macro-mini__bar {
  width: 48px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  overflow: hidden;
  margin-top: 2px;
}

.macro-mini__bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.macro-mini__bar-fill--protein { background: #3B82F6; }
.macro-mini__bar-fill--fat { background: #F59E0B; }
.macro-mini__bar-fill--carb { background: #22C55E; }

/* ==========================================================================
   8. Meal Card (餐次卡片)
   ========================================================================== */
.meal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.meal-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  cursor: pointer;
}

.meal-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--color-primary-lightest);
  flex-shrink: 0;
}

.meal-card__icon--breakfast { background: #FEF3C7; }
.meal-card__icon--lunch { background: #DBEAFE; }
.meal-card__icon--dinner { background: #E0E7FF; }
.meal-card__icon--snack { background: #FCE7F3; }

.meal-card__title-group {
  flex: 1;
  min-width: 0;
}

.meal-card__title {
  font-size: var(--text-h3);
  font-weight: 600;
  color: var(--color-text-primary);
}

.meal-card__time {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.meal-card__calories {
  text-align: right;
  flex-shrink: 0;
}

.meal-card__calorie-value {
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.meal-card__calorie-unit {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.meal-card__body {
  padding: 0 var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.meal-card__food-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.meal-card__food-item:last-child {
  border-bottom: none;
}

.meal-card__food-name {
  font-size: var(--text-body-sm);
  color: var(--color-text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-card__food-amount {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
  margin: 0 var(--space-3);
  flex-shrink: 0;
}

.meal-card__food-calories {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.meal-card__add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3);
  margin: 0 var(--space-4) var(--space-4);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  font-size: var(--text-body-sm);
  font-weight: 600;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.meal-card__add-btn:active {
  border-color: var(--color-primary);
  background: var(--color-primary-lightest);
}

/* Empty state */
.meal-card--empty .meal-card__header {
  border-bottom: none;
}

.meal-card__empty-text {
  padding: 0 var(--space-4) var(--space-4);
  font-size: var(--text-body-sm);
  color: var(--color-text-tertiary);
  text-align: center;
}

/* ==========================================================================
   9. Food Card (食物搜索结果)
   ========================================================================== */
.food-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.food-card:active {
  background: var(--color-surface-2);
}

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

.food-card__name {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.food-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.food-card__category {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  background: var(--color-surface-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

.food-card__nutrients {
  display: flex;
  gap: var(--space-4);
}

.food-card__nutrient {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.food-card__nutrient-label {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.food-card__nutrient-value {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.food-card__calories {
  text-align: right;
  flex-shrink: 0;
}

.food-card__calorie-value {
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.food-card__calorie-unit {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

/* ==========================================================================
   10. Nutrition Label (营养标签 — 小圆点+数值)
   ========================================================================== */
.nutrition-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}

.nutrition-label__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.nutrition-label__value {
  font-weight: 600;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

/* Dot color variants */
.nutrition-label__dot--success { background: var(--color-success); }
.nutrition-label__dot--warning { background: var(--color-warning); }
.nutrition-label__dot--danger { background: var(--color-danger); }

/* Pyramid category dots */
.nutrition-label__dot--grain { background: var(--pyramid-grain); }
.nutrition-label__dot--vegetable { background: var(--pyramid-vegetable); }
.nutrition-label__dot--fruit { background: var(--pyramid-fruit); }
.nutrition-label__dot--meat { background: var(--pyramid-meat); }
.nutrition-label__dot--fish { background: var(--pyramid-fish); }
.nutrition-label__dot--egg { background: var(--pyramid-egg); }
.nutrition-label__dot--dairy { background: var(--pyramid-dairy); }
.nutrition-label__dot--oil { background: var(--pyramid-oil); }

/* ==========================================================================
   11. Linear Progress Bar
   ========================================================================== */
.progress-bar {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar__fill--success { background: var(--color-success); }
.progress-bar__fill--warning { background: var(--color-warning); }
.progress-bar__fill--danger { background: var(--color-danger); }

/* Overfill marker — for >100% values */
.progress-bar__marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  background: var(--color-danger);
  border-radius: var(--radius-full);
  transform: translateX(-50%);
}

/* Larger variant for nutrient detail rows */
.progress-bar--lg {
  height: 8px;
}

/* ==========================================================================
   12. Nutrient Detail Row (营养素详情行)
   ========================================================================== */
.nutrient-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.nutrient-row:last-child {
  border-bottom: none;
}

.nutrient-row__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nutrient-row__name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.nutrient-row__values {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  font-variant-numeric: tabular-nums;
}

.nutrient-row__actual {
  font-size: var(--text-body);
  font-weight: 700;
  color: var(--color-text-primary);
}

.nutrient-row__separator {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.nutrient-row__reference {
  font-size: var(--text-body-sm);
  color: var(--color-text-secondary);
}

.nutrient-row__unit {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.nutrient-row__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nutrient-row__percent {
  font-size: var(--text-caption);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nutrient-row__percent--success { color: var(--color-success); }
.nutrient-row__percent--warning { color: var(--color-warning); }
.nutrient-row__percent--danger { color: var(--color-danger); }

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  font-weight: 600;
}

.status-badge--success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status-badge--warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.status-badge--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* ==========================================================================
   13. Search Input
   ========================================================================== */
.search-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.search-input:focus-within {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.search-input__icon {
  width: 20px;
  height: 20px;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.search-input__field {
  flex: 1;
  font-size: var(--text-body);
  color: var(--color-text-primary);
}

.search-input__field::placeholder {
  color: var(--color-text-tertiary);
}

.search-input__clear {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.search-input__clear:active {
  background: var(--color-border);
}

/* ==========================================================================
   14. Category Chip
   ========================================================================== */
.chip-group {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1) 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chip-group::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 32px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.chip:active {
  transform: scale(0.95);
}

.chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* Pyramid category chip — active state uses layer color */
.chip.active.chip--grain { background: var(--pyramid-grain); border-color: var(--pyramid-grain); }
.chip.active.chip--vegetable { background: var(--pyramid-vegetable); border-color: var(--pyramid-vegetable); }
.chip.active.chip--fruit { background: var(--pyramid-fruit); border-color: var(--pyramid-fruit); }
.chip.active.chip--meat { background: var(--pyramid-meat); border-color: var(--pyramid-meat); }
.chip.active.chip--fish { background: var(--pyramid-fish); border-color: var(--pyramid-fish); }
.chip.active.chip--egg { background: var(--pyramid-egg); border-color: var(--pyramid-egg); }
.chip.active.chip--dairy { background: var(--pyramid-dairy); border-color: var(--pyramid-dairy); }
.chip.active.chip--oil { background: var(--pyramid-oil); border-color: var(--pyramid-oil); }

.chip__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.chip__dot--grain { background: var(--pyramid-grain); }
.chip__dot--vegetable { background: var(--pyramid-vegetable); }
.chip__dot--fruit { background: var(--pyramid-fruit); }
.chip__dot--meat { background: var(--pyramid-meat); }
.chip__dot--fish { background: var(--pyramid-fish); }
.chip__dot--egg { background: var(--pyramid-egg); }
.chip__dot--dairy { background: var(--pyramid-dairy); }
.chip__dot--oil { background: var(--pyramid-oil); }

.chip.active .chip__dot { background: var(--color-text-inverse); }

/* ==========================================================================
   15. Tab Bar (底部导航)
   ========================================================================== */
.tab-bar {
  height: var(--tab-bar-height);
  padding-bottom: var(--safe-area-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  align-items: stretch;
  position: sticky;
  bottom: 0;
  z-index: 100;
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--color-text-tertiary);
  transition: color var(--transition-fast);
}

.tab-item.active {
  color: var(--color-primary);
}

.tab-item__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-item__icon svg {
  width: 22px;
  height: 22px;
}

.tab-item__label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

/* ==========================================================================
   16. Food Detail Drawer (底部抽屉)
   ========================================================================== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
  z-index: 200;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: var(--container-max);
  max-height: 85vh;
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-xl);
  transition: transform var(--transition-normal);
  z-index: 201;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer.open {
  transform: translate(-50%, 0);
}

.drawer__handle {
  width: 36px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  margin: var(--space-2) auto var(--space-1);
  flex-shrink: 0;
}

.drawer__header {
  padding: var(--space-2) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.drawer__title {
  font-size: var(--text-h3);
  font-weight: 700;
  color: var(--color-text-primary);
}

.drawer__category {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  -webkit-overflow-scrolling: touch;
}

.drawer__footer {
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + var(--safe-area-bottom));
  border-top: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

/* Nutrition grid inside drawer */
.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.nutrition-grid__item {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-1);
  text-align: center;
}

.nutrition-grid__label {
  font-size: 10px;
  color: var(--color-text-tertiary);
  font-weight: 500;
  margin-bottom: 2px;
}

.nutrition-grid__value {
  font-size: var(--text-body-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.nutrition-grid__unit {
  font-size: 10px;
  color: var(--color-text-tertiary);
}

/* Serving size adjuster */
.serving-adjuster {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  margin: var(--space-3) 0;
}

.serving-adjuster__btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-h3);
  font-weight: 700;
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.serving-adjuster__btn:active {
  background: var(--color-primary-lightest);
}

.serving-adjuster__value-group {
  flex: 1;
  text-align: center;
}

.serving-adjuster__value {
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.serving-adjuster__unit {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.serving-adjuster__slider {
  width: 100%;
  margin-top: var(--space-2);
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  outline: none;
}

.serving-adjuster__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.serving-adjuster__slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* Meal selector inside drawer */
.meal-selector {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.meal-selector__option {
  flex: 1;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.meal-selector__option.active {
  border-color: var(--color-primary);
  background: var(--color-primary-lightest);
  color: var(--color-primary);
}

/* ==========================================================================
   17. Dietary Pyramid Visualization (膳食宝塔)
   ========================================================================== */
.pyramid {
  display: flex;
  flex-direction: column-reverse; /* Layer 1 at bottom */
  align-items: center;
  padding: var(--space-4) 0;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
}

.pyramid-layer {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.pyramid-layer:active {
  transform: scale(0.98);
}

.pyramid-layer.selected {
  filter: brightness(1.05) drop-shadow(0 0 6px rgba(0,0,0,0.15));
  z-index: 10;
}

/* Layer clip-paths (bottom→top, widths decrease 10% per layer) */
.pyramid-layer--1 {
  clip-path: polygon(5% 0, 95% 0, 100% 100%, 0% 100%);
}
.pyramid-layer--2 {
  clip-path: polygon(10% 0, 90% 0, 95% 100%, 5% 100%);
}
.pyramid-layer--3 {
  clip-path: polygon(15% 0, 85% 0, 90% 100%, 10% 100%);
}
.pyramid-layer--4 {
  clip-path: polygon(20% 0, 80% 0, 85% 100%, 15% 100%);
}
.pyramid-layer--5 {
  clip-path: polygon(25% 0, 75% 0, 80% 100%, 20% 100%);
}
.pyramid-layer--6 {
  clip-path: polygon(30% 0, 70% 0, 75% 100%, 25% 100%);
}
.pyramid-layer--7 {
  clip-path: polygon(35% 0, 65% 0, 70% 100%, 30% 100%);
}
.pyramid-layer--8 {
  clip-path: polygon(40% 0, 60% 0, 65% 100%, 35% 100%);
}

/* Layer colors — base */
.pyramid-layer--1 { background: var(--pyramid-grain); }
.pyramid-layer--2 { background: var(--pyramid-vegetable); }
.pyramid-layer--3 { background: var(--pyramid-fruit); }
.pyramid-layer--4 { background: var(--pyramid-meat); }
.pyramid-layer--5 { background: var(--pyramid-fish); }
.pyramid-layer--6 { background: var(--pyramid-egg); }
.pyramid-layer--7 { background: var(--pyramid-dairy); }
.pyramid-layer--8 { background: var(--pyramid-oil); }

/* Layer status — insufficient (<60%) */
.pyramid-layer.status-insufficient {
  opacity: 0.25;
}

/* Layer status — partial (60-99%) */
.pyramid-layer.status-partial {
  opacity: 0.5;
}

/* Layer status — met (100%) */
.pyramid-layer.status-met {
  opacity: 1;
}

/* Layer status — exceeded (>120%) */
.pyramid-layer.status-exceeded {
  opacity: 1;
  outline: 2px dashed var(--color-danger);
  outline-offset: -4px;
}

/* Layer label (inside) */
.pyramid-layer__label {
  font-size: var(--text-caption);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  pointer-events: none;
}

/* Layer label for insufficient/partial — use dark text */
.pyramid-layer.status-insufficient .pyramid-layer__label,
.pyramid-layer.status-partial .pyramid-layer__label {
  color: var(--color-text-primary);
  text-shadow: none;
}

/* External labels for narrow top layers (6-8) */
.pyramid-external-labels {
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  padding-left: 0;
}

.pyramid-ext-label {
  height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: var(--space-2);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}

.pyramid-ext-label__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.pyramid-ext-label__name {
  font-weight: 600;
  color: var(--color-text-primary);
}

.pyramid-ext-label__value {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary);
}

.pyramid-ext-label__status {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
}

/* Pyramid detail panel (below pyramid) */
.pyramid-detail {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.pyramid-detail__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pyramid-detail__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pyramid-detail__title {
  font-size: var(--text-h3);
  font-weight: 600;
  color: var(--color-text-primary);
}

.pyramid-detail__range {
  font-size: var(--text-body-sm);
  color: var(--color-text-secondary);
}

.pyramid-detail__progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.pyramid-detail__progress-header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}

.pyramid-detail__progress-value {
  font-weight: 700;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.pyramid-detail__foods {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.pyramid-detail__food {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-body-sm);
  padding: var(--space-1) 0;
}

.pyramid-detail__food-name {
  color: var(--color-text-primary);
}

.pyramid-detail__food-amount {
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   18. Pyramid Quick Bar (首页底部宝塔快览)
   ========================================================================== */
.pyramid-quick-bar {
  display: flex;
  gap: 2px;
  padding: var(--space-2);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.pyramid-quick-bar__item {
  flex: 1;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.pyramid-quick-bar__item--1 { background: var(--pyramid-grain); }
.pyramid-quick-bar__item--2 { background: var(--pyramid-vegetable); }
.pyramid-quick-bar__item--3 { background: var(--pyramid-fruit); }
.pyramid-quick-bar__item--4 { background: var(--pyramid-meat); }
.pyramid-quick-bar__item--5 { background: var(--pyramid-fish); }
.pyramid-quick-bar__item--6 { background: var(--pyramid-egg); }
.pyramid-quick-bar__item--7 { background: var(--pyramid-dairy); }
.pyramid-quick-bar__item--8 { background: var(--pyramid-oil); }

/* Status opacity */
.pyramid-quick-bar__item.status-insufficient { opacity: 0.25; }
.pyramid-quick-bar__item.status-partial { opacity: 0.5; }
.pyramid-quick-bar__item.status-met { opacity: 1; }
.pyramid-quick-bar__item.status-exceeded { opacity: 1; }
.pyramid-quick-bar__item.status-exceeded::after {
  content: "!";
  color: var(--color-text-inverse);
  font-weight: 700;
  font-size: var(--text-body-sm);
}

/* ==========================================================================
   19. Warning Banner (预警横幅)
   ========================================================================== */
.warning-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  font-size: var(--text-body-sm);
}

.warning-banner--warning {
  background: var(--color-warning-bg);
  border-left-color: var(--color-warning);
  color: #92400E;
}

.warning-banner--danger {
  background: var(--color-danger-bg);
  border-left-color: var(--color-danger);
  color: #991B1B;
}

.warning-banner__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.warning-banner__content {
  flex: 1;
}

.warning-banner__title {
  font-weight: 600;
  margin-bottom: 2px;
}

.warning-banner__detail {
  font-size: var(--text-caption);
  opacity: 0.8;
}

.warning-banner__close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.5;
}

/* ==========================================================================
   20. Radar Chart (营养素雷达图)
   ========================================================================== */
.radar-chart {
  display: flex;
  justify-content: center;
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.radar-chart__svg {
  width: 280px;
  height: 280px;
}

.radar-chart__grid {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 1;
}

.radar-chart__axis {
  stroke: var(--color-border-light);
  stroke-width: 1;
}

.radar-chart__target {
  fill: var(--color-primary-lightest);
  stroke: var(--color-primary-light);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.radar-chart__actual {
  fill: rgba(22, 163, 74, 0.15);
  stroke: var(--color-primary);
  stroke-width: 2;
}

.radar-chart__label {
  font-size: 10px;
  fill: var(--color-text-secondary);
  text-anchor: middle;
  dominant-baseline: middle;
}

.radar-chart__dot {
  fill: var(--color-primary);
}

/* ==========================================================================
   21. Line Chart (能量趋势折线图)
   ========================================================================== */
.line-chart {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.line-chart__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.line-chart__title {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
}

.line-chart__period {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.line-chart__svg {
  width: 100%;
  height: 160px;
}

.line-chart__grid-line {
  stroke: var(--color-border-light);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.line-chart__area {
  fill: url(#chart-gradient);
  opacity: 0.15;
}

.line-chart__line {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart__dot {
  fill: var(--color-surface);
  stroke: var(--color-primary);
  stroke-width: 2;
}

.line-chart__dot--active {
  fill: var(--color-primary);
}

.line-chart__label {
  font-size: 10px;
  fill: var(--color-text-tertiary);
  text-anchor: middle;
}

.line-chart__value {
  font-size: 10px;
  fill: var(--color-text-secondary);
  font-weight: 600;
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   22. Heatmap (宝塔达标热图)
   ========================================================================== */
.heatmap {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.heatmap__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.heatmap__title {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-primary);
}

.heatmap__grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 3px;
  align-items: center;
}

.heatmap__cell {
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.heatmap__cell--header {
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 10px;
}

.heatmap__cell--label {
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-caption);
  font-weight: 500;
  text-align: right;
  padding-right: var(--space-1);
}

/* Heatmap intensity colors */
.heatmap__cell--0 { background: var(--color-surface-2); color: var(--color-text-tertiary); }
.heatmap__cell--1 { background: var(--color-danger-bg); color: var(--color-danger); }
.heatmap__cell--2 { background: #FED7AA; color: #C2410C; }
.heatmap__cell--3 { background: var(--color-warning-bg); color: var(--color-warning); }
.heatmap__cell--4 { background: var(--color-primary-lighter); color: var(--color-primary-darker); }
.heatmap__cell--5 { background: var(--color-primary-light); color: var(--color-text-inverse); }
.heatmap__cell--6 { background: var(--color-success); color: var(--color-text-inverse); }

.heatmap__legend {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: 10px;
  color: var(--color-text-tertiary);
}

.heatmap__legend-bar {
  display: flex;
  gap: 2px;
}

.heatmap__legend-item {
  width: 16px;
  height: 12px;
  border-radius: 2px;
}

/* ==========================================================================
   23. Date List Item (历史记录列表)
   ========================================================================== */
.date-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.date-list-item:active {
  background: var(--color-surface-2);
}

.date-list-item__date {
  flex-shrink: 0;
  text-align: center;
  min-width: 44px;
}

.date-list-item__day {
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.date-list-item__month {
  font-size: var(--text-caption);
  color: var(--color-text-tertiary);
}

.date-list-item__info {
  flex: 1;
  min-width: 0;
}

.date-list-item__weekday {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.date-list-item__calories {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.date-list-item__badges {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.date-list-item__badge {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.date-list-item__chevron {
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

/* ==========================================================================
   24. Settings Form (设置页)
   ========================================================================== */
.settings-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.settings-section__title {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: var(--space-3) var(--space-4) var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  min-height: 52px;
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row__label {
  font-size: var(--text-body);
  color: var(--color-text-primary);
  font-weight: 500;
}

.settings-row__value {
  font-size: var(--text-body-sm);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Segmented control for gender/activity */
.segmented {
  display: inline-flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.segmented__option {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.segmented__option.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* DRI preview table */
.dri-table {
  width: 100%;
  border-collapse: collapse;
}

.dri-table th,
.dri-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--text-body-sm);
  border-bottom: 1px solid var(--color-border-light);
}

.dri-table th {
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dri-table td {
  color: var(--color-text-primary);
}

.dri-table td:last-child {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary);
}

/* ==========================================================================
   25. Advice Card (建议卡片)
   ========================================================================== */
.advice-card {
  background: var(--color-primary-lightest);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
  border: 1px solid var(--color-primary-lighter);
}

.advice-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.advice-card__content {
  flex: 1;
}

.advice-card__title {
  font-size: var(--text-body-sm);
  font-weight: 700;
  color: var(--color-primary-darker);
  margin-bottom: var(--space-1);
}

.advice-card__text {
  font-size: var(--text-body-sm);
  color: var(--color-primary-dark);
  line-height: 1.5;
}

/* ==========================================================================
   26. Utility Classes
   ========================================================================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-wrap { flex-wrap: wrap; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.hidden { display: none !important; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Section title (within page content) */
.section-title {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: var(--space-1) 0;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border-light) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
  gap: var(--space-3);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--color-text-tertiary);
}

.empty-state__title {
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--color-text-secondary);
}

.empty-state__text {
  font-size: var(--text-body-sm);
  color: var(--color-text-tertiary);
  max-width: 240px;
}

/* ==========================================================================
   27. Responsive (sm breakpoint ≥ 480px)
   ========================================================================== */
@media (min-width: 480px) {
  .app-shell {
    margin-top: env(safe-area-inset-top, 0px);
    min-height: calc(100vh - env(safe-area-inset-top, 0px));
  }
}

@media (min-width: 768px) {
  :root {
    --text-display: 2.25rem;
    --text-h1: 1.625rem;
  }

  .app-shell {
    margin: var(--space-4) auto;
    min-height: calc(100vh - var(--space-8));
    border-radius: var(--radius-xl);
    overflow: hidden;
  }
}
