/* Nourity design system. Dark, calm, phone first (390px), then scaled up.
   Contrast (checked in tests): text 16.7:1, muted 8.9:1, sage 10.8:1, dark on sage 10.3:1 (WCAG AA needs 4.5:1). */
:root {
  color-scheme: dark;
  --bg: #0e1311;
  --surface: #161d1a;
  --surface-2: #1e2723;
  --line: #2c3833;
  --text: #eef3f0;
  --muted: #a8b6af;
  --sage: #8fd3a9;
  --sage-ink: #0b1a12;
  --sage-soft: rgba(143, 211, 169, 0.12);
  --apricot: #f5b98a;
  --apricot-soft: rgba(245, 185, 138, 0.12);
  --danger: #ff9b8f;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --nav-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans);
  font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--sage); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 7vw, 44px); }
h2 { font-size: clamp(22px, 5vw, 30px); }
h3 { font-size: 18px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid var(--apricot); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--apricot); color: #1a120b; padding: 10px 14px; border-radius: 10px; z-index: 100; font-weight: 700; }
.skip-link:focus { top: 8px; }

/* Layout */
.shell { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 32px + var(--safe-b)); }
.page { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 680px; margin: 0 auto; }
.section { padding-top: 48px; padding-bottom: 48px; }
@media (min-width: 900px) { .section { padding-top: 72px; padding-bottom: 72px; } }

/* Top bar (public pages) */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(14, 19, 17, 0.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .page { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-family: var(--serif); font-weight: 700; font-size: 22px; color: var(--text); text-decoration: none; display: inline-flex; gap: 8px; align-items: center; }
.logo-mark { width: 28px; height: 28px; border-radius: 9px; background: var(--sage); color: var(--sage-ink); display: grid; place-items: center; font-size: 17px; }
.topnav { display: flex; gap: 6px; align-items: center; }
.topnav a { color: var(--muted); text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; }
.topnav a:hover { color: var(--text); }
.topnav .hide-sm { display: none; }
@media (min-width: 640px) { .topnav .hide-sm { display: inline-flex; } }

/* App header */
.app-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 18px; gap: 12px; }
.app-head h1 { font-size: 26px; margin: 0; }
.back { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }

/* Bottom nav with a raised Log button in thumb reach */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b); background: rgba(22, 29, 26, 0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottom-nav ul { list-style: none; margin: 0 auto; padding: 0 8px; max-width: 520px; height: var(--nav-h); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; min-height: 48px; justify-content: center; }
.bottom-nav a[aria-current="page"] { color: var(--sage); }
.bottom-nav svg { width: 24px; height: 24px; }
.bottom-nav .log-fab { width: 60px; height: 60px; border-radius: 50%; background: var(--sage); color: var(--sage-ink); margin-top: -22px; box-shadow: var(--shadow); gap: 0; }
.bottom-nav .log-fab svg { width: 28px; height: 28px; }
.bottom-nav .log-fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 12px; }
.card.soft { background: var(--surface-2); }
.card.accent { background: linear-gradient(160deg, #1d3027, #15201b); border-color: #2f4a3c; }
.card h2, .card h3 { margin-top: 0; }
.card-title { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-family: var(--sans); }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 20px;
  border-radius: 14px; border: 1px solid transparent; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer;
  text-decoration: none; transition: transform 0.12s ease, background 0.2s ease; width: auto;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--sage); color: var(--sage-ink); }
.btn-primary:hover { background: #a6ddb9; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-quiet { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255, 155, 143, 0.5); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 17px; border-radius: 16px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.link-btn { background: none; border: 0; color: var(--sage); font: inherit; cursor: pointer; padding: 10px 0; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }

/* Forms */
label.field { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 14px; font: inherit; font-size: 17px; min-height: 52px;
}
textarea.input { resize: vertical; min-height: 96px; line-height: 1.45; }
.input:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px var(--sage-soft); }
.input::placeholder { color: #7d8b84; }
.code-input { font-size: 30px; letter-spacing: 12px; text-align: center; font-weight: 700; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--sage); }
.help { font-size: 14px; color: var(--muted); margin: 6px 0 0; }

/* Chip choice (radio) */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 15px; white-space: nowrap; cursor: pointer; }
.chip input:checked + span { background: var(--sage-soft); color: var(--sage); border-color: rgba(143, 211, 169, 0.6); }
.chip input:focus-visible + span { outline: 3px solid var(--apricot); outline-offset: 2px; }
a.chip-link, button.chip-link { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none; }
button.chip-link { font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; }
a.chip-link[aria-current="true"] { background: var(--sage-soft); color: var(--sage); border-color: rgba(143, 211, 169, 0.6); }

/* Sliders (check-in) */
.slider-row { padding: 14px 0; }
.slider-row + .slider-row { border-top: 1px solid var(--line); }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.slider-value { color: var(--sage); font-weight: 700; }
input[type="range"] { width: 100%; height: 44px; accent-color: var(--sage); background: transparent; }
.scale-ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

/* Flash */
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; background: var(--sage-soft); border: 1px solid rgba(143, 211, 169, 0.35); }
.flash.error { background: rgba(255, 155, 143, 0.1); border-color: rgba(255, 155, 143, 0.4); color: #ffd2cc; }

/* Score */
.score { display: flex; gap: 16px; align-items: center; }
.ring { width: 96px; height: 96px; flex-shrink: 0; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .value { stroke: var(--sage); stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-size: 30px; font-weight: 700; }
details.explain { margin-top: 10px; }
details.explain summary { cursor: pointer; color: var(--sage); font-weight: 600; min-height: 44px; display: flex; align-items: center; list-style: none; }
details.explain summary::-webkit-details-marker { display: none; }
details.explain summary::after { content: "+"; margin-left: 8px; font-weight: 700; }
details.explain[open] summary::after { content: "–"; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 24px; }
.stat span { font-size: 13px; color: var(--muted); }

/* Entries */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: flex; gap: 12px; padding: 12px 0; align-items: flex-start; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry-emoji { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.entry-main { flex: 1; min-width: 0; }
.entry-title { font-weight: 600; overflow-wrap: anywhere; }
.entry-meta { font-size: 14px; color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.sage { background: var(--sage-soft); color: var(--sage); }
.pill.apricot { background: var(--apricot-soft); color: var(--apricot); }

/* Nutrients */
.macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.macro { background: var(--surface-2); border-radius: 12px; padding: 10px 6px; text-align: center; }
.macro b { display: block; font-size: 20px; font-family: var(--serif); }
.macro span { font-size: 12px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.kv:first-child { border-top: 0; }

/* Map */
.map-row { padding: 12px 0; }
.map-row + .map-row { border-top: 1px solid var(--line); }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; position: relative; }
.bar i { position: absolute; top: 0; bottom: 0; background: var(--sage); border-radius: 99px; }
.bar i.lower { background: var(--apricot); }
.bar .mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--muted); opacity: 0.5; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; }
.week div { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week i { width: 100%; max-width: 28px; border-radius: 8px 8px 4px 4px; background: var(--sage); min-height: 4px; }
.week i.none { background: var(--line); }
.week span { font-size: 12px; color: var(--muted); }
.locked { position: relative; }
.locked .blur { filter: blur(6px); user-select: none; pointer-events: none; }
.locked .overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; }

/* Meal library */
.meal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .meal-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .meal-grid { grid-template-columns: repeat(4, 1fr); } }
.meal-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.meal-card:hover { border-color: #3d4d45; }
.meal-photo { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; font-size: 44px; overflow: hidden; }
.meal-photo img { width: 100%; height: 100%; object-fit: cover; }
.meal-card .body { padding: 12px; }
.meal-card .name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.meal-card .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.hero-photo { border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; font-size: 72px; }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
ol.steps { padding-left: 22px; }
ol.steps li { margin-bottom: 10px; }
ul.ingredients { padding-left: 20px; }
ul.ingredients li { margin-bottom: 6px; }

/* Landing */
.hero { padding-top: 40px; padding-bottom: 24px; }
.hero h1 { font-size: clamp(36px, 9vw, 64px); }
.hero h1 em { font-style: normal; color: var(--sage); }
.lead { font-size: 18px; color: var(--muted); max-width: 560px; }
.hero-cta { display: flex; flex-direction: column; gap: 10px; margin: 24px 0 12px; max-width: 360px; }
@media (min-width: 640px) { .hero-cta { flex-direction: row; } }
.ticks { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 15px; }
.ticks li::before { content: "✓"; color: var(--sage); margin-right: 6px; font-weight: 700; }
.grid-2 { display: grid; gap: 12px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; gap: 16px; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.grid-3 { display: grid; gap: 12px; }
.step-num { width: 36px; height: 36px; border-radius: 50%; background: var(--sage-soft); color: var(--sage); display: grid; place-items: center; font-weight: 700; margin-bottom: 10px; }
.phone-demo { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 18px; box-shadow: var(--shadow); max-width: 360px; }
.price { font-family: var(--serif); font-size: 40px; font-weight: 700; }
.price small { font-family: var(--sans); font-size: 16px; color: var(--muted); font-weight: 500; }
.plan.featured { border-color: rgba(143, 211, 169, 0.6); box-shadow: 0 0 0 1px rgba(143, 211, 169, 0.25); }
.plan ul { padding-left: 0; list-style: none; margin: 12px 0 16px; }
.plan li { padding: 6px 0; }
.plan li::before { content: "✓"; color: var(--sage); margin-right: 8px; font-weight: 700; }
.faq details { border-top: 1px solid var(--line); padding: 4px 0; }
.faq summary { cursor: pointer; font-weight: 600; min-height: 48px; display: flex; align-items: center; }

/* Footer */
.footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: 14px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0; }
.footer a { color: var(--muted); min-height: 44px; display: inline-flex; align-items: center; }
.disclaimer { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* Onboarding steps */
.progress { display: flex; gap: 6px; margin: 4px 0 20px; }
.progress i { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.progress i.on { background: var(--sage); }
.js .ob-step { display: none; }
.js .ob-step.active { display: block; }
.choice-list { display: grid; gap: 10px; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1.5px solid var(--line); font-weight: 600; cursor: pointer; min-height: 56px; }
.choice input:checked + span { border-color: var(--sage); background: var(--sage-soft); }
.choice input:focus-visible + span { outline: 3px solid var(--apricot); outline-offset: 2px; }

/* Log screen */
.log-box { position: relative; }
.mic { position: absolute; right: 8px; bottom: 8px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--sage-soft); color: var(--sage); display: grid; place-items: center; cursor: pointer; }
.mic svg { width: 24px; height: 24px; }
.mic.listening { background: var(--apricot); color: #1a120b; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(245, 185, 138, 0.15); } }
.sticky-action { position: sticky; bottom: calc(var(--nav-h) + 12px + var(--safe-b)); z-index: 5; margin-top: 16px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px + var(--safe-b)); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), #26302b, var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Legal pages */
.draft-banner { background: #3a2e12; color: #ffe7a8; text-align: center; padding: 10px 16px; font-size: 14px; font-weight: 600; border-bottom: 1px solid #6b5520; }
.legal { padding-top: 28px; padding-bottom: 48px; }
.legal .section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; }
.legal .section h2 { font-size: 20px; }
.legal .section h3 { font-size: 16px; font-family: var(--sans); margin: 14px 0 6px; }
.legal p, .legal li { color: #d3ddd8; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal strong { color: var(--text); }
.legal .updated { color: var(--muted); font-size: 14px; }
.legal .highlight { background: var(--sage-soft); border: 1px solid rgba(143, 211, 169, 0.35); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.legal .highlight p { margin: 0; color: var(--text); }
.legal .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 6px 0 10px; }
.legal table { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 14px; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); line-height: 1.5; }
.legal th { color: var(--text); background: var(--surface-2); }
.legal td { color: #d3ddd8; }
.bottom-nav a.log-fab[aria-current="page"] { color: var(--sage-ink); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--sage); }
.kv > span:first-child { white-space: nowrap; margin-right: 16px; color: var(--muted); }
.kv > span:last-child { text-align: right; }

/* Guides */
.guide-body h2 { margin-top: 28px; }
.guide-body h3 { font-size: 17px; margin-top: 18px; }
.guide-body p, .guide-body li { color: #d3ddd8; }
.guide-meals, .guide-links { padding-left: 20px; }
.guide-meals li, .guide-links li { margin-bottom: 8px; }
