:root {
  /* day */
  --page: #faf6ef;
  --card: #ffffff;
  --ink: #2b2925;
  --ink-2: #6f6a60;
  --line: #ece5d8;
  --accent: #9a5b13;
  --sleep: #2a78d6;
  --sleep-tint: #e6f0fc;
  --sleep-ink: #184f95;
  --feed: #eb6834;
  --feed-tint: #fdeee6;
  --feed-ink: #9c3a12;
  --diaper: #1baf7a;
  --diaper-tint: #e3f6ee;
  --diaper-ink: #0b6645;
  --memory-tint: #fbeaf1;
  --memory-ink: #8a2c5c;
  --danger: #b3261e;
  /* night */
  --n-page: #000000;
  --n-tile: #131211;
  --n-edge: #2c2c2a;
  --n-label: #888780;
  --n-icon: #ba7517;
  --n-line: #d3d1c7;
  --n-on: #412402;
  --n-on-edge: #854f0b;
  --n-on-ink: #fac775;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

body.is-night { background: var(--n-page); }

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- night log ---------- */

.night {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 44px) 18px calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  user-select: none;
}

.night .pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.tile-n {
  height: clamp(104px, 17dvh, 150px);
  background: var(--n-tile);
  border: 1px solid var(--n-edge);
  border-radius: 22px;
  color: var(--n-label);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.tile-n svg { width: 42px; height: 42px; stroke: var(--n-icon); stroke-width: 1.5; }
.tile-n:active { background: var(--n-edge); transform: scale(0.97); }
.tile-n.on { background: var(--n-on); border-color: var(--n-on-edge); color: var(--n-on-ink); }
.tile-n.on svg { stroke: var(--n-on-ink); }
.tile-n.tapped { border-color: var(--n-icon); }
.tile-n.nope { animation: nope 0.3s; }

.night .line {
  color: var(--n-line);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  margin: 10px 0 20px;
  min-height: 22px;
}

.undo-row { display: flex; justify-content: center; min-height: 40px; }
.undo {
  background: transparent;
  border: 1px solid var(--n-edge);
  border-radius: 16px;
  color: var(--n-label);
  font-size: 14px;
  padding: 8px 20px;
}
.undo:active { background: var(--n-edge); }

.night-exit {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 6px);
  right: 12px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 0;
  color: #444441;
  display: grid;
  place-items: center;
}
.night-exit svg { width: 22px; height: 22px; }

@keyframes nope {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- day screens ---------- */

.day {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.top h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.top .date { color: var(--ink-2); font-size: 15px; }
.top .date::first-letter { text-transform: uppercase; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 12px;
}
.card h2 { font-size: 17px; font-weight: 600; }

.g-sleep { --c: var(--sleep); --tint: var(--sleep-tint); --cink: var(--sleep-ink); }
.g-feed { --c: var(--feed); --tint: var(--feed-tint); --cink: var(--feed-ink); }
.g-diaper { --c: var(--diaper); --tint: var(--diaper-tint); --cink: var(--diaper-ink); }

.subject-head { display: flex; align-items: center; gap: 12px; }
.badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--tint);
  color: var(--cink);
  display: grid;
  place-items: center;
  flex: none;
}
.badge svg { width: 26px; height: 26px; }
.status { color: var(--ink-2); font-size: 15px; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.act {
  flex: 1;
  min-height: 52px;
  border-radius: 16px;
  border: 0;
  background: var(--tint);
  color: var(--cink);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s;
}
.act svg { width: 22px; height: 22px; }
.act.strong { background: var(--cink); color: #ffffff; }
.act:active { transform: scale(0.98); }
.act.nope { animation: nope 0.3s; }
.sub { color: var(--ink-2); font-size: 14px; margin-top: 10px; }

.log { list-style: none; margin: 8px 0 0; padding: 0; }
.log li + li { border-top: 1px solid var(--line); }
.log button {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.log .dot {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--tint);
  color: var(--cink);
  display: grid;
  place-items: center;
  flex: none;
}
.log .dot svg { width: 19px; height: 19px; }
.log .what { flex: 1; }
.log time { color: var(--ink-2); font-variant-numeric: tabular-nums; }

.empty { color: var(--ink-2); font-size: 15px; padding: 10px 0 4px; }

.add {
  margin-top: 10px;
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px dashed #d9cfbd;
  background: transparent;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.add svg { width: 18px; height: 18px; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  max-width: 160px;
  background: transparent;
  border: 0;
  border-radius: 14px;
  padding: 6px 0;
  color: var(--ink-2);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); font-weight: 600; }
.tab { position: relative; }
/* A reminder is waiting on the Today screen. */
.tab.has-due::after {
  content: '';
  position: absolute;
  top: 3px;
  left: calc(50% + 7px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--feed);
  border: 2px solid #ffffff;
}

/* ---------- reminders and memory ideas ---------- */

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.link {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  min-height: 44px;
  padding: 0 6px;
  margin: -10px -6px;
}

.rems { list-style: none; margin: 6px 0 -6px; padding: 0; }
.rems li + li { border-top: 1px solid var(--line); }
.rem {
  width: 100%;
  min-height: 58px;
  background: transparent;
  border: 0;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.rem .tick {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  color: transparent;
  display: grid;
  place-items: center;
  flex: none;
  transition: background 0.15s;
}
.rem .tick svg { width: 18px; height: 18px; stroke-width: 2.4; }
.rem.done .tick { background: var(--accent); color: #ffffff; }
.rem.waiting .tick { border-color: #d9cfbd; color: #b3a892; }
.rem:active .tick { transform: scale(0.92); }
.rem-text { display: flex; flex-direction: column; min-width: 0; }
.rem-text b { font-weight: 600; overflow-wrap: anywhere; }
.rem-text small { color: var(--ink-2); font-size: 14px; }
.rem.due small { color: var(--accent); font-weight: 500; }
.rem.done b, .rem.waiting b { color: var(--ink-2); font-weight: 500; }

.memory { --tint: var(--memory-tint); --cink: var(--memory-ink); }
.memory .idea { font-size: 17px; line-height: 1.4; margin-top: 12px; }
.memory .idea.kept { color: var(--ink-2); }
.act.quiet { background: transparent; border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; }
.thanks { display: flex; align-items: center; gap: 8px; color: var(--cink); font-weight: 600; margin-top: 12px; }
.thanks svg { width: 20px; height: 20px; flex: none; stroke-width: 2.2; }
.private { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-2); font-size: 13px; margin-top: 12px; }
.private svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }

/* ---------- charts ---------- */

.chips { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #ffffff; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.tile span { display: block; color: var(--ink-2); font-size: 12px; line-height: 1.25; min-height: 30px; }
.tile b { display: block; font-size: 20px; font-weight: 600; margin-top: 4px; }

.chart-card .hint { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.chart { display: block; width: 100%; height: auto; margin-top: 10px; stroke: none; }
.chart .tick { fill: #898781; font-size: 11px; stroke: none; }
.chart .tick-now { fill: var(--ink); font-weight: 600; }
.chart .hit { cursor: pointer; }
.tip { color: var(--ink-2); font-size: 13px; margin-top: 6px; min-height: 18px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; background: var(--c); }
.sw-box { width: 12px; height: 12px; border-radius: 3px; }
.sw-dot { width: 10px; height: 10px; border-radius: 50%; }
.sw-tick { width: 5px; height: 12px; border-radius: 2px; }

.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.data th, .data td { padding: 7px 4px; text-align: right; border-top: 1px solid var(--line); font-weight: 400; }
.data thead th { border-top: 0; color: var(--ink-2); font-size: 12px; }
.data th[scope='row'] { text-align: left; color: var(--ink-2); }

/* ---------- dialogs ---------- */

dialog {
  border: 0;
  border-radius: 22px;
  padding: 20px;
  width: min(92vw, 400px);
  color: var(--ink);
  background: var(--card);
}
dialog::backdrop { background: rgba(30, 24, 14, 0.45); }
dialog h2 { font-size: 20px; margin-bottom: 14px; }
dialog label { display: block; margin-bottom: 12px; }
dialog label span { display: block; color: var(--ink-2); font-size: 13px; margin-bottom: 4px; }
dialog select, dialog input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #d9cfbd;
  border-radius: 12px;
  padding: 0 12px;
  background: #ffffff;
}
dialog .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
dialog .hint { color: var(--ink-2); font-size: 13px; margin: -4px 0 14px; }
dialog .error { color: var(--danger); font-size: 14px; min-height: 20px; }
dialog button {
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid #d9cfbd;
  background: #ffffff;
  padding: 0 16px;
}
dialog button.primary { background: var(--ink); border-color: var(--ink); color: #ffffff; font-weight: 600; }
dialog button.danger { color: var(--danger); border-color: #edc9c6; }
dialog button.wide { width: 100%; margin-bottom: 10px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

dialog h2:focus { outline: none; }
dialog h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 18px 0 8px; }
dialog .private { margin: 0 0 14px; }
dialog label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 4px; }
dialog label.check input { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--ink); }
dialog label.check span { display: inline; color: var(--ink); font-size: 16px; margin: 0; }

#reminders { max-height: 92dvh; overflow-y: auto; }
#reminders .hint { margin: -6px 0 0; }
.rem-edit { list-style: none; margin: 0; padding: 0; }
.rem-edit li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 8px;
  align-items: center;
  padding: 10px 0;
}
.rem-edit li + li { border-top: 1px solid var(--line); }
.rem-edit .name { font-weight: 600; overflow-wrap: anywhere; }
.rem-edit .none { display: block; color: var(--ink-2); font-size: 15px; padding: 4px 0; }
.rem-edit select { grid-column: 1; grid-row: 2; max-width: 210px; min-height: 40px; padding: 0 8px; font-size: 15px; }
.rem-edit button.icon { grid-column: 2; grid-row: 1 / span 2; }
/* The way out stays in reach however long the list gets. */
#reminders .dialog-actions {
  position: sticky;
  bottom: -20px;
  margin: 8px -20px -20px;
  padding: 10px 20px 20px;
  background: var(--card);
  border-top: 1px solid var(--line);
}
dialog button.icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-color: transparent;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  flex: none;
}
dialog button.icon svg { width: 18px; height: 18px; }
.rem-presets { display: flex; flex-wrap: wrap; gap: 8px; }
dialog button.pill {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 14px 0 10px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
dialog button.pill svg { width: 16px; height: 16px; color: var(--accent); }
.rem-new { display: flex; gap: 8px; margin-bottom: 8px; }
.rem-new input { flex: 1; min-width: 0; }
.grow { flex: 1; }

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