/* ============================================================== Crayon ===
   Bold, flat, unmissable. Everything is drawn with a thick ink outline and
   dropped on the page with a hard offset shadow — no blur, no gradients.
   Outfit at 800 for anything that has to be read at 3am.
   ======================================================================== */

:root {
  --bg: #fffdf6;
  --bg-tint: #f4efdf;
  --surface: #ffffff;
  --surface-2: #fffaea;
  --ink: #1b1a17;
  --ink-2: #45423c;
  --muted: #837e73;
  --line: #1b1a17;
  --line-soft: #ded9c8;

  --pee: #e0a413;
  --pee-soft: #ffe9ae;
  --poop: #b56b34;
  --poop-soft: #f6d9be;
  --feed: #109171;
  --feed-soft: #b4efdb;
  --sleep: #6250e0;
  --sleep-soft: #ded9ff;
  --danger: #cf3520;

  --on-ink: #fffdf6;
  --on-sleep: #ffffff;

  --r: 14px;
  --r-lg: 20px;
  --bw: 2px;
  --pop: 2px 3px 0 var(--line);
  --pop-sm: 2px 2px 0 var(--line);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --dock-h: calc(96px + var(--safe-b));
  --font: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14130f;
    --bg-tint: #2b2820;
    --surface: #1f1d17;
    --surface-2: #262319;
    --ink: #fdfbf4;
    --ink-2: #d6d2c6;
    --muted: #918b7d;
    --line: #fdfbf4;
    --line-soft: #3a362b;

    --pee: #ffc93f;
    --pee-soft: #453208;
    --poop: #e08a4a;
    --poop-soft: #3d2413;
    --feed: #2ad3a3;
    --feed-soft: #0b3d2f;
    --sleep: #9b8bff;
    --sleep-soft: #241d5a;
    --danger: #ff7d66;

    --on-ink: #14130f;
    --on-sleep: #14130f;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }
:focus-visible { outline: 3px solid var(--sleep); outline-offset: 2px; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(12px, env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: var(--bw) solid var(--line);
}

.topbar-row { display: flex; align-items: center; gap: 8px; }

.brand {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.025em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand span { color: var(--muted); font-weight: 600; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background .12s, color .12s;
}
.icon-btn:active { background: var(--bg-tint); }
.icon-btn.on {
  background: var(--ink);
  color: var(--on-ink);
}
.icon-btn svg { width: 19px; height: 19px; }

/* ------------------------------------------------------------ week strip */
.weekbar { display: flex; align-items: center; gap: 2px; margin-top: 9px; }
.week { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0 4px;
  border-radius: 12px;
  color: var(--ink-2);
}
.day:active { background: var(--bg-tint); }
.day .dow {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.day .num {
  font-size: 15px; font-weight: 700;
  width: 29px; height: 29px;
  display: grid; place-items: center;
  border-radius: 50%;
}
.day .dots { display: flex; gap: 3px; height: 4px; }
.day .dots i { width: 4px; height: 4px; border-radius: 50%; display: block; }
.day.today .num { box-shadow: inset 0 0 0 var(--bw) var(--line); }
.day.sel .num { background: var(--ink); color: var(--on-ink); font-weight: 800; box-shadow: none; }
.day.future { opacity: .35; }

.weeknav { width: 28px; height: 38px; display: grid; place-items: center; color: var(--muted); border-radius: 10px; }
.weeknav:active { background: var(--bg-tint); }
.weeknav svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ main */
main { flex: 1; padding: 15px 16px calc(var(--dock-h) + 22px); }

.datehead { display: flex; align-items: baseline; gap: 9px; margin-bottom: 13px; }
.datehead h2 { font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.datehead .sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.chip-btn {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  color: var(--ink);
  box-shadow: var(--pop-sm);
}
.chip-btn:active { transform: translate(2px, 2px); box-shadow: none; }

/* -------------------------------------------------------------- stat box */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 17px;
}
.stat {
  padding: 9px 3px 8px;
  text-align: center;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--pop-sm);
}
.stat .em { display: grid; place-items: center; height: 17px; }
.stat .em svg { width: 16px; height: 16px; }
.stat .v {
  font-size: clamp(15px, 4.2vw, 18px);
  font-weight: 800;
  letter-spacing: -.03em;
  margin-top: 3px;
}
.stat .k {
  font-size: 8.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}

/* -------------------------------------------------------------- timeline */
.section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

.timeline { display: flex; flex-direction: column; gap: 7px; }

.entry {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  box-shadow: var(--pop-sm);
  transition: transform .1s ease, box-shadow .1s ease;
}
.entry:active { transform: translate(2px, 2px); box-shadow: none; }

.entry .em {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: var(--bw) solid var(--line);
}
.entry .em svg { width: 19px; height: 19px; }
.entry .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry .title { display: block; font-weight: 800; font-size: 14.5px; letter-spacing: -.01em; }
.entry .meta { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.entry .note { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.entry .time { display: block; font-size: 12.5px; font-weight: 800; color: var(--ink-2); text-align: right; flex: none; }
.entry.live .time { color: var(--sleep); }

.entry .meta .dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 5px;
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.entry.t-pee   .em { color: var(--pee);   background: var(--pee-soft); }
.entry.t-poop  .em,
.entry.t-both  .em { color: var(--poop);  background: var(--poop-soft); }
.entry.t-feed  .em { color: var(--feed);  background: var(--feed-soft); }
.entry.t-sleep .em { color: var(--sleep); background: var(--sleep-soft); }

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
}
.empty .big {
  display: grid;
  place-items: center;
  height: auto;
  margin: 0 auto 14px;
  width: 62px;
  border-radius: 50%;
  border: var(--bw) solid var(--line-soft);
  padding: 15px;
  background: none;
  box-shadow: none;
  color: var(--muted);
}
.empty .big svg { width: 30px; height: 30px; }

/* ------------------------------------------------------------ sleep card */
.livecard {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  margin-bottom: 15px;
  border-radius: var(--r-lg);
  background: var(--sleep-soft);
  border: var(--bw) solid var(--line);
  box-shadow: var(--pop-sm);
}
.livecard .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--sleep);
  animation: pulse 2.4s ease-in-out infinite; flex: none;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.livecard .lbl {
  font-size: 9.5px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--sleep);
}
.livecard .val { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.livecard .val small { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.livecard button {
  margin-left: auto;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--sleep);
  border: var(--bw) solid var(--line);
  color: var(--on-sleep);
  font-weight: 800;
  font-size: 13px;
  box-shadow: var(--pop-sm);
}
.livecard button:active { transform: translate(2px, 2px); box-shadow: none; }

/* ------------------------------------------------------------------ dock */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: var(--bg);
  border-top: var(--bw) solid var(--line);
}
.dock-inner {
  max-width: 520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.big {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 68px;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  border: var(--bw) solid var(--line);
  box-shadow: var(--pop);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0;
  transition: transform .1s ease, box-shadow .1s ease;
  user-select: none;
  -webkit-user-select: none;
}
.big svg { width: 22px; height: 22px; }
.big:active { transform: translate(2px, 3px); box-shadow: none; }
.big.hold { transform: translate(2px, 3px); box-shadow: none; }
/* Tint the button and its icon, but keep the label in ink — amber-on-amber
   is unreadable at 3am. */
.big[data-t="pee"]      { background: var(--pee-soft); }
.big[data-t="pee"]  svg { color: var(--pee); }
.big[data-t="poop"]     { background: var(--poop-soft); }
.big[data-t="poop"] svg { color: var(--poop); }
.big[data-t="feed"]     { background: var(--feed-soft); }
.big[data-t="feed"] svg { color: var(--feed); }
.big[data-t="sleep"]    { background: var(--sleep-soft); }
.big[data-t="sleep"] svg { color: var(--sleep); }
.big.awake { background: var(--sleep); color: var(--on-sleep); }
.big.awake svg { color: var(--on-sleep); }

/* ---------------------------------------------------------------- sheets */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 19, 15, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  border-top: var(--bw) solid var(--line);
  border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(18px + var(--safe-b));
  max-height: 92vh;
  overflow-y: auto;
  animation: rise .22s cubic-bezier(.2, .8, .25, 1);
}
@keyframes rise { from { transform: translateY(100%); } }

.grabber { width: 40px; height: 4px; border-radius: 99px; background: var(--line-soft); margin: 6px auto 15px; }

.sheet h3 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.025em;
  margin-bottom: 17px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.sheet h3 svg { width: 21px; height: 21px; }

.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field > label .opt { letter-spacing: .07em; opacity: .7; }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 7px;
}
.seg button {
  padding: 11px 4px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  transition: transform .1s ease, box-shadow .1s ease, background .12s, color .12s;
}
.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 800;
  box-shadow: var(--pop-sm);
}

input[type="text"], input[type="number"], input[type="datetime-local"], input[type="password"], textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: var(--r);
  border: var(--bw) solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  outline: none;
  transition: box-shadow .12s;
}
input:focus, textarea:focus { box-shadow: var(--pop-sm); }
textarea { resize: none; }

/* --------------------------------------------------------------- colours */
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 9px 2px 7px;
  border-radius: var(--r);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  transition: transform .1s ease, box-shadow .1s ease, background .12s;
}
.swatch i {
  width: 26px; height: 26px; border-radius: 50%; display: block;
  box-shadow: inset 0 0 0 1.5px var(--ink);
}
.swatch span {
  font-size: 8.5px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted);
}
.swatch[aria-pressed="true"] { background: var(--bg-tint); box-shadow: var(--pop-sm); }
.swatch[aria-pressed="true"] span { color: var(--ink); font-weight: 800; }

.hint {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.45;
  margin-top: 11px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--pee-soft);
  border: var(--bw) solid var(--line);
}

/* -------------------------------------------------------------- controls */
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 50px; height: 50px; flex: none;
  border-radius: var(--r);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  box-shadow: var(--pop-sm);
  font-size: 21px; font-weight: 800; color: var(--ink);
  transition: transform .1s ease, box-shadow .1s ease;
}
.stepper button:active { transform: translate(2px, 2px); box-shadow: none; }
.stepper input { text-align: center; font-size: 20px; font-weight: 800; }
.stepper .unit {
  font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); width: 30px;
}

.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.quick button {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  font-size: 12.5px; font-weight: 700; color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .1s ease, background .12s;
}
.quick button svg { width: 15px; height: 15px; }
.quick button:active { transform: translate(1px, 1px); background: var(--bg-tint); }

.btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--r-lg);
  font-weight: 800;
  font-size: 16px;
  background: var(--ink);
  color: var(--on-ink);
  border: var(--bw) solid var(--line);
  box-shadow: var(--pop);
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn:active { transform: translate(2px, 3px); box-shadow: none; }
.btn.ghost {
  background: transparent; color: var(--muted);
  border-color: transparent; box-shadow: none;
  padding: 12px; font-size: 14px; font-weight: 700;
}
.btn.ghost:active { transform: none; }
.btn.danger {
  background: transparent; color: var(--danger);
  border-color: transparent; box-shadow: none;
  padding: 12px; font-size: 14px; font-weight: 700;
}
.btn.danger:active { transform: none; }
.row { display: flex; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- toasts */
.toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--dock-h) + 12px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink);
  color: var(--on-ink);
  border: var(--bw) solid var(--line);
  padding: 9px 10px 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  pointer-events: auto;
  animation: pop .2s ease;
  max-width: calc(100% - 32px);
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
.toast.out { animation: fadeout .18s ease forwards; }
@keyframes fadeout { to { opacity: 0; transform: translateY(6px); } }
.toast button {
  font-weight: 800; font-size: 11px;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--on-ink);
  color: var(--ink);
}

/* --------------------------------------------------------------- summary */
.card {
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--pop-sm);
  padding: 15px 16px;
  margin-bottom: 13px;
}
.card h3 {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 11px;
  margin-bottom: 14px;
  border-bottom: var(--bw) solid var(--line-soft);
}

.avgs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.avg .v { font-size: 25px; font-weight: 800; letter-spacing: -.04em; line-height: 1.15; }
.avg .k {
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 5px;
}
.avg .k svg { width: 13px; height: 13px; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; }
.bar-row .d { font-size: 11px; font-weight: 700; color: var(--muted); }
.bar-row .track {
  height: 20px;
  background: var(--bg-tint);
  border: var(--bw) solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}
.bar-row .track i { display: block; height: 100%; transition: width .35s ease; }
.bar-row .n { font-size: 11.5px; font-weight: 800; text-align: right; min-width: 34px; white-space: nowrap; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.legend span { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--muted); }
.legend i { width: 11px; height: 11px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1.5px var(--ink); }

.tally {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px;
  border-top: var(--bw) solid var(--line-soft);
}
.tally span {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  border: var(--bw) solid var(--line);
  padding: 3px 10px;
  border-radius: 999px;
}
.tally b { color: var(--ink); font-weight: 800; }
.tally i { width: 9px; height: 9px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1.5px var(--ink); }

/* ----------------------------------------------------------------- login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 320px; text-align: center; }
.login .mark {
  display: grid; place-items: center;
  width: 76px; height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: var(--bw) solid var(--line);
  background: var(--feed-soft);
  box-shadow: var(--pop);
  color: var(--feed);
}
.login .mark svg { width: 38px; height: 38px; }
.login h1 { font-size: 26px; font-weight: 800; letter-spacing: -.035em; margin-bottom: 4px; }
.login p { color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 22px; }
.login input { text-align: center; margin-bottom: 12px; padding: 14px; }
.login .err { color: var(--danger); font-size: 13px; font-weight: 700; margin-bottom: 10px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
