:root {
  --brand-blue: #728bc7;
  --brand-dark: #272147;
  --brand-dark-alt: #3a316a;
  --brand-blue-dark: #4d6db8;
  --brand-blue-light: #96a9d5;
  --bg-white: #ffffff;
  --bg-surface: #f7f8fc;
  --border-subtle: #dde3f2;
  --text-muted: #525870;
  --success-bg: #ebf7f0;
  --success-text: #145c36;
  --success-border: #9bd6b4;
  --warn-bg: #fff6e8;
  --warn-text: #7a4b00;
  --danger-text: #a61b2b;
  --shadow-sm: 0 2px 8px rgba(39, 33, 71, 0.06);
  --shadow-md: 0 8px 24px rgba(39, 33, 71, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-surface);
  color: var(--brand-dark-alt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 顶部 Header */
.app-header {
  background-color: var(--brand-dark);
  color: var(--bg-white);
  padding-top: 14px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  flex-shrink: 0;
  border-radius: 8px;
}

.brand-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--bg-white);
  letter-spacing: 0.02em;
}

.brand-subtitle {
  margin: 0;
  font-size: 0.75rem;
  color: var(--brand-blue-light);
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.date-badge {
  font-size: 0.75rem;
  color: var(--brand-blue-light);
}

.season-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--brand-dark-alt);
  color: var(--bg-white);
  border: 1px solid var(--brand-blue);
}

/* 快捷控制栏 */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  padding-bottom: 14px;
  border-top: 1px solid rgba(150, 169, 213, 0.25);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 0.8125rem;
  color: var(--brand-blue-light);
  white-space: nowrap;
}

.stepper {
  display: inline-flex;
  align-items: center;
  background-color: var(--brand-dark-alt);
  border: 1px solid var(--brand-blue);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--bg-white);
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:hover,
.stepper-btn:focus-visible {
  background-color: rgba(114, 139, 199, 0.28);
  outline: none;
}

.stepper-value {
  min-width: 48px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bg-white);
}

.season-select {
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-blue);
  background-color: var(--brand-dark-alt);
  color: var(--bg-white);
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-primary-header {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-blue-light);
  background-color: var(--brand-blue-dark);
  color: var(--bg-white);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary-header:hover {
  background-color: #3f5da4;
}

/* 桌面端导航（移动端隐藏） */
.desktop-nav {
  display: none;
  gap: 6px;
  padding-bottom: 0;
}

.nav-tab {
  position: relative;
  padding: 10px 18px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--brand-blue-light);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-tab.active {
  color: var(--bg-white);
  border-bottom-color: var(--brand-blue-light);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  background-color: var(--brand-blue-dark);
  color: var(--bg-white);
}

/* 主内容区 */
.main-content {
  padding-top: 16px;
  padding-bottom: 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* 季节贴士横幅 */
.season-tip-banner {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--brand-blue-dark);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.season-tip-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--brand-dark);
}

.season-tip-sub {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand-blue-dark);
}

.season-tip-body {
  margin: 0;
  font-size: 0.875rem;
  color: var(--brand-dark-alt);
}

/* 膳食结构概览卡片 */
.nutrition-summary-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

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

.section-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.section-subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.score-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
  white-space: nowrap;
}

.nutrition-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nutri-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-muted);
}

.nutri-chip.covered {
  background-color: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
  font-weight: 600;
}

/* 三餐卡片 */
.meals-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.meal-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.meal-heading-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-tag {
  padding: 3px 10px;
  border-radius: 999px;
  background-color: var(--brand-dark);
  color: var(--bg-white);
  font-size: 0.8125rem;
  font-weight: 700;
}

.meal-time-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

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

.btn-icon {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-white);
  color: var(--brand-blue-dark);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-icon:hover {
  background-color: var(--bg-surface);
  border-color: var(--brand-blue-dark);
}

.btn-icon.locked {
  background-color: var(--brand-dark);
  color: var(--bg-white);
  border-color: var(--brand-dark);
}

.dish-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dish-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dish-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.dish-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dish-role {
  display: inline-block;
  width: fit-content;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-blue-dark);
}

.dish-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.dish-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.dish-highlight {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--brand-dark-alt);
}

.dish-ingredients-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ing-pill {
  padding: 2px 8px;
  border-radius: 6px;
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--brand-dark-alt);
}

.dish-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.btn-link {
  padding: 4px 0;
  border: none;
  background: transparent;
  color: var(--brand-blue-dark);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-swap-single {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-white);
  color: var(--brand-blue-dark);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-swap-single:hover {
  border-color: var(--brand-blue-dark);
}

/* 买菜清单 */
.panel-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.shopping-actions {
  display: flex;
  gap: 8px;
}

.shopping-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.shopping-group-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.shopping-group-title {
  margin: 0 0 10px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--brand-dark);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
}

.shopping-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shopping-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  cursor: pointer;
  min-height: 42px;
}

.shopping-item.checked {
  opacity: 0.6;
  text-decoration: line-through;
}

.shopping-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shopping-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--brand-blue-dark);
  cursor: pointer;
}

.shopping-item-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--brand-dark);
}

.shopping-item-amount {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-blue-dark);
  white-space: nowrap;
}

/* 膳食指南 */
.guide-hero {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.guide-targets-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.guide-target-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.guide-target-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.guide-target-name {
  font-weight: 700;
  color: var(--brand-dark);
}

.guide-target-amount {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-blue-dark);
}

.guide-target-family {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--success-text);
  margin-bottom: 4px;
}

.guide-target-detail {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.guide-principles-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.subsection-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.principles-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9375rem;
  color: var(--brand-dark-alt);
}

/* 偏好设置 */
.pref-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 14px;
  box-shadow: var(--shadow-sm);
}

.pref-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pref-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--brand-dark-alt);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.pref-chip input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-blue-dark);
}

.pref-help {
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.pref-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* 通用按钮 */
.btn-primary {
  height: 42px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--brand-blue-dark);
  color: var(--bg-white);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: #3f5da4;
}

.btn-secondary {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--brand-blue-dark);
  border-radius: var(--radius-sm);
  background-color: var(--bg-white);
  color: var(--brand-blue-dark);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-white);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger-outline {
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--danger-text);
  border-radius: var(--radius-sm);
  background-color: var(--bg-white);
  color: var(--danger-text);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

/* 移动端底部导航 */
.mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background-color: var(--brand-dark);
  border-top: 1px solid rgba(150, 169, 213, 0.3);
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-btn {
  position: relative;
  border: none;
  background: transparent;
  color: var(--brand-blue-light);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.mobile-nav-btn.active {
  color: var(--bg-white);
  background-color: var(--brand-dark-alt);
}

.mobile-nav-icon {
  font-size: 1.125rem;
  line-height: 1.2;
}

.mobile-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 24px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background-color: var(--brand-blue-dark);
  color: var(--bg-white);
  font-size: 0.6875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 弹窗 */
.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: rgba(39, 33, 71, 0.58);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-sheet {
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  background-color: var(--bg-white);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background-color: var(--brand-dark);
  color: var(--bg-white);
}

.modal-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--brand-blue-light);
  margin-bottom: 2px;
}

.modal-title {
  margin: 0;
  font-size: 1.125rem;
  color: var(--bg-white);
}

.modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(150, 169, 213, 0.4);
  border-radius: 8px;
  background: transparent;
  color: var(--bg-white);
  font-size: 1rem;
  cursor: pointer;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.modal-highlight {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border-left: 3px solid var(--brand-blue-dark);
  font-size: 0.875rem;
  color: var(--brand-dark-alt);
}

.modal-section {
  margin-bottom: 16px;
}

.modal-section-title {
  margin: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.modal-ingredients {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.modal-ingredients li {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background-color: var(--bg-surface);
  font-size: 0.875rem;
}

.modal-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9375rem;
  color: var(--brand-dark-alt);
}

.modal-footer {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
}

/* Toast 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  z-index: 80;
  background-color: var(--brand-dark);
  color: var(--bg-white);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--brand-blue);
}

/* 桌面端响应式断点 */
@media (min-width: 768px) {
  body {
    padding-bottom: 24px;
  }

  .desktop-nav {
    display: flex;
  }

  .mobile-bottom-nav {
    display: none;
  }

  .meals-grid {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
  }

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

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

  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }

  .modal-sheet {
    border-radius: var(--radius-lg);
  }

  .toast {
    bottom: 28px;
  }
}
