:root {
  --paper: #f3f8fb;
  --card: #ffffff;
  --ink: #4a2c22;
  --muted: #7a5e52;
  --line: #d6e4ec;
  --field: #f8fbfd;
  --kibble: #4a2c22;
  --kibble-ink: #ffffff;
  --sky: #cfe6f5;
  --sky-ink: #2f4a5c;
  --sky-strong: #7fb3d9;
  --ok: #2e7a4c;
  --warn: #a86c08;
  --bad: #b23a2a;
  --info: #7b8a80;
  --track: #e6f0f6;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 18px; }
h1, h2, h3 { font-family: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif; line-height: 1.15; }
h2 { font-size: 1.6rem; margin: 1.6rem 0 .4rem; font-weight: 700; }
h3 { font-size: 1.15rem; margin: 1.4rem 0 .4rem; font-weight: 700; }
p { max-width: 68ch; }
a { color: inherit; }

.masthead { padding: 0; border-bottom: 1px solid var(--line); background: var(--paper); }
.sitebar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.home-link { font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.sitebar nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.sitebar nav a { color: var(--muted); font-weight: 700; text-decoration: none; font-size: .95rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.sitebar nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--sky-strong); }
.sitebar a:focus-visible { outline: 3px solid var(--sky-strong); outline-offset: 2px; }
.footnav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 10px; font-weight: 700; }
textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; resize: vertical; }
textarea:focus-visible { outline: 3px solid var(--sky-strong); outline-offset: 2px; }
.brand { font-size: clamp(2.4rem, 8vw, 3.6rem); font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.brand-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
/* River sits on the line above the tabs, which hides the flat bottom of the cutout */
.sticker { flex: none; display: block; height: 150px; width: auto; margin-bottom: -1px; }
@media (max-width: 560px) { .sticker { height: 104px; } }
.tagline { color: var(--muted); margin: .3rem 0 .4rem; }
.byline { margin: 0 0 1rem; font-weight: 700; }
.byline a, .foot a { color: var(--ink); text-decoration-color: var(--sky-strong); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line); }
.tabs button {
  font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0;
  padding: 10px 12px 12px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--sky-strong); }

main { padding-bottom: 40px; }
.view > :first-child { margin-top: 1.4rem; }
.lead { color: var(--muted); margin-top: 0; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 14px 0; }
.panel h3:first-child { margin-top: 0; }

label { font-weight: 700; font-size: .92rem; display: block; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: .88rem; font-weight: 400; }
input, select {
  font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--sky-strong); outline-offset: 2px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.btn {
  font: inherit; font-weight: 700; border-radius: 999px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--sky); background: var(--sky); color: var(--sky-ink);
}
.btn.primary { background: var(--kibble); border-color: var(--kibble); color: var(--kibble-ink); }
.btn.ghost { background: none; border-color: var(--line); color: var(--ink); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn.danger { color: var(--bad); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.recipe-bar { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.recipe-bar .row-actions { margin: 0; }

.items { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) 90px 92px 40px; gap: 8px; align-items: center; }
.item .x { background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; border-radius: 8px; height: 40px; }
.item .meta { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; margin-top: -4px; }
.item .meta.warn { color: var(--bad); }
.colhead { display: grid; grid-template-columns: minmax(0, 1fr) 90px 92px 40px; gap: 8px; color: var(--muted); font-size: .82rem; font-weight: 700; }
@media (max-width: 560px) {
  .colhead { display: none; }
  .item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .item > select[data-k="f"] { grid-column: 1 / -1; }
  .recipe-bar { grid-template-columns: 1fr; }
}

.portion { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: start; }
.big { font-family: "Bricolage Grotesque", system-ui, sans-serif; font-size: 2.2rem; font-weight: 800; line-height: 1; }
.big small { font-size: 1rem; font-weight: 700; color: var(--muted); }
.stat-label { color: var(--muted); font-size: .9rem; }

.summary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.pill { display: inline-block; font-weight: 700; font-size: .8rem; padding: 2px 10px; border-radius: 999px; border: 1.5px solid currentColor; }
.s-ok { color: var(--ok); } .s-borderline { color: var(--warn); } .s-low, .s-high, .s-over, .s-under { color: var(--bad); } .s-info { color: var(--info); }

/* Nutrient meter */
.report-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; }
.meter-list { display: grid; gap: 2px; }
.meter { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr) 92px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.meter .name { font-weight: 700; }
.meter .name .hint { display: block; }
.track { position: relative; height: 12px; background: var(--track); border-radius: 999px; overflow: visible; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: currentColor; transition: width .4s ease; }
.min-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); left: 33.333%; }
.max-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--bad); }
.meter .val { text-align: right; font-size: .9rem; }
.meter .val .pill { margin-top: 2px; }
.legend { color: var(--muted); font-size: .88rem; }
@media (max-width: 560px) {
  .meter { grid-template-columns: minmax(0, 1fr) 84px; }
  .meter .track { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }

details { border-top: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 700; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; }
td input, td select { padding: 6px 8px; }

.notice { border-left: 4px solid var(--sky-strong); padding: 10px 14px; background: var(--card); border-radius: 0 10px 10px 0; margin: 14px 0; }
.never { columns: 2 220px; padding-left: 1.1rem; }
.foot { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); padding-top: 14px; padding-bottom: 30px; }

#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
