/* PetTrack — calm, legible, one-thumb usable.
   Palette: porcelain sage base; semantic event colors
   (water blue = pee, earth = poop, kibble amber = meal). */

:root {
  --paper: #f2f6f4;
  --card: #ffffff;
  --ink: #22312f;
  --ink-soft: #5c6e6a;
  --line: #dde6e2;
  --pee: #3f7f96;
  --pee-soft: #e3eff3;
  --poop: #7d5638;
  --poop-soft: #f0e7de;
  --meal: #b47c22;
  --meal-soft: #f6ecda;
  --water: #2e9e8f;
  --water-soft: #dff1ee;
  --ok: #4c8562;
  --warn: #c07f2c;
  --over: #b34a31;
  --over-soft: #f6e4de;
  --shadow: 0 1px 2px rgba(34, 49, 47, .06), 0 6px 20px rgba(34, 49, 47, .07);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151f1d;
    --card: #1e2b28;
    --ink: #e6eeec;
    --ink-soft: #93a5a0;
    --line: #2c3b38;
    --pee: #6cb2c9;
    --pee-soft: #1e3238;
    --poop: #c39a72;
    --poop-soft: #33291f;
    --meal: #d9a84e;
    --meal-soft: #362c19;
    --water: #5bc4b4;
    --water-soft: #1e3532;
    --ok: #6faf88;
    --warn: #d99c4a;
    --over: #d9705a;
    --over-soft: #3c241f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* taps are clicks, never zoom gestures (iOS double-tap zoom fix) */
  touch-action: manipulation;
}

/* controls shouldn't trigger the long-press selection magnifier */
button, .chip, .lbl, .hint {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  margin: 0;
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  background: var(--paper);
  color: var(--ink);
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

h1, h2, .count {
  font-family: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;
}

main, .top {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: calc(14px + env(safe-area-inset-top));
  padding-bottom: 6px;
}

.top h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.date { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }

.iconbtn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 16px;
}
.iconbtn:active { transform: scale(.94); }

/* ---------- status card + ring ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-top: 10px;
}

.ring-wrap { position: relative; width: 210px; margin: 0 auto; }
#ring { width: 210px; height: 210px; transform: rotate(-90deg); }

.ring-track {
  fill: none;
  stroke: var(--line);
  stroke-width: 12;
}
.ring-fill {
  fill: none;
  stroke: var(--ok);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 540.35; /* 2πr, r=86 */
  stroke-dashoffset: 540.35;
  transition: stroke-dashoffset 1s linear, stroke .5s;
}
.ring-warn .ring-fill { stroke: var(--warn); }
.ring-over .ring-fill { stroke: var(--over); animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse {
  50% { opacity: .55; }
}
@media (prefers-reduced-motion: reduce) {
  .ring-over .ring-fill { animation: none; }
  .ring-fill { transition: none; }
}

.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 30px;
}
.count { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.count-sub { color: var(--ink-soft); font-size: 14px; margin-top: 6px; }
.count-at { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.ring-over .count { color: var(--over); }

/* ---------- chips ---------- */

.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.chip {
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  border: none;
  white-space: nowrap;
}
.chip.pee  { background: var(--pee-soft);  color: var(--pee); }
.chip.poop { background: var(--poop-soft); color: var(--poop); }
.chip.meal { background: var(--meal-soft); color: var(--meal); }
.chip.water { background: var(--water-soft); color: var(--water); }
.chips.small { justify-content: flex-start; margin-top: 8px; }
.chips.small .chip { cursor: pointer; background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); }

/* ---------- timeline ---------- */

.tl-head { font-size: 18px; margin: 26px 2px 10px; }
.day-head {
  list-style: none;
  color: var(--ink-soft);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 18px 2px 8px;
}
.events { list-style: none; margin: 0; padding: 0; }
.event {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  border-left: 4px solid var(--line);
}
.event:active { transform: scale(.99); }
.event.pee   { border-left-color: var(--pee); }
.event.poop  { border-left-color: var(--poop); }
.event.both  { border-left-color: var(--ok); }
.event.meal  { border-left-color: var(--meal); }
.event.water { border-left-color: var(--water); }
.event.empty-try { border-left-color: var(--warn); }
.ev-time { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 14px; min-width: 66px; }
.ev-body { flex: 1; min-width: 0; }
.ev-main { font-weight: 700; font-size: 15.5px; }
.ev-notes {
  color: var(--ink-soft); font-size: 14px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty { color: var(--ink-soft); text-align: center; padding: 20px 10px; }

/* ---------- bottom actions ---------- */

.actions {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex; gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}
.action {
  flex: 1;
  border: none;
  border-radius: 18px;
  padding: 16px 10px;
  font-family: inherit;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: var(--shadow);
}
.action:active { transform: scale(.97); }
.act-potty { background: var(--pee); }
.act-meal  { background: var(--meal); }
.act-icon { font-size: 20px; }

/* ---------- sheets ---------- */

.backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 20, 18, .45);
  z-index: 40;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .2);
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  z-index: 50;
  max-height: 88dvh;
  overflow-y: auto;
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.sheet-bar {
  width: 42px; height: 4px; border-radius: 2px;
  background: var(--line);
  margin: 6px auto 2px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.sheet-head h2 { margin: 8px 0; font-size: 22px; }
.close { width: 38px; height: 38px; font-size: 15px; }

.field { margin: 14px 0; }
.lbl { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 7px; font-weight: 700; }
.pee-lbl { color: var(--pee); }
.poop-lbl { color: var(--poop); }
.hint { font-size: 13.5px; color: var(--ink-soft); margin: 8px 2px 0; }
.error { color: var(--over); font-size: 14px; }

/* segmented choices */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button, .tog {
  flex: 1;
  min-height: 48px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 6px;
  white-space: nowrap;
}
.seg button.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}
.seg.two .tog { min-height: 62px; font-size: 19px; font-weight: 700; }
.tog.pee.on   { background: var(--pee-soft);   border-color: var(--pee);   color: var(--pee); }
.tog.poop.on  { background: var(--poop-soft);  border-color: var(--poop);  color: var(--poop); }
.tog.food.on  { background: var(--meal-soft);  border-color: var(--meal);  color: var(--meal); }
.tog.water.on { background: var(--water-soft); border-color: var(--water); color: var(--water); }
.water-lbl { color: var(--water); }

input[type="text"], input[type="number"], input[type="password"],
input[type="time"], input[type="datetime-local"], textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
  font-size: 16px;
}
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--pee);
  outline-offset: 2px;
}

/* tertiary action that must still read as tappable, not as text */
.linkbtn {
  display: block;
  width: 100%;
  background: none;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  color: var(--pee);
  font-family: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
  padding: 12px;
  text-align: center;
}
.linkbtn:active { transform: scale(.98); }
.seg.when { gap: 6px; }
.seg.when button {
  flex: 1 1 auto;
  min-height: 44px;
  font-size: 14.5px;
  padding: 8px 10px;
}
/* tap-to-nudge time stepper: big buttons, no spinner wheels */
.stepper {
  margin-top: 10px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--card);
}
.day-row { display: flex; gap: 6px; }
.daybtn, .day-nav {
  flex: 1;
  min-height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  cursor: pointer;
}
.daybtn.on, .day-nav.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}
.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  cursor: default;
}
.day-nav .day-label { font-weight: 700; white-space: nowrap; }
.day-arrow {
  width: 40px;
  min-height: 40px;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 10px;
}
.day-arrow:active { transform: scale(.9); }
.time-readout {
  font-family: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -.01em;
  text-align: center;
  margin: 14px 0;
  font-variant-numeric: tabular-nums;
}
.time-readout.limit {
  color: var(--over);
  animation: at-limit .4s;
}
@keyframes at-limit {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@media (prefers-reduced-motion: reduce) {
  .time-readout.limit { animation: none; }
}
.nudges {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.nudges button {
  min-height: 52px;
  padding: 0 2px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.nudges button:active {
  transform: scale(.94);
  background: var(--pee-soft);
  border-color: var(--pee);
  color: var(--pee);
}
.stepper .linkbtn { margin-top: 10px; }
.stepper .dt-wrap { margin-top: 10px; }

/* custom date+time: a clearly tappable field, not naked text */
.dt-wrap {
  position: relative;
  display: block;
  margin-top: 10px;
  cursor: pointer;
}
.dt-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--pee);
  pointer-events: none;
}
.dt-wrap input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 54px;
  padding: 12px 12px 12px 46px;
  border: 2px solid var(--pee);
  background: var(--pee-soft);
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--ink); }
.check input { width: 22px; height: 22px; accent-color: var(--ok); }
#quietRange { margin-top: 10px; }

.meal-time-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.meal-time-row input { flex: 1; }
.meal-time-row .iconbtn { flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; }

/* buttons */
.sheet-actions {
  display: flex; gap: 10px;
  margin-top: 20px;
}
.btn {
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 18px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary {
  flex: 1;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.btn.danger {
  background: var(--over-soft);
  border-color: transparent;
  color: var(--over);
}
.btn.danger.armed {
  background: var(--over);
  color: #fff;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; }

/* ---------- pin gate ---------- */

.gate {
  position: fixed; inset: 0;
  background: var(--paper);
  z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
}
.gate-card { width: 100%; max-width: 340px; text-align: center; }
.gate-card h2 { font-size: 24px; }
.gate-card p { color: var(--ink-soft); font-size: 15px; }
.gate-card input {
  text-align: center; font-size: 24px; letter-spacing: .3em;
  margin-bottom: 12px;
}
.gate-card .btn { width: 100%; }

/* ---------- pet profile onboarding ---------- */

.ob-gate {
  display: block;
  overflow-y: auto;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  z-index: 90;
}
.ob-card {
  max-width: 440px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.ob-card { position: relative; }
.ob-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 38px; height: 38px;
  font-size: 15px;
}

/* breed combobox */
.combo { position: relative; }
.combo-sug {
  margin-top: 6px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.combo-sug button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.combo-sug button:last-child { border-bottom: none; }
.combo-sug button:active { background: var(--pee-soft); }
.combo-sug .combo-add { color: var(--pee); font-weight: 700; }

.ob-dots {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin: 4px 0 10px;
}
.ob-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line);
}
.ob-dots span.on { background: var(--ink); }
.ob-step h2 { margin: 8px 0 2px; font-size: 23px; }
.ob-sub { color: var(--ink-soft); font-size: 14.5px; margin: 4px 0 16px; }
.ob-actions { display: flex; gap: 10px; margin-top: 20px; }
.ob-actions .btn.primary { flex: 1; }
.ob-card .linkbtn { margin-top: 12px; }

.btn.wide { width: 100%; }
.btn.call {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  text-decoration: none;
  box-sizing: border-box;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: calc(104px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 15px;
  z-index: 60;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }

@media (min-width: 700px) {
  body { font-size: 16px; }
  .top { padding-top: 26px; }
}
