:root {
  color-scheme: light;
  --bg: #f8f2e8;
  --panel: #fffdf8;
  --ink: #2b211b;
  --muted: #82776d;
  --line: #eee1d3;
  --accent: #2f8d68;
  --accent-strong: #1f6c50;
  --accent-soft: #e7f5ec;
  --peach: #ffe0cf;
  --cream: #fff4d8;
  --rose: #ffe2dd;
  --lavender: #e8e5ff;
  --warn: #d5452f;
  --shadow: 0 18px 48px rgba(86, 65, 39, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 218, 184, 0.55), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(222, 243, 226, 0.8), transparent 26%),
    var(--bg);
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 1.15fr);
  gap: 24px;
  min-height: 250px;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(135deg, #fff3dc 0%, #ffe0cf 56%, #e8f5e7 100%);
  box-shadow: var(--shadow);
}

.hero-card::after {
  content: "";
  position: absolute;
  left: -60px;
  bottom: -120px;
  width: 420px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255, 164, 128, 0.22);
}

.hero-copy {
  position: relative;
  z-index: 1;
  padding: 36px 0 34px 36px;
}

.hero-card img {
  width: 100%;
  height: 100%;
  min-height: 250px;
  object-fit: cover;
  object-position: right center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 54px;
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.22;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.hero-text {
  max-width: 360px;
  margin-bottom: 0;
  color: #6f5c4f;
  font-size: 17px;
  line-height: 1.65;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.module-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  align-items: center;
  min-height: 94px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.9);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 28px rgba(86, 65, 39, 0.08);
  cursor: pointer;
}

.module-tile:hover,
.module-tile.active {
  border-color: rgba(47, 141, 104, 0.45);
  background: #fffaf0;
  box-shadow: 0 14px 32px rgba(86, 65, 39, 0.12);
}

.module-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--cream);
  font-size: 24px;
}

.module-tile strong,
.module-tile em {
  display: block;
}

.module-tile strong {
  font-size: 18px;
}

.module-tile em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.feature-card {
  margin-top: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
  scroll-margin-top: 18px;
}

.app-page[hidden] {
  display: none;
}

.app-page.active-page {
  display: block;
}

.feature-card.highlight {
  outline: 3px solid rgba(47, 141, 104, 0.22);
}

.section-heading,
.library-header,
.progress-meta {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 18px;
}

.soft-badge,
.food-count {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label,
.panel-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.food-library {
  margin: 8px 0 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #fffaf1, #fffdf8);
}

.library-header {
  margin-bottom: 14px;
}

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

.back-category {
  min-height: 36px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(47, 141, 104, 0.22);
}

.back-category:hover {
  background: var(--accent-soft);
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.category-tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

.category-tabs button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.food-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
  max-height: 276px;
  overflow: auto;
  padding-right: 2px;
}

.app-page.food-library .food-grid {
  max-height: 520px;
}

.food-card {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.food-card:hover,
.food-card:focus,
.food-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

.food-card.selected {
  background: var(--accent-soft);
}

.food-card strong,
.food-card span {
  display: block;
}

.food-card strong {
  margin-bottom: 8px;
  line-height: 1.35;
}

.food-card span {
  color: var(--muted);
  font-size: 13px;
}

.no-foods {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.6;
}

.match-name {
  min-height: 24px;
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.5;
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(260px, 1.25fr);
  gap: 16px;
  align-items: stretch;
}

.input-unit {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.input-unit input {
  border: 0;
  border-radius: 0;
}

.input-unit span {
  padding: 0 14px;
  color: var(--muted);
  border-left: 1px solid var(--line);
}

.quantity-unit select {
  width: 112px;
  flex: 0 0 112px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #fff;
  padding: 0 10px;
}

.portion-hint {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.calorie-result {
  min-height: 140px;
  padding: 22px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft), #fff3d7);
}

.calorie-result span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.calorie-result strong {
  display: inline-block;
  margin-top: 18px;
  font-size: 68px;
  line-height: 0.95;
  letter-spacing: 0;
}

.calorie-result em {
  margin-left: 8px;
  color: var(--muted);
  font-size: 22px;
  font-style: normal;
}

.add-plan-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: #fff7e8;
}

.meal-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.meal-picker button {
  min-height: 36px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

.meal-picker button.active {
  background: var(--accent);
  color: #fff;
}

.chooser-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.3fr);
  gap: 16px 18px;
  align-items: start;
}

.chooser-layout .field:first-child {
  grid-row: span 2;
}

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

.choice-chips button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

.choice-chips button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.chooser-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 2px;
  padding: 16px;
  border-radius: 18px;
  background: #fff7e8;
}

.chooser-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.chooser-status.error {
  color: var(--warn);
  font-weight: 800;
}

.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.recommendation-card {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, #fff, #fff5e2);
}

.recommendation-card strong,
.recommendation-card p,
.recommendation-card em {
  display: block;
}

.meal-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.recommendation-card strong {
  line-height: 1.35;
}

.recommendation-card p {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.recommendation-card em {
  color: var(--accent-strong);
  font-size: 24px;
  font-style: normal;
  font-weight: 800;
}

.secondary-action {
  min-height: 42px;
  margin-top: 14px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(47, 141, 104, 0.28);
}

.secondary-action:hover {
  background: var(--accent-soft);
}

.primary-action {
  min-height: 44px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 0 20px;
  font-weight: 800;
  cursor: pointer;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.target-row {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(260px, 1.3fr);
  gap: 16px;
  align-items: end;
}

.progress-panel {
  padding: 16px;
  border-radius: 18px;
  background: #fff7e8;
}

.progress-meta {
  margin-bottom: 10px;
}

.progress-meta span {
  color: var(--muted);
  font-weight: 800;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadfce;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #67c58e, #f6c76c);
  transition: width 0.18s ease;
}

.progress-fill.over {
  background: linear-gradient(90deg, #ef8d63, #d5452f);
}

.plan-warning {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffe1da;
  color: var(--warn);
  font-weight: 800;
}

.meal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.meal-card {
  min-height: 190px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.meal-card header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.meal-card header span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: var(--cream);
}

.meal-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.meal-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: #fff8eb;
}

.meal-list strong,
.meal-list span {
  display: block;
}

.meal-list strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.meal-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.remove-entry {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #ffe1da;
  color: var(--warn);
  cursor: pointer;
}

.empty-meal {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .hero-card,
  .calc-grid,
  .chooser-layout,
  .target-row,
  .meal-grid {
    grid-template-columns: 1fr;
  }

  .chooser-layout .field:first-child {
    grid-row: auto;
  }

  .hero-copy {
    padding-right: 28px;
  }

  .hero-card img {
    max-height: 240px;
  }

  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .add-plan-panel,
  .chooser-action-row {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1040px);
    padding: 18px 0 32px;
  }

  .hero-copy,
  .feature-card,
  .food-library {
    padding: 18px;
  }

  h1 {
    font-size: 40px;
  }

  h2 {
    font-size: 24px;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .library-header {
    align-items: start;
    flex-direction: column;
  }

  .library-actions {
    width: 100%;
    justify-content: space-between;
  }

  .food-grid {
    grid-template-columns: 1fr;
    max-height: 280px;
  }

  .calorie-result strong {
    font-size: 56px;
  }
}
