:root {
  --bg: #111318;
  --card: #1a1d24;
  --line: rgba(255,255,255,.08);
  --text: #f4f6fb;
  --muted: rgba(244,246,251,.68);
  --dim: rgba(244,246,251,.45);
  --cal: #4cd964;
  --pro: #5ac8fa;
  --carb: #ffd60a;
  --over: #ff6b6b;
  --fill: rgba(255,255,255,.12);
  --accent: #4cd964;
  --radius: 18px;
  --pad: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0);
}

.screen { min-height: 100dvh; }
#app {
  max-width: 42rem;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bot) + 28px);
  display: grid;
  gap: 14px;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 2px;
}
h1 { font-size: 1.7rem; margin: 0; letter-spacing: -0.03em; }
h2 { font-size: .92rem; margin: 0 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.eyebrow { margin: 0; color: var(--muted); font-size: .86rem; font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}
.hero .remain {
  margin: 2px 0 0;
  font-size: 2.4rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.hero .remain.over { color: var(--over); }
.bars { display: grid; gap: 14px; margin-top: 18px; }
.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .92rem;
  margin-bottom: 6px;
}
.metric-row.dim { color: var(--dim); font-size: .82rem; margin: 6px 0 0; }
.track { height: 8px; background: var(--fill); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: inherit; }
.fill.cal { background: var(--cal); }
.fill.pro { background: var(--pro); }
.fill.over { background: var(--over); }
#carb-val { color: var(--carb); font-weight: 650; font-variant-numeric: tabular-nums; }
.meta { margin: 14px 0 0; color: var(--dim); font-size: .82rem; }
.section-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.section-row h2 { margin: 0; }
.section-row .meta { margin: 0; }

.meals { display: grid; gap: 16px; }
.meal h3 {
  margin: 0 0 8px;
  font-size: .95rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-transform: capitalize;
}
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: .95rem;
}
.row .food { min-width: 0; }
.row .food .name { display: block; }
.row .food .when { color: var(--dim); font-size: .78rem; margin-top: 2px; }
.row .kcal { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--dim); margin: 0; }

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
  height: 132px;
  margin-top: 6px;
}
.day-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  min-width: 0;
}
.day-col .bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--fill);
  border-radius: 8px 8px 6px 6px;
  overflow: hidden;
}
.day-col .bar {
  width: 100%;
  background: var(--cal);
  min-height: 0;
  border-radius: 8px 8px 0 0;
}
.day-col.over .bar { background: var(--over); }
.day-col.active .bar-wrap { outline: 2px solid rgba(255,255,255,.35); outline-offset: 1px; }
.day-col .lbl { font-size: .7rem; color: var(--dim); }
.day-col.active .lbl { color: var(--text); }

.recent, .regulars { display: grid; gap: 0; }
.recent button, .regular-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--line);
  color: inherit;
  padding: 12px 0;
}
.recent button:first-child, .regular-row:first-child { border-top: 0; padding-top: 4px; }
.recent .when, .regular-row .name { font-weight: 550; }
.recent .nums, .regular-row .nums { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; text-align: right; }
.ghost {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 36px;
}
.banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #20242d;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--muted);
  font-size: .9rem;
}
.banner p { margin: 0; }
.footnote { margin: 4px 2px 0; color: var(--dim); font-size: .8rem; text-align: center; }

#lock {
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bot) + 24px);
}
#lock[hidden], #app[hidden], [hidden] { display: none !important; }
.lock-card { width: min(100%, 22rem); text-align: center; }
.lock-card h1 { font-size: 2rem; }
#login-form { display: grid; gap: 10px; margin-top: 22px; }
input[type="password"] {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1.05rem;
  min-height: 52px;
}
#login-btn {
  background: var(--accent);
  color: #0b120d;
  border: 0;
  border-radius: 14px;
  min-height: 52px;
  font-weight: 700;
}
.error { color: var(--over); margin: 0; font-size: .9rem; }
.mark {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px;
  background: #16181d url("/icon-192.png") center / 64px 64px no-repeat;
  border: 1px solid var(--line);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f7;
    --card: #ffffff;
    --line: rgba(16,18,23,.08);
    --text: #15171c;
    --muted: rgba(21,23,28,.66);
    --dim: rgba(21,23,28,.45);
    --fill: rgba(16,18,23,.1);
    color-scheme: light;
  }
  .banner { background: #eceef3; }
  #login-btn { color: #0b120d; }
  input[type="password"] { background: #fff; }
}
