/* Volume — app styles. Mobile-first app shell; desktop gets top nav + grid. */

:root {
  --green: #15803d;
  --green-strong: #166534;
  --green-soft: #dcfce7;
  --accent: #d97706;
  --bg: #f6f8f6;
  --card: #ffffff;
  --ink: #1a2e22;
  --ink-2: #52665a;
  --line: #e2e8e4;
  --chip: #eef4ef;
  --safe: #16a34a;
  --caution: #d97706;
  --trigger: #dc2626;
  --shadow: 0 1px 3px rgba(10, 40, 20, .08), 0 4px 14px rgba(10, 40, 20, .06);
  --radius: 14px;
  --tabbar-h: calc(60px + env(safe-area-inset-bottom, 0px));
}
@media (prefers-color-scheme: dark) {
  :root {
    --green: #4ade80;
    --green-strong: #86efac;
    --green-soft: #14351f;
    --accent: #fbbf24;
    --bg: #0c1410;
    --card: #16211a;
    --ink: #e6efe9;
    --ink-2: #9fb3a7;
    --line: #24312a;
    --chip: #1d2a22;
    --safe: #4ade80;
    --caution: #fbbf24;
    --trigger: #f87171;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  padding-bottom: var(--tabbar-h);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--green); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  display: flex; align-items: center; gap: 12px;
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--green); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}
@media (prefers-color-scheme: dark) { .brand-mark { color: #06210f; } }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.topnav { display: none; gap: 2px; margin-left: 8px; }
.navbtn { padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--ink-2); }
.navbtn.active { background: var(--green-soft); color: var(--green-strong); }
.profile-toggle {
  margin-left: auto; display: flex; border: 1px solid var(--line);
  border-radius: 99px; overflow: hidden; background: var(--chip);
}
.pt-opt { padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.pt-opt.active { background: var(--green); color: #fff; }
@media (prefers-color-scheme: dark) { .pt-opt.active { color: #06210f; } }

/* ---------- Screen ---------- */
.screen { max-width: 1080px; margin: 0 auto; padding: 16px 16px 32px; outline: none; }
.screen-title { font-size: 24px; font-weight: 800; margin: 6px 0 2px; }
.screen-sub { color: var(--ink-2); margin: 0 0 16px; font-size: 14px; }

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: var(--ink-2); }
.tab.active { color: var(--green-strong); }
.tab-ico { font-size: 20px; line-height: 1; }
.tab-lbl { font-size: 11px; font-weight: 600; position: relative; }
.tab-badge {
  position: absolute; top: -14px; right: -16px;
  background: var(--accent); color: #fff; border-radius: 99px;
  font-size: 10px; font-weight: 700; padding: 1px 5px; min-width: 16px; text-align: center;
}

/* Desktop: top nav instead of tab bar */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .topnav { display: flex; }
  .tabbar { display: none; }
  .screen { padding: 24px; }
}

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px)  { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px)  { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; position: relative;
}
.card.tappable { cursor: pointer; transition: transform .08s ease; }
.card.tappable:active { transform: scale(.985); }

.food-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.food-name { font-weight: 700; font-size: 15px; }
.food-brand { color: var(--ink-2); font-size: 12.5px; margin-top: 1px; }
.food-rank {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: var(--green-soft); color: var(--green-strong);
  font-weight: 800; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge {
  font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px;
  background: var(--chip); color: var(--ink-2); border: 1px solid var(--line);
}
.badge.ed-veryLow { background: var(--green-soft); color: var(--green-strong); border-color: transparent; }
.badge.ed-low     { background: var(--green-soft); color: var(--green-strong); border-color: transparent; opacity: .85; }
.badge.ed-medium  { background: #fef3c7; color: #92400e; border-color: transparent; }
.badge.ed-high    { background: #fee2e2; color: #991b1b; border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .badge.ed-medium { background: #3a2e10; color: #fcd34d; }
  .badge.ed-high   { background: #3d1414; color: #fca5a5; }
}
.badge.flag-safe    { color: var(--safe); }
.badge.flag-caution { color: var(--caution); }
.badge.flag-trigger { color: var(--trigger); }
.badge.protein { background: var(--green); color: #fff; border-color: transparent; }
@media (prefers-color-scheme: dark) { .badge.protein { color: #06210f; } }

.food-price { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.food-price b { color: var(--ink); font-size: 15px; }
.food-why { margin-top: 8px; font-size: 13px; color: var(--ink-2); }

/* ---------- Sections ---------- */
.section { margin: 22px 0 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-title { font-size: 17px; font-weight: 800; }
.section-note { font-size: 12.5px; color: var(--ink-2); }

/* ---------- Slot tabs (meals) & pills ---------- */
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none; padding: 8px 16px; border-radius: 99px; font-weight: 700; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-2);
}
.pill.active { background: var(--green); border-color: var(--green); color: #fff; }
@media (prefers-color-scheme: dark) { .pill.active { color: #06210f; } }

/* ---------- Home ---------- */
.hero {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-strong) 100%);
  color: #fff; border-radius: var(--radius); padding: 18px 16px; margin-bottom: 16px;
}
@media (prefers-color-scheme: dark) { .hero { color: #06210f; } }
.hero h1 { font-size: 20px; margin: 0 0 4px; }
.hero p { margin: 0; font-size: 13.5px; opacity: .92; }
.data-age { margin-top: 10px; font-size: 12px; opacity: .85; }
.tipcard { border-left: 4px solid var(--accent); }
.tip-src { display: block; margin-top: 6px; font-size: 11.5px; color: var(--ink-2); }
.home-shortcuts { margin-top: 4px; }
.shortcut { display: flex; align-items: center; gap: 12px; }
.shortcut-ico { font-size: 26px; }
.shortcut-txt b { display: block; font-size: 15px; }
.shortcut-txt span { font-size: 12.5px; color: var(--ink-2); }

/* ---------- Detail sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.25);
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 768px) {
  .sheet { left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%);
    width: min(560px, 92vw); border-radius: 18px; max-height: 84vh; }
  .sheet-grab { display: none; }
}
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 10px; }
.sheet h2 { font-size: 19px; margin: 6px 0 2px; }
.sheet .food-brand { font-size: 13px; }
.macro-row { display: flex; gap: 8px; margin: 12px 0; }
.macro {
  flex: 1; text-align: center; background: var(--chip); border-radius: 12px; padding: 10px 4px;
}
.macro b { display: block; font-size: 17px; }
.macro span { font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; }
.stores-table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 13.5px; }
.stores-table th { text-align: left; color: var(--ink-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.stores-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stores-table td.price { font-weight: 700; white-space: nowrap; }
.store-link { font-size: 12.5px; font-weight: 600; }
.dealia-box {
  background: var(--chip); border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 13px;
}
.dealia-box b { font-size: 14px; }
.dealia-link { display: inline-block; margin-top: 6px; font-weight: 700; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; text-align: center; padding: 12px; border-radius: 12px; font-weight: 700; font-size: 14.5px;
  background: var(--green); color: #fff;
}
@media (prefers-color-scheme: dark) { .btn { color: #06210f; } }
.btn.ghost { background: var(--chip); color: var(--ink); border: 1px solid var(--line); }
.swapfor { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.swapfor b { color: var(--ink); }

/* ---------- Builder ---------- */
.build-summary {
  position: sticky; top: calc(52px + env(safe-area-inset-top, 0px)); z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 14px;
}
.build-totals { display: flex; gap: 8px; }
.fullness { margin-top: 10px; }
.fullness-bar { height: 10px; border-radius: 6px; background: var(--chip); overflow: hidden; }
.fullness-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #f59e0b, #84cc16, #16a34a); transition: width .25s ease; }
.fullness-lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.plate-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.plate-item:last-child { border-bottom: 0; }
.plate-name { flex: 1; font-size: 14px; font-weight: 600; }
.plate-macros { font-size: 12px; color: var(--ink-2); }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button {
  width: 30px; height: 30px; border-radius: 9px; background: var(--chip);
  border: 1px solid var(--line); font-weight: 800; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.qty span { min-width: 26px; text-align: center; font-weight: 700; }
.build-suggest { border-left: 4px solid var(--green); }

/* ---------- Recipes (soups & salads) ---------- */
.recipe-meta { display: flex; gap: 12px; font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.recipe-meta b { color: var(--ink); }
.ing-list, .step-list { margin: 8px 0 0; padding-left: 20px; font-size: 13.5px; }
.ing-list li, .step-list li { margin-bottom: 4px; }

/* ---------- Shopping list ---------- */
.list-store-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; margin: 18px 0 8px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--green); }
.list-item.done .li-name { text-decoration: line-through; color: var(--ink-2); }
.li-name { flex: 1; font-size: 14px; font-weight: 600; }
.li-price { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.li-remove { color: var(--trigger); font-size: 18px; padding: 4px 8px; }
.empty {
  text-align: center; color: var(--ink-2); padding: 40px 16px; font-size: 14px;
}
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- Treat fixes ---------- */
.treat-card { border-left: 4px solid var(--accent); }
.treat-fix { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }
.treat-fix li { margin-bottom: 5px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 12px); z-index: 60;
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); max-width: 90vw;
}
@media (min-width: 768px) { .toast { bottom: 24px; } }

/* ---------- Footer ---------- */
.appfoot { margin-top: 34px; text-align: center; font-size: 11.5px; color: var(--ink-2); }
.appfoot a { color: inherit; }

/* ---------- Utility ---------- */
.muted { color: var(--ink-2); }
.mt0 { margin-top: 0; }
.filter-note { font-size: 12.5px; color: var(--ink-2); margin: -4px 0 10px; }
.searchbox {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 15px; margin-bottom: 12px;
}
.searchbox:focus { outline: 2px solid var(--green); border-color: transparent; }
