/* Health Log — one page, phone first. Colour roles are tokens so light and dark swap in one place. */
:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series: #2a78d6;       /* the one data colour: calories and weight */
  --series-track: #cde2fb; /* lighter step of the same ramp, for meter tracks */
  --over: #d03b3b;         /* over the goal — always paired with the words "over by" */
  --over-track: #f6d5d5;
  --good-text: #006300;
  --button-ink: #ffffff;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series: #3987e5;
    --series-track: #0d366b;
    --over: #e66767;
    --over-track: #4a1f1f;
    --good-text: #0ca30c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 2px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.stack { display: flex; flex-direction: column; gap: 10px; }

/* header + day nav */
.daynav { display: flex; align-items: center; gap: 4px; }
.daynav .label { min-width: 104px; text-align: center; font-weight: 600; font-size: 15px; }

button, .button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  min-height: 44px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.primary { background: var(--series); border-color: var(--series); color: var(--button-ink); font-weight: 600; }
button.icon { min-width: 44px; padding: 8px; font-size: 18px; line-height: 1; }
button.link { border: 0; background: none; color: var(--ink-2); text-decoration: underline; min-height: 44px; padding: 8px 4px; }
button:disabled { opacity: 0.55; cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, .bar-hit:focus-visible {
  outline: 2px solid var(--series);
  outline-offset: 2px;
}

textarea, input {
  font: inherit;
  width: 100%;
  color: var(--ink);
  background: var(--plane);
  border: 1px solid var(--axis);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 76px; resize: vertical; }
label { font-size: 13px; color: var(--ink-2); display: block; margin-bottom: 4px; }

/* hero figure: today's calories */
.hero { font-size: 52px; font-weight: 650; line-height: 1; letter-spacing: -0.02em; }
.hero-unit { font-size: 15px; color: var(--ink-2); font-weight: 500; }
.meter { height: 8px; border-radius: 999px; background: var(--series-track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--series); }
.meter.over { background: var(--over-track); }
.meter.over > span { background: var(--over); }
.meter.thin { height: 6px; }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.macro .value { font-weight: 600; }

/* log box */
.notice { font-size: 14px; padding: 10px 12px; border-radius: 10px; background: var(--plane); border: 1px solid var(--border); }
.notice.bad { border-color: var(--over); }

/* entries */
.meal-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 12px; }
.meal-title + .entry { border-top: 0; padding-top: 4px; }
.entry { border-top: 1px solid var(--grid); padding: 10px 0 2px; }
.entry:first-of-type { border-top: 0; }
.entry summary { list-style: none; display: flex; gap: 10px; align-items: baseline; cursor: pointer; min-height: 32px; }
.entry summary::-webkit-details-marker { display: none; }
.entry .kcal { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { font-size: 11px; border: 1px solid var(--axis); color: var(--ink-2); border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
.items { margin: 8px 0 4px; padding: 0; list-style: none; font-size: 14px; color: var(--ink-2); }
.items li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }

/* charts */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
/* value labels carry a surface-coloured halo so they stay readable where they cross a line */
.chart .value-label { fill: var(--ink); font-weight: 600; font-size: 12px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .goal { stroke: var(--ink-2); stroke-width: 1; }
.chart .bar { fill: var(--series); }
.chart .bar.selected, .chart .bar-hit:hover + .bar, .chart .bar-hit:focus + .bar { opacity: 0.8; }
.chart .none { stroke: var(--axis); stroke-width: 2; stroke-linecap: round; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .bar-hit, .chart .hit { fill: transparent; cursor: pointer; }
.chart .today text, .chart text.today { fill: var(--ink); font-weight: 600; }

.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--ink);
  color: var(--plane);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 13px;
  line-height: 1.3;
  max-width: 220px;
}
.tip strong { display: block; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 4px 6px 4px 0; border-top: 1px solid var(--grid); }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; padding-right: 0; }
details.table > summary { font-size: 13px; color: var(--ink-2); cursor: pointer; min-height: 32px; display: flex; align-items: center; }

.usual { border-top: 1px solid var(--grid); padding: 8px 0; }
.usual:first-of-type { border-top: 0; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form .grow input { min-height: 44px; }
footer { text-align: center; }
