@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,500;6..72,600&display=swap");

:root {
  --paper: #f6f4ed;
  --surface: #fffdf8;
  --ink: #1d2922;
  --muted: #6d766f;
  --line: #dddcd3;
  --green: #1f6848;
  --green-dark: #174e38;
  --green-pale: #dfe9df;
  --lime: #b9cc8c;
  --clay: #d28a67;
  --sun: #e9bc57;
  --shadow: 0 18px 45px rgba(39, 53, 43, 0.07);
  --radius-lg: 28px;
  --radius-md: 20px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 8%, rgba(185, 204, 140, 0.15), transparent 30rem),
    var(--paper);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(31, 104, 72, 0.22);
  outline-offset: 2px;
}
.app-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(109, 118, 111, 0.17);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: "Newsreader", Georgia, serif;
  font-size: 25px;
  font-weight: 600;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: white;
}
.brand-mark svg { width: 23px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.save-status { margin: 0; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #5b9d6b; }
.icon-button, .date-arrow {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.4);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: .2s ease;
}
.icon-button:hover, .date-arrow:hover { background: white; border-color: #c2c4ba; transform: translateY(-1px); }
.icon-button svg, .date-arrow svg { width: 20px; }
.date-nav { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 38px 0 28px; }
.date-display {
  min-width: 230px;
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr auto;
  text-align: center;
  cursor: pointer;
}
.date-display .eyebrow { grid-column: 1 / -1; }
.date-display svg { width: 16px; margin: 6px 0 0 10px; color: var(--muted); }
.eyebrow {
  display: block;
  margin: 0 0 5px;
  color: var(--green);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.selected-date { font-family: "Newsreader", Georgia, serif; font-size: 24px; line-height: 1.2; }
.hero-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.summary-card, .macro-card, .food-card, .week-card {
  background: var(--surface);
  border: 1px solid rgba(184, 184, 173, .48);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.summary-card {
  padding: 42px 48px;
  min-height: 310px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  overflow: hidden;
  position: relative;
}
.summary-card::before {
  content: "";
  position: absolute;
  width: 250px;
  height: 250px;
  right: -100px;
  top: -140px;
  border-radius: 50%;
  background: rgba(185, 204, 140, .13);
}
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Newsreader", Georgia, serif; }
h1 { margin-bottom: 9px; max-width: 390px; font-size: clamp(36px, 4vw, 53px); font-weight: 500; line-height: .99; letter-spacing: -.025em; }
h1 span { color: var(--green); }
h2 { margin-bottom: 0; font-size: 28px; font-weight: 600; line-height: 1.05; }
.summary-copy > p:not(.eyebrow) { color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.primary-button, .secondary-button, .text-button {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  transition: .2s ease;
}
.primary-button { padding: 13px 20px; border-radius: 13px; background: var(--green); color: white; }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(31, 104, 72, .18); }
.primary-button svg, .secondary-button svg { width: 17px; }
.calorie-ring {
  --progress: 0deg;
  flex: 0 0 auto;
  width: 172px;
  height: 172px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--green) var(--progress), var(--green-pale) 0);
  position: relative;
}
.calorie-ring::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: var(--surface);
}
.ring-center { z-index: 1; text-align: center; }
.ring-center span { display: block; font-family: "Newsreader", Georgia, serif; font-size: 35px; line-height: 1; }
.ring-center small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.macro-card { padding: 34px 36px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.quiet-label { color: var(--muted); font-size: 12px; }
.macro-list { margin-top: 35px; display: grid; gap: 26px; }
.macro-meta { display: flex; justify-content: space-between; margin-bottom: 9px; font-size: 13px; }
.macro-meta span { display: flex; align-items: center; gap: 9px; }
.macro-meta strong { font-size: 12px; font-weight: 600; color: var(--muted); }
.macro-dot { width: 8px; height: 8px; border-radius: 50%; }
.macro-dot.protein, .protein-bar { background: var(--green); }
.macro-dot.carbs, .carbs-bar { background: var(--sun); }
.macro-dot.fat, .fat-bar { background: var(--clay); }
.progress-track { height: 7px; overflow: hidden; border-radius: 10px; background: #ecebe4; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .45s ease; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; margin: 20px 0 40px; }
.food-card, .week-card { min-height: 390px; padding: 32px 36px; }
.food-heading { align-items: center; }
.secondary-button { padding: 10px 14px; border-radius: 12px; background: transparent; color: var(--green); border: 1px solid #cad5cb; }
.secondary-button:hover { background: #f0f5ee; border-color: #9db3a1; }
.food-list { margin-top: 28px; display: grid; gap: 10px; }
.meal-group + .meal-group { margin-top: 17px; }
.meal-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.food-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid #e8e6de; }
.food-name { font-size: 14px; font-weight: 600; }
.food-macros { color: var(--muted); font-size: 11px; margin-top: 3px; }
.food-calories { font-size: 14px; font-weight: 700; white-space: nowrap; }
.item-actions { display: flex; opacity: 0; transition: opacity .2s; }
.food-item:hover .item-actions, .item-actions:focus-within { opacity: 1; }
.item-button { border: 0; background: none; color: var(--muted); padding: 5px; cursor: pointer; }
.item-button:hover { color: var(--green); }
.item-button.delete:hover { color: #a04435; }
.item-button svg { width: 16px; height: 16px; }
.empty-state { max-width: 350px; margin: 62px auto 30px; text-align: center; }
.empty-icon { width: 58px; height: 58px; border-radius: 20px; background: #edf1e6; color: var(--green); display: grid; place-items: center; margin: 0 auto 17px; transform: rotate(-3deg); }
.empty-icon svg { width: 29px; transform: rotate(3deg); }
.empty-state h3 { font-size: 22px; margin-bottom: 7px; }
.empty-state p { color: var(--muted); font-size: 13px; line-height: 1.55; margin-bottom: 12px; }
.text-button { background: transparent; color: var(--green); padding: 7px; font-size: 13px; }
.text-button span { transition: transform .2s; }
.text-button:hover span { transform: translateX(3px); }
.week-chart { height: 190px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 32px; border-bottom: 1px solid var(--line); }
.chart-day { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; position: relative; }
.chart-bar { width: min(24px, 80%); min-height: 4px; border-radius: 8px 8px 2px 2px; background: var(--green-pale); transition: height .5s ease; }
.chart-day.selected .chart-bar { background: var(--green); }
.chart-label { margin-bottom: -24px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.chart-value { position: absolute; top: -2px; font-size: 9px; color: var(--muted); opacity: 0; }
.chart-day:hover .chart-value { opacity: 1; }
.week-insight { margin-top: 42px; padding: 14px 16px; border-radius: 14px; background: #f0f2e9; color: #59665b; font-size: 12px; line-height: 1.5; }
footer { display: flex; justify-content: space-between; padding: 22px 0 40px; color: var(--muted); font-size: 11px; border-top: 1px solid rgba(109, 118, 111, .17); }
footer p { margin: 0; }
dialog {
  width: min(590px, calc(100% - 28px));
  padding: 0;
  border: 1px solid #d8d6cd;
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(29, 41, 34, .22);
}
dialog::backdrop { background: rgba(24, 33, 28, .43); backdrop-filter: blur(3px); }
dialog form { padding: 32px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 27px; }
.dialog-heading h2 { font-size: 31px; }
.dialog-heading .icon-button { margin-top: -8px; margin-right: -8px; background: transparent; border: 0; }
label, legend { display: block; color: #465149; font-size: 12px; font-weight: 600; }
input, select {
  width: 100%;
  margin-top: 7px;
  border: 1px solid #d4d4cb;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  transition: border .2s;
}
input:hover, select:hover { border-color: #aeb5ac; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 17px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 43px; }
.input-suffix span { position: absolute; right: 11px; top: 21px; color: var(--muted); font-size: 11px; font-weight: 500; }
fieldset { padding: 0; border: 0; margin: 23px 0 0; }
legend span { color: var(--muted); font-weight: 400; }
.field-error { display: block; min-height: 16px; margin-top: 4px; color: #a04435; font-size: 10px; font-weight: 500; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }
.settings-note { padding: 12px 14px; margin: 22px 0 0; border-radius: 10px; background: #f0f2e9; color: var(--muted); font-size: 11px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  padding: 11px 17px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  .hero-grid, .content-grid { grid-template-columns: 1fr; }
  .content-grid { margin-top: 16px; }
  .week-card { min-height: 360px; }
}
@media (max-width: 590px) {
  .app-shell { width: min(100% - 24px, 1180px); }
  .topbar { height: 70px; }
  .save-status { display: none; }
  .date-nav { padding: 25px 0 20px; gap: 10px; }
  .date-display { min-width: 185px; }
  .selected-date { font-size: 20px; }
  .summary-card { padding: 30px 25px; min-height: 380px; flex-direction: column-reverse; align-items: flex-start; }
  .calorie-ring { width: 135px; height: 135px; align-self: flex-end; margin-bottom: -35px; }
  .ring-center span { font-size: 28px; }
  .macro-card, .food-card, .week-card { padding: 26px 22px; }
  .food-heading { align-items: flex-start; }
  .food-heading .secondary-button { padding: 9px; font-size: 0; }
  .food-heading .secondary-button svg { width: 20px; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  dialog form { padding: 25px 20px; }
  footer { flex-direction: column; gap: 7px; }
  .item-actions { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
