:root{font:16px/1.55 "Segoe UI","Leelawadee UI","Yu Gothic UI",sans-serif;color-scheme:light;--bg:#f5f7f5;--panel:#fff;--text:#182823;--muted:#52645e;--line:#dce5df;--accent:#18634e;--tint:#e3f2eb;--warn:#fff2d8;--warning:#6d470b}
:root[data-theme=dark]{color-scheme:dark;--bg:#13201c;--panel:#1c2c26;--text:#edf7f1;--muted:#afc6bb;--line:#365047;--accent:#9ce0c1;--tint:#264638;--warn:#453517;--warning:#ffe2ab}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);display:grid;grid-template-columns:252px minmax(0,1fr);min-height:100vh}a{color:var(--accent)}aside#sidebar{background:#142f27;color:#e9fff4;display:flex;flex-direction:column;padding:24px 16px;position:sticky;top:0;height:100dvh;overflow:auto}.brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-weight:750;color:inherit;white-space:nowrap;margin:2px 0 30px}.brand span{background:#b7f1cf;color:#142f27;border-radius:10px;padding:3px 9px}nav{display:grid;gap:4px}nav a{display:flex;gap:13px;align-items:center;padding:9px 12px;border-radius:9px;color:#c5ded3;text-decoration:none;font-size:.94rem}nav a:hover,nav a[aria-current]{background:#2b4e40;color:#fff}nav i{width:20px;text-align:center;font-style:normal}#local{margin-top:auto;padding:24px 12px 0;color:#b5d7c7;font-size:.86rem}header{height:65px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:12px;padding:0 clamp(16px,4vw,48px);background:var(--panel)}.controls{margin-left:auto;display:flex;gap:8px}main{max-width:1320px;margin:auto;padding:clamp(16px,4vw,48px)}h1,h2,p{margin:0}h1{font-size:clamp(1.85rem,4vw,3rem);line-height:1.15;letter-spacing:-.025em}h2{font-size:1.12rem;margin-bottom:12px}.heading{display:flex;align-items:flex-end;justify-content:space-between;gap:15px;flex-wrap:wrap;margin-bottom:24px}.heading p{margin-top:9px}.muted,small{color:var(--muted)}small{font-size:.875rem}.eyebrow{color:var(--accent);font-size:.86rem;font-weight:750;margin-bottom:8px}.grid{display:grid;gap:16px;margin-bottom:16px}.stats{grid-template-columns:repeat(4,minmax(0,1fr))}.columns{grid-template-columns:minmax(0,1.65fr) minmax(0,1fr)}.equal{grid-template-columns:repeat(2,minmax(0,1fr))}.card{background:var(--panel);border:1px solid var(--line);border-radius:15px;padding:20px;min-width:0}.stat strong{display:block;font-size:clamp(1.35rem,2.5vw,2rem);font-variant-numeric:tabular-nums;margin-top:5px}.symbol{display:inline-grid;place-items:center;width:36px;height:36px;border-radius:10px;background:var(--tint);color:var(--accent);margin-bottom:10px}.hero{background:#194135;color:#f2fff7}.hero p,.hero small,.hero a{color:#c9e8da}.hero h2{font-size:1.65rem;margin:4px 0}.notice{padding:14px 16px;border-radius:10px;background:var(--warn);color:var(--warning);margin-top:12px}.actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center}.button,button,input,select{font:inherit;border:1px solid var(--line);border-radius:8px;padding:7px 10px;background:var(--panel);color:var(--text)}button,.button{cursor:pointer;font-weight:650;text-decoration:none;display:inline-block}.primary{background:var(--accent);color:var(--panel);border-color:transparent}button:hover,.button:hover{filter:brightness(.93)}:focus-visible{outline:2px solid var(--accent);outline-offset:3px}form{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,155px),1fr));gap:12px;align-items:end}label{display:grid;gap:4px;font-size:.91rem;color:var(--muted)}input,select{min-width:0;width:100%}form .actions{grid-column:1/-1}article+article{border-top:1px solid var(--line)}.record{padding:12px 0;display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;overflow-wrap:anywhere}.photo{display:block;width:min(240px,100%);max-height:220px;object-fit:contain;border-radius:8px;margin-top:8px}.chart{width:100%;height:auto;display:block}.chart text{font:14px "Segoe UI",sans-serif;fill:var(--muted)}.chart line{stroke:var(--line)}.chart path{fill:none;stroke:var(--accent);stroke-width:3}.chart circle{fill:var(--accent)}.empty{min-height:170px;display:grid;place-items:center;text-align:center;border:1px dashed var(--line);border-radius:10px;color:var(--muted);padding:18px}#status:not(:empty){position:fixed;bottom:14px;right:14px;max-width:calc(100% - 28px);background:var(--text);color:var(--panel);padding:10px 16px;border-radius:8px;z-index:3}#menu{display:none}.range{margin:8px 0}.stack>*+*{margin-top:14px}
@media(max-width:1050px){.stats{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:760px){body{display:block}aside#sidebar{display:none;position:fixed;z-index:2;top:65px;height:calc(100dvh - 65px);width:min(290px,90vw)}aside#sidebar.open{display:flex}#menu{display:block}.columns,.equal{grid-template-columns:1fr}}
@media(max-width:360px){.card{padding:13px}header{padding:0 8px}.stats{gap:8px}}
.ingredient-row{display:grid;grid-template-columns:minmax(130px,2fr) minmax(85px,1fr) minmax(100px,1fr) auto;gap:8px;align-items:end;margin:10px 0}.ingredient-footer{margin-top:14px}.ingredient-source{display:block;margin-top:8px}.ingredient-preview[hidden]{display:none}
@media(max-width:600px){.ingredient-row{grid-template-columns:1fr 1fr}.ingredient-row label:first-child{grid-column:1/-1}}
.custom-ingredient{grid-column:1/-1}.custom-ingredient[hidden]{display:none}

/* Rounded navigation, tactile controls, and color-coded tracking cards. */
:root {
  font-family: ui-rounded, "Arial Rounded MT Bold", "Segoe UI", "Leelawadee UI", "Yu Gothic UI", sans-serif;
  --bg: #f8fbfa;
  --panel: #fff;
  --text: #203348;
  --muted: #526579;
  --line: #d9e5e5;
  --accent: #006959;
  --tint: #d9f5eb;
  --press: #004b41;
  --shadow: #dce8e6;
  --hero: #075f57;
  --hero-edge: #05473f;
  --hero-text: #f4fffc;
  --hero-subtext: #defff4;
  --selected: #c2eadd;
  --warn: #fff0d4;
  --warning: #744611;
}
:root[data-theme=dark] {
  --bg: #15232c;
  --panel: #1e3039;
  --text: #edf8fa;
  --muted: #b4c8d2;
  --line: #3a535d;
  --accent: #a1ead3;
  --tint: #294c48;
  --press: #6db7a0;
  --shadow: #12232c;
  --hero: #254d48;
  --hero-edge: #122c28;
  --selected: #40706a;
  --warn: #503c1d;
  --warning: #ffdfab;
}
body { grid-template-columns: 276px minmax(0,1fr); }
aside#sidebar {
  background: var(--panel);
  color: var(--text);
  border-right: 2px solid var(--line);
  padding: 24px 16px 20px;
}
.brand { margin: 0 4px 22px; color: var(--accent); font-size: 1.02rem; font-weight: 850; }
.brand span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 13px;
  background: #006959;
  color: white;
  border-bottom: 3px solid #004b41;
  font-size: 1.3rem;
}
nav { gap: 4px; }
nav a {
  min-height: 48px;
  padding: 6px 9px;
  gap: 9px;
  border: 2px solid transparent;
  border-radius: 14px;
  color: var(--text);
  font-weight: 750;
}
nav a:hover, nav a[aria-current] { background: var(--tint); color: var(--accent); }
nav a[aria-current] { border-color: var(--selected); }
nav i {
  display: grid;
  place-items: center;
  width: 28px;
  height: 31px;
  flex: 0 0 auto;
  font-size: 1.12rem;
  line-height: 1;
}
#local { color: var(--muted); font-weight: 650; }
header { height: 65px; border-bottom: 2px solid var(--line); }
#breadcrumb { font-weight: 750; }
main { max-width: 1260px; }
h1 { font-weight: 850; font-size: clamp(1.9rem,4vw,3rem); }
h2 { font-weight: 800; }
.eyebrow { font-weight: 800; }
.card {
  border: 2px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 3px 0 var(--shadow);
}
.stat .symbol {
  width: 44px;
  height: 44px;
  font-size: 1.35rem;
  border-radius: 14px;
  background: var(--tint);
}
.stat:nth-child(2) .symbol { color: #8c3518; background: #ffe0d2; }
.stat:nth-child(3) .symbol { color: #14528a; background: #dcefff; }
.stat:nth-child(4) .symbol { color: #573389; background: #eee2ff; }
.hero {
  background: var(--hero);
  color: var(--hero-text);
  border-color: var(--hero-edge);
  box-shadow: 0 4px 0 var(--hero-edge);
}
.hero h2 { font-size: clamp(1.55rem,3vw,2rem); }
.hero p, .hero small, .hero a { color: var(--hero-subtext); }
.hero :focus-visible { outline-color: var(--hero-text); }
.notice, .empty { border-radius: 14px; }
.empty { border-width: 2px; }
input, select, button, .button {
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 12px;
}
button, .button {
  min-height: 44px;
  padding: 7px 14px;
  border-bottom-width: 4px;
  font-weight: 800;
}
button:active:not(:disabled), .button:active { transform: translateY(2px); }
button:disabled { opacity: .55; cursor: default; filter: none; }
.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); border-bottom-color: var(--press); }
.controls select { width: auto; }
@media (max-width:760px) {
  aside#sidebar { box-shadow: 5px 0 0 var(--shadow); }
  main { padding-bottom: 32px; }
}
@media (prefers-reduced-motion:reduce) {
  button:active:not(:disabled), .button:active { transform: none; }
}
.stats { grid-template-columns: repeat(5, minmax(0,1fr)); }
@media (max-width: 1180px) { .stats { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2,minmax(0,1fr)); } }

#mobile-shortcuts { display: none; }
@media (max-width: 760px) {
  #mobile-shortcuts {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    padding: 7px 11px;
    gap: 5px;
    background: var(--panel);
    border-bottom: 2px solid var(--line);
  }
  #mobile-shortcuts a {
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    padding: 5px 3px;
    text-align: center;
    line-height: 1.25;
    font-size: .875rem;
    overflow-wrap: anywhere;
  }
}

.cooking-ideas { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.cooking-ideas .cooking-idea { display:flex; flex-direction:column; border:2px solid var(--line); border-radius:14px; padding:14px; }
.cooking-idea h3 { margin:0; font-size:1.05rem; }
.cooking-idea ul { padding-inline-start:20px; margin:8px 0; }

@media (max-width: 960px) { .cooking-ideas { grid-template-columns:1fr; } }

.cooking-idea button { align-self:flex-start; margin-top:auto; }

@media (max-width: 760px) {
  .workspace > header { position:sticky; top:0; z-index:2; }
  aside#sidebar.open { z-index:4; height:calc(100dvh - 65px); padding-bottom:max(20px,env(safe-area-inset-bottom)); }
  #breadcrumb { min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .controls { flex:0 0 auto; }
  #mobile-shortcuts {
    position:fixed;
    z-index:3;
    inset:auto 0 0;
    grid-template-columns:repeat(4,minmax(0,1fr));
    padding:5px max(6px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
    border-top:2px solid var(--line);
    border-bottom:0;
    box-shadow:0 -3px 0 var(--shadow);
  }
  #mobile-shortcuts a { min-height:51px; font-size:.8rem; }
  #mobile-shortcuts a span { font-size:1.12rem; }
  main { padding-bottom:calc(96px + env(safe-area-inset-bottom)); }
  #status:not(:empty) { bottom:calc(80px + env(safe-area-inset-bottom)); z-index:5; }
  input:not([type=file]), select { min-height:46px; font-size:1rem; }
  .record .actions button { white-space:normal; }
  .cooking-idea button { align-self:stretch; }
}
@media (max-width: 480px) {
  form { grid-template-columns:minmax(0,1fr); }
  form .actions button { flex:1 1 auto; }
  .ingredient-row { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .ingredient-row > button { grid-column:1/-1; justify-self:end; }
  .heading .actions { width:100%; }
  .heading .actions a { flex:1; text-align:center; }
}

/* Mobile UX, Touch Ergonomics, Quick Log & Cloud Sync */
html { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body { overscroll-behavior-y: contain; }
#backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 3; }
#backdrop[hidden] { display: none; }
.sync-pill { font-size: .82rem; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.sync-pill[data-state="ok"] { background: var(--tint); color: var(--accent); border-color: var(--accent); }
.sync-pill[data-state="busy"] { opacity: .8; }
.sync-pill[data-state="offline"], .sync-pill[data-state="error"] { background: var(--warn); color: var(--warning); border-color: var(--warning); }
.quick-log-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.quick-weight-form { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; flex: 1 1 200px; min-width: 0; }
.quick-weight-form input { width: 110px; flex: 1 1 auto; }
@media (max-width: 760px) {
  header { padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  aside#sidebar.open { z-index: 4; }
  button, .button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
  .controls button, .controls select { min-height: 38px; }
  .quick-log-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-weight-form { grid-column: 1 / -1; }
  .quick-weight-form input { width: auto; }
  .sync-pill { max-width: 112px; overflow: hidden; text-overflow: ellipsis; }
}
