:root {
  color-scheme: light;
  --ink: #17332b;
  --muted: #61736d;
  --paper: #fffdf8;
  --canvas: #f4f1e8;
  --line: #d9dfda;
  --green: #176b51;
  --green-dark: #0c4c39;
  --green-soft: #dff0e8;
  --orange: #e77a39;
  --orange-soft: #fff0e5;
  --yellow: #f1bc4b;
  --blue: #477da5;
  --danger: #a63d3d;
  --shadow: 0 20px 60px rgba(31, 54, 45, 0.09);
  --radius: 24px;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 90% 3%, rgba(241, 188, 75, 0.18), transparent 23rem),
    var(--canvas);
  color: var(--ink);
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  min-height: 44px;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(23, 107, 81, 0.32);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  border-bottom: 1px solid rgba(23, 51, 43, 0.1);
  background: rgba(255, 253, 248, 0.92);
}

.header-inner {
  width: min(1120px, calc(100% - 32px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: var(--green);
  color: white;
}

.header-note {
  display: none;
  color: var(--muted);
  font-size: 0.84rem;
}

.hero {
  width: min(800px, calc(100% - 32px));
  margin: 0 auto;
  padding: 54px 0 34px;
  text-align: center;
}

.eyebrow,
.step-label,
.mini-label {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 680px;
  margin: 0 auto;
  font-size: clamp(2.15rem, 8vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.hero-copy {
  max-width: 620px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 1rem;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.hero-badges span {
  padding: 7px 12px;
  border: 1px solid rgba(23, 107, 81, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.page-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
}

.panel,
.method-panel {
  border: 1px solid rgba(23, 51, 43, 0.09);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 24px 18px;
}

.section-heading,
.plan-toolbar,
.meal-heading,
.plan-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.method-panel h2,
.plan-intro h3,
.shopping-card h3,
.comparison-card h3 {
  margin: 0;
  line-height: 1.2;
}

.section-heading h2,
.method-panel h2 {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
}

.text-button {
  min-height: 40px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 800;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

.field {
  min-width: 0;
}

.field label,
.choice-group legend {
  display: block;
  margin-bottom: 7px;
  font-size: 0.88rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  color: var(--ink);
}

input {
  padding: 11px 48px 11px 13px;
}

select {
  padding: 11px 38px 11px 13px;
}

input:hover,
select:hover {
  border-color: #aebdb6;
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fff8f8;
}

.input-with-unit {
  position: relative;
}

.input-with-unit > span {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.field-help,
.field-error {
  display: block;
  min-height: 18px;
  margin-top: 5px;
  font-size: 0.73rem;
}

.field-help {
  color: var(--muted);
}

.field-error {
  color: var(--danger);
}

.choice-group {
  min-width: 0;
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  gap: 8px;
}

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

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 68px;
  align-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  font-weight: 800;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.segmented small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 500;
}

.segmented input:checked + span {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
}

.segmented input:focus-visible + span {
  outline: 3px solid rgba(23, 107, 81, 0.3);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 14px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  min-height: 54px;
  margin-top: 26px;
  padding: 12px 20px;
  border: 0;
  background: var(--green);
  color: white;
  box-shadow: 0 12px 26px rgba(23, 107, 81, 0.2);
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  padding: 9px 15px;
  border: 1px solid var(--green);
  background: white;
  color: var(--green);
}

.danger-button {
  padding: 8px 12px;
  border: 1px solid rgba(166, 61, 61, 0.25);
  background: transparent;
  color: var(--danger);
}

.results {
  padding: 52px 0 0;
  scroll-margin-top: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.summary-card {
  position: relative;
  overflow: hidden;
  min-height: 122px;
  padding: 17px;
  border: 1px solid rgba(23, 51, 43, 0.08);
  border-radius: 20px;
  background: var(--paper);
}

.summary-card::after {
  position: absolute;
  right: -24px;
  bottom: -38px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--tone-color);
  opacity: 0.16;
  content: "";
}

.tone-calories { --tone-color: var(--green); }
.tone-protein { --tone-color: var(--orange); }
.tone-fat { --tone-color: var(--yellow); }
.tone-carbs { --tone-color: var(--blue); }
.tone-salt { --tone-color: #8f6a4a; }

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-value {
  display: block;
  margin-top: 14px;
  font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1;
}

.summary-note {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.energy-meta {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.energy-meta span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.energy-meta small {
  color: var(--muted);
  font-size: 0.64rem;
}

.energy-meta strong {
  overflow: hidden;
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seasoning-disclaimer {
  grid-column: 1 / -1;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.plan-toolbar {
  flex-direction: column;
  margin-top: 42px;
}

.style-tabs {
  display: flex;
  max-width: 100%;
  gap: 6px;
  overflow-x: auto;
  padding: 4px;
  border-radius: 14px;
  background: rgba(23, 107, 81, 0.08);
}

.style-tabs button {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.style-tabs button[aria-selected="true"] {
  background: white;
  color: var(--green-dark);
  box-shadow: 0 4px 12px rgba(23, 51, 43, 0.08);
}

#meal-plan {
  margin-top: 18px;
}

.plan-intro,
.shopping-card,
.meal-card,
.comparison-card {
  border: 1px solid rgba(23, 51, 43, 0.09);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 12px 38px rgba(31, 54, 45, 0.06);
}

.plan-intro {
  align-items: center;
  padding: 18px;
}

.difficulty-label {
  color: var(--orange);
  font-size: 0.72rem;
  font-weight: 800;
}

.plan-intro h3 {
  margin-top: 4px;
  font-size: 1.25rem;
}

.basis-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.tolerance-badge {
  display: none;
  min-width: 112px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--green-soft);
  text-align: right;
}

.tolerance-badge span,
.tolerance-badge strong {
  display: block;
}

.tolerance-badge span {
  color: var(--muted);
  font-size: 0.64rem;
}

.shopping-card,
.comparison-card {
  margin-top: 12px;
  padding: 18px;
}

.shopping-grid {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.shopping-item,
.ingredient-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shopping-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f5ef;
}

.shopping-item > div,
.ingredient-list span {
  display: grid;
}

.shopping-item span,
.ingredient-list small {
  color: var(--muted);
  font-size: 0.66rem;
}

.meal-stack {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.meal-card {
  overflow: hidden;
  padding: 18px;
}

.meal-heading h3 {
  margin: 5px 0 0;
  font-size: 1rem;
  line-height: 1.35;
}

.meal-index {
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
}

.nutrient-pill {
  display: none;
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--orange-soft);
  color: #914418;
  font-size: 0.68rem;
  font-weight: 800;
}

.ingredient-list {
  display: grid;
  gap: 2px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.ingredient-list li {
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}

.recipe-list {
  margin-top: 14px;
}

.recipe-details {
  border-top: 1px solid var(--line);
}

.recipe-details summary {
  padding: 12px 0;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.recipe-details ol {
  margin: 0 0 14px;
  padding-left: 22px;
  color: var(--muted);
  font-size: 0.78rem;
}

.comparison-table {
  display: grid;
  gap: 2px;
  margin-top: 14px;
}

.comparison-row {
  display: grid;
  grid-template-columns: 0.8fr 1fr 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.77rem;
}

.comparison-row > span {
  display: grid;
}

.comparison-row small {
  color: var(--muted);
  font-size: 0.58rem;
}

.error-good {
  min-width: 54px;
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  text-align: center;
  font-weight: 800;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
  padding: 18px 0;
}

.app-status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.method-panel {
  margin: 28px 0 48px;
  padding: 24px 18px;
  box-shadow: none;
}

.method-panel details {
  border-top: 1px solid var(--line);
}

.method-panel details:first-of-type {
  margin-top: 18px;
}

.method-panel summary {
  padding: 15px 0;
  font-weight: 800;
  cursor: pointer;
}

.method-panel details p,
.disclaimer {
  color: var(--muted);
  font-size: 0.82rem;
}

.disclaimer {
  margin: 18px 0 0;
  padding: 13px;
  border-radius: 12px;
  background: #f3f2ed;
}

footer {
  padding: 24px 16px 36px;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (min-width: 620px) {
  .header-note {
    display: inline;
  }

  .page-shell {
    width: min(1120px, calc(100% - 48px));
  }

  .input-panel,
  .method-panel {
    padding: 34px;
  }

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

  .field-wide {
    grid-column: 1 / -1;
  }

  .segmented-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .tolerance-badge,
  .nutrient-pill {
    display: inline-block;
  }
}

@media (min-width: 900px) {
  .hero {
    padding-top: 78px;
  }

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

  .input-panel {
    width: min(840px, 100%);
    margin: 0 auto;
    padding: 44px;
  }

  .results {
    width: min(1040px, 100%);
    margin: 0 auto;
  }

  .plan-toolbar {
    flex-direction: row;
    align-items: flex-end;
  }

  .meal-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .meal-card {
    padding: 20px;
  }

  .meal-heading {
    display: block;
  }

  .nutrient-pill {
    margin-top: 10px;
  }

  .method-panel {
    width: min(840px, 100%);
    margin-right: auto;
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
