:root {
  /* woodland at night: pine-dark greens, parchment text, honey accent */
  --bg: #10150f;
  --bg2: #161d15;
  --card: #1c241b;
  --card2: #263125;
  --line: #34412f;
  --text: #f1ead9;
  --dim: #b2b49f;
  --faint: #7d8471;
  --accent: #e3a857;
  --danger: #e2775f;
  --ok: #9fd08a;
  --sleep: #9db4e0;   /* owl at dusk */
  --breast: #eda59d;  /* rosehip */
  --bottle: #e6b86a;  /* acorn */
  --pump: #c7a6dd;    /* berries */
  --nappy: #8fcf9f;   /* fern */
  --med: #e57f62;     /* toadstool */
  --mum: #ecc76a;     /* buttercup */
  --growth: #b8cf72;  /* moss */
  --tree: #1f2a1e;
  --r: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
:root.light {
  --bg: #f3ecdc;
  --bg2: #ebe2cd;
  --card: #fffaf0;
  --card2: #f0e7d3;
  --line: #ddd1b6;
  --text: #2c2a1f;
  --dim: #6c6955;
  --faint: #9a957c;
  --accent: #a8691d;
  --danger: #b94a2f;
  --ok: #4f8a3a;
  --sleep: #4f6aa8;
  --breast: #c4605a;
  --bottle: #b47a1f;
  --pump: #85569f;
  --nappy: #3c8a55;
  --med: #c24f30;
  --mum: #a8800f;
  --growth: #6c8a1f;
  --tree: #dcd2b8;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text); }
body {
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100dvh; overscroll-behavior-y: none; touch-action: manipulation;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, select, textarea {
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; width: 100%; min-height: 48px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 72px; resize: vertical; }
h1, h2, h3 { margin: 0; font-weight: 650; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
#app { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-t) + 8px) 14px calc(96px + var(--safe-b)); position: relative; }
/* a treeline behind the header */
body::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: calc(var(--safe-t) + 118px); z-index: -1; pointer-events: none;
  background: var(--tree);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='118' viewBox='0 0 240 118'%3E%3Cpath d='M0 118V96l10-18 8 14 12-30 12 30 6-12 10 20 14-40 14 40 8-16 10 18 12-34 12 34 9-22 9 22 12-28 12 28 7-14 9 16 13-38 13 38 6-10 6 6V118z' fill='black'/%3E%3C/svg%3E") repeat-x bottom / 240px 118px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='118' viewBox='0 0 240 118'%3E%3Cpath d='M0 118V96l10-18 8 14 12-30 12 30 6-12 10 20 14-40 14 40 8-16 10 18 12-34 12 34 9-22 9 22 12-28 12 28 7-14 9 16 13-38 13 38 6-10 6 6V118z' fill='black'/%3E%3C/svg%3E") repeat-x bottom / 240px 118px;
  opacity: 0.9;
}
body { position: relative; }
header.top { display: flex; align-items: center; gap: 12px; padding: 6px 2px 14px; }
header.top .who { flex: 1; min-width: 0; }
header.top h1 { font-size: 27px; letter-spacing: -0.2px; font-weight: 750; }
header.top .critter { font-size: 34px; line-height: 1; }
header.top .age { color: var(--dim); font-size: 14px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: inline-block; margin-right: 6px; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.iconbtn { width: 44px; height: 44px; border-radius: 14px; background: var(--card); display: grid; place-items: center; font-size: 20px; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg2) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--safe-b));
  display: flex; justify-content: center;
}
nav.tabs .inner { display: flex; width: 100%; max-width: 640px; }
nav.tabs a {
  flex: 1; text-align: center; text-decoration: none; color: var(--faint); font-size: 12px; padding: 6px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 12px;
}
nav.tabs a .ic { font-size: 22px; line-height: 1; filter: grayscale(0.8); opacity: 0.6; }
nav.tabs a.on { color: var(--text); }
nav.tabs a.on .ic { filter: none; opacity: 1; }

/* ---------- cards & tiles ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; }
.section { margin: 22px 2px 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--faint); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--card); border-radius: var(--r); padding: 14px; text-align: left; min-height: 104px;
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.tile::before { content: ""; position: absolute; inset: 10px auto 10px 0; width: 4px; border-radius: 0 4px 4px 0; background: var(--c); }
.tile .t .em { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 20%, transparent); }
.tile .t { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px; }
.tile .t .em { font-size: 20px; }
.tile .big { font-size: 20px; font-weight: 650; color: var(--c); }
.tile .sub { color: var(--dim); font-size: 13px; }
.tile.wide { grid-column: span 2; }
.tile.feed { min-height: 150px; }
.lr { display: grid; grid-template-columns: 1fr 1fr 0.8fr; gap: 8px; margin-top: auto; }
.lr button {
  background: color-mix(in srgb, var(--breast) 16%, var(--card2)); color: var(--text); border-radius: 14px;
  padding: 12px 0; font-weight: 700; font-size: 17px; border: 1px solid transparent;
}
.lr button.suggest { border-color: var(--breast); }
.lr button small { display: block; font-weight: 500; font-size: 11px; color: var(--dim); }

.running {
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 30%, var(--card)), var(--card));
  border-radius: var(--r); padding: 14px 16px; display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.running .em { font-size: 26px; }
.running .lbl { font-weight: 650; }
.running .time { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c); }
.running .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--c); animation: pulse 1.6s infinite; display: inline-block; margin-right: 6px; }
.running.paused .pulse { animation: none; opacity: 0.4; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 60%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.btn {
  white-space: nowrap;
  background: var(--card2); border-radius: 14px; padding: 12px 18px; font-weight: 650; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); color: #1f1608; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.c { background: var(--c); color: #15121a; }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: 0.45; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card2); border-radius: 999px; padding: 9px 14px; font-size: 15px; border: 1.5px solid transparent;
}
.chip.on { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--card2)); }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: var(--text); }

.seg { display: flex; background: var(--card); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 10px 0; border-radius: 10px; color: var(--dim); font-weight: 600; }
.seg button.on { background: var(--card2); color: var(--text); }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.summary .s { background: var(--card); border-radius: 14px; padding: 10px 8px; text-align: center; }
.summary .s b { display: block; font-size: 18px; color: var(--c); font-variant-numeric: tabular-nums; }
.summary .s span { font-size: 11px; color: var(--dim); }

.list { background: var(--card); border-radius: var(--r); overflow: hidden; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.item:first-child { border-top: 0; }
.item .dot { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 22%, transparent); font-size: 17px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .main .l1 { font-weight: 600; }
.item .main .l2 { color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .when { color: var(--dim); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.item .by { font-size: 11px; color: var(--faint); }

/* ---------- sheets ---------- */
#sheet-wrap { position: fixed; inset: 0; z-index: 40; display: none; }
#sheet-wrap.open { display: block; }
#sheet-wrap .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
#sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto;
  background: var(--bg2); border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + var(--safe-b));
  max-width: 640px; margin: 0 auto; animation: up 0.18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }
#sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
#sheet h2 { font-size: 21px; display: flex; align-items: center; gap: 10px; }
#sheet .field { display: flex; flex-direction: column; gap: 6px; }
#sheet .field > label, .lab { font-size: 13px; color: var(--dim); }
#sheet .actions { display: flex; gap: 10px; margin-top: 6px; }
#sheet .actions .btn { flex: 1; }
.notice { background: color-mix(in srgb, var(--accent) 14%, var(--card)); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.notice.warn { background: color-mix(in srgb, var(--danger) 18%, var(--card)); }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side {
  aspect-ratio: 1; border-radius: 50%; background: var(--card); border: 3px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.side .letter { font-size: 34px; font-weight: 800; }
.side .t { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--dim); }
.side .hint { font-size: 12px; color: var(--dim); min-height: 16px; }
.side.on { border-color: var(--breast); background: color-mix(in srgb, var(--breast) 20%, var(--card)); }
.side.on .t { color: var(--text); }
.side.suggest:not(.on) { border-style: dashed; border-color: var(--breast); }
.bigtime { text-align: center; font-size: 48px; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--c); letter-spacing: -1px; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 52px; height: 52px; border-radius: 14px; background: var(--card); font-size: 24px; }
.stepper input { text-align: center; font-size: 22px; font-weight: 650; }

/* ---------- day timeline ---------- */
.daybar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.daybar .title { flex: 1; text-align: center; font-weight: 650; }
.timeline { position: relative; background: var(--card); border-radius: var(--r); height: 960px; margin-top: 10px; }
.timeline .hr { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.timeline .hr span { position: absolute; left: 8px; top: -9px; font-size: 11px; color: var(--faint); background: var(--card); padding: 0 4px; }
.timeline .lane { position: absolute; top: 0; bottom: 0; }
.timeline .blk {
  position: absolute; left: 2px; right: 2px; border-radius: 8px; background: color-mix(in srgb, var(--c) 70%, transparent);
  min-height: 6px; font-size: 11px; padding: 2px 6px; color: #121018; overflow: hidden; font-weight: 600;
}
.timeline .mark {
  position: absolute; left: 2px; right: 2px; height: 22px; margin-top: -11px; border-radius: 11px; font-size: 12px;
  background: color-mix(in srgb, var(--c) 28%, var(--card2)); border-left: 3px solid var(--c); padding: 2px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.timeline .now { position: absolute; left: 40px; right: 0; border-top: 2px solid var(--accent); z-index: 3; }

/* ---------- week ---------- */
.week { display: grid; grid-template-columns: 30px repeat(7, 1fr); gap: 3px; }
.week .head { text-align: center; font-size: 12px; color: var(--dim); padding-bottom: 4px; }
.week .head b { display: block; font-size: 15px; color: var(--text); }
.week .head.today b { color: var(--accent); }
.week .hours { position: relative; height: 640px; }
.week .hours span { position: absolute; right: 2px; font-size: 10px; color: var(--faint); transform: translateY(-50%); }
.week .colm { position: relative; height: 640px; background: var(--card); border-radius: 8px; overflow: hidden; }
.week .colm .g { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); opacity: 0.6; }
.week .colm .w { position: absolute; border-radius: 3px; background: var(--c); }
.week .colm .w.sl { left: 6%; width: 44%; opacity: 0.85; }
.week .colm .w.fd { left: 54%; width: 40%; }
.week .colm .w.pt { left: 54%; width: 40%; height: 3px !important; }
.week .colm .w.nap { left: 30%; width: 40%; height: 3px !important; }
.week .foot { text-align: center; font-size: 11px; color: var(--dim); line-height: 1.35; padding-top: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12px; color: var(--dim); margin-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 5px; vertical-align: -1px; }

/* ---------- month ---------- */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month .wd { text-align: center; font-size: 11px; color: var(--faint); padding: 4px 0; }
.month .cell { background: var(--card); border-radius: 10px; min-height: 76px; padding: 5px; font-size: 11px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.month .cell.out { opacity: 0.35; }
.month .cell.today { outline: 2px solid var(--accent); }
.month .cell .n { font-weight: 700; font-size: 13px; }
.month .cell .m { display: flex; align-items: center; gap: 3px; color: var(--dim); }
.month .cell .m i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

/* ---------- meds ---------- */
.med { background: var(--card); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; border-left: 4px solid var(--c); }
.med .name { font-weight: 700; font-size: 17px; }
.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 10px; background: var(--card2); white-space: nowrap; }
.badge.late { background: color-mix(in srgb, var(--danger) 30%, var(--card2)); color: var(--text); }
.badge.ok { background: color-mix(in srgb, var(--ok) 22%, var(--card2)); }
.pips { display: flex; gap: 6px; }
.pips i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--c); }
.pips i.on { background: var(--c); }

/* ---------- login ---------- */
.login { max-width: 420px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 14px; }
.login .logo { width: 84px; height: 84px; border-radius: 24px; margin: 0 auto; display: block; }
.login h1 { text-align: center; font-size: 26px; }
.err { color: var(--danger); font-size: 14px; min-height: 18px; }
.toast {
  display: flex; align-items: center; gap: 14px;
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); z-index: 60;
  background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); max-width: 90vw;
}

.critters .chip { font-size: 22px; padding: 6px 10px; }

.toast-act { color: var(--accent); font-weight: 750; padding: 6px 4px; }
/* quick time buttons under date-time fields */
.tchips { display: flex; gap: 6px; flex-wrap: wrap; }
.tchips button { background: var(--card); border-radius: 10px; padding: 7px 11px; font-size: 14px; color: var(--dim); font-variant-numeric: tabular-nums; }
.tchips button:active { background: var(--card2); color: var(--text); }
/* the "last fed" panel */
.lastfed { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 2px 0 2px; }
.lastfed .ago { font-size: 30px; font-weight: 800; color: var(--breast); letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.lastfed .lbl { color: var(--dim); font-size: 14px; }
.nextside { font-size: 15px; }
.nextside b { color: var(--breast); }
.qn { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: auto; }
.qn button { background: color-mix(in srgb, var(--nappy) 16%, var(--card2)); border-radius: 12px; padding: 10px 0; font-weight: 700; font-size: 14px; }
.qn button:active { background: color-mix(in srgb, var(--nappy) 35%, var(--card2)); }

details.fold { background: var(--card); border-radius: var(--r); padding: 14px 16px; }
details.fold summary { cursor: pointer; font-weight: 650; list-style: none; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::before { content: "▸ "; color: var(--faint); }
details.fold[open] summary::before { content: "▾ "; }

.lr button.bottlebtn { background: color-mix(in srgb, var(--bottle) 16%, var(--card2)); font-size: 15px; }
.feedswitch button.on { background: color-mix(in srgb, var(--breast) 25%, var(--card2)); }
.feedswitch button[data-fmode="bottle"].on { background: color-mix(in srgb, var(--bottle) 25%, var(--card2)); }
