:root {
  --ink: #17201b;
  --muted: #60706a;
  --line: #d9e2db;
  --paper: #fbfaf5;
  --panel: #ffffff;
  --green: #1f7a4d;
  --green-dark: #145837;
  --saffron: #d8851f;
  --rose: #b34a5a;
  --teal: #237d88;
  --shadow: 0 18px 50px rgba(25, 35, 30, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.hero {
  position: relative;
  min-height: clamp(340px, 45vh, 520px);
  display: grid;
  align-items: end;
  overflow: hidden;
  background: #23362d;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.84;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(12, 24, 17, 0.74), rgba(12, 24, 17, 0.28) 55%, rgba(12, 24, 17, 0.08));
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 86px;
  color: white;
}

.eyebrow {
  margin: 0 0 12px;
  color: #f2c46c;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--green);
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 560px;
  margin: 20px 0 0;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.55;
}

.dashboard {
  width: min(1120px, calc(100% - 32px));
  margin: -54px auto 48px;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.summary-panel,
.tracker-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(217, 226, 219, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-panel {
  padding: 22px;
  align-self: start;
  display: grid;
  gap: 22px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.12);
}

.goal-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.goal-row span {
  color: var(--muted);
  font-weight: 800;
}

.progress-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.progress-ring {
  width: 168px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0deg, var(--green) var(--progress, 0deg), #e8eee8 var(--progress, 0deg));
  box-shadow: inset 0 0 0 16px white;
}

.progress-ring span {
  font-size: 2.6rem;
  font-weight: 900;
}

.progress-ring small,
.macro-grid small {
  color: var(--muted);
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e8eee8;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--saffron));
}

#remainingCalories {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.calorie-alert {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f0c8ce;
  border-radius: 6px;
  color: #8a2432;
  background: #fff5f6;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.macro-grid div {
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  background: #fbfcfa;
}

.macro-grid span {
  display: block;
  font-weight: 900;
}

.target-grid {
  display: grid;
  gap: 8px;
}

.target-grid div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.target-grid strong {
  color: var(--ink);
}

.storage-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.profile-summary {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.profile-summary strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

.tracker-panel {
  padding: 22px;
}

.food-form {
  display: grid;
  grid-template-columns: minmax(230px, 1.6fr) 110px 140px 140px auto;
  align-items: end;
  gap: 12px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 6px;
  border: 0;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 900;
}

.primary-button {
  color: white;
  background: var(--green);
}

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

.secondary-button {
  color: white;
  background: var(--teal);
}

.ghost-button {
  color: var(--green-dark);
  background: #edf5ef;
  border: 1px solid #cee2d3;
}

.compact {
  min-height: 38px;
}

.match-card,
.custom-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

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

.match-card strong {
  display: block;
}

.match-card span,
.match-card small {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.custom-form {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.1fr repeat(4, minmax(92px, 0.55fr)) auto;
  gap: 10px;
}

.food-library {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

#foodCount {
  color: var(--muted);
  font-weight: 800;
}

.food-list {
  max-height: 280px;
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: auto;
}

.food-item {
  min-width: 0;
  border: 1px solid #e8eee8;
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: white;
  cursor: pointer;
  text-align: left;
}

.food-item:hover {
  border-color: var(--green);
  background: #f5faf6;
}

.food-item strong {
  display: block;
  margin-bottom: 4px;
}

.food-item span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-section {
  margin-top: 18px;
}

.chart-header {
  margin-top: 0;
}

.chart-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.chart-panel canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid #eef2ee;
  border-radius: 6px;
  background: #fbfcfa;
}

.chart-panel canvas + canvas {
  margin-top: 12px;
}

.chart-summary {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.macro-bar {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.macro-bar div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.macro-bar strong {
  color: var(--ink);
}

.macro-bar .bar {
  height: 10px;
  border-radius: 999px;
  background: #e8eee8;
  overflow: hidden;
}

.macro-bar .bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.macro-bar.protein .bar i {
  background: var(--green);
}

.macro-bar.carbs .bar i {
  background: var(--saffron);
}

.macro-bar.fat .bar i {
  background: var(--rose);
}

.section-header {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
}

#entryCount {
  color: var(--muted);
  font-weight: 800;
}

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

.meal-group {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.meal-title {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 900;
  font-size: 0.9rem;
}

.entry {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #eef2ee;
}

.entry strong {
  display: block;
}

.entry small {
  color: var(--muted);
}

.calorie-pill {
  min-width: 82px;
  padding: 8px 10px;
  border-radius: 999px;
  color: #7b3d07;
  background: #fff0da;
  text-align: center;
  font-weight: 900;
}

.delete-button {
  width: 34px;
  height: 34px;
  border: 1px solid #f0c8ce;
  border-radius: 50%;
  color: var(--rose);
  background: #fff5f6;
  cursor: pointer;
  font-weight: 900;
}

.empty-state {
  padding: 34px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 24, 18, 0.58);
}

.setup-modal {
  width: min(760px, 100%);
  max-height: min(92vh, 840px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: white;
  box-shadow: var(--shadow);
}

.setup-modal h2 {
  margin-bottom: 18px;
  font-size: 1.7rem;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.profile-grid {
  align-items: end;
}

.gender-field {
  min-height: 44px;
  margin: 0;
  border: 0;
  padding: 0;
  display: flex;
  align-items: end;
  gap: 12px;
}

.gender-field legend {
  float: left;
  min-width: 64px;
  margin: 0 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.gender-field label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.gender-field input {
  width: auto;
  min-height: auto;
  padding: 0;
}

.recommendation-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.recommendation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.recommendation-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.12);
}

.recommendation-card strong {
  display: block;
}

.recommendation-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.setup-preview {
  margin: 16px 0;
  padding: 12px;
  border-radius: 6px;
  color: var(--muted);
  background: #fbfcfa;
  font-weight: 800;
}

@media (max-width: 940px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    grid-template-columns: 1fr 1.3fr;
  }

  .macro-grid,
  .summary-panel .ghost-button {
    grid-column: 1 / -1;
  }

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

  .food-form .wide,
  .primary-button,
  .custom-form input:first-child,
  .custom-form button {
    grid-column: 1 / -1;
  }

  .chart-summary {
    grid-template-columns: 1fr;
  }

  .food-list {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .hero-copy {
    padding-bottom: 74px;
  }

  .dashboard {
    width: min(100% - 20px, 1120px);
    margin-top: -42px;
  }

  .summary-panel {
    grid-template-columns: 1fr;
  }

  .food-form,
  .custom-form {
    grid-template-columns: 1fr;
  }

  .custom-form input:first-child,
  .custom-form button {
    grid-column: auto;
  }

  .entry {
    grid-template-columns: 1fr auto;
  }

  .delete-button {
    grid-column: 2;
  }

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

  .gender-field {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .gender-field legend {
    float: none;
    grid-column: 1 / -1;
  }
}
