/* Give Me The Food. Dark, bold, mobile first. System fonts only (nothing to download). */
:root {
  --bg: #0c0c0e; --surface: #17171b; --surface-2: #202026; --line: #2e2e36;
  --text: #f4f4f5; --muted: #b9b9c3; --accent: #d4ff3a; --on-accent: #0c0c0e;
  --protein: #ff7a66; --carbs: #4cc9ff; --fat: #ffc83d; --kcal: #d4ff3a;
  --ok: #7dff9b; --warn: #ffc83d; --bad: #ff7a7a;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); }
[hidden] { display: none !important; }
button, input, output { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.preview-badge { position: fixed; top: 10px; right: 10px; z-index: 50; background: #ff3d7f; color: #fff;
  font-weight: 900; font-size: 12px; letter-spacing: .08em; padding: 6px 10px; border-radius: 999px; box-shadow: 0 4px 14px #0008; }

.top { padding: 18px 18px 0; max-width: 1180px; margin: 0 auto; }
.logo { display: inline-block; text-decoration: none; color: var(--text); font-weight: 900; font-size: 15px; line-height: 1; letter-spacing: .04em; }
.logo { display: inline-flex; align-items: center; gap: 9px; }
.logo-mark { display: block; height: 36px; width: auto; flex: none; }
.logo-text { display: block; }
.logo-text span { color: var(--accent); font-size: 22px; }

main { max-width: 1180px; margin: 0 auto; padding: 8px 16px 40px; }
.headline { font-size: clamp(34px, 9vw, 64px); line-height: .98; font-weight: 900; letter-spacing: -.02em; margin: 18px 0 22px; text-transform: uppercase; }
.headline.small { font-size: clamp(28px, 7vw, 40px); margin: 6px 0 14px; }
.intro { margin: -6px 0 16px; color: #d4d4dc; font-size: 16px; line-height: 1.4; font-weight: 500; max-width: 38rem; text-transform: none; letter-spacing: 0; }
@media (max-width: 390px) { .intro { font-size: 15px; margin-bottom: 14px; } }
.hl { color: var(--accent); }

.card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; min-width: 0; }
.label { font-weight: 900; text-transform: uppercase; letter-spacing: .1em; font-size: 13px; color: var(--muted); padding: 0 6px; }
.sublabel { display: block; font-weight: 700; font-size: 14px; color: var(--muted); margin: 14px 0 8px; }
.hint { color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.hint.warn { color: var(--warn); }
.error { color: var(--bad); font-weight: 700; }

.macro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.macro-field { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; background: var(--surface-2);
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px 8px; border-top: 5px solid var(--c); }
.macro-field:focus-within { border-color: var(--c); }
.macro-field span { grid-column: 1 / 3; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.macro-field input, .macro-field output { width: 100%; min-width: 0; background: transparent; border: 0; outline: none; font-size: 40px; font-weight: 900;
  font-variant-numeric: tabular-nums; padding: 0; line-height: 1.1; -moz-appearance: textfield; }
.macro-field input::-webkit-outer-spin-button, .macro-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.macro-field input::placeholder { color: #8d8d97; }
.macro-field output { display: block; margin: 0; }
.macro-field em { font-style: normal; align-self: end; color: var(--muted); font-weight: 700; padding-bottom: 8px; }
.m-protein { --c: var(--protein); } .m-carbs { --c: var(--carbs); } .m-fat { --c: var(--fat); } .m-kcal { --c: var(--kcal); }
/* Calories can be a 5-digit comma value (e.g. 12,345). Shrink only that number so it never
   collides with the kcal unit; protein, carbs and fat stay at 40px. */
.m-kcal { cursor: default; container-type: inline-size; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
.m-kcal output { width: auto; max-width: 100%; min-width: 0; justify-self: start; align-self: end;
  white-space: nowrap; font-size: clamp(16px, 22cqi, 40px); padding-bottom: 2px; }

.seg { display: flex; gap: 8px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 14px 8px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface-2); font-weight: 800; font-size: 17px; cursor: pointer; }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg-num span { font-size: 22px; padding: 12px 0; }
.meals-row.disabled { opacity: .45; pointer-events: none; }

.switch { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 17px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.track { width: 54px; height: 32px; border-radius: 999px; background: var(--surface-2); border: 2px solid var(--line); position: relative; flex: none; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(22px); background: var(--on-accent); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }

.likes-panel { margin-top: 14px; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 12px; }
.tabs button { background: var(--surface-2); border: 2px solid var(--line); border-radius: 10px; padding: 10px 2px; font-weight: 800; cursor: pointer; font-size: 13px; }
.tabs button[aria-selected="true"] { border-color: var(--text); background: var(--text); color: var(--bg); }
.tabs button .n { display: inline-block; min-width: 20px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; padding: 1px 5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-block; padding: 9px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface-2); font-weight: 700; font-size: 15px; cursor: pointer; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.chips-x .chip input:checked + span { background: var(--bad); border-color: var(--bad); color: #1a0000; text-decoration: line-through; }

.exclude-box summary { list-style: none; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 800; font-size: 17px; padding: 6px 0; }
.exclude-box summary::-webkit-details-marker { display: none; }
.exclude-box[open] .chev { transform: rotate(45deg); }
.chev { font-size: 28px; line-height: 1; transition: transform .15s; }
.search { width: 100%; margin: 12px 0; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); font-size: 17px; }

.go-wrap { padding: 6px 0 calc(12px + env(safe-area-inset-bottom)); }
.btn-go { width: 100%; padding: 20px; border: 0; border-radius: 16px; background: var(--accent); color: var(--on-accent);
  font-size: 30px; font-weight: 900; letter-spacing: .14em; cursor: pointer; box-shadow: 0 8px 30px #d4ff3a33; }
.btn-go:active { transform: translateY(1px); }

/* results */
.results-layout { display: grid; gap: 16px; }
.bar-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn-ghost { flex: 1; padding: 13px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; font-size: 16px; cursor: pointer; }
.btn-ghost:hover { border-color: var(--muted); }
.status { border-radius: 12px; padding: 12px 14px; font-weight: 700; margin-bottom: 14px; border-left: 6px solid var(--ok); background: var(--surface); }
.status.warn { border-left-color: var(--warn); } .status.bad { border-left-color: var(--bad); }
.status strong { display: block; font-size: 18px; font-weight: 900; }
.status ul { margin: 6px 0 0; padding-left: 18px; font-weight: 500; color: var(--text); }
.bars { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bar-name { font-weight: 900; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; color: var(--muted); }
.bar-num { font-weight: 900; font-size: 30px; font-variant-numeric: tabular-nums; line-height: 1; }
.bar-num small { font-size: 15px; color: var(--muted); font-weight: 700; }
.bar-delta { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar-delta.in { color: var(--ok); } .bar-delta.out { color: var(--bad); }
.track-bar { position: relative; height: 18px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; display: flex; gap: 2px; }
.seg-fill { height: 100%; background: var(--c); width: 0; transition: width .5s ease-out; }
.seg-fill:nth-child(2n) { filter: brightness(.8); }
.target-mark { position: absolute; top: -3px; bottom: -3px; width: 3px; background: var(--text); }
.b-protein { --c: var(--protein); } .b-carbs { --c: var(--carbs); } .b-fat { --c: var(--fat); } .b-kcal { --c: var(--kcal); }
.note { color: var(--muted); font-size: 13px; margin: 10px 2px 0; }

.meals { display: grid; gap: 14px; }
.meal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.meal-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.meal-type { font-weight: 900; text-transform: uppercase; letter-spacing: .12em; font-size: 13px; color: var(--accent); }
.meal-name { font-size: 22px; font-weight: 900; margin: 2px 0 6px; line-height: 1.15; }
.meal-macros { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.meal-macros .p { color: var(--protein); } .meal-macros .c { color: var(--carbs); } .meal-macros .f { color: var(--fat); } .meal-macros .k { color: var(--kcal); }
.items { list-style: none; margin: 0; padding: 0; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.item-g { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 82px; line-height: 1; }
.item-g small { font-size: 14px; color: var(--muted); }
.item-name { font-weight: 800; font-size: 17px; line-height: 1.2; }
.item-unit { color: var(--muted); font-size: 14px; }
.btn-swap { padding: 10px 14px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface-2); font-weight: 800; cursor: pointer; font-size: 15px; }
.btn-swap:hover { border-color: var(--accent); }
.oats-toggle { display: inline-flex; margin: 0 16px 8px; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.oats-toggle button { border: 0; background: transparent; color: var(--text); padding: 8px 14px; font-weight: 800; font-size: 14px; cursor: pointer; min-height: 44px; min-width: 44px; }
.oats-toggle button[aria-checked="true"] { background: var(--text); color: var(--bg); }
.oats-toggle button:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.recipe { padding: 12px 16px 16px; }
.recipe summary { cursor: pointer; font-weight: 800; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.recipe .time { color: var(--muted); font-weight: 700; white-space: nowrap; text-align: right; }
.recipe ol { margin: 10px 0 0; padding-left: 22px; }
.recipe li { margin: 6px 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 800; z-index: 60; max-width: 90vw; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 16px 28px; }

@media (min-width: 760px) {
  .macro-grid { grid-template-columns: repeat(4, 1fr); }
  #form { max-width: 820px; }
  .meals { grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (min-width: 1100px) {
  .results-layout { grid-template-columns: 360px 1fr; align-items: start; }
  .summary { position: sticky; top: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.seg-mode { margin: 0 0 4px; } .seg-mode span { font-size: 16px; padding: 12px 6px; }
.mode-hint { color: var(--text); margin: 8px 0 14px; }
.chip span { padding: 8px 11px; font-size: 14px; }
.item-g { font-size: 24px; min-width: 66px; }
@media (min-width: 760px) { .chip span { padding: 9px 12px; font-size: 15px; } .item-g { font-size: 26px; min-width: 82px; } }

/* ---------- Checkpoint B polish: layout, contrast, tap targets ---------- */
:root { --ctl: #7c7c88; } /* control borders: at least 3:1 against the surfaces they sit on */
.preview-badge { background: #b0124f; color: #fff; }
#screen-input { max-width: 820px; margin: 0 auto; }
#form { max-width: none; }
.macro-field { border-color: var(--ctl); border-top: 5px solid var(--c); }
.macro-field input::placeholder { color: #a9a9b3; }
.seg span, .tabs button, .search, .btn-ghost, .btn-swap { border-color: var(--ctl); }
.chip span { border-color: var(--ctl); min-height: 44px; display: inline-flex; align-items: center; }
.track { border-color: var(--ctl); }
.track::after { background: #c9c9d1; }
.switch { min-height: 44px; }
.logo { padding: 6px 0; min-height: 44px; }
.exclude-box summary { min-height: 44px; }
.recipe summary { min-height: 44px; align-items: center; }
.btn-swap { min-height: 44px; min-width: 64px; }
.meals-row.disabled { opacity: 1; }
.meals-row.disabled .seg span { color: #9a9aa4; border-color: #4a4a54; background: var(--surface); }
.meals-row.disabled .seg input:checked + span { background: #3a3a44; color: var(--text); border-color: #4a4a54; }
.meals-row.disabled .sublabel { color: #9a9aa4; }
.item-name, .meal-name, .status, .recipe li { overflow-wrap: anywhere; }
@media (min-width: 1100px) {
  main { padding-left: 32px; padding-right: 32px; }
}
.seg-num { gap: 4px; }
@media (max-width: 380px) { main { padding-left: 12px; padding-right: 12px; } .card { padding: 14px 12px; } }
/* calories are information, not a target */
.bar-delta.neutral { color: var(--muted); }
.status-note { margin: 8px 0 0; font-weight: 500; color: var(--muted); font-size: 14px; }
.tip { margin: -6px 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--fat); color: var(--text); font-size: 14px; font-weight: 600; }
/* logo lines up with the content column: same side padding as main, and the input column width on the input screen */
.top { padding: 18px 16px 0; }
body.on-input .top { max-width: 852px; }
@media (max-width: 380px) { .top { padding-left: 12px; padding-right: 12px; } body.on-input .top { max-width: none; } }
@media (min-width: 1100px) { .top { padding-left: 32px; padding-right: 32px; } body.on-input .top { max-width: 884px; } }
