/* health.statue-of-us.com — docs/HEALTH.md.

   The museum's paper (cream, terracotta, the serif wordmark) on an app
   layout: one column, big tap targets, a bottom tab bar, bottom sheets
   for everything that is done quickly. Numbers are set in the system
   sans with tabular figures because a diary is read as a table. No zoom
   trick here — the layout is phone-first and simply widens. Every
   full-height rule uses dvh/svh; the shell pads for the safe areas. */

:root {
  --bg: #f7f0e8;
  --bg-soft: #efe5d4;
  --card: #fdf8f0;
  --fg: #3a3027;
  --fg-soft: #5e524a;
  --muted: #9d8a78;
  --line: #e3d6c2;
  --accent: #b06a5b;
  --accent-hover: #985649;
  --error: #b9523f;
  --protein: #5a809b;
  --carb: #6b7b5a;
  --fat: #c9a227;
  --tab-h: 58px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ── Shell ─────────────────────────────────────────────────────── */

.hl-top {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: calc(0.9rem + env(safe-area-inset-top, 0px)) 1.1rem 0.6rem;
}
.hl-brand { font-family: var(--serif); font-style: italic; font-size: 1.2rem; color: var(--fg); text-decoration: none; }
.hl-brand span { color: var(--muted); }
.hl-person { font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }

.hl-main {
  max-width: 40rem; margin: 0 auto; padding: 0 1rem;
  padding-bottom: calc(var(--tab-h) + 5.5rem + env(safe-area-inset-bottom, 0px));
}
.hl-gate .hl-main { padding-bottom: 2rem; }

.hl-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(253, 248, 240, 0.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.hl-tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.hl-tabs a.is-on { color: var(--accent); }
.hl-tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hl-card {
  background: var(--card); border: 1px solid rgba(58, 48, 39, 0.08); border-radius: 12px;
  padding: 1rem 1.1rem; margin: 0 0 0.9rem;
  box-shadow: 0 1px 1px rgba(58,48,39,.04), 0 6px 18px rgba(58,48,39,.06);
}
.hl-card h2 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.15rem; margin: 0 0 0.6rem; }
.hl-muted { color: var(--muted); }
.hl-small { font-size: 0.82rem; }
.hl-danger { color: var(--error); }

/* ── Buttons ───────────────────────────────────────────────────── */

.hl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0.55rem 1.1rem; border-radius: 10px;
  background: var(--bg-soft); color: var(--fg); border: 1px solid var(--line);
  font-size: 0.95rem;
}
.hl-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hl-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.hl-btn-primary:hover { background: var(--accent-hover); }
.hl-btn-danger { background: transparent; color: var(--error); border-color: rgba(185,82,63,.35); }
.hl-btn-small { min-height: 38px; padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.hl-btn-wide { width: 100%; }
.hl-btn[disabled] { opacity: 0.5; cursor: default; }
.hl-link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: 0.9rem; }
.hl-iconbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; line-height: 1; color: var(--fg-soft);
}
.hl-iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Date bar ──────────────────────────────────────────────────── */

.hl-datebar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.2rem 0 0.9rem; position: relative; }
.hl-date { flex: 1; min-height: 44px; background: none; border: none; font-family: var(--serif); font-style: italic; font-size: 1.25rem; color: var(--fg); }
.hl-date-input { position: absolute; left: 50%; top: 100%; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ── Summary ───────────────────────────────────────────────────── */

.hl-summary { display: grid; grid-template-columns: 7.2rem 1fr; gap: 1rem; align-items: center; }
.hl-ring {
  --p: 0; --ring: var(--accent);
  width: 7.2rem; height: 7.2rem; border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--bg-soft) 0);
  display: grid; place-items: center; position: relative;
}
.hl-ring.is-over { --ring: var(--error); }
.hl-ring-inner {
  width: 5.6rem; height: 5.6rem; border-radius: 50%; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.hl-ring-inner strong { font-size: 1.45rem; font-weight: 600; }
.hl-ring-inner small { font-size: 0.7rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.hl-summary-row { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--fg-soft); padding: 0.05rem 0; }
.hl-summary-row b { font-weight: 600; color: var(--fg); }
.hl-macros { margin-top: 0.5rem; display: grid; gap: 0.35rem; }
.hl-macro-head { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--fg-soft); }
.hl-macro-head b { font-weight: 500; }
.hl-bar { height: 6px; border-radius: 3px; background: var(--bg-soft); overflow: hidden; }
.hl-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--accent); transition: width 300ms ease; }
.hl-macro[data-macro="protein_g"] .hl-bar i { background: var(--protein); }
.hl-macro[data-macro="carb_g"] .hl-bar i { background: var(--carb); }
.hl-macro[data-macro="fat_g"] .hl-bar i { background: var(--fat); }
.hl-bar i.is-over { background: var(--error); }

.hl-setup p, .hl-checkin p { margin: 0.3rem 0 0.6rem; color: var(--fg-soft); font-size: 0.92rem; }
.hl-checkin-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.hl-checkin-actions { display: flex; gap: 0.5rem; }

/* ── Weight ────────────────────────────────────────────────────── */

.hl-weight { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 1.1rem; }
.hl-weight label { display: flex; flex-direction: column; font-size: 0.9rem; }
.hl-weight label small { font-size: 0.75rem; }
.hl-weight-field { display: flex; align-items: center; gap: 0.4rem; }
.hl-weight-field input {
  width: 5.2rem; min-height: 40px; text-align: right; font-size: 1.05rem; padding: 0.3rem 0.5rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.hl-unit { color: var(--muted); font-size: 0.85rem; }

/* ── Meals ─────────────────────────────────────────────────────── */

.hl-meal { background: var(--card); border: 1px solid rgba(58,48,39,.08); border-radius: 12px; margin-bottom: 0.9rem; overflow: hidden; }
.hl-meal-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.6rem 0.55rem 1.1rem; }
.hl-meal-head h2 { flex: 1; margin: 0; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.1rem; }
.hl-meal-kcal { color: var(--muted); font-size: 0.9rem; }
.hl-meal-more { width: 36px; height: 36px; font-size: 1.1rem; border-color: transparent; background: transparent; }
.hl-meal-add {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--accent); color: #fff;
  font-size: 1.5rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.hl-entries { list-style: none; margin: 0; padding: 0; }
.hl-entries:empty { display: none; }
.hl-entry {
  display: grid; grid-template-columns: 1fr auto; gap: 0 0.6rem; align-items: center;
  padding: 0.55rem 1.1rem; border-top: 1px solid var(--line); cursor: pointer; min-height: 48px;
}
.hl-entry:active { background: var(--bg-soft); }
.hl-entry-label { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-entry-sub { font-size: 0.78rem; color: var(--muted); grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-entry-kcal { grid-column: 2; grid-row: 1 / span 2; font-weight: 600; font-size: 0.95rem; }
.hl-entry-kcal small { display: block; font-weight: 400; color: var(--muted); font-size: 0.72rem; text-align: right; }
.hl-streak { text-align: center; font-size: 0.82rem; margin: 0.4rem 0 0; }


/* ── Sheets ────────────────────────────────────────────────────── */

.hl-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; margin: 0 auto; width: 100%; max-width: 40rem;
  max-height: 92dvh; border: none; border-radius: 16px 16px 0 0; padding: 0 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  background: var(--card); color: var(--fg); box-shadow: 0 -10px 40px rgba(58,48,39,.18);
  overflow-y: auto; overflow-x: hidden; overflow-x: clip;
}
.hl-sheet::backdrop { background: rgba(58,48,39,.35); }
.hl-sheet:not([open]) { display: none; }
.hl-sheet-short { max-height: 80dvh; }
.hl-sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0.6rem auto 0.4rem; }
.hl-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.3rem 0 0.6rem; position: sticky; top: 0; background: var(--card); z-index: 2; }
.hl-sheet-head strong { font-size: 1.05rem; }
.hl-sheet-close { width: 38px; height: 38px; }

.hl-chips { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.hl-chips button {
  min-height: 34px; padding: 0.25rem 0.8rem; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--fg-soft); font-size: 0.85rem;
}
.hl-chips button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.hl-chips-small button { min-height: 32px; font-size: 0.8rem; }

.hl-seg { display: flex; background: var(--bg-soft); border-radius: 10px; padding: 3px; margin: 0 0 0.8rem; }
.hl-seg button { flex: 1; min-height: 38px; border: none; border-radius: 8px; background: transparent; color: var(--fg-soft); font-size: 0.9rem; }
.hl-seg button.is-on { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(58,48,39,.12); }
.hl-seg-top { margin-top: 0.2rem; }

.hl-search-row { display: flex; gap: 0.5rem; align-items: center; }
.hl-search-row input {
  flex: 1; min-width: 0; min-height: 46px; font-size: 16px; padding: 0.5rem 0.8rem;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; -webkit-appearance: none;
}
.hl-results { margin-top: 0.6rem; }
.hl-results-head { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin: 0.9rem 0 0.3rem; }
.hl-result {
  display: grid; grid-template-columns: 1fr auto; gap: 0 0.6rem; align-items: center; width: 100%;
  padding: 0.55rem 0.3rem; border: none; border-top: 1px solid var(--line); background: transparent; text-align: left; min-height: 50px;
}
.hl-result:first-child { border-top: none; }
.hl-result:active { background: var(--bg-soft); }
.hl-result-name { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-result-sub { grid-column: 1; font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-result-kcal { grid-column: 2; grid-row: 1 / span 2; font-weight: 600; font-size: 0.9rem; text-align: right; }
.hl-result-kcal small { display: block; font-weight: 400; color: var(--muted); font-size: 0.7rem; }
.hl-results-empty { color: var(--muted); font-size: 0.9rem; padding: 0.8rem 0.3rem; }
.hl-results-foot { margin: 0.8rem 0 0; text-align: center; }

.hl-pane textarea {
  width: 100%; min-height: 5.5rem; font-size: 16px; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; resize: vertical;
}
.hl-describe-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.hl-describe-row .hl-btn-primary { flex: 1; }
.hl-describe-status { margin: 0.5rem 0 0; font-size: 0.85rem; min-height: 1.2em; }
.hl-ai-items { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.hl-ai-item { display: grid; grid-template-columns: auto 1fr auto; gap: 0 0.6rem; align-items: center; padding: 0.5rem 0; border-top: 1px solid var(--line); }
.hl-ai-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.hl-ai-item-name { font-size: 0.95rem; }
.hl-ai-item-sub { font-size: 0.78rem; color: var(--muted); }
.hl-ai-item-sub .is-low { color: var(--error); }
.hl-ai-item-kcal { font-weight: 600; text-align: right; }
.hl-ai-item-kcal input { width: 4.2rem; text-align: right; min-height: 34px; padding: 0.2rem 0.4rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 16px; }
.hl-ai-item-kcal small { display: block; font-weight: 400; color: var(--muted); font-size: 0.7rem; }
.hl-ai-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 0.8rem; }

.hl-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 0.7rem; margin: 0.4rem 0 0.8rem; }
.hl-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--fg-soft); min-width: 0; }
.hl-field input, .hl-field select {
  min-height: 44px; font-size: 16px; padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%; max-width: 100%;
}
.hl-field-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; margin: 0.8rem 0 0.3rem; }
.hl-field-row input { width: 6rem; }
.hl-span2 { grid-column: 1 / -1; }
.hl-inline { display: flex; gap: 0.4rem; }

.hl-portion-title { min-width: 0; display: flex; flex-direction: column; }
.hl-portion-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-portion-row { display: flex; gap: 0.6rem; align-items: center; }
.hl-stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.hl-stepper button { width: 44px; height: 44px; border: none; background: transparent; font-size: 1.3rem; color: var(--accent); }
.hl-stepper input { width: 3.6rem; min-height: 44px; border: none; text-align: center; font-size: 16px; background: transparent; -moz-appearance: textfield; }
.hl-stepper input::-webkit-outer-spin-button, .hl-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.hl-portion-row select { flex: 1; min-width: 0; min-height: 44px; font-size: 16px; padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.hl-portion-grams { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.6rem; color: var(--muted); font-size: 0.9rem; }
.hl-portion-grams input { width: 6rem; min-height: 40px; font-size: 16px; text-align: right; padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.hl-portion-nums { display: flex; justify-content: space-between; margin: 0.9rem 0; font-size: 0.9rem; color: var(--fg-soft); }
.hl-portion-nums b { display: block; font-size: 1.15rem; color: var(--fg); font-weight: 600; }
.hl-portion-nums span { text-align: center; }
.hl-portion-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; }

.hl-menu { display: flex; flex-direction: column; }
.hl-menu button { min-height: 50px; border: none; border-top: 1px solid var(--line); background: transparent; text-align: left; font-size: 1rem; padding: 0 0.3rem; }
.hl-menu button:first-child { border-top: none; }

.hl-scan-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.hl-scan-wrap video { width: 100%; height: 100%; object-fit: cover; }
.hl-scan-box { position: absolute; inset: 22% 12%; border: 2px solid rgba(255,255,255,.8); border-radius: 8px; }
#hl-scan-manual { margin-top: 0.6rem; }

.hl-toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 1.4rem + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: #fff; padding: 0.55rem 1rem; border-radius: 999px; font-size: 0.9rem; z-index: 30; max-width: 90%;
}

/* ── Trends ────────────────────────────────────────────────────── */

.hl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-bottom: 0.9rem; }
.hl-stat { background: var(--card); border: 1px solid rgba(58,48,39,.08); border-radius: 12px; padding: 0.7rem 0.6rem; display: flex; flex-direction: column; min-width: 0; }
.hl-stat small { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hl-stat b { font-size: 1.25rem; font-weight: 600; margin: 0.15rem 0; }
.hl-stat span { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-chart { position: relative; height: 220px; }
.hl-chart canvas { max-width: 100%; }
.hl-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.hl-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.3rem 0.2rem; }
.hl-table td { padding: 0.45rem 0.2rem; border-top: 1px solid var(--line); }
.hl-table td:not(:first-child), .hl-table th:not(:first-child) { text-align: right; }

/* ── Me ────────────────────────────────────────────────────────── */

.hl-targets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.hl-target { display: flex; flex-direction: column; align-items: center; background: var(--bg-soft); border-radius: 10px; padding: 0.5rem 0.2rem; }
.hl-target small { font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hl-target b { font-size: 1.1rem; font-weight: 600; }
.hl-reco { margin-top: 0.8rem; padding: 0.8rem; background: var(--bg-soft); border-radius: 10px; }
.hl-reco p { margin: 0 0 0.6rem; font-size: 0.92rem; }
.hl-details { margin-top: 0.6rem; }
.hl-details summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; min-height: 44px; display: flex; align-items: center; }
.hl-saved { list-style: none; margin: 0; padding: 0; }
.hl-saved li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-top: 1px solid var(--line); }
.hl-saved li:first-child { border-top: none; }
.hl-saved small { color: var(--muted); display: block; }
.hl-save-note { text-align: center; font-size: 0.85rem; min-height: 1.4em; }
.hl-signout { text-align: center; margin: 1.5rem 0; }

/* ── Gate / offline ────────────────────────────────────────────── */

.hl-login { text-align: center; max-width: 24rem; margin: 18vh auto 0; margin-top: 18svh; }
.hl-login-mark { width: 56px; height: 56px; margin: 0 auto 1.2rem; color: var(--accent); }
.hl-login-mark svg { width: 100%; height: 100%; }
.hl-login h1 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.9rem; margin: 0 0 1.4rem; }
.hl-login-form { display: flex; flex-direction: column; gap: 0.9rem; align-items: center; }
.hl-login-form input {
  width: 100%; font-family: var(--serif); font-style: italic; font-size: 1.2rem; text-align: center; min-height: 46px;
  background: transparent; border: none; border-bottom: 1px solid var(--muted); border-radius: 0; padding: 0.4rem;
}
.hl-login-form input:focus { outline: none; border-bottom-color: var(--accent); }
.hl-login-form button { letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.85rem; padding: 0.7rem 1.75rem; }
.hl-login-status { margin-top: 1.2rem; min-height: 1.4em; color: var(--muted); font-style: italic; }
.hl-login-status[data-state="error"] { color: var(--error); }
.hl-offline { text-align: center; padding-top: 20svh; }
.hl-offline h1 { font-family: var(--serif); font-style: italic; font-weight: 400; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
