:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #66736d;
  --cream: #f5f1e7;
  --paper: #fffdf8;
  --green: #173f35;
  --green-soft: #dce8e1;
  --orange: #d76d3b;
  --line: #dedbd1;
  --shadow: 0 12px 30px rgba(38, 50, 44, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  padding: calc(20px + env(safe-area-inset-top)) clamp(18px, 4vw, 48px) 20px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  background: var(--green);
  color: white;
}

.topbar h1, h2, h3, p { margin-top: 0; }
.topbar h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 44px); }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.status-pill { padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.16); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.eyebrow { margin-bottom: 5px; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; opacity: .75; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 4px solid transparent;
  padding: 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.tab.active { color: var(--green); border-bottom-color: var(--orange); }

main { max-width: 1180px; margin: 0 auto; padding: clamp(18px, 4vw, 44px); }
.view { display: none; }
.view.active { display: block; }

.week-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 18px; }
.meal-card {
  min-height: 175px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.meal-card:active { transform: scale(.99); }
.meal-day { color: var(--orange); font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.meal-title { font-family: Georgia, serif; font-size: 23px; line-height: 1.12; }
.meal-action { margin-top: auto; color: var(--green); font-weight: 850; }

.recipe-picker-wrap {
  position: sticky;
  top: 55px;
  z-index: 4;
  margin-bottom: 20px;
  padding: 14px;
  border-radius: 16px;
  background: var(--green-soft);
}
.recipe-picker-wrap label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
select { width: 100%; padding: 13px; border: 1px solid #b9c9c0; border-radius: 11px; background: white; color: var(--ink); }

.recipe-header, .recipe-section, .shopping-store {
  margin-bottom: 20px;
  padding: clamp(18px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.recipe-header h2 { margin-bottom: 10px; font: 700 clamp(28px, 5vw, 48px)/1.05 Georgia, serif; }
.recipe-header p { color: var(--muted); font-size: 18px; line-height: 1.5; }
.recipe-section h3, .shopping-store h3 { margin-bottom: 15px; color: var(--green); font-size: 21px; }
.recipe-section li { margin-bottom: 13px; line-height: 1.5; }
.steps { padding-left: 30px; counter-reset: step; list-style: none; }
.steps li { position: relative; min-height: 42px; padding-left: 26px; font-size: 18px; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: -28px; top: -3px; width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: white; display: grid; place-items: center; font-weight: 900; }
.macro { border-left: 5px solid var(--orange); background: #fff6ee; }

.shopping-heading { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 18px; }
.shopping-heading h2 { margin-bottom: 0; font: 700 34px Georgia, serif; }
.shopping-category { margin-top: 22px; }
.shopping-category h4 { margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.shopping-item { display: flex; gap: 12px; align-items: flex-start; padding: 13px 4px; border-bottom: 1px solid var(--line); line-height: 1.35; }
.shopping-item input { width: 23px; height: 23px; flex: 0 0 auto; accent-color: var(--green); }
.shopping-item:has(input:checked) span { color: var(--muted); text-decoration: line-through; }

.secondary { padding: 10px 14px; border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; font-weight: 800; }
.hidden { display: none; }

.feedback-heading { display: flex; justify-content: space-between; gap: 18px; align-items: start; margin-bottom: 18px; }
.feedback-heading h2 { margin-bottom: 8px; font: 700 34px Georgia, serif; }
.feedback-heading p { color: var(--muted); }
.save-status { padding: 7px 11px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 850; }
.feedback-card {
  margin-bottom: 18px;
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.feedback-card h3 { margin: 5px 0 20px; color: var(--green); font-size: 20px; }
.feedback-card label { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.feedback-card fieldset { margin: 0 0 18px; padding: 0; border: 0; }
.feedback-card legend { margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 800; }
.rating-row { display: flex; gap: 9px; }
.rating-choice input { position: absolute; opacity: 0; pointer-events: none; }
.rating-choice span { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--green); font-size: 17px; font-weight: 900; }
.rating-choice input:checked + span { border-color: var(--orange); background: var(--orange); color: white; }
.feedback-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.feedback-card select, .feedback-card textarea { width: 100%; margin-top: 6px; border: 1px solid #b9c9c0; border-radius: 11px; background: white; color: var(--ink); }
.feedback-card textarea { padding: 12px; resize: vertical; font: inherit; font-weight: 400; }
.overall-feedback label { margin-top: 16px; }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.primary { padding: 12px 18px; border: 0; border-radius: 999px; background: var(--green); color: white; font-weight: 850; }
.feedback-actions .secondary { color: var(--green); }
.share-result { margin-top: 14px; color: var(--green); font-weight: 750; }

@media (min-width: 850px) {
  #recipe-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .recipe-header, .macro { grid-column: 1 / -1; }
  #shopping-list { columns: 2; column-gap: 20px; }
  .shopping-store { break-inside: avoid; }
}

@media (max-width: 600px) {
  .topbar { align-items: start; }
  .topbar .secondary { display: none; }
  main { padding: 16px; }
  .week-grid { grid-template-columns: 1fr; }
  .week-grid { gap: 12px; }
  .meal-card {
    min-height: 0;
    padding: 18px;
    gap: 8px;
  }
  .meal-title { font-size: 21px; }
  .meal-action { margin-top: 4px; }
  .tab { padding: 14px 6px; font-size: 13px; }
  .feedback-fields { grid-template-columns: 1fr; }
}
