/* 暖色主题（默认） */
[data-theme="warm"] {
  --bg: #faf6f1;
  --bg-accent: #fff3e8;
  --surface: #ffffff;
  --text: #3d2f24;
  --text-muted: #9a8575;
  --primary: #e07a3a;
  --primary-soft: #fde8d8;
  --primary-text: #ffffff;
  --border: #edd9c8;
  --shadow: 0 12px 40px rgba(224, 122, 58, 0.12);
  --btn-shadow: 0 8px 24px rgba(224, 122, 58, 0.28);
}

/* 冷色主题 */
[data-theme="cool"] {
  --bg: #f3f7fa;
  --bg-accent: #e8f2f8;
  --surface: #ffffff;
  --text: #24303d;
  --text-muted: #7a8a99;
  --primary: #3d8bfd;
  --primary-soft: #e3efff;
  --primary-text: #ffffff;
  --border: #d5e3ef;
  --shadow: 0 12px 40px rgba(61, 139, 253, 0.12);
  --btn-shadow: 0 8px 24px rgba(61, 139, 253, 0.25);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  width: 100%;
  max-width: min(480px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    env(safe-area-inset-top, 0)
    max(16px, env(safe-area-inset-right, 0))
    max(20px, env(safe-area-inset-bottom, 0))
    max(16px, env(safe-area-inset-left, 0));
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 8px;
  min-height: 52px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.home-top-btn {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.home-top-btn:active {
  transform: scale(0.98);
}

.home-top-btn.hidden {
  display: none;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
}

.icon-btn.hidden {
  visibility: hidden;
  pointer-events: none;
}

.theme-switch {
  display: flex;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.theme-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-btn.active {
  background: var(--primary);
  color: var(--primary-text);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: flex;
}

/* 步骤页：内容居中，确认按钮不贴底 */
#screen-dining.active,
#screen-people.active,
#screen-budget.active {
  justify-content: center;
  min-height: calc(100dvh - 88px);
  padding: 8px 0 24px;
}

#screen-dining .dining-btns,
#screen-people .number-input-wrap,
#screen-budget .field,
#screen-budget .staple-panel {
  width: 100%;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

#screen-people .field-hint {
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.screen-actions {
  width: 100%;
  max-width: 320px;
  margin: 28px auto 0;
  padding: 0;
}

.screen-actions .action-btn {
  margin-top: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 首页 Logo */
.logo-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 0 40px;
}

.logo-icon {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.logo-title {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, var(--primary), var(--text));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.diet-mode-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.diet-mode-btn {
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s, color 0.15s;
  box-shadow: var(--shadow);
}

.diet-mode-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.diet-mode-btn:active {
  transform: scale(0.98);
}

.delivery-sharing-panel {
  margin: 16px 0 8px;
}

.delivery-sharing-btns {
  margin-top: 8px;
}

.allocation-mode-panel {
  margin-bottom: 12px;
}

.allocation-btns {
  margin-top: 8px;
}

.diet-mode-hint {
  margin: 0 0 18px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.home-mode-btns {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
}

.home-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 20px 22px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}

.home-mode-btn:active {
  transform: scale(0.98);
}

.home-mode-btn:hover {
  border-color: var(--primary);
}

.home-mode-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 4px;
}

.home-mode-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.home-mode-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.result-day-list .meal-section {
  margin-bottom: 20px;
}

.result-day-list .meal-section-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.result-day-list .meal-section-meta {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.meal-subtitle {
  margin: 10px 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.meal-item-group + .meal-item-group {
  margin-top: 4px;
}

.dish-row.staple-row .dish-name-text,
.dish-card.staple-row .dish-tag {
  color: var(--primary);
}

.meal-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding-bottom: 20px;
}

.meal-btn {
  aspect-ratio: 1;
  border: none;
  border-radius: 24px;
  background: var(--surface);
  border: 2px solid var(--border);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}

.meal-btn:active {
  transform: scale(0.96);
}

.meal-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.dining-btns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding-bottom: 20px;
}

.dining-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px 22px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}

.dining-btn .dining-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.dining-btn:active {
  transform: scale(0.98);
}

.dining-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.admin-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.admin-link:hover {
  color: var(--primary);
}

/* 通用步骤页 */
.screen-title {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 5vw, 1.6rem);
  font-weight: 700;
  text-align: center;
}

.screen-desc {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
}

#screen-dining.active .screen-title,
#screen-people.active .screen-title,
#screen-budget.active .screen-title,
#screen-dining.active .screen-desc,
#screen-people.active .screen-desc,
#screen-budget.active .screen-desc {
  width: 100%;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.field span {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.field input[type="number"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 1.1rem;
  background: var(--surface);
  color: var(--text);
}

.number-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
}

.number-input-wrap.compact {
  padding: 6px;
}

.number-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}

.number-input-wrap input::-webkit-outer-spin-button,
.number-input-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.4rem;
  cursor: pointer;
}

.staple-panel {
  width: 100%;
  max-width: 360px;
  margin: 8px auto 0;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.staple-panel .field select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

.staple-panel .toggle-row {
  padding: 4px 0 12px;
}

.staple-details.hidden {
  display: none;
}

.staple-details {
  overflow: hidden;
}

.field-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 12px 0 0;
}

.mixed-meal-row {
  margin-bottom: 16px;
}

.mixed-meal-btns {
  flex-wrap: wrap;
  gap: 8px;
}

#budget-low-warning.warn {
  color: #c45c20;
}

.action-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
}

.action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.action-btn.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  margin-top: 16px;
}

.action-btn.primary {
  background: var(--primary);
  color: var(--primary-text);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin: 20px auto 0;
  padding-bottom: 8px;
  flex-shrink: 0;
}

.result-actions .action-btn {
  margin-top: 0;
}

.result-actions .action-btn.ghost {
  margin-top: 0;
}

/* 结果页 */
.result-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.summary-item {
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 14px 16px;
}

.summary-item strong {
  font-size: 1.15rem;
  color: var(--text);
}

.fat-loss-encouragement {
  margin: 4px 0 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  text-align: center;
}

.fat-loss-encouragement.hidden {
  display: none;
}

.summary-item span {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.summary-item strong {
  font-size: 1.25rem;
  color: var(--primary);
}

.summary-item.optional.hidden {
  display: none;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 20px;
  cursor: pointer;
  font-size: 0.95rem;
}

.toggle-row input {
  display: none;
}

.toggle {
  width: 48px;
  height: 28px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.toggle-row input:checked + .toggle {
  background: var(--primary);
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(20px);
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 1 auto;
  overflow-y: auto;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

#screen-result.active {
  min-height: calc(100dvh - 88px);
  padding-bottom: 12px;
}

.dish-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.dish-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.dish-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  vertical-align: middle;
}

.dish-meta {
  display: flex;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 10px;
}

.dish-meta .cal {
  color: var(--text-muted);
  font-weight: 400;
}

.dish-meta .portion {
  color: var(--text);
  font-weight: 600;
}

.dish-meta .cal.hidden {
  display: none;
}

.dish-steps {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.dish-list-compact {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  min-height: 64px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s, border-color 0.12s;
}

.dish-row:active {
  transform: scale(0.98);
  border-color: var(--primary);
}

.dish-name-text {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  text-align: left;
}

.dish-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.dish-row-portion {
  font-size: 0.86rem;
  color: var(--primary);
  white-space: nowrap;
  font-weight: 600;
}

.dish-row-cal {
  font-size: 0.92rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.dish-card.clickable {
  cursor: pointer;
  padding: 20px 22px;
  transition: transform 0.12s, border-color 0.12s;
}

.dish-card.clickable:active {
  transform: scale(0.98);
  border-color: var(--primary);
}

.dish-card.clickable h3 {
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.dish-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dish-dialog.hidden {
  display: none;
}

.dish-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.dish-dialog-panel {
  position: relative;
  width: min(100%, 420px);
  max-height: min(80dvh, 560px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.dish-dialog-panel h3 {
  margin: 0 32px 12px 0;
  font-size: 1.15rem;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
}

.dish-dialog-body .detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 600;
}

.dish-dialog-body .detail-block {
  margin-bottom: 14px;
}

.dish-dialog-body .detail-block h4 {
  margin: 0 0 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.dish-dialog-body .detail-block p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  z-index: 99;
  max-width: calc(100% - 40px);
  text-align: center;
}

.toast.error {
  background: #d64545;
}

.toast.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

/* 登录注册 */
.auth-topbar {
  justify-content: flex-end;
}

.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
  padding: 16px 0 24px;
}

.logo-wrap.compact {
  padding: 16px 0 24px;
}

.logo-wrap.compact .logo-icon {
  width: 72px;
  height: 72px;
  font-size: 2rem;
  margin-bottom: 12px;
}

.logo-wrap.compact .logo-title {
  font-size: 2rem;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
}

.auth-tab.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 4px;
}

.auth-form.active {
  display: flex;
}

.auth-form .action-btn {
  margin-top: 16px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 480px) {
  .page {
    max-width: 100%;
  }

  .logo-title {
    font-size: clamp(1.75rem, 8vw, 2.4rem);
  }

  .meal-btns {
    gap: 10px;
  }

  .meal-btn {
    font-size: clamp(1.5rem, 7vw, 2rem);
    border-radius: 20px;
  }

  .dining-btn {
    padding: 18px 20px;
    font-size: 1.05rem;
  }

  .number-input-wrap input {
    font-size: 1.6rem;
  }

  .step-btn {
    width: 44px;
    height: 44px;
  }

  .topbar {
    padding: 12px 0 6px;
  }

  .toast {
    bottom: max(24px, env(safe-area-inset-bottom, 0));
    max-width: calc(100% - 32px);
  }
}

@media (max-width: 400px) {
  .user-bar {
    order: 3;
    width: 100%;
    margin-top: 4px;
  }
}

@media (max-width: 360px) {
  .logo-title {
    font-size: 1.75rem;
  }

  .meal-btn {
    font-size: 1.5rem;
  }

  .screen-actions,
  .result-actions {
    max-width: 100%;
  }
}

.user-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  overflow: hidden;
}

.user-bar #user-name {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.link-btn {
  border: none;
  background: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0;
}

.link-btn.danger {
  color: #c44;
}

.topbar {
  flex-wrap: wrap;
}

/* ========== 平板 / 桌面自适应 ========== */
@media (min-width: 768px) {
  body {
    background: linear-gradient(165deg, var(--bg) 0%, var(--bg-accent) 42%, var(--bg) 100%);
    background-attachment: fixed;
  }

  .page {
    max-width: min(920px, calc(100% - 40px));
    padding-left: 24px;
    padding-right: 24px;
  }

  #app-main.page,
  #auth-gate.page,
  #profile-app.page {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
    margin-top: 20px;
    margin-bottom: 20px;
    min-height: calc(100dvh - 40px);
    padding:
      env(safe-area-inset-top, 0)
      32px
      max(28px, env(safe-area-inset-bottom, 0))
      32px;
  }

  .topbar {
    flex-wrap: nowrap;
    padding-top: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    padding-bottom: 12px;
  }

  .user-bar {
    order: 0;
    width: auto;
    margin-top: 0;
    justify-content: flex-end;
  }

  .user-bar #user-name,
  .user-bar #user-display-name {
    max-width: 160px;
  }

  /* 首页：左介绍 + 右操作 */
  #screen-home.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 36px;
    align-content: center;
    flex: 1;
    padding: 16px 0 32px;
  }

  #screen-home .logo-wrap {
    grid-column: 1;
    grid-row: 1 / span 4;
    flex: none;
    padding: 24px 12px;
    justify-content: center;
  }

  #screen-home .diet-mode-btns,
  #screen-home .diet-mode-hint,
  #screen-home .home-mode-btns {
    grid-column: 2;
  }

  #screen-home .diet-mode-hint {
    text-align: left;
    margin-bottom: 8px;
  }

  .home-mode-btns {
    padding-bottom: 0;
  }

  .home-mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08);
  }

  /* 餐次选择：三列横排，限制宽度 */
  .meal-btns {
    max-width: 520px;
    margin: 0 auto;
    padding-bottom: 24px;
  }

  .meal-btn {
    aspect-ratio: auto;
    min-height: 96px;
    max-height: 112px;
    font-size: 1.75rem;
  }

  /* 就餐方式：三列 */
  .dining-btns {
    grid-template-columns: repeat(3, 1fr);
    max-width: 720px;
    margin: 0 auto;
  }

  .dining-btn:hover {
    transform: translateY(-2px);
  }

  /* 步骤页加宽 */
  #screen-dining .dining-btns,
  #screen-people .number-input-wrap,
  #screen-budget .field,
  #screen-budget .staple-panel,
  #screen-people .field-hint,
  #screen-dining.active .screen-title,
  #screen-people.active .screen-title,
  #screen-budget.active .screen-title,
  #screen-dining.active .screen-desc,
  #screen-people.active .screen-desc,
  #screen-budget.active .screen-desc {
    max-width: 520px;
  }

  .staple-panel {
    max-width: 520px;
  }

  .screen-actions,
  .result-actions {
    max-width: 400px;
  }

  /* 结果页：摘要居中，菜品两列 */
  .result-summary {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }

  .dish-list-compact {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .dish-row:hover,
  .dish-card.clickable:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
  }

  .dish-dialog-panel {
    width: min(100%, 480px);
  }

  .auth-main {
    max-width: 420px;
    padding: 24px 0 32px;
  }
}

@media (min-width: 1024px) {
  .page {
    max-width: min(980px, calc(100% - 48px));
  }

  #app-main.page,
  #auth-gate.page,
  #profile-app.page {
    margin-top: 28px;
    margin-bottom: 28px;
    padding-left: 40px;
    padding-right: 40px;
  }

  .logo-icon {
    width: 96px;
    height: 96px;
    font-size: 2.6rem;
  }

  .logo-title {
    font-size: 2.6rem;
  }

  .logo-sub {
    font-size: 1rem;
    max-width: 320px;
  }

  #screen-meal.active {
    justify-content: center;
    padding: 24px 0;
  }

  #screen-meal .screen-title,
  #screen-meal .screen-desc,
  #screen-meal .meal-btns {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  #screen-result.active .result-day-list {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (min-width: 1280px) {
  .page {
    max-width: 1040px;
  }

  .dish-list-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
  }
}
