[hidden]{display:none!important}
:root{
  --bg:#FAF7F0;--card:#FFFFFF;--border:#E7E1D4;--text:#1F2A24;--sec:#5B6560;
  --primary:#1E6B47;--pressed:#155236;--hi:#F2B705;--warn:#B5532A;--info:#0F6E8C;--track:#EFE9DC;
  --field:#8C8577;
  --shadow:0 1px 2px rgba(31,42,36,.06);
  --head:"Bricolage Grotesque",system-ui,-apple-system,"Segoe UI",sans-serif;
  --body:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;
  --nav-h:84px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font:400 1rem/1.5rem var(--body);font-variant-numeric:tabular-nums}
button,input,select{font:inherit;color:inherit}
h1,h2,h3{font-family:var(--head);font-weight:600;margin:0}
p{margin:0 0 8px}
.screen-title{font-size:1.5rem;line-height:1.875rem}
.card-title{font-size:1.125rem;line-height:1.5rem;margin-bottom:12px}
.small{font-size:.875rem;line-height:1.25rem}
.sec{color:var(--sec)}
.num{font-variant-numeric:tabular-nums}
.visually-hidden{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.app{max-width:560px;margin:0 auto;min-height:100vh;min-height:100dvh}
main{padding:calc(16px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));outline:none}
#main:focus,#main:focus-visible{outline:none}
.screen{display:flex;flex-direction:column;gap:12px}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:48px;margin-bottom:4px}
.card{background:var(--card);border:1px solid var(--border);border-radius:16px;padding:16px;box-shadow:var(--shadow)}
svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.icon-btn{min-width:48px;min-height:48px;display:inline-grid;place-items:center;border:0;background:transparent;border-radius:999px;cursor:pointer;color:var(--text)}
.icon-btn:hover{background:var(--track)}
:focus-visible{outline:3px solid var(--info);outline-offset:2px}
.btn{min-height:52px;border-radius:12px;border:1px solid transparent;padding:0 16px;font-weight:600;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px}
.btn.primary{background:var(--primary);color:#fff;width:100%}
.btn.primary:active,.btn.primary:hover{background:var(--pressed)}
.btn.secondary{background:var(--card);border-color:var(--field);color:var(--text)}
.btn.secondary:hover{background:var(--track)}
.link-btn{background:none;border:0;color:var(--primary);font-weight:600;min-height:48px;cursor:pointer;padding:0 4px;text-decoration:underline;text-underline-offset:3px}
.link-btn.wide{align-self:center}
.text-btn{background:none;border:0;min-height:48px;font-weight:600;cursor:pointer;padding:0 8px}
.text-btn.danger{color:var(--warn)}
/* Ring */
.ring-card{display:flex;flex-direction:column;align-items:center;gap:8px}
.ring-wrap{position:relative;width:200px;height:200px}
.ring-wrap svg{width:200px;height:200px;stroke-width:14}
.ring-wrap .prog{transition:stroke-dashoffset .8s ease}
.ring-center{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center}
.ring-total{font-family:var(--head);font-weight:600;font-size:2.5rem;line-height:2.75rem}
.left-line{font-weight:600;margin:0}
.left-line.over{color:var(--warn)}
/* Macros */
.macro{display:grid;grid-template-columns:1fr auto;gap:4px 8px;margin-bottom:12px}
.macro:last-of-type{margin-bottom:8px}
.macro .bar{grid-column:1/-1;height:8px;border-radius:999px;background:var(--track);overflow:hidden}
.macro .bar i{display:block;height:100%;border-radius:999px}
.bar-protein i{background:#1E6B47}.bar-carbs i{background:#F2B705;box-shadow:inset 0 0 0 1px #8a6a00}.bar-fat i{background:#B5532A}
.dot{display:inline-block;width:10px;height:10px;border-radius:999px;margin-right:6px;vertical-align:middle}
/* Meal cards */
#meal-cards{display:flex;flex-direction:column;gap:12px}
.meal-card{display:flex;align-items:center;gap:12px;min-height:72px;width:100%;text-align:left;cursor:pointer}
.meal-card .meta{flex:1;min-width:0}
.meal-card h3{font-size:1.125rem;line-height:1.5rem}
.thumbs{display:flex;gap:4px}
.thumbs img,.thumb-ph{width:48px;height:48px;border-radius:12px;object-fit:cover;background:var(--track);display:grid;place-items:center;color:var(--primary)}
.add-pill{min-height:48px;padding:0 16px;border-radius:999px;border:1px solid var(--field);background:var(--card);font-weight:600;color:var(--primary);cursor:pointer}
.meal-title{font:600 1.125rem/1.5rem var(--head)}
/* Result */
.photo-wrap{position:relative;aspect-ratio:16/10;border-radius:16px;overflow:hidden;background:var(--track)}
.photo-wrap img{width:100%;height:100%;object-fit:cover;display:block}
.ai-chip{position:absolute;top:12px;left:12px;background:var(--info);color:#fff;border-radius:999px;padding:4px 12px;font-size:.875rem;font-weight:600}
.total-card .big{font-family:var(--head);font-weight:600;font-size:2rem;line-height:2.5rem}
#result-body{display:flex;flex-direction:column;gap:12px}
.items{padding:4px 16px}
.item-row{display:flex;align-items:center;gap:12px;min-height:64px;padding:8px 0;border-bottom:1px solid var(--border)}
.item-row:last-child{border-bottom:0}
.item-row .meta{flex:1;min-width:0}
.item-name{font-weight:600;overflow-wrap:anywhere}
.item-kcal{font-weight:600;white-space:nowrap}
.chips{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:4px}
.chip{display:inline-flex;align-items:center;border-radius:999px;padding:2px 10px;font-size:.875rem;line-height:1.25rem;border:1px solid var(--border);color:var(--sec);background:var(--card)}
.chip.est{border-style:dashed;color:var(--text)}
.chip.check{border-color:var(--warn);color:var(--warn);font-weight:600;min-height:32px}
.check-hit{display:inline-flex;align-items:center;padding:8px 0}
.src-tag{font-size:.75rem;line-height:1rem;border-radius:999px;padding:1px 8px;background:var(--track);color:var(--text);font-weight:600;letter-spacing:.02em}
.trust{text-align:center;margin:4px 8px}
.sticky-bar{position:fixed;left:0;right:0;bottom:0;z-index:20;background:var(--card);border-top:1px solid var(--border);padding:12px 16px calc(12px + env(safe-area-inset-bottom));display:flex;gap:8px;max-width:560px;margin:0 auto}
.sticky-bar .secondary{flex:0 0 auto}
.split{flex:1;display:flex;border-radius:12px;overflow:hidden}
.split .btn.primary{border-radius:12px 0 0 12px}
.meal-name{text-decoration:none}
.meal-pick{display:flex;align-items:center;gap:12px;font-weight:600}
.meal-pick select{min-height:48px;border:1px solid var(--field);border-radius:12px;padding:0 12px;background:#fff;font-weight:600;flex:1}
.split-select{position:relative;width:52px;background:var(--primary);color:#fff;display:grid;place-items:center;border-left:1px solid rgba(255,255,255,.35);border-radius:0 12px 12px 0}
.split-select:hover{background:var(--pressed)}
.split-select select{position:absolute;inset:0;opacity:0;width:100%;height:100%;cursor:pointer;font-size:16px}
.skel{height:64px;border-radius:12px;background:linear-gradient(90deg,var(--track),#f6f2e8,var(--track));background-size:200% 100%;animation:sh 1.2s infinite linear;margin:8px 0}
@keyframes sh{to{background-position:-200% 0}}
.empty{text-align:center}
.search-field{width:100%;min-height:48px;border:1px solid var(--field);border-radius:12px;padding:0 14px;background:var(--card);font-size:1rem}
.search-field:focus{border-color:var(--primary)}
.result-list{list-style:none;margin:8px 0 0;padding:0}
.result-list li button{width:100%;min-height:56px;border:0;border-bottom:1px solid var(--border);background:none;text-align:left;padding:8px 4px;display:flex;align-items:center;gap:8px;cursor:pointer}
.result-list li button:hover{background:var(--bg)}
.result-list .rmeta{flex:1;min-width:0}
/* History */
#week-chart svg{width:100%;height:auto;stroke:none}
#history-list{display:flex;flex-direction:column;gap:12px}
.day-card summary{cursor:pointer;min-height:48px;display:flex;align-items:center;justify-content:space-between;gap:8px;list-style:none}
.day-card summary::-webkit-details-marker{display:none}
.day-card summary .end{display:inline-flex;align-items:center}
.day-card summary .end::after{content:"";width:10px;height:10px;border-right:2px solid var(--sec);border-bottom:2px solid var(--sec);transform:rotate(45deg);margin-left:8px;flex:0 0 auto}
.day-card[open] summary .end::after{transform:rotate(-135deg)}
.over-txt{color:var(--warn);font-weight:600}
/* Bottom nav */
.bottom-nav{position:fixed;left:0;right:0;bottom:0;z-index:10;background:var(--card);border-top:1px solid var(--border);display:flex;justify-content:space-around;align-items:flex-end;padding:6px 16px calc(6px + env(safe-area-inset-bottom));max-width:560px;margin:0 auto}
.nav-btn{flex:1;min-height:56px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;background:none;border:0;color:var(--sec);font-size:.875rem;font-weight:600;cursor:pointer}
.nav-btn[aria-current="page"]{color:var(--primary)}
.nav-btn[aria-current="page"]::after{content:"";width:24px;height:4px;border-radius:999px;background:var(--hi);margin-top:2px}
.snap-btn{flex:0 0 auto;display:flex;flex-direction:column;align-items:center;gap:4px;background:none;border:0;cursor:pointer;font-size:.875rem;font-weight:600;color:var(--text);margin-top:-28px}
.snap-btn svg{box-sizing:content-box;width:28px;height:28px;padding:18px;border-radius:999px;background:var(--primary);color:#fff;box-shadow:0 2px 8px rgba(31,42,36,.2)}
.snap-btn:hover svg{background:var(--pressed)}
body.result-open .bottom-nav{display:none}
/* Sheet */
.scrim{position:fixed;inset:0;background:rgba(31,42,36,.4);z-index:40}
.sheet{position:fixed;left:0;right:0;bottom:0;z-index:50;height:80vh;height:80dvh;max-width:560px;margin:0 auto;background:var(--card);border-radius:16px 16px 0 0;display:flex;flex-direction:column;transition:transform .25s ease;box-shadow:0 -4px 16px rgba(31,42,36,.12)}
.grab{padding:8px 0 4px;display:flex;justify-content:center;cursor:grab;touch-action:none;min-height:24px}
.grab span{width:40px;height:5px;border-radius:999px;background:var(--border)}
.sheet-inner{flex:1;overflow:auto;padding:4px 16px 0;display:flex;flex-direction:column;gap:12px}
.sheet-inner:not(:has(.sheet-foot)){padding-bottom:calc(16px + env(safe-area-inset-bottom))}
.sheet-head{display:flex;justify-content:space-between;align-items:flex-start;gap:8px}
.live-kcal{font-family:var(--head);font-weight:600;font-size:2.5rem;line-height:2.75rem}
.stepper{display:flex;align-items:center;gap:12px}
.stepper button{width:48px;height:48px;border-radius:12px;border:1px solid var(--field);background:var(--card);font-size:1.5rem;cursor:pointer}
.stepper .qty{min-width:64px;text-align:center;font-size:1.5rem;font-weight:600}
.unit-chips{display:flex;flex-wrap:wrap;gap:8px}
.unit-chip{min-height:48px;padding:0 14px;border-radius:999px;border:1px solid var(--field);background:var(--card);cursor:pointer;font-weight:600}
.unit-chip[aria-pressed="true"]{background:var(--hi);border-color:var(--hi);color:#1F2A24}
.form label{display:flex;flex-direction:column;gap:4px;font-weight:600;margin-bottom:12px}
.form input,.grams-input{min-height:48px;border:1px solid var(--field);border-radius:12px;padding:0 12px;background:var(--card);font-size:1rem;font-weight:400}
.sheet-foot{margin-top:auto;display:flex;flex-direction:column;gap:8px;position:sticky;bottom:0;background:var(--card);padding:12px 16px calc(12px + env(safe-area-inset-bottom));margin:0 -16px;border-top:1px solid var(--border);z-index:1}
.remove-row{display:flex;justify-content:center;margin-top:8px}
.notice{border-left:4px solid var(--info)}
.notice p,.privacy-text p{margin:0}
.notice,.privacy-text{display:flex;flex-direction:column;gap:8px}
.drop-hint{position:fixed;inset:0;z-index:70;background:rgba(30,107,71,.16);border:3px dashed var(--primary);display:flex;align-items:center;justify-content:center;pointer-events:none}
.drop-hint span{background:var(--card);padding:16px 20px;border-radius:12px;font-weight:600;box-shadow:var(--shadow)}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));background:var(--text);color:#fff;padding:12px 16px;border-radius:12px;z-index:60;max-width:90vw}
.unmatched .item-name{color:var(--warn)}
@media (min-width:900px){
  body{background:linear-gradient(var(--bg),var(--bg))}
  .app{border-left:1px solid var(--border);border-right:1px solid var(--border)}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important}
}
