:root {
  --bg: #f6efe6;
  --card: #fffaf4;
  --ink: #3d3230;
  --muted: #8a7b74;
  --line: #eadfd3;
  --accent: #c2694a;      /* terracotta */
  --accent-soft: #f3d9cc;
  --sage: #7d9a7f;
  --sage-soft: #dfe9dd;
  --ochre: #d4a24c;
  --blue: #6f97b0;
  --danger: #b5483a;
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { font-size: 17px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
main { max-width: 560px; margin: 0 auto; padding: 18px 16px 110px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 10px; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 14px; box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(120, 80, 60, .06);
}
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

button, .btn {
  font: inherit; border: 0; border-radius: 999px; padding: 11px 18px;
  background: var(--accent); color: #fff; cursor: pointer; font-weight: 600;
}
button.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
button.soft { background: var(--accent-soft); color: var(--ink); }
button.sage { background: var(--sage-soft); color: var(--ink); }
button.danger { background: transparent; color: var(--danger); }
button:disabled { opacity: .45; }
button.full { width: 100%; }

label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.choice { display: grid; gap: 8px; }
.choice label {
  display: flex; gap: 10px; align-items: center; margin: 0; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-size: 16px;
}
.choice input { width: auto; accent-color: var(--accent); }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* header with date navigation */
.datebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.datebar h1 { margin: 0; font-size: 26px; text-align: center; flex: 1; }
.datebar button { background: var(--card); color: var(--ink); width: 44px; height: 44px; padding: 0; font-size: 20px; }

/* energy ring */
.energy { display: flex; gap: 18px; align-items: center; }
.ring { width: 128px; height: 128px; flex: none; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .big { font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1; }
.bars { flex: 1; display: grid; gap: 10px; }
.bar .lbl { display: flex; justify-content: space-between; font-size: 14px; }
.bar .track { height: 9px; border-radius: 9px; background: var(--line); overflow: hidden; margin-top: 3px; }
.bar .fill { height: 100%; border-radius: 9px; }

/* meals */
.meal h3 { display: flex; justify-content: space-between; align-items: baseline; }
.meal h3 span { font-family: system-ui, sans-serif; font-size: 14px; color: var(--muted); font-weight: 400; }
.item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); cursor: pointer; }
.item:first-of-type { border-top: 0; }
.item .name { font-size: 16px; }
.item .amt { font-size: 13px; color: var(--muted); }
.item .kc { white-space: nowrap; font-weight: 600; }

.water .glasses { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.water .g { width: 22px; height: 30px; border: 2px solid var(--blue); border-top: 0; border-radius: 0 0 6px 6px; position: relative; overflow: hidden; }
.water .g i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--blue); opacity: .55; }

.fab {
  position: fixed; right: max(18px, calc(50% - 262px)); bottom: 92px; width: 62px; height: 62px;
  border-radius: 50%; font-size: 32px; padding: 0; box-shadow: 0 8px 20px rgba(194, 105, 74, .4);
}

nav#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav#tabs button {
  flex: 1; max-width: 112px; background: transparent; color: var(--muted);
  font-size: 13px; padding: 10px 2px; border-radius: 12px; font-weight: 500;
}
nav#tabs button.on { color: var(--accent); background: var(--accent-soft); font-weight: 700; }

/* bottom sheet */
#sheet { position: fixed; inset: 0; background: rgba(40, 28, 24, .35); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
#sheet[hidden] { display: none; }
#sheet .panel {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.sugg { border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-top: 4px; max-height: 240px; overflow: auto; }
.sugg div { padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.sugg div:first-child { border-top: 0; }
.sugg small { color: var(--muted); display: block; }

#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 15px;
}
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps i { flex: 1; height: 5px; border-radius: 5px; background: var(--line); }
.steps i.on { background: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
td, th { padding: 7px 4px; border-top: 1px solid var(--line); text-align: right; }
th { color: var(--muted); font-weight: 500; font-size: 13px; border-top: 0; }
td:first-child, th:first-child { text-align: left; }
.note { background: var(--sage-soft); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin: 8px 0; }
.chart { width: 100%; height: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; background: var(--sage-soft); }
.pill.over { background: var(--accent-soft); }

nav#tabs[hidden], #toast[hidden] { display: none; }
