:root {
  color-scheme: light;
  --background: #eff0e8;
  --paper: #fffefa;
  --ink: #172c23;
  --muted: #526257;
  --line: #d6dbd0;
  --lime: #e3efb9;
  --green: #286449;
  --warn: #775222;
  --danger: #973e36;
  --shadow: 0 16px 50px #25352611;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  background: var(--background);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .56; }

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}

h1, h2, h3, p, dl, dd, form { margin: 0; }
h1 {
  font-size: clamp(2.15rem, 8vw, 3.35rem);
  font-weight: 780;
  letter-spacing: -.08em;
  line-height: 1;
}
h2 { font-size: 1.23rem; letter-spacing: -.025em; }
h3 { font-size: 1.04rem; }
p { line-height: 1.45; }
.muted { color: var(--muted); font-size: .9rem; }
.full { width: 100%; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.shell { max-width: 760px; margin-inline: auto; }
.masthead {
  min-height: 67px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-inline: 16px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; letter-spacing: -.035em; }
.brand-mark {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 31px;
  height: 31px;
  padding-bottom: 7px;
  border-radius: 9px;
  background: var(--ink);
}
.brand-mark i { background: var(--lime); width: 4px; height: 10px; border-radius: 2px; }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-mark i:nth-child(3) { height: 13px; }
.sign-out, .text-button {
  min-height: 42px;
  padding: 5px 2px;
  background: none;
  border: 0;
  color: var(--green);
  font-weight: 680;
}
.sign-out { color: var(--muted); font-size: .86rem; }

main { padding: 26px 16px calc(105px + env(safe-area-inset-bottom)); }
.day-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 19px; }
.day-heading p { margin-top: 8px; }
.calendar-controls { display: flex; align-items: center; gap: 5px; }
.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  min-height: 44px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 1.65rem;
  line-height: 1;
}
.calendar-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  min-width: 0;
  cursor: pointer;
}
.calendar-picker input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; }
.calendar-picker:focus-within { outline: 3px solid var(--green); outline-offset: 3px; }

.summary {
  padding: 18px;
  border-radius: 23px;
  background: var(--lime);
}
.summary-main { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 9px; }
.summary-main h2 { font-size: .95rem; font-weight: 680; letter-spacing: 0; }
.summary-states { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
#nutrient-status { color: #674a1d; background: #f3e7be; border-color: #d1c493; }
.summary-state {
  border: 1px solid #b0c484;
  border-radius: 30px;
  padding: 5px 9px;
  color: #34452b;
  font-size: .79rem;
  font-weight: 700;
  line-height: 1.35;
}
.energy { margin-top: 4px; display: flex; align-items: baseline; gap: 5px; }
.energy strong {
  font-size: clamp(2.85rem, 11vw, 4.7rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.085em;
  line-height: 1;
}
.energy span { font-weight: 650; }
.macros { display: grid; grid-template-columns: 1fr 1.3fr .8fr; border-top: 1px solid #bdcd91; margin-top: 15px; padding-top: 12px; }
.macros div + div { padding-left: 12px; border-left: 1px solid #bdcd91; }
.macros dt { color: #465639; font-size: .83rem; }
.macros dd { font-variant-numeric: tabular-nums; font-weight: 750; margin-top: 3px; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.button {
  min-height: 48px;
  padding: 9px 12px;
  display: inline-flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border-radius: 13px;
  border: 1px solid transparent;
  font-size: .92rem;
  font-weight: 720;
  line-height: 1.22;
  text-align: center;
}
.primary { color: #fdfefa; background: var(--ink); }
.primary:hover { background: #274536; }
.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.secondary:hover, .icon-button:hover { background: #f5f7ef; }
.danger { background: var(--danger); color: white; }
.remove-button { color: var(--danger); }

.icon { display: inline-block; position: relative; width: 17px; height: 17px; flex: 0 0 17px; }
.barcode-icon {
  background: linear-gradient(90deg, currentColor 10%, transparent 10% 21%, currentColor 21% 37%, transparent 37% 48%, currentColor 48% 59%, transparent 59% 70%, currentColor 70% 82%, transparent 82% 94%, currentColor 94%);
}
.search-icon { width: 16px; flex-basis: 16px; }
.search-icon::before { content: ""; position: absolute; width: 9px; height: 9px; border: 1.6px solid; border-radius: 50%; left: 0; top: 0; }
.search-icon::after { content: ""; position: absolute; width: 7px; border-top: 1.6px solid; transform: rotate(45deg); right: -1px; bottom: 3px; }
.calendar-icon { border: 1.5px solid; border-radius: 3px; }
.calendar-icon::after { content: ""; position: absolute; top: 4px; left: 0; right: 0; border-top: 1.5px solid; }
.list-icon { height: 15px; background: repeating-linear-gradient(to bottom, currentColor 0 1.5px, transparent 1.5px 6px); }
.pending-icon { border: 1.5px solid; border-radius: 50%; }
.pending-icon::after { content: ""; position: absolute; border-left: 1.5px solid; border-bottom: 1.5px solid; width: 4px; height: 5px; left: 6px; top: 3px; }

.favorites, .meals { margin-top: 25px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.quick-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.quick-item, .list-product {
  width: 100%;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  min-height: 52px;
}
.quick-item:hover, .list-product:hover { border-color: #a7b5a5; }
.quick-item b, .list-product b, .entry-name { overflow-wrap: anywhere; }
.meal-items, .item-list { display: grid; gap: 9px; }
.meal-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}
.meal-header { display: flex; justify-content: space-between; align-items: center; min-height: 49px; padding: 0 7px 0 12px; gap: 8px; }
.meal-header h3 { display: flex; gap: 8px; align-items: baseline; }
.meal-add { min-height: 42px; padding-inline: 9px; font-size: .9rem; }
.meal-rows { padding-inline: 12px; }
.meal-row {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  text-align: left;
  gap: 9px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  padding: 9px 0;
}
.entry-description { display: flex; flex-direction: column; gap: 4px; }
.entry-value { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.entry-value.needs-review { color: var(--warn); font-size: .83rem; font-weight: 680; }
.day-status-form { margin-top: 16px; display: flex; gap: 9px; flex-direction: column; align-items: flex-start; }
.empty-message { padding: 15px 6px; }
#catalog-new { margin: 12px 0; }

.nav-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: min(100%, 760px);
  transform: translateX(-50%);
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px 9px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.nav-bar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 48px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  font-size: .85rem;
  font-weight: 680;
  color: var(--muted);
}
.nav-bar button[aria-current="page"] { background: #e7eedb; color: var(--ink); }
#pending-badge { font-size: .76rem; margin-left: 1px; background: #efdfc9; color: #694418; padding: 1px 5px; border-radius: 9px; }

dialog {
  width: min(100%, 510px);
  max-width: 100%;
  max-height: calc(100dvh - 16px);
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: #10211780; }
.sheet { padding: 15px 16px calc(15px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 1.35rem; }
.close-button { background: var(--background); }
.mode > * + * { margin-top: 10px; }
.field-stack {
  display: grid;
  gap: 10px;
}
.field-stack > * + * { margin-top: 0; }
.field-grid, .search-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; align-items: end; }
.search-form { grid-template-columns: minmax(0, 1fr) auto; }
.field-stack label:not(.check-label) { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 650; min-width: 0; }
.pending-card .meal-row { border-top: 0; }
.field-stack label .muted { font-size: .83rem; font-weight: 400; }
input:not([type="checkbox"]):not([type="hidden"]), select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #c9d2c6;
  background: white;
  color: var(--ink);
  font-size: 1rem;
}
input::placeholder { color: #617063; opacity: 1; }
.check-label { display: flex; align-items: center; gap: 8px; min-height: 35px; }
input[type="checkbox"] { width: 19px; height: 19px; accent-color: var(--green); }
.selected-product { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #edf2e5; border-radius: 12px; padding: 7px 9px; }
.selected-product > div { display: grid; gap: 4px; overflow-wrap: anywhere; }
.confirm-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#lookup-items { max-height: 32dvh; overflow-y: auto; }
.toast, .form-error { margin-bottom: 10px; padding: 9px 10px; border-radius: 10px; background: #e3ecd7; overflow-wrap: anywhere; }
.form-error, .toast[data-error="true"] { color: #75271d; background: #f8e8e3; }
#entry-label-preview { display: block; width: 100%; max-height: 200px; object-fit: contain; border-radius: 10px; background: var(--background); }
.camera { position: relative; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 13px; background: var(--ink); }
.camera video { display: block; width: 100%; height: 100%; object-fit: cover; }
.scan-guide { position: absolute; inset: 27% 12%; pointer-events: none; border: 2px solid var(--lime); border-radius: 9px; box-shadow: 0 0 0 200px #14241e45; }
.camera-stop { position: absolute; right: 8px; bottom: 8px; min-height: 40px; border: 0; border-radius: 7px; padding: 5px 10px; background: var(--ink); color: white; }
.no-script { padding: 14px; }
.auth-page { display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(100%, 410px); padding: 25px; border-radius: 21px; background: var(--paper); box-shadow: var(--shadow); }
.auth-card h1 { font-size: clamp(1.65rem, 7vw, 2.45rem); margin-bottom: 16px; }
.auth-card form { display: grid; gap: 10px; }
.auth-card label { display: grid; gap: 5px; }
.auth-card .button { width: 100%; }

@media (min-width: 640px) {
  .masthead { margin-inline: 26px; }
  main { padding-inline: 26px; padding-top: 30px; }
  .summary { padding: 24px; }
  .meal-header { padding-inline: 15px; }
  .meal-rows { padding-inline: 15px; }
  .quick-items { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  dialog { margin: auto; border: 1px solid var(--line); border-radius: 24px; }
  .sheet { padding: 20px; }
}

@media (max-width: 357px) {
  .quick-actions { grid-template-columns: 1fr; }
  .calendar-controls { gap: 2px; }
  .day-heading h1 { font-size: 1.85rem; }
}
