/* Mobile first (iPhone Home Screen app). No inline styles anywhere: the CSP allows stylesheets from 'self' only. */
:root {
  --bg: #f6f3f0; --card: #ffffff; --ink: #1d1916; --muted: #6f655d; --line: #e4ddd6;
  --accent: #e8611a; --accent-ink: #ffffff; --warn: #a15c00; --danger: #b3261e; --ok: #2e7d4f;
  --radius: 14px; --gap: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16120f; --card: #221c18; --ink: #f2ece6; --muted: #a39789; --line: #3a312a;
          --accent: #f26b1d; --warn: #f0b04a; --danger: #ff8a80; --ok: #7fd1a1; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
}
.boot { padding: 2rem 16px; color: var(--muted); }
main { padding: 8px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; color: var(--muted); font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.warn { color: var(--warn); }
.row { display: flex; align-items: center; gap: 8px; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
        margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons and inputs: 16px+ text so iOS never zooms on focus; 44px touch targets */
button, .button {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 10px 14px; min-height: 44px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
                                  font-weight: 600; }
button.block, .button.block { width: 100%; }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); }
button.danger { color: var(--danger); }
button.icon { min-width: 44px; padding: 0 10px; }
button:disabled { opacity: 0.5; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input.grams { width: 5.5em; text-align: right; }
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
label.check input { width: auto; min-height: 0; }

/* Today */
.daynav { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.daynav h1 { margin: 0; text-align: center; flex: 1; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: 0.8rem; color: var(--muted); }
.stat.main { grid-column: span 3; }
.stat.main b { font-size: 1.8rem; }
.meal-head { display: flex; justify-content: space-between; gap: 8px; }
.tag { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line);
       color: var(--muted); }

/* meal form */
.item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item .kcal { width: 4.5em; text-align: right; color: var(--muted); font-size: 0.9rem; }
.results { margin-top: 6px; }
.results button { width: 100%; justify-content: space-between; border-radius: 10px; margin: 4px 0; text-align: left; }
.banner { background: var(--card); border: 1px solid var(--warn); border-radius: var(--radius); padding: 10px 12px; }

/* supplements */
.row.wrap { flex-wrap: wrap; margin-top: 8px; }
label.field.narrow { width: 5.5em; flex: none; }
.unit { width: 3em; }

.sticky-save { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); padding-top: 8px;
               background: linear-gradient(transparent, var(--bg) 30%); }

/* bottom tab bar */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
nav.tabs a { flex: 1; text-align: center; padding: 10px 0 8px; color: var(--muted); text-decoration: none;
             font-size: 0.8rem; min-height: 56px; }
nav.tabs a b { display: block; font-size: 1.3rem; line-height: 1.2; font-weight: 400; }
nav.tabs a.on { color: var(--accent); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20;
         background: var(--ink); color: var(--bg); border-radius: 12px; padding: 12px 14px; text-align: center; }
.toast.error { background: var(--danger); color: #fff; }
.center { text-align: center; padding: 3rem 0; }
.login-logo { width: 96px; height: 96px; border-radius: 22px; }
.hidden { display: none; }
label.button.disabled { opacity: 0.6; pointer-events: none; }

.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
span.block { display: block; }
