/* Emily Sanchez Nutrition — "Clinic": white, no cards, hairline rules, one quiet blue.
 * Built to Apple's HIG: the device's own type stack (San Francisco on iPhone),
 * semantic colour roles that adapt to light and dark, an 8pt grid, 44pt tap
 * targets, and spring motion that never blocks input. Chrome stays quiet so the
 * meal plan is the only thing on screen worth looking at. */

:root {
  /* content */
  --bg: #ffffff;            /* the page itself */
  --bg2: #f6f7f8;           /* the only tinted surface: inputs, quiet fills */
  --ink: #101418;           /* primary label */
  --ink2: #5c6670;          /* secondary label */
  --ink3: #8d969e;          /* tertiary label: timestamps, units */
  --line: #dfe3e6;          /* hairline */
  --fill: #eef1f3;          /* unfilled track */

  /* one accent, used sparingly */
  --acc: #15639e;
  --acc-tint: #eaf2f8;
  --onacc: #ffffff;

  /* state, never decorative */
  --late: #a8452f;  --late-tint: #fbeeea;
  --watch: #8a6a16; --watch-tint: #faf3e2;
  --good: #1f6b4a;  --good-tint: #e9f3ee;
  --water: #2d6f93;

  /* Apple's spring as a CSS curve: fast out, settles, no bounce on utility UI */
  --spring: linear(0, .0037, .0142, .031, .0534, .0804, .1108, .1438, .1784, .2135,
    .2484, .3145, .3746, .4283, .4755, .5562, .6215, .6726, .7112, .7735, .8196,
    .854, .8793, .9185, .9458, .9647, .9779, .9921, 1);
  --spring-ms: 420ms;
  --quick: 180ms;

  /* San Francisco on Apple devices, Roboto on Android. Never a downloaded font. */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;

  --gut: 20px;              /* side gutter, 8pt grid */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark is dimmed, not inverted: the base goes black, raised surfaces lighten. */
    --bg: #000000; --bg2: #1c1c1e; --ink: #f2f3f4; --ink2: #9ba3ab; --ink3: #72797f;
    --line: #2a2c2e; --fill: #1f2022;
    --acc: #6cb6ef; --acc-tint: #12232f; --onacc: #04131f;
    --late: #e89281; --late-tint: #2a1a16; --watch: #d9bb72; --watch-tint: #272015;
    --good: #72c79e; --good-tint: #132319; --water: #7cb3d2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.4;   /* iOS body size */
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
::selection { background: var(--acc-tint); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button, a, label.btn, .tabbar a { -webkit-user-select: none; user-select: none; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
svg.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app {
  max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--gut) calc(env(safe-area-inset-bottom, 0px) + 104px);
}
#app.notabs { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 36px); }
.boot { color: var(--ink3); text-align: center; margin-top: 42vh; }
.view { display: contents; }

/* ---------- type ---------- */
h1.hi {                                  /* iOS large title */
  font-size: 34px; font-weight: 700; letter-spacing: -.028em; line-height: 1.08;
  margin: 0; text-wrap: balance;
}
h2.h {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .055em;
  color: var(--ink3); margin: 10px 0 -12px;
}
.sub { font-size: 15px; color: var(--ink2); margin: 4px 0 0; text-wrap: pretty; }
.lbl { font-size: 13px; font-weight: 600; color: var(--ink3); margin: 0 0 8px; }
.q { font-size: 28px; font-weight: 700; letter-spacing: -.024em; line-height: 1.14; margin: 8px 0 0; text-wrap: balance; }

/* ---------- the grouped list: no boxes, hairlines only ---------- */
.box { display: grid; }
.row {
  display: flex; gap: 14px; align-items: center; min-height: 56px; padding: 11px 0;
  border-bottom: 1px solid var(--line); position: relative;
  transition: background-color var(--quick) ease-out;
}
.box > .row:first-child { border-top: 1px solid var(--line); }
.row .w { flex: 1; min-width: 0; font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.row .w small { display: block; font-size: 14px; font-weight: 400; color: var(--ink3); margin-top: 2px; }
.row.done .w { color: var(--ink2); }
.row.late small.when { color: var(--late); }
.row .t { width: 62px; flex: none; font-size: 14px; color: var(--ink3); font-weight: 500; }
a.row { color: inherit; text-decoration: none; }
a.row::after {                           /* iOS disclosure chevron */
  content: ""; width: 8px; height: 8px; flex: none; border-right: 2px solid var(--ink3);
  border-top: 2px solid var(--ink3); transform: rotate(45deg); opacity: .7;
}
@media (min-resolution: 2dppx) {         /* true hairlines on retina */
  .row, .box > .row:first-child, .tabbar, .math, .btn.alt, .kv, .tgt, .tgt div + div,
  .macros, .macros div + div, .used, .note, .need, .sum, .opt, .opts .opt:first-child { border-width: .5px; }
}

/* the one control that carries state: 44pt, springy, instant */
.tickbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line);
  background: transparent; display: grid; place-items: center; color: var(--line); flex: none;
  transition: transform var(--quick) var(--spring), background-color var(--spring-ms) var(--spring),
              border-color var(--spring-ms) var(--spring), color var(--spring-ms) var(--spring);
}
.tickbtn:active { transform: scale(.88); }
.tickbtn.done { background: var(--acc); border-color: var(--acc); color: var(--onacc); }
.tickbtn.late { border-color: var(--late); color: var(--late); }

/* ---------- the day's numbers: plain figures and a rule, no tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; }
.tile {
  background: none; border: 0; padding: 2px 0 14px; text-align: left; color: inherit;
  border-bottom: 1px solid var(--line);
}
.tile + .tile { padding-left: 20px; border-left: 1px solid var(--line); }
.tile .k { font-size: 13px; font-weight: 600; color: var(--ink3); letter-spacing: .02em; }
.tile .v { font-size: 40px; font-weight: 700; letter-spacing: -.035em; line-height: 1.05; margin: 1px 0 9px; }
.tile .v span { font-size: 17px; color: var(--ink3); font-weight: 500; letter-spacing: -.01em; }
.seg { display: flex; gap: 3px; padding-right: 20px; }
.tile + .tile .seg { padding-right: 0; }
.seg i { flex: 1; height: 4px; border-radius: 2px; background: var(--fill); transition: background-color var(--spring-ms) var(--spring); }
.seg.m i.f { background: var(--acc); }
.seg.h i.f { background: var(--water); }
.macline { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink3); margin-top: -8px; }
.macline b { color: var(--ink); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  background: var(--acc); color: var(--onacc); border: 0; border-radius: 12px;
  min-height: 50px; padding: 13px 18px; font-size: 17px; font-weight: 600; letter-spacing: -.01em;
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  text-decoration: none; transition: transform var(--quick) var(--spring), opacity var(--quick) ease-out;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; }
.btn.alt { background: transparent; color: var(--acc); border: 1px solid var(--line); }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.small { min-height: 36px; padding: 8px 15px; font-size: 15px; width: auto; border-radius: 9px; white-space: nowrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link {
  background: none; border: 0; color: var(--acc); font-size: 17px; font-weight: 500;
  padding: 12px 0; text-align: left; min-height: 44px;
}
.back {
  display: inline-flex; align-items: center; gap: 4px; color: var(--acc); font-size: 17px;
  background: none; border: 0; padding: 6px 0; align-self: flex-start; margin-bottom: -10px; min-height: 44px;
}
.back svg.ic { width: 17px; height: 17px; stroke-width: 2.4; }

/* ---------- forms ---------- */
.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink3); }
input, select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid transparent; border-radius: 11px;
  padding: 13px 14px; font-size: 17px; min-height: 50px;
  transition: border-color var(--quick) ease-out, background-color var(--quick) ease-out;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; background: var(--bg); border-color: var(--acc); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.err { color: var(--late); font-size: 15px; margin: 0; }

/* ---------- choices (onboarding) ---------- */
.prog { height: 3px; background: var(--fill); border-radius: 2px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--acc); transition: width var(--spring-ms) var(--spring); }
.opts { display: grid; }
.opt {
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 15px 2px;
  text-align: left; font-size: 17px; font-weight: 500; min-height: 56px; width: 100%;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; color: inherit;
  transition: transform var(--quick) var(--spring), color var(--quick) ease-out;
}
.opts .opt:first-child { border-top: 1px solid var(--line); }
.opt:active { transform: scale(.99); }
.opt small { display: block; font-size: 14px; font-weight: 400; color: var(--ink3); margin-top: 2px; }
.opt .ck {
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line); flex: none;
  display: grid; place-items: center; color: var(--onacc);
  transition: background-color var(--spring-ms) var(--spring), border-color var(--spring-ms) var(--spring);
}
.opt.on { color: var(--acc); }
.opt.on .ck { background: var(--acc); border-color: var(--acc); }
.opt .ck svg { opacity: 0; width: 13px; height: 13px; stroke-width: 3; transition: opacity var(--quick) ease-out; }
.opt.on .ck svg { opacity: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 9px 15px;
  font-size: 15px; font-weight: 500; min-height: 40px; color: inherit;
  transition: transform var(--quick) var(--spring), background-color var(--quick) ease-out;
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--acc); border-color: var(--acc); color: var(--onacc); }

/* ---------- status ---------- */
.pill { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 7px; white-space: nowrap; letter-spacing: 0; }
.p-behind { background: var(--late-tint); color: var(--late); }
.p-watch { background: var(--watch-tint); color: var(--watch); }
.p-ok { background: var(--good-tint); color: var(--good); }
.p-none { background: var(--fill); color: var(--ink3); }
.av {
  width: 38px; height: 38px; border-radius: 50%; background: var(--acc-tint); color: var(--acc);
  display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; letter-spacing: 0;
}
.ktiles { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.ktiles .tile { border-bottom: 0; padding-bottom: 12px; }
.ktiles .tile + .tile { padding-left: 16px; }
.ktiles .tile .v { font-size: 34px; margin-bottom: 0; }
.ktiles .b .v { color: var(--late); } .ktiles .wa .v { color: var(--watch); } .ktiles .o .v { color: var(--good); }

/* ---------- coach: plan editor ---------- */
.tgt { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tgt div { padding: 12px 4px; font-size: 12px; color: var(--ink3); font-weight: 500; }
.tgt div + div { border-left: 1px solid var(--line); padding-left: 10px; }
.tgt strong { display: block; font-size: 22px; color: var(--ink); font-weight: 700; letter-spacing: -.025em; }
.tgt em { display: block; font-style: normal; font-size: 12px; margin-top: 3px; }
.tgt em.ok { color: var(--good); } .tgt em.off { color: var(--late); }
.ai {
  background: var(--ink); color: var(--bg); border: 0; border-radius: 14px; padding: 16px;
  display: flex; gap: 13px; align-items: center; text-align: left; font-size: 17px; font-weight: 600; width: 100%;
  transition: transform var(--quick) var(--spring);
}
.ai:active { transform: scale(.985); }
.ai small { display: block; font-weight: 400; opacity: .7; font-size: 14px; margin-top: 2px; letter-spacing: 0; }
.ai .spark { width: 22px; height: 22px; flex: none; }
.ai.busy .spark { animation: spin 1.3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.used { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 0; display: grid; gap: 9px; }
.used b { font-size: 13px; font-weight: 600; color: var(--ink3); letter-spacing: .02em; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { background: var(--bg2); border-radius: 7px; padding: 5px 10px; font-size: 14px; font-weight: 500; }
.editbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--ink3); flex: none;
  transition: transform var(--quick) var(--spring), background-color var(--quick) ease-out;
}
.editbtn:active { transform: scale(.88); background: var(--bg2); }
.editform { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.empty {
  border: 1px dashed var(--line); border-radius: 14px; padding: 26px 18px; text-align: center;
  color: var(--ink2); font-size: 15px; line-height: 1.5;
}
.sum {
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 14px 2px;
  display: grid; gap: 4px; text-align: left; width: 100%; color: inherit;
  transition: transform var(--quick) var(--spring);
}
.sum:active { transform: scale(.99); }
.sum .h2 {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--ink3); letter-spacing: .02em;
}
.sum p { margin: 0; font-size: 17px; font-weight: 500; }
.sum p.m { color: var(--ink3); font-weight: 400; font-size: 15px; }
.allergy { display: flex; flex-wrap: wrap; gap: 7px; }
.allergy span { border-radius: 7px; padding: 4px 10px; font-size: 14px; font-weight: 600; background: var(--late-tint); color: var(--late); }
.math { display: grid; gap: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 13px 0; font-size: 15px; }
.math div { display: flex; justify-content: space-between; gap: 12px; }
.math span { color: var(--ink3); }
.math .tot { border-top: 1px solid var(--line); padding-top: 9px; font-weight: 600; }
.math .tot span { color: var(--ink); }
.segtabs { display: flex; background: var(--bg2); border-radius: 10px; padding: 2px; gap: 2px; }   /* iOS segmented control */
.segtabs button {
  flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 8px; min-height: 36px;
  font-size: 15px; font-weight: 500; color: var(--ink2);
  transition: background-color var(--quick) ease-out, color var(--quick) ease-out, transform var(--quick) var(--spring);
}
.segtabs button:active { transform: scale(.97); }
.segtabs button.on { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .09); }
@media (prefers-color-scheme: dark) { .segtabs button.on { background: #38383a; box-shadow: none; } }

/* ---------- scanner ---------- */
.cam { position: relative; background: #0b0c0d; border-radius: 16px; overflow: hidden; aspect-ratio: 4 / 3.2; display: grid; place-items: center; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam .frame { position: relative; width: 72%; height: 36%; z-index: 1; }
.cam .frame i { position: absolute; width: 24px; height: 24px; border: 0 solid #fff; }
.cam .frame i:nth-child(1) { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 10px; }
.cam .frame i:nth-child(2) { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 10px; }
.cam .frame i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 10px; }
.cam .frame i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 10px; }
.cam .hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; font-size: 15px; z-index: 1; text-shadow: 0 1px 6px rgba(0, 0, 0, .7); }
.cam .msg { color: #fff; z-index: 1; text-align: center; padding: 24px; font-size: 16px; line-height: 1.45; }
.prod { display: flex; gap: 14px; align-items: center; }
.thumb { width: 48px; height: 48px; border-radius: 11px; background: var(--acc-tint); display: grid; place-items: center; color: var(--acc); flex: none; }
.prod h3 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; text-wrap: balance; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 56px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:first-of-type { border-top: 1px solid var(--line); }
.kv > span, .kv > label { color: var(--ink2); flex: none; font-size: 17px; }
.kv b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.kv select, .kv input { width: auto; min-width: 0; flex: 1; max-width: 62%; text-align: right; padding: 9px 12px; min-height: 40px; }
.macros { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.macros div { padding: 12px 2px; font-size: 12px; color: var(--ink3); font-weight: 500; text-align: center; }
.macros div + div { border-left: 1px solid var(--line); }
.macros strong { display: block; font-size: 22px; color: var(--ink); font-weight: 700; letter-spacing: -.025em; }
.stepper { display: flex; align-items: center; gap: 14px; font-weight: 600; }
.round {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  display: grid; place-items: center; font-size: 20px; font-weight: 400; flex: none; color: var(--acc);
  transition: transform var(--quick) var(--spring), background-color var(--quick) ease-out;
}
.round:active { transform: scale(.9); background: var(--bg2); }
.water { display: flex; align-items: center; gap: 12px; }

/* ---------- notices ---------- */
.note { border-top: 1px solid var(--line); padding: 14px 0; font-size: 16px; line-height: 1.45; }
.note b { display: block; font-size: 13px; color: var(--ink3); font-weight: 500; margin-bottom: 3px; }
.note strong { font-weight: 600; }
.banner { background: var(--acc-tint); border-radius: 14px; padding: 15px; font-size: 15px; display: grid; gap: 11px; line-height: 1.45; }
.banner b { font-weight: 600; }
.fine { display: flex; align-items: center; gap: 9px; font-size: 15px; color: var(--ink2); padding: 6px 0; }
.need { border-bottom: 1px solid var(--line); padding: 15px 0; display: grid; gap: 11px; }
.need .h { display: flex; align-items: center; gap: 13px; }
.need .h .w { flex: 1; min-width: 0; font-weight: 600; }
.need .h small { display: block; color: var(--ink3); font-size: 14px; font-weight: 400; margin-top: 2px; }
.sug { background: var(--bg2); border-radius: 11px; padding: 12px 13px; font-size: 15px; line-height: 1.45; }
.sug b { display: block; font-size: 13px; color: var(--ink3); font-weight: 500; margin-bottom: 3px; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line); padding: 7px 0 calc(env(safe-area-inset-bottom, 0px) + 7px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .tabbar { background: var(--bg); } }
.tabbar .inner { display: flex; width: 100%; max-width: 560px; justify-content: space-around; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 68px; min-height: 48px;
  padding: 4px 12px; font-size: 10.5px; font-weight: 500; letter-spacing: 0; color: var(--ink3); text-decoration: none;
  transition: color var(--quick) ease-out, opacity var(--quick) ease-out;
}
.tabbar a.on { color: var(--acc); }
.tabbar a:active { opacity: .5; }
.tabbar svg.ic { width: 25px; height: 25px; stroke-width: 1.7; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); transform: translateX(-50%);
  background: color-mix(in srgb, var(--ink) 92%, transparent); color: var(--bg);
  padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 500; z-index: 20;
  max-width: calc(100vw - 36px); text-align: center;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: rise var(--spring-ms) var(--spring);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } }

/* ---------- never let a row push the page sideways ---------- */
html, body { overflow-x: clip; }
#app > .view > *, #panel > * { min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
