@font-face { font-family: "Figtree"; src: url("/fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #FBF6EE;
  --card: #FFFFFF;
  --ink: #2B1810;
  --muted: #6E5446;
  --line: #E9DCCB;
  --soft: #F3E9DA;
  --accent: #C14C23;
  --accent-dark: #9E3A16;
  --accent-soft: #F8E2D6;
  --low: #17824F;
  --low-soft: #DDF1E5;
  --med: #C98200;
  --med-soft: #FBEBC9;
  --high: #C3321C;
  --high-soft: #F9DCD5;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --radius: 18px;
  --tabs-h: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -0.015em; line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0; }
.brand { font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: -0.02em; color: var(--ink); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; user-select: all; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 13px; color: var(--muted); }

/* boot splash */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.boot .brand { font-size: 28px; opacity: .85; }

/* ---------- sign in ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; align-items: center; padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.gate__inner { width: 100%; max-width: 420px; margin: 0 auto; display: grid; gap: 14px; }
.gate__brand { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.gate__brand .brand { font-size: 30px; }
.by { font-size: 14px; color: var(--muted); }
.gate__title { font-size: 32px; }
.gate__lead { color: var(--muted); font-size: 16px; }
.gate__form { display: grid; gap: 10px; margin-top: 8px; }
.gate__links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.gate__msg { background: var(--high-soft); color: #7A1E10; border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.gate__msg.is-ok { background: var(--low-soft); color: #0E5132; }
.gate__ended { display: grid; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

.label { font-size: 14px; font-weight: 650; }
.input { width: 100%; min-height: 52px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); font-size: 17px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input--code { font-size: 28px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 20px; border-radius: 999px; border: 0; font-weight: 700; font-size: 16px; text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(193, 76, 35, .28); }
.btn--primary:active { background: var(--accent-dark); }
.btn--primary[disabled] { opacity: .6; box-shadow: none; }
.btn--ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn--block { width: 100%; }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font-weight: 650; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.link[disabled] { color: var(--muted); text-decoration: none; cursor: default; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(env(safe-area-inset-top) + 12px) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left)); background: rgba(251, 246, 238, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top__day { font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.view { max-width: 560px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-right)) calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px) max(16px, env(safe-area-inset-left)); display: grid; gap: 16px; outline: none; }
.view > * { min-width: 0; }
.remove.is-armed { width: auto; padding: 0 12px; border-radius: 999px; color: var(--high); background: var(--high-soft); font-size: 14px; font-weight: 700; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(43, 24, 16, .06); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 650; min-width: 0; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.tab.is-active { color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 15px; font-weight: 600; box-shadow: 0 8px 20px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); }

/* ---------- shared blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; min-width: 0; box-shadow: 0 2px 6px rgba(43, 24, 16, .04); }
.card--accent { background: var(--ink); color: #fff; border-color: var(--ink); }
.card--accent .muted, .card--accent .small { color: #E6D6C8; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.card--accent .eyebrow { color: #F4A57F; }
.h-page { font-size: 30px; }
.h-card { font-size: 21px; }
.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row > .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-weight: 650; font-size: 15px; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--soft); border-radius: 999px; padding: 4px; }
.seg button { min-height: 42px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; font-size: 14px; color: var(--muted); padding: 6px 8px; }
.seg button.is-on { background: var(--card); color: var(--ink); box-shadow: 0 2px 6px rgba(43, 24, 16, .1); }

/* toggles on Today */
.check { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card); text-align: left; }
.check__box { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #CDB8A5; display: grid; place-items: center; }
.check__box svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.check__title { font-weight: 750; font-size: 16px; line-height: 1.3; }
.check__sub { font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.check.is-on { border-color: var(--low); background: var(--low-soft); }
.check.is-on .check__box { background: var(--low); border-color: var(--low); }
.check.is-on .check__box svg { opacity: 1; }

.streak { display: flex; align-items: baseline; gap: 8px; }
.streak b { font-family: var(--display); font-size: 40px; line-height: 1; color: #F4A57F; }
.grid30 { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.grid30 span { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--soft); color: var(--muted); min-width: 0; }
.grid30 span.is-done { background: var(--low); color: #fff; }
.grid30 span.is-today { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- meal checker ---------- */
.search { position: relative; }
.search .input { padding-left: 44px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.results { display: grid; gap: 6px; }
.result { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-align: left; }
.result__name { flex: 1; min-width: 0; font-weight: 650; line-height: 1.25; }
.result__serv { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.dot { flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%; }
.dot--low { background: var(--low); } .dot--med { background: var(--med); } .dot--high { background: var(--high); }
.add { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 22px; font-weight: 700; line-height: 1; }
.groups { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.groups::-webkit-scrollbar { display: none; }
.groups .chip { white-space: nowrap; flex-shrink: 0; }

.plate { display: grid; gap: 8px; }
.plate__item { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; padding: 12px; border-radius: 14px; background: var(--soft); min-width: 0; }
.plate__name { font-weight: 700; line-height: 1.25; min-width: 0; }
.plate__name small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.remove { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--card); color: var(--muted); font-size: 20px; line-height: 1; }
.portions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.portions button { min-height: 36px; min-width: 52px; padding: 4px 10px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 14px; }
.portions button.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

.meter { border-radius: var(--radius); padding: 18px; display: grid; gap: 10px; }
.meter--low { background: var(--low-soft); } .meter--med { background: var(--med-soft); } .meter--high { background: var(--high-soft); } .meter--none { background: var(--soft); }
.meter__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.meter__label { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.05; }
.meter--low .meter__label { color: var(--low); } .meter--med .meter__label { color: #9A6300; } .meter--high .meter__label { color: var(--high); }
.meter__num { font-weight: 700; color: var(--muted); font-size: 14px; }
.bar { position: relative; height: 12px; border-radius: 999px; background: linear-gradient(90deg, var(--low) 0 25%, var(--med) 25% 50%, var(--high) 50% 100%); }
.bar i { position: absolute; top: 50%; width: 22px; height: 22px; margin-left: -11px; transform: translateY(-50%); border-radius: 50%; background: #fff; border: 4px solid var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: left .25s ease; }
.bar-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 650; }
.tips { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.tips li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; font-size: 15px; line-height: 1.45; }
.tips li::before { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 15px no-repeat; }
.tips b { font-weight: 750; }

/* ---------- log ---------- */
.field { display: grid; gap: 6px; }
.value-row { display: flex; align-items: center; gap: 10px; }
.value-row .input { font-size: 26px; font-weight: 700; text-align: center; max-width: 160px; }
.unit { font-weight: 700; color: var(--muted); }
.scale5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale5 button { min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-weight: 750; }
.scale5 button.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.scale-hint { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: 170px; display: block; }
.history { display: grid; gap: 8px; }
.entry { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); min-width: 0; }
.entry__main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.entry__title { font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.entry__sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.entry__val { font-family: var(--display); font-weight: 700; font-size: 22px; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill--low { background: var(--low-soft); color: var(--low); } .pill--med { background: var(--med-soft); color: #8A5A00; } .pill--high { background: var(--high-soft); color: var(--high); }

/* ---------- plan / more ---------- */
.week { display: grid; gap: 6px; padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.week.is-now { border: 2px solid var(--accent); }
.week__head { display: flex; align-items: center; gap: 10px; min-height: 24px; }
.week__badge { justify-self: start; font-size: 12px; font-weight: 800; color: #fff; background: var(--accent); padding: 3px 10px; border-radius: 999px; }
.acc { border: 1px solid var(--line); border-radius: 16px; background: var(--card); overflow: hidden; }
.acc summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 15px 16px; font-weight: 750; line-height: 1.3; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary .num { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 14px; font-weight: 800; }
.acc summary .grow { flex: 1; min-width: 0; }
.acc summary::after { content: "+"; font-size: 22px; font-weight: 500; color: var(--muted); }
.acc[open] summary::after { content: "–"; }
.acc .acc__body { padding: 0 16px 16px 58px; color: var(--muted); font-size: 15px; display: grid; gap: 8px; }
.swaps { display: grid; gap: 8px; }
.swap { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 14.5px; line-height: 1.35; }
.swap .from { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(195, 50, 28, .6); }
.swap .to { font-weight: 700; }
.swap .arrow { color: var(--accent); font-weight: 800; }
.list-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); text-align: left; }
.list-link .grow { flex: 1; min-width: 0; font-weight: 700; line-height: 1.3; }
.list-link .grow small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.list-link::after { content: "›"; font-size: 24px; color: var(--muted); }
.recipe-list { display: grid; gap: 8px; }
.ingredients, .steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.back { justify-self: start; display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 700; text-decoration: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.note { font-size: 13px; color: var(--muted); line-height: 1.45; }

@media (min-width: 700px) {
  .tabs { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 18px 18px 0 0; }
}
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }

/* sticky plate summary on Check */
.platebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px); z-index: 15; width: min(528px, calc(100vw - 32px)); display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border: 0; border-radius: 16px; background: var(--ink); color: #fff; text-align: left; box-shadow: 0 10px 24px rgba(43, 24, 16, .28); }
.platebar .grow { flex: 1; min-width: 0; font-weight: 700; line-height: 1.25; }
.platebar small { display: block; font-weight: 500; font-size: 13px; color: #E6D6C8; }
body.has-platebar .view { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 96px); }
#meter-wrap { scroll-margin-top: 76px; }
.platebar.is-away { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }
.platebar { transition: opacity .2s ease, transform .2s ease; }
body.has-platebar .toast { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 88px); }
