/* Macros: a nutrition label you can photograph into. Black on white, heavy rules, one tomato-red action. */
:root {
  --paper: #ffffff;
  --ink: #000000;
  --muted: #5c5c5c;
  --rule: #000000;
  --tomato: #e0401f;
  --on-tomato: #ffffff;
  --protein: #2457c5;
  --carbs: #d99a00;
  --fat: #c2185b;
  --field: #f2f2f2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #000000; --ink: #ffffff; --muted: #a8a8a8; --rule: #ffffff; --field: #1c1c1c;
    --protein: #6f97f2; --carbs: #f2bf3a; --fat: #f0679b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #000000; --ink: #ffffff; --muted: #a8a8a8; --rule: #ffffff; --field: #1c1c1c;
  --protein: #6f97f2; --carbs: #f2bf3a; --fat: #f0679b; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.4 "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
main { max-width: 480px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--tomato); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* The label: the day's totals. */
.label { border: 2px solid var(--rule); padding: 6px 10px 8px; }
h1 { margin: 0; font-size: 40px; font-weight: 900; letter-spacing: -0.02em; line-height: 1; }
.date { margin: 2px 0 6px; color: var(--muted); font-size: 15px; border-bottom: 10px solid var(--rule); padding-bottom: 6px; }
.kcal { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 5px solid var(--rule); padding: 2px 0 4px; }
.kcal span { font-weight: 900; font-size: 24px; }
.kcal b { font-weight: 900; font-size: 48px; line-height: 1; letter-spacing: -0.02em; }
.split { display: flex; height: 8px; margin: 8px 0 2px; background: var(--field); }
.split i { display: block; background: var(--c); }
.protein { --c: var(--protein); } .carbs { --c: var(--carbs); } .fat { --c: var(--fat); }
.macros { margin: 0; }
.macros div { display: flex; justify-content: space-between; border-top: 1px solid var(--rule); padding: 5px 0; }
.macros div:first-child { border-top: 0; }
.macros dt { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.macros dt::before { content: ""; width: 10px; height: 10px; background: var(--c); }
.macros dd { margin: 0; }

/* Adding a meal. */
.add { margin: 18px 0; display: grid; gap: 10px; }
.shoot { display: block; text-align: center; background: var(--tomato); color: var(--on-tomato); font-weight: 800; font-size: 19px;
  padding: 16px; cursor: pointer; }
.shoot:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.shoot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.typed { display: flex; gap: 8px; }
.typed input { flex: 1; min-width: 0; min-height: 48px; padding: 0 12px; background: var(--field); border: 0; border-bottom: 2px solid var(--rule); }
.typed button, .btn { min-height: 48px; padding: 0 18px; border: 2px solid var(--rule); background: none; font-weight: 800; cursor: pointer; }
.btn.main { background: var(--ink); color: var(--paper); }

/* Checking what the AI found. */
.check { border: 2px solid var(--rule); padding: 10px; margin: 0 0 18px; }
.check h2, .meals h2 { margin: 0 0 6px; font-size: 22px; font-weight: 900; }
.check img { width: 100%; max-height: 220px; object-fit: cover; display: block; margin-bottom: 10px; }
.reading { color: var(--muted); }
.reading::after { content: ""; display: block; height: 4px; margin-top: 10px; background: linear-gradient(90deg, var(--tomato) 30%, transparent 0) 0 0 / 200% 100%; animation: scan 1.2s linear infinite; }
@keyframes scan { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .reading::after { animation: none; } }
.error { color: var(--tomato); font-weight: 700; }
.item { border-top: 1px solid var(--rule); padding: 8px 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.item .food { background: none; border: 0; padding: 0; text-align: left; font-weight: 700; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer; }
.item .guess { display: block; font-weight: 400; font-size: 14px; color: var(--muted); text-decoration: none; }
.item .n { text-align: right; font-weight: 800; }
.grams { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; }
.grams input { width: 76px; min-height: 40px; padding: 0 8px; background: var(--field); border: 0; border-bottom: 2px solid var(--rule); color: var(--ink); }
.remove { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px 0; justify-self: end; font-size: 15px; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions .btn { flex: 1; }

/* Changing a food: search the table. */
.find input { width: 100%; min-height: 48px; padding: 0 12px; background: var(--field); border: 0; border-bottom: 2px solid var(--rule); margin-bottom: 6px; }
.find ul { list-style: none; margin: 0; padding: 0; }
.find li button { width: 100%; display: flex; justify-content: space-between; gap: 10px; text-align: left; background: none; border: 0; border-top: 1px solid var(--rule); padding: 10px 0; cursor: pointer; }
.find li span { color: var(--muted); white-space: nowrap; }

/* Today's meals. */
.meal { border-top: 5px solid var(--rule); padding: 8px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.meal p { margin: 0; color: var(--muted); font-size: 15px; grid-column: 1 / -1; }
.meal b { font-weight: 800; }
.meal b + b { text-align: right; }
.meal .remove { grid-column: 2; }
.btn:disabled { opacity: .4; cursor: default; }
.empty { color: var(--muted); }
footer { margin-top: 28px; color: var(--muted); font-size: 13px; }
.noscript { text-align: center; padding: 40px 16px; }

/* Legal page. */
.doc h1 { font-size: 32px; font-weight: 900; margin: 8px 0 12px; }
.doc h2 { font-size: 20px; font-weight: 900; margin: 22px 0 6px; border-top: 5px solid var(--rule); padding-top: 8px; }
.doc li { margin-bottom: 6px; }
