:root {
  color-scheme: light dark;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --text: #1d1c1a;
  --muted: #6a6761;
  --line: #e2dfd8;
  --accent: #2d6a5b;
  --on-accent: #ffffff;
  --accent-soft: #e3f1ec;
  --warn: #8a5a00;
  --warn-soft: #fbefd2;
  --danger: #a3352b;
  /* Chart series. Validated as a pair against the card surface in each mode. */
  --series-left: #2a78d6;
  --series-right: #eb6834;
  --tabs-height: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151413;
    --surface: #211f1d;
    --text: #f2f0eb;
    --muted: #a39e96;
    --line: #37342f;
    --accent: #74c2ab;
    --on-accent: #0f211c;
    --accent-soft: #1c302a;
    --warn: #e5b955;
    --warn-soft: #33290f;
    --danger: #f0958b;
    --series-left: #3987e5;
    --series-right: #d95926;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + var(--tabs-height) + 28px);
}
.boot, .notice { padding: 48px 8px; color: var(--muted); text-align: center; }

h1 { margin: 0; font-size: 26px; line-height: 1.25; }
h2 { margin: 0 0 12px; font-size: 18px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 15px; }
.header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 16px; }
.sync { color: var(--muted); font-size: 14px; white-space: nowrap; }
.sync[data-state="waiting"] { color: var(--warn); }

.card { margin: 0 0 16px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.btn {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 18px;
  font-weight: 600;
}
.btn.quiet { border: 1px solid var(--line); background: transparent; color: var(--text); font-weight: 500; }
.btn.small { flex: none; min-height: 40px; width: auto; padding: 0 14px; font-size: 15px; white-space: nowrap; }
.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.45; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.link { padding: 6px 4px; border: 0; background: none; color: var(--muted); font-size: 14px; text-decoration: underline; }

/* The two breasts, side by side. */
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.side { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.side-name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.side-gap { font-size: 20px; font-weight: 600; line-height: 1.3; }
.side[data-state="late"] { border-color: var(--warn); background: var(--warn-soft); }
.side[data-state="late"] .side-gap { color: var(--warn); }
.tag { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.dot.left { background: var(--series-left); }
.dot.right { background: var(--series-right); }

.feed-list { margin: 12px 0 0; padding: 0; list-style: none; }
.feed-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }

/* One row per thing to tick off. The whole row is the button. */
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 8px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
}
.check:first-of-type { border-top: 0; }
.check .box {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--muted);
  border-radius: 9px;
  color: transparent;
  font-size: 18px;
  font-weight: 700;
}
.check .name { flex: 1; font-weight: 500; }
.check .when { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.check[aria-pressed="true"] .box { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.check[aria-pressed="true"] .name { color: var(--muted); }
.check[data-late="true"] .box { border-color: var(--warn); }
.check[data-late="true"] .when { color: var(--warn); font-weight: 600; }

.tabs {
  position: fixed;
  inset: auto 0 0;
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.tabs button { flex: 1; max-width: 180px; height: var(--tabs-height); border: 0; background: none; color: var(--muted); font-size: 15px; }
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* Entry sheets slide up from the bottom, within thumb reach. */
dialog.sheet {
  width: 100%;
  max-width: 520px;
  margin: auto auto 0;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px);
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
}
dialog.sheet::backdrop { background: rgb(0 0 0 / 0.45); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chips button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: none; font-size: 15px; }
.chips button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 14px; }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-size: 17px;
}
.field.inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field.inline > span { margin: 0; }
.field.inline input[type="number"], .field.inline input[type="time"] { width: 130px; }
.field.inline input[type="checkbox"] { width: 24px; min-height: 24px; accent-color: var(--accent); }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.item-row:first-of-type { border-top: 0; }
.item-row[data-active="false"] .item-name { color: var(--muted); text-decoration: line-through; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabs-height) + 14px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  white-space: nowrap;
}
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; }

/* Charts. Marks carry the series color; all text stays in ink. */
.legend { display: flex; gap: 16px; margin-bottom: 4px; color: var(--muted); font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.readout { min-height: 24px; margin-bottom: 4px; font-size: 15px; font-variant-numeric: tabular-nums; }
.chart { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .band { fill: transparent; }
.chart .band[data-selected="true"] { fill: var(--bg); }
.chart .bar-left { fill: var(--series-left); }
.chart .bar-right { fill: var(--series-right); }
.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.grid-table th, .grid-table td { padding: 6px 4px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
.grid-table th:first-child, .grid-table td:first-child { text-align: left; }
.grid-table th { color: var(--muted); font-weight: 500; }
.table-scroll { overflow-x: auto; }
.streak { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.streak:first-of-type { border-top: 0; }
.streak .name { flex: none; width: 5.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.streak .cells { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.streak .cell { height: 18px; border-radius: 3px; background: var(--line); }
.streak .cell[data-level="part"] { background: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.streak .cell[data-level="full"] { background: var(--accent); }
.streak .rate { flex: none; width: 3.2em; color: var(--muted); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); font-size: 15px; }
