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

:root {
  --bg: #FAFBFC;
  --surface: #FFFFFF;
  --surface-alt: #F0F3F1;
  --text: #12372A;
  --text-2: #2A4A3F;
  --muted: #6B7B73;
  --muted-2: #8B9B93;
  --border: #E8ECEA;
  --border-light: #F0F3F1;
  --primary: #12372A;
  --primary-dark: #0D2A20;
  --primary-light: #E8F0EC;
  --accent: #EF7651;
  --accent-dark: #C5653D;
  --accent-light: #FDF4F0;
  --highlight: #C8EF78;
  --highlight-bg: #F1FBE6;
  --highlight-ink: #5A7A2E;
  --warning: #E8B44C;
  --warning-light: #FDF6E8;
  --warning-ink: #8A6B1F;
  --info: #5079A5;
  --info-light: #EAF0F6;
  --danger: #C75B5B;
  --danger-light: #FAEEEE;
  --danger-ink: #9A3D3D;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(18,55,42,0.06);
  --shadow-md: 0 2px 12px rgba(18,55,42,0.08);
  --shadow-lg: 0 8px 32px rgba(18,55,42,0.14);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-num: 'SF Pro Display', -apple-system, 'Segoe UI', 'PingFang SC', sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Number font */
.num, .summary-value, .reco-value, .trend-stat-value, .meal-card-cal, .progress-panel-title {
  font-family: 'Inter', -apple-system, 'PingFang SC', sans-serif;
  font-variant-numeric: tabular-nums;
}

/* ==================== Topbar ==================== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
  min-width: 0;
}
.logo-icon { font-size: 1.4rem; flex-shrink: 0; }
.logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}
.profile-btn {
  min-width: 0;
  overflow: hidden;
}
.profile-btn #profileSummary {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.date-display {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.guide-trigger-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  height: 36px;
}
.guide-trigger-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.profile-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  height: 36px;
}
.profile-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ==================== Guide Bar ==================== */
.guide-bar {
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.guide-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
}
.guide-step {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.guide-step:hover { background: rgba(34,102,74,0.08); }
.guide-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.guide-step-text {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
}
.guide-arrow {
  color: var(--muted);
  font-size: 0.8rem;
}
.guide-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
}

/* ==================== App Container (2-column desktop dashboard) ==================== */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  align-items: start;
}

/* Columns */
.col-left, .col-center, .col-right,
.col-main, .col-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Panel base */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-input {
  position: static;
  max-height: none;
  overflow: visible;
}
.panel-input::-webkit-scrollbar { width: 4px; }
.panel-input::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ==================== Entry Center ==================== */
.entry-center {
  padding: 16px;
}
.entry-center-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.entry-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
}
.entry-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.entry-card-photo {
  border-color: var(--primary);
  border-width: 2px;
  background: var(--primary-light);
}
/* Secondary entry cards: side-by-side, smaller */
.entry-cards-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.entry-card-secondary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.entry-card-secondary:hover {
  border-color: var(--primary);
  background: var(--surface-alt);
}
.entry-card-secondary:active { transform: scale(0.97); }
.entry-card-secondary .entry-card-icon { font-size: 1.2rem; }
.entry-card-secondary .entry-card-title { font-size: 0.78rem; }
.entry-card-secondary .entry-card-desc {
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.3;
}
.entry-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  min-width: 48px;
}
.entry-card-icon { font-size: 1.4rem; }

/* SVG line icons for main functions */
.entry-icon-svg, .bottom-nav-icon-svg, .section-icon-svg {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.entry-icon-svg { width: 28px; height: 28px; }
.bottom-nav-icon-svg { width: 22px; height: 22px; }
.section-icon-svg { width: 18px; height: 18px; }
.entry-card-secondary .entry-icon-svg { width: 22px; height: 22px; }
.entry-card-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}
.entry-card-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}
.entry-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  height: 44px;
}
.entry-card-btn:hover { background: var(--primary-dark); }
.entry-card-btn:active { transform: scale(0.97); }
.entry-card-btn-green { background: var(--primary); }
.entry-card-btn-blue { background: var(--info); }
.entry-card-btn-blue:hover { background: #3D6790; }
.entry-card-time {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==================== AI Engine Badge ==================== */
.ai-engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--primary);
  margin-top: 8px;
}
.badge-dot {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ==================== Photo Progress Panel ==================== */
.photo-progress-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.progress-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.progress-panel-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}
.progress-panel-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.progress-panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}
.progress-panel-sub {
  font-size: 0.8rem;
  color: var(--muted);
}
.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  transition: var(--transition);
}
.progress-step-item.ps-active {
  background: var(--accent-light);
}
.progress-step-item.ps-done {
  background: var(--primary-light);
}
.progress-step-item.ps-error {
  background: var(--danger-light);
}
.ps-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--border);
  color: var(--muted);
  flex-shrink: 0;
  transition: var(--transition);
}
.ps-active .ps-icon {
  background: var(--accent);
  color: #fff;
  animation: psPulse 1.5s ease-in-out infinite;
}
.ps-done .ps-icon {
  background: var(--primary);
  color: #fff;
}
.ps-error .ps-icon {
  background: var(--danger);
  color: #fff;
}
@keyframes psPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.ps-text {
  font-size: 0.82rem;
  color: var(--text);
}
.ps-active .ps-text { font-weight: 600; }
.ps-done .ps-text { color: var(--primary); }
.ps-error .ps-text { color: var(--danger); }
.progress-panel-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--warning-light);
  border-radius: var(--radius-sm);
}
.progress-panel-error {
  margin-top: 10px;
  padding: 12px;
  background: var(--danger-light);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
}
.pp-error-msg {
  font-size: 0.85rem;
  color: var(--danger);
  margin-bottom: 8px;
  font-weight: 600;
}
.pp-error-actions {
  display: flex;
  gap: 8px;
}

/* ==================== Photo Display Area ==================== */
.photo-display-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.photo-preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
}
.photo-analyzing-text {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}
.analyzing-icon {
  display: inline-block;
  margin-right: 4px;
  animation: analyzingPulse 1.2s ease-in-out infinite;
}
@keyframes analyzingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ==================== Result Section ==================== */
.result-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title-lg { font-size: 1rem; }
.section-icon { font-size: 1rem; }
.result-edit-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: auto;
}
.result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.result-source-message {
  font-size: 0.8rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.result-item-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}
.result-item-info {
  flex: 1;
  min-width: 0;
}
.result-item-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}
.result-item-weight {
  font-size: 0.8rem;
  color: var(--muted);
}
.result-item-nutrition {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.result-item-micro {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.micro-tag {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border-light);
}
.result-item-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.portion-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  transition: var(--transition);
}
.portion-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.portion-value {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 36px;
  text-align: center;
  color: var(--text);
}
.portion-input {
  width: 50px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--surface);
}
.result-item-remove {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}
.result-item-remove:hover {
  background: var(--danger-light);
}
.result-actions {
  display: flex;
  gap: 8px;
}
.result-actions-lg { margin-top: 8px; }

/* ==================== Nutri Tags ==================== */
.nutri-tag {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}
.nutri-protein { background: var(--primary-light); color: var(--primary); }
.nutri-fat { background: var(--warning-light); color: #8A6B1F; }
.nutri-carb { background: var(--info-light); color: var(--info); }
.nutri-fiber { background: var(--accent-light); color: var(--accent); }

/* ==================== Quick Food Section ==================== */
.quick-food-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.quick-food-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.quick-food-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  transition: var(--transition);
  text-align: left;
}
.quick-food-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.quick-food-btn:active {
  transform: scale(0.97);
}
.quick-food-icon { font-size: 1.1rem; flex-shrink: 0; }
.quick-food-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-food-cal { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }

/* ==================== Custom Food Section ==================== */
.custom-food-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: var(--transition);
}
.section-header:hover { background: var(--surface-alt); }
.section-title-inline {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.section-toggle {
  font-size: 0.8rem;
  color: var(--muted);
  transition: var(--transition);
}
.custom-food-content {
  padding: 0 14px 14px;
}
.custom-food-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.custom-food-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.custom-food-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 16px;
}

/* ==================== Today Summary ==================== */
.today-summary {
  padding: 16px;
}
.today-summary h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.summary-card {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  overflow: hidden;
  word-break: break-word;
}
.summary-card.main {
  grid-column: span 2;
  background: var(--primary-light);
  border-color: var(--primary);
}
.summary-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.summary-card.main .summary-value {
  font-size: 1.8rem;
  color: var(--primary);
}
.summary-unit {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 2px;
  font-weight: 400;
}
.summary-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-progress {
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.summary-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.summary-progress-bar.over { background: var(--danger); }

/* ==================== Nutrition Detail (collapsible) ==================== */
.nutrition-detail-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--muted);
  transition: var(--transition);
  width: 100%;
}
.nutrition-detail-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.nutrition-detail-content {
  display: none;
  margin-top: 8px;
}
.nutrition-detail-content.show {
  display: block;
}
.nutrition-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.nutrition-detail-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}
.nutrition-detail-name { color: var(--muted); }
.nutrition-detail-value { font-weight: 600; color: var(--text); }

/* ==================== Meal Records ==================== */
.meal-records {
  padding: 16px;
}
.meal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.meal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.meal-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.meal-card-type {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.meal-card-time {
  font-size: 0.8rem;
  color: var(--muted);
}
.meal-card-cal {
  margin-left: auto;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.meal-card-delete {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}
.meal-card-delete:hover {
  background: var(--danger-light);
  color: var(--danger);
}
.meal-card-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.meal-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border-light);
}
.meal-card-nutrition {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ==================== Empty State ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}
.empty-icon { font-size: 2.4rem; margin-bottom: 8px; opacity: 0.6; }
.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-sub {
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.empty-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ==================== Chart Box ==================== */
.chart-box {
  width: 100%;
  height: 200px;
  margin-top: 8px;
}

/* ==================== Trend Chart Grid (responsive 3/2/1 columns) ==================== */
.trend-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.trend-chart-grid .chart-box {
  height: auto;
  margin-top: 0;
}
.trend-chart-grid .chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  padding: 0 4px;
}

/* ==================== Trend Card ==================== */
.trend-card {
  max-width: none;
  margin: 0;
  padding: 0;
}
.trend-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.trend-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  transition: var(--transition);
}
.trend-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chart-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.trend-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 0.88rem;
}
.trend-empty .empty-icon { font-size: 2rem; }

/* Trend empty state: guide + tips */
.trend-empty-guide {
  text-align: left;
  margin-top: 8px;
  padding: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.trend-empty-guide-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.trend-empty-guide-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.trend-empty-guide-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.trend-empty-guide-step:hover {
  background: var(--primary-light);
}
.trend-empty-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.trend-empty-step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.trend-empty-step-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.trend-empty-step-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.trend-empty-tips {
  text-align: left;
  margin-top: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.trend-empty-tips-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.trend-empty-tips-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trend-empty-tips-list li {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  padding-left: 14px;
  position: relative;
}
.trend-empty-tips-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.trend-summary {
  margin-top: 8px;
}
.trend-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.trend-stat {
  text-align: center;
  padding: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.trend-stat-label {
  font-size: 0.78rem;
  color: var(--muted);
}
.trend-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}
.trend-stat-value.good { color: var(--primary); }
.trend-stat-value.warn { color: var(--warning); }
.trend-stat-value.bad { color: var(--danger); }
.trend-stat-date {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ==================== AI Advice ==================== */
.ai-advice-card {
  padding: 14px;
}
.ai-advice-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.ai-advice-content {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px;
  border-left: 3px solid var(--primary);
}
.ai-advice-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.ai-advice-status.good { background: var(--primary-light); color: var(--primary); }
.ai-advice-status.warn { background: var(--warning-light); color: #8A6B1F; }
.ai-advice-status.bad { background: var(--danger-light); color: var(--danger); }

/* Daily advice (in right column) */
.daily-advice {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}
.advice-content { width: 100%; }
.advice-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.advice-text {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Nutrient section title */
.nutrient-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin: 8px 0 6px;
}

/* Export report section */
.export-report-section {
  text-align: center;
  padding: 8px 0;
}
.export-report-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ==================== Buttons ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 44px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-lg {
  height: 48px;
  padding: 0 20px;
  font-size: 0.92rem;
}
.btn-sm {
  height: 36px;
  padding: 0 12px;
  font-size: 0.82rem;
}
.btn-inline {
  flex: 1;
}
.btn-block {
  width: 100%;
}
.btn-export-report {
  background: var(--accent);
  color: #fff;
  width: 100%;
  height: 48px;
}
.btn-export-report:hover { background: #D06A3F; }
.btn-export-report:disabled { opacity: 0.6; cursor: not-allowed; }

/* ==================== Forms ==================== */
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34,102,74,0.1);
}
.form-input-sm {
  height: 36px;
  font-size: 0.85rem;
}
.form-row {
  margin-bottom: 14px;
}
.form-row-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

/* Age selector */
.age-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.age-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  transition: var(--transition);
}
.age-btn:hover {
  border-color: var(--primary);
}
.age-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.age-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

/* Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition: var(--transition);
}
.chip:hover {
  border-color: var(--primary);
}
.chip.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Recommendation preview */
.recommendation-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
}
.reco-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}
.reco-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.reco-grid-micro {
  grid-template-columns: repeat(5, 1fr);
  margin-top: 6px;
}
.reco-item {
  text-align: center;
}
.reco-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.reco-label {
  font-size: 0.7rem;
  color: var(--muted);
}
.reco-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ==================== Profile Modal ==================== */
.profile-modal {
  position: fixed;
  inset: 0;
  background: rgba(24,33,28,0.5);
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.profile-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.profile-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.profile-modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.profile-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: var(--transition);
}
.profile-modal-close:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.profile-modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.profile-modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.profile-intro {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.profile-form {
  display: flex;
  flex-direction: column;
}

/* Label scan modal specifics */
#labelScanModal .profile-modal-content { max-width: 560px; }
#labelScanModal .profile-modal-body {
  padding-bottom: 140px;
  overflow-y: auto;
  max-height: calc(90vh - 130px);
}
#labelScanModal .chip-group {
  flex-wrap: wrap;
  gap: 6px;
}
#labelScanModal .profile-modal-footer {
  position: relative;
  z-index: 2147483003;
  background: var(--surface);
}

/* Label scan upload */
.label-upload-area { margin-bottom: 12px; }
.label-upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface-alt);
}
.label-upload-box:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.label-upload-box-lg { padding: 36px 16px; }
.upload-icon { font-size: 2rem; }
.upload-text { font-size: 0.88rem; color: var(--muted); }
.label-scan-result {
  margin-top: 12px;
}
.scan-result-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}
.label-scan-status {
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}
.label-scan-status.status-error {
  background: var(--warning-light);
  border-color: var(--warning);
  color: #8A6B1F;
}

/* ==================== Voice Overlay ==================== */
.voice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24,33,28,0.5);
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.voice-overlay-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.voice-overlay-icon { font-size: 2rem; margin-bottom: 8px; }
.voice-overlay-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.voice-overlay-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.voice-live-text {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface-alt);
  outline: none;
  text-align: left;
  margin-bottom: 12px;
}
.voice-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}
.voice-preset-label {
  width: 100%;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.voice-preset-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  transition: var(--transition);
}
.voice-preset-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.voice-timer {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.voice-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.voice-btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--transition);
  height: 44px;
}
.voice-btn-gray {
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}
.voice-btn-green {
  background: var(--primary);
  color: #fff;
}
.voice-btn-green:hover { background: var(--primary-dark); }
.voice-btn-green:disabled { opacity: 0.6; cursor: not-allowed; }
#voiceStatus {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 8px 0;
  min-height: 20px;
}

/* ==================== Manual Nutrient Grid ==================== */
.manual-nutrient-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.manual-nutrient-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.manual-nutrient-item label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.manual-nutrient-item input {
  flex: 1;
  width: 60px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  text-align: right;
}

/* ==================== Onboarding Overlay ==================== */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
}
.onboarding-highlight {
  position: absolute;
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(24,33,28,0.55);
  transition: all 0.3s ease;
}
.onboarding-card {
  position: absolute;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 18px;
}
.onboarding-card-arrow {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--surface);
  transform: rotate(45deg);
  border: 3px solid var(--accent);
  z-index: -1;
}
.onboarding-card-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
}
.onboarding-step-num {
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
}
.onboarding-step-total {
  font-size: 0.82rem;
  color: var(--muted);
}
.onboarding-skip {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.onboarding-skip:hover { background: var(--surface-alt); }
.onboarding-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.onboarding-card-body {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 14px;
}
.onboarding-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.onboarding-dismiss {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}
.onboarding-nav-btns {
  display: flex;
  gap: 8px;
}
.onboarding-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  height: 40px;
}
.onboarding-btn-prev {
  background: var(--surface-alt);
  color: var(--muted);
}
.onboarding-btn-prev:hover { background: var(--border-light); }
.onboarding-btn-next {
  background: var(--accent);
  color: #fff;
}
.onboarding-btn-next:hover { background: #D06A3F; }

/* ==================== Footer ==================== */
.app-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 24px;
}
.disclaimer-bar {
  background: var(--warning-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.5;
}
.disclaimer-icon { flex-shrink: 0; }

/* ==================== Bottom Nav (mobile) ==================== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  height: 56px;
}
.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--muted);
  transition: var(--transition);
}
.bottom-nav-item.active {
  color: var(--primary);
  font-weight: 600;
}
.bottom-nav-item-icon { font-size: 1.2rem; }

/* Prominent center camera button */
.bottom-nav-camera {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: -16px;
  transition: var(--transition);
}
.bottom-nav-camera:active { transform: scale(0.92); }
.bottom-nav-camera .bottom-nav-item-icon { font-size: 1.4rem; }

/* ==================== Quick Food Horizontal List ==================== */
.quick-food-grid.horizontal {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick-food-grid.horizontal .quick-food-btn {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
}
.quick-food-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}
.quick-food-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ==================== Animations ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.2s ease; }

/* ==================== Demo Banner ==================== */
.demo-banner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 24px;
  background: var(--info-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}

/* ==================== Mobile Tab Content ==================== */
.mobile-tab-content {
  display: none;
}
.mobile-tab-content.active {
  display: block;
}

/* ==================== Responsive: Large desktop chart grid ==================== */
/* 1200px and above: 3-column chart grid (default) */

/* ==================== Responsive: Medium screens (769px ~ 1199px) ==================== */
@media (max-width: 1199px) {
  .trend-chart-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==================== Responsive: Tablet ==================== */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .panel-input {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .trend-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==================== Responsive: Mobile ==================== */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .topbar { padding: 0 12px; }
  .topbar-inner { height: 52px; }
  .logo-text { font-size: 1.1rem; }
  .date-display { display: none; }
  .guide-trigger-btn { padding: 4px 10px; font-size: 0.75rem; height: 32px; }
  .profile-btn { padding: 4px 10px; font-size: 0.75rem; height: 32px; }

  .app-container {
    padding: 8px 12px;
    padding-bottom: 70px;
  }

  .entry-cards { gap: 6px; }
  .entry-card {
    padding: 12px;
    gap: 10px;
  }
  .entry-card-icon { font-size: 1.3rem; }
  .entry-card-desc { font-size: 0.78rem; }
  .entry-card-btn { padding: 8px 12px; font-size: 0.8rem; height: 40px; }
  .entry-cards-secondary { gap: 6px; }
  .entry-card-secondary { padding: 10px 6px; }

  .quick-food-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .summary-card.main { grid-column: span 2; }

  .reco-grid, .reco-grid-micro {
    grid-template-columns: repeat(3, 1fr);
  }

  .trend-card { padding: 0; }
  .trend-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .trend-chart-grid {
    grid-template-columns: 1fr;
  }

  .profile-modal {
    padding: 0;
    align-items: flex-end;
  }
  .profile-modal-content {
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92vh;
    max-width: 100%;
  }
  .voice-overlay { padding: 0; align-items: flex-end; }
  .voice-overlay-content {
    border-radius: var(--radius) var(--radius) 0 0;
    max-width: 100%;
    padding: 20px 16px;
  }

  .form-row-two-col { grid-template-columns: 1fr; }

  .bottom-nav { display: block; }
  .app-footer { padding-bottom: 70px; }

  .onboarding-card {
    width: calc(100vw - 24px);
    padding: 14px;
  }
}

@media (max-width: 390px) {
  .app-container { padding: 8px; }
  .entry-card { padding: 10px; gap: 8px; }
  .entry-card-header { min-width: 40px; }
  .entry-card-icon { font-size: 1.2rem; }
  .entry-card-title { font-size: 0.72rem; }
  .entry-card-desc { font-size: 0.72rem; }
  .entry-card-btn { padding: 6px 10px; font-size: 0.75rem; height: 36px; }
  .entry-card-time { font-size: 0.68rem; }
  .quick-food-grid { grid-template-columns: 1fr 1fr; gap: 4px; }
  .quick-food-btn { padding: 6px 8px; font-size: 0.75rem; }
  .summary-value { font-size: 1.2rem; }
  .summary-card.main .summary-value { font-size: 1.5rem; }
  .pp-error-actions { flex-direction: column; }
  .result-actions { flex-direction: column; }
  .result-actions .btn { width: 100%; }
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-alt); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ================================================================
   Premium Viewfinder + Nutrition Report
   ================================================================ */

/* ==================== Premium Split Layout ==================== */
.premium-split {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 0;
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 0;
  min-height: 560px;
  border-bottom: 1px solid var(--border);
}

/* ==================== Viewfinder ==================== */
.viewfinder {
  position: relative;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 560px;
  overflow: hidden;
}

/* Corner brackets */
.vf-bracket {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 2px solid var(--muted);
  opacity: 0.3;
  z-index: 5;
}
.vf-bracket-tl { top: 24px; left: 24px; border-right: none; border-bottom: none; }
.vf-bracket-tr { top: 24px; right: 24px; border-left: none; border-bottom: none; }
.vf-bracket-bl { bottom: 24px; left: 24px; border-right: none; border-top: none; }
.vf-bracket-br { bottom: 24px; right: 24px; border-left: none; border-top: none; }

/* Empty state */
.vf-empty {
  text-align: center;
  padding: 48px;
  max-width: 400px;
}
.vf-camera-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  color: var(--muted);
  opacity: 0.4;
}
.vf-camera-icon svg { width: 100%; height: 100%; }
.vf-empty-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.vf-empty-sub {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 28px;
}
.vf-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 36px;
  height: 56px;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 100ms var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.vf-primary-btn:hover { background: var(--accent-dark); }
.vf-primary-btn:active { transform: scale(0.98); }
.vf-primary-btn svg { width: 20px; height: 20px; }

.vf-secondary {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  justify-content: center;
}
.vf-secondary-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  padding: 8px;
}
.vf-secondary-btn:hover { color: var(--text); }
.vf-secondary-btn svg { width: 20px; height: 20px; }

.vf-scan-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-size: 14px;
  color: var(--muted-2);
  margin-top: 20px;
}
.vf-scan-hint .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: vf-pulse 2s ease infinite;
}
@keyframes vf-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Active state: photo + scan */
.vf-active {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
}
.vf-active.show { display: flex; flex-direction: column; }
.vf-photo-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  min-height: 420px;
}
.vf-photo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Scan line */
.vf-scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  opacity: 0.5;
  z-index: 4;
  animation: vf-scan-move 2.5s ease-in-out infinite;
  display: none;
}
.vf-scan-line.active { display: block; }
@keyframes vf-scan-move {
  0% { top: 15%; }
  50% { top: 85%; }
  100% { top: 15%; }
}

/* Status badge */
.vf-status {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 6;
}
.vf-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
}
.vf-status-badge.scanning {
  background: var(--accent-light);
  color: var(--accent-dark);
  border-color: var(--accent);
}
.vf-status-badge.done {
  background: var(--highlight-bg);
  color: var(--highlight-ink);
  border-color: var(--highlight);
}
.vf-status-badge.error {
  background: var(--danger-light);
  color: var(--danger-ink);
  border-color: var(--danger);
}
.vf-status-badge svg { width: 14px; height: 14px; }

/* Food labels on photo */
.vf-labels {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
}
.vf-label {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  white-space: nowrap;
  pointer-events: auto;
}
.vf-label-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-num);
  flex-shrink: 0;
}
.vf-label-weight {
  color: var(--muted);
  font-weight: 500;
}
.vf-label-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  z-index: 4;
  pointer-events: none;
}
.vf-label-line {
  position: absolute;
  background: rgba(18, 55, 42, 0.2);
  z-index: 3;
  pointer-events: none;
}

/* Edge label list (default mode) */
.vf-edge-labels {
  position: absolute;
  bottom: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 6;
}

/* Progress steps below photo */
.vf-progress {
  padding: 12px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.vf-progress-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.vf-progress-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted-2);
}
.vf-progress-step.done { color: var(--highlight-ink); }
.vf-progress-step.active { color: var(--accent-dark); }
.vf-progress-step.error { color: var(--danger-ink); }
.vf-ps-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.vf-progress-hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}
.vf-progress-error {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--danger-ink);
  display: none;
}
.vf-progress-error.show { display: block; }
.vf-progress-error-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ==================== Report Panel ==================== */
.report-panel {
  background: var(--surface);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.report-header { margin-bottom: 24px; }
.report-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.report-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.report-date-small {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.report-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.report-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

/* Calorie */
.report-cal-block { margin: 24px 0; }
.report-cal-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.report-cal-display {
  font-family: var(--font-num);
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.report-cal-display.empty { color: var(--border); }
.report-cal-unit {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}
.report-cal-target {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

/* Stat rows */
.report-stat-list { display: flex; flex-direction: column; }
.report-stat-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.report-stat-row:last-child { border-bottom: none; }
.report-stat-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.report-stat-left {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.report-stat-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
}
.report-stat-right {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.report-stat-value {
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.report-stat-value.empty { color: var(--border); }
.report-stat-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-2);
}
.report-stat-pct {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  margin-left: 8px;
}
.report-stat-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.report-stat-badge.ok {
  background: var(--highlight-bg);
  color: var(--highlight-ink);
}
.report-stat-badge.warn {
  background: var(--warning-light);
  color: var(--warning-ink);
}
.report-progress {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}
.report-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--text);
  transition: width 400ms var(--transition);
}
.report-progress-fill.good { background: var(--highlight-ink); }
.report-progress-fill.warn { background: var(--warning); }
.report-progress-fill.over { background: var(--accent); }

/* AI block */
.report-ai-block {
  margin: 20px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--highlight);
  display: none;
}
.report-ai-block.show { display: block; }
.report-ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.report-ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: uppercase;
}
.report-ai-text {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-2);
}

/* Food list in report */
.report-foods {
  margin: 16px 0;
}
.report-food-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.report-food-item:last-child { border-bottom: none; }
.report-food-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-num);
  flex-shrink: 0;
}
.report-food-info { flex: 1; min-width: 0; }
.report-food-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.report-food-detail {
  font-size: 13px;
  color: var(--muted);
}
.report-food-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.report-food-portion-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition);
}
.report-food-portion-btn:hover { border-color: var(--text); }
.report-food-portion-input {
  width: 56px;
  height: 32px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-num);
  color: var(--text);
  background: var(--surface);
}
.report-food-remove {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: var(--muted-2);
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: color var(--transition);
}
.report-food-remove:hover { color: var(--danger); }

/* Report footer */
.report-footer {
  margin-top: auto;
  padding-top: 20px;
}
.report-confirm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 56px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 100ms var(--transition);
}
.report-confirm-btn:hover { background: var(--primary-dark); }
.report-confirm-btn:active { transform: scale(0.98); }
.report-confirm-btn svg { width: 20px; height: 20px; }
.report-secondary-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
}
.report-secondary-btn {
  background: none;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  transition: color var(--transition);
}
.report-secondary-btn:hover { color: var(--text); }

/* ==================== Premium Split Responsive ==================== */
@media (max-width: 1024px) {
  .premium-split {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .viewfinder {
    min-height: 360px;
  }
  .report-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 24px 20px;
  }
  .report-cal-display { font-size: 56px; }
}

@media (max-width: 768px) {
  .premium-split { padding: 8px 12px 0; }
  .viewfinder { min-height: 300px; }
  .vf-photo-wrap { min-height: 240px; }
  .vf-empty { padding: 32px 20px; }
  .vf-empty-title { font-size: 22px; }
  .vf-empty-sub { font-size: 16px; }
  .report-panel { padding: 20px 16px; }
  .report-cal-display { font-size: 48px; }
  .report-stat-value { font-size: 18px; }
  .report-stat-label { font-size: 15px; }
  .vf-bracket { width: 24px; height: 24px; }
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
