/* ======== 全局重置 & 变量 ======== */
:root {
  --primary: #FF6B35;
  --primary-light: #FF8C61;
  --primary-dark: #E55100;
  --secondary: #4CAF50;
  --secondary-light: #81C784;
  --bg: #F5F6FA;
  --card-bg: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 56px;
  --sidebar-w: 220px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* ======== 全页屏幕（登录/引导） ======== */
.screen {
  display: none;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* ======== 应用主框架 ======== */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ======== 侧边栏 ======== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 28px;
  flex-shrink: 0;
}

.sidebar-brand {
  min-width: 0;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.sidebar-item:hover {
  background: #F9FAFB;
  color: var(--text);
}

.sidebar-item.active {
  background: linear-gradient(135deg, #FFF5F0, #FFE8DA);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-item.active svg {
  stroke: var(--primary);
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 12px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF5F0, #F0FFF4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-user span {
  font-size: 14px;
  font-weight: 600;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}

.sidebar-logout:hover {
  background: #FEF2F2;
  color: var(--danger);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ======== 主内容区 ======== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* 内容屏幕 */
.content-screen {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
.content-screen.active {
  display: flex;
}

/* ======== 引导页 ======== */
#onboardingScreen {
  background: linear-gradient(160deg, #FFF5F0 0%, #FFFFFF 40%, #F0FFF4 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.onboarding-container {
  max-width: 420px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  width: 100%;
}

.logo-area {
  text-align: center;
  margin-bottom: 36px;
  animation: fadeInDown 0.6s ease;
}

.logo-icon {
  font-size: 56px;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(255,107,53,0.3));
}

.logo-area h1 {
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.6s ease;
}

.form-card h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.form-desc {
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.gender-selector {
  display: flex;
  gap: 12px;
}

.gender-selector.hint .gender-option {
  animation: genderHint 1.5s ease-in-out infinite;
  border-color: var(--warning);
}

@keyframes genderHint {
  0%, 100% { border-color: var(--warning); background: #FFF; }
  50% { border-color: var(--warning); background: #FFF8E1; }
}

.gender-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s;
  font-weight: 500;
}

.gender-option.selected {
  border-color: var(--primary);
  background: #FFF5F0;
  color: var(--primary);
}

.gender-icon {
  font-size: 22px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
  text-align: center;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  transition: border-color 0.25s;
}

.input-row:focus-within {
  border-color: var(--primary);
}

.input-row input, .select-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 0;
  font-size: 16px;
  background: transparent;
  color: var(--text);
  width: 100%;
}

.unit {
  color: var(--text-light);
  font-size: 14px;
}

.select-input {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  transition: border-color 0.25s;
}

.select-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* ======== 按钮 ======== */
.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #FFF;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 4px 14px rgba(255,107,53,0.3);
}

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

.btn-primary:disabled {
  background: #F3F4F6;
  box-shadow: none;
  cursor: not-allowed;
  color: var(--text-secondary);
  font-size: 14px;
}

.btn-secondary {
  padding: 14px 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* ======== 主界面头部 ======== */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: var(--header-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top, 0px);
}

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.menu-toggle:active {
  background: #F3F4F6;
}

.header-info {
  flex: 1;
  min-width: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-light);
}

/* ======== 热量进度条 ======== */
.calorie-progress-bar {
  background: var(--card-bg);
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.progress-label {
  font-size: 14px;
  font-weight: 700;
}

.progress-label span:first-child {
  color: var(--primary);
  font-size: 18px;
}

.progress-remaining {
  font-size: 12px;
  color: var(--text-secondary);
}

.progress-track {
  height: 8px;
  background: #F3F4F6;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--secondary-light));
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-fill.over {
  background: linear-gradient(90deg, var(--danger), #FF8A80);
}

/* ======== 聊天区域 ======== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 0;
}

.chat-messages {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 消息气泡 */
.message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.message.bot .msg-avatar {
  background: linear-gradient(135deg, #FFF5F0, #FFE0D0);
}

.message.user .msg-avatar {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #FFF;
  font-size: 14px;
  font-weight: 600;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.message.bot .msg-bubble {
  background: var(--card-bg);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow);
}

.message.user .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #FFF;
  border-top-right-radius: 4px;
}

/* 图片消息 */
.msg-image {
  width: 200px;
  border-radius: 12px;
  margin-bottom: 8px;
  display: block;
}

/* 食物卡片 */
.food-result-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-top: 8px;
  box-shadow: var(--shadow);
}

.food-result-card .total-cal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.food-result-card .total-cal-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.food-result-card .total-cal-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.food-result-card .total-cal-unit {
  font-size: 12px;
  color: var(--text-light);
}

.food-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.food-item-emoji {
  font-size: 24px;
  flex-shrink: 0;
}

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

.food-item-name {
  font-size: 14px;
  font-weight: 600;
}

.food-item-detail {
  font-size: 12px;
  color: var(--text-light);
}

.food-item-cal {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

/* 营养素分布 */
.macro-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
  background: #F3F4F6;
}

.macro-bar > div {
  transition: width 0.5s;
}

.macro-protein { background: #3B82F6; }
.macro-carbs { background: #F59E0B; }
.macro-fat { background: #EF4444; }

.macro-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.macro-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.macro-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* 打字动画 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-light);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* ======== 快捷问题 ======== */
.quick-questions {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  background: var(--bg);
  scrollbar-width: none;
}

.quick-questions::-webkit-scrollbar {
  display: none;
}

.quick-q {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-q:active {
  background: #FFF5F0;
  border-color: var(--primary);
  color: var(--primary);
}

/* ======== 底部输入栏 ======== */
.input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.camera-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(255,107,53,0.3);
}

.camera-btn:active {
  transform: scale(0.92);
}

#messageInput {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 15px;
  outline: none;
  background: #F9FAFB;
  transition: border-color 0.2s;
  min-width: 0;
}

#messageInput:focus {
  border-color: var(--primary);
  background: #FFF;
}

.send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--secondary);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:active {
  transform: scale(0.92);
}

.send-btn:disabled {
  background: #D1D5DB;
}

/* ======== 图片预览 ======== */
.image-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.preview-container {
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.preview-container img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 12px;
  margin-bottom: 20px;
}

.preview-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.preview-actions .btn-primary {
  width: auto;
  padding: 12px 28px;
}

/* ======== 分析中动画 ======== */
.analyzing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.analyzing-content {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  max-width: 300px;
  width: 90%;
}

.analyzing-animation {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
}

.analyzing-icon {
  font-size: 48px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 1.5s ease-in-out infinite;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  border-radius: 2px;
  animation: scanMove 2s ease-in-out infinite;
}

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

/* ======== 热量建议卡片（原Modal内容） ======== */
.recommend-card {
  text-align: center;
  padding: 24px 16px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.recommend-card.lose {
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
}

.recommend-card.maintain {
  background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
}

.recommend-card.gain {
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
}

.recommend-card .rec-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.recommend-card .rec-value {
  font-size: 36px;
  font-weight: 700;
}

.recommend-card .rec-unit {
  font-size: 14px;
  color: var(--text-secondary);
}

.bmr-info {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.bmr-info-item {
  flex: 1;
  text-align: center;
  padding: 16px 8px;
  background: #F9FAFB;
  border-radius: 12px;
}

.bmr-info-item .bmr-label {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.bmr-info-item .bmr-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* ======== 动画 ======== */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
}

@keyframes scanMove {
  0%, 100% { top: 0; }
  50% { top: calc(100% - 3px); }
}

/* ======== 登录页 ======== */
#loginScreen {
  background: linear-gradient(160deg, #FFF5F0 0%, #FFFFFF 40%, #F0FFF4 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.login-container {
  max-width: 420px;
  margin: 0 auto;
  padding: 60px 24px 40px;
  width: 100%;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0;
  text-align: center;
}

/* ======== 热量建议页 ======== */
.target-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.target-loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-light);
  font-size: 15px;
}

.target-section {
  margin-bottom: 24px;
}

.target-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 热量建议页 - 个人信息编辑表单 */
.profile-edit-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.profile-edit-card .form-group {
  margin-bottom: 16px;
}

.profile-edit-card .btn-primary {
  margin-top: 8px;
}

/* ======== 看板页面 ======== */
.dashboard-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 24px;
}
.dash-section {
  margin-bottom: 20px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* 概览卡片 */
.dash-overview-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.overview-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.overview-card .ov-label {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.overview-card .ov-value {
  font-size: 22px;
  font-weight: 700;
}
.overview-card .ov-unit {
  font-size: 12px;
  color: var(--text-light);
}
.overview-card.cal .ov-value { color: var(--primary); }
.overview-card.meals .ov-value { color: var(--info); }
.overview-card.protein .ov-value { color: #3B82F6; }
.overview-card.remaining .ov-value { color: var(--secondary); }
.overview-card.over .ov-value { color: var(--danger); }

/* 图表切换 */
.dash-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: #F3F4F6;
  border-radius: 10px;
  padding: 4px;
}
.dash-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.dash-tab.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* 图表容器 */
.chart-box {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.chart-header h3 {
  font-size: 15px;
  font-weight: 700;
}
.chart-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.chart-hint {
  font-size: 12px;
  color: var(--text-light);
}
.chart-wrapper {
  position: relative;
  height: 240px;
  width: 100%;
}
.chart-box-inner {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

/* 月份选择器 */
.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.month-selector label {
  font-size: 13px;
  color: var(--text-secondary);
}
.month-selector input[type="month"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
.btn-small {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #FFF;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-small:active { transform: scale(0.96); }

/* 餐食记录列表 */
.meal-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meal-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.meal-card .meal-thumb {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  background: #F3F4F6;
  flex-shrink: 0;
}
.meal-card .meal-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  background: linear-gradient(135deg, #FFF5F0, #F0FFF4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.meal-card .meal-info {
  flex: 1;
  min-width: 0;
}
.meal-card .meal-type-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}
.meal-card .meal-type-tag.早餐 { background: #FFF3E0; color: #E65100; }
.meal-card .meal-type-tag.午餐 { background: #E8F5E9; color: #2E7D32; }
.meal-card .meal-type-tag.晚餐 { background: #E3F2FD; color: #1565C0; }
.meal-card .meal-type-tag.下午茶 { background: #F3E5F5; color: #7B1FA2; }
.meal-card .meal-type-tag.夜宵 { background: #FCE4EC; color: #C62828; }
.meal-card .meal-type-tag.未知 { background: #F3F4F6; color: #6B7280; }
.meal-card .meal-foods {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meal-card .meal-detail {
  font-size: 12px;
  color: var(--text-light);
}
.meal-card .meal-cal {
  text-align: right;
  flex-shrink: 0;
}
.meal-card .meal-cal-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.meal-card .meal-cal-unit {
  font-size: 11px;
  color: var(--text-light);
}
.meal-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ======== 餐食删除按钮 ======== */
.meal-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  opacity: 0.6;
}
.meal-delete-btn:active {
  background: rgba(239, 68, 68, 0.25);
  opacity: 1;
}
.meal-card {
  position: relative;
}

/* ======== 文字记录按钮 ======== */
.text-meal-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--secondary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.text-meal-btn:active {
  transform: scale(0.92);
  background: var(--secondary-light);
}

/* ======== 文字记录弹窗 ======== */
.text-meal-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.text-meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.text-meal-header h3 {
  font-size: 18px;
  font-weight: 700;
}
.text-meal-close {
  border: none;
  background: #F3F4F6;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
}
.text-meal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.text-meal-textarea {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  transition: border-color 0.2s;
}
.text-meal-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.text-meal-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}
.text-meal-tag {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.text-meal-tag:active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ======== 响应式：桌面端侧边栏常驻 ======== */
@media (min-width: 769px) {
  .menu-toggle {
    display: none;
  }
  .sidebar-overlay {
    display: none !important;
  }
  .sidebar {
    position: static;
    transform: none !important;
  }
}

/* ======== 响应式：移动端侧边栏为抽屉 ======== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 2px 0 20px rgba(0,0,0,0.1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show {
    display: block;
  }
  .menu-toggle {
    display: flex;
  }
  .menu-toggle-alt {
    display: flex;
  }
  .logo-area h1 { font-size: 22px; }
  .form-card { padding: 20px 16px; }
  .msg-bubble { font-size: 13px; }
  .header-title { font-size: 14px; }
  .dash-overview-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .overview-card { padding: 12px; }
  .overview-card .ov-value { font-size: 18px; }
  .target-area { padding: 16px; }
  .recommend-card .rec-value { font-size: 28px; }
  .sidebar-title { font-size: 14px; }
  .sidebar-item { padding: 14px 12px; font-size: 14px; }
}

@media (max-width: 380px) {
  .sidebar { width: 200px; }
}
