:root {
  --bg: #FFF4E4;
  --ink: #4A3426;
  --muted: #A08571;
  --line: #F1E2D0;
  --pee-1: #FFE680;
  --pee-2: #FFC83D;
  --pee-edge: #E3A41B;
  --pee-ink: #6B4A00;
  --poop-1: #F6DABE;
  --poop-2: #E6B386;
  --poop-edge: #C38A5B;
  --poop-ink: #5A3418;
  --font: 'Varela Round', 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150' viewBox='0 0 150 150'%3E%3Cg fill='%23B98A5E' opacity='.09'%3E%3Cg transform='translate(34 38) rotate(-18)'%3E%3Cellipse cx='0' cy='8' rx='9' ry='7.5'/%3E%3Ccircle cx='-9.5' cy='-4' r='3.7'/%3E%3Ccircle cx='-3.3' cy='-9.5' r='3.7'/%3E%3Ccircle cx='3.8' cy='-9.5' r='3.7'/%3E%3Ccircle cx='10' cy='-4' r='3.7'/%3E%3C/g%3E%3Cg transform='translate(108 108) rotate(24)'%3E%3Cellipse cx='0' cy='8' rx='9' ry='7.5'/%3E%3Ccircle cx='-9.5' cy='-4' r='3.7'/%3E%3Ccircle cx='-3.3' cy='-9.5' r='3.7'/%3E%3Ccircle cx='3.8' cy='-9.5' r='3.7'/%3E%3Ccircle cx='10' cy='-4' r='3.7'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; cursor: pointer; -webkit-touch-callout: none; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 10px) 18px calc(env(safe-area-inset-bottom) + 96px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* top bar */
.top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.icon-btn {
  margin-inline-start: auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .75);
  display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(74, 52, 38, .08);
}
.icon-btn:active { transform: scale(.94); }
.status {
  border: 0;
  border-radius: 99px;
  padding: 8px 14px;
  font-size: 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(74, 52, 38, .08);
  display: inline-flex; align-items: center; gap: 8px;
  max-width: calc(100% - 60px);
}
.status[hidden] { display: none; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.warn { background: #FFF0D2; color: #9A5B00; }
.status.busy { color: #8A7462; }
.status.busy::before { animation: blink 1s ease-in-out infinite; }
.status.ok { background: #E9F7E4; color: #3D7A2E; }

/* hero */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; margin-top: -6px; }
.dog { width: 128px; height: 128px; transform-origin: 50% 85%; animation: tilt 6s ease-in-out infinite; }
.dog svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 0 rgba(139, 94, 60, .12)); }
.dog.happy { animation: wiggle .5s ease-in-out 2; }
.name-chip {
  margin: 4px 0 0;
  padding: 4px 14px;
  border-radius: 99px;
  background: #fff;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(74, 52, 38, .07);
}
.name-chip[hidden] { display: none; }
h1 { margin: 6px 0 0; font-size: 34px; font-weight: 400; letter-spacing: -.3px; }

/* the two big buttons */
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.big {
  --edge: var(--pee-edge);
  position: relative;
  border: 0;
  border-radius: 30px;
  min-height: 236px;
  padding: 20px 10px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  touch-action: manipulation;
  transition: transform .09s ease, box-shadow .09s ease;
  outline: none;
}
.big.pee {
  background: linear-gradient(180deg, var(--pee-1), var(--pee-2));
  color: var(--pee-ink);
  box-shadow: 0 8px 0 var(--pee-edge), 0 16px 26px rgba(227, 164, 27, .35);
}
.big.poop {
  --edge: var(--poop-edge);
  background: linear-gradient(180deg, var(--poop-1), var(--poop-2));
  color: var(--poop-ink);
  box-shadow: 0 8px 0 var(--poop-edge), 0 16px 26px rgba(195, 138, 91, .35);
}
.big:active, .big.pressed {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--edge), 0 6px 12px rgba(74, 52, 38, .18);
}
.big:focus-visible { box-shadow: 0 8px 0 var(--edge), 0 0 0 4px #fff, 0 0 0 7px var(--edge); }
.plate {
  width: 104px; height: 104px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
  display: grid; place-items: center;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .05), 0 4px 12px rgba(74, 52, 38, .10);
}
.plate .ico { width: 82px; height: 82px; }
.big.bounce .plate { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.big .label { font-size: 32px; line-height: 1; margin-top: 4px; }
.big .meta { font-size: 14px; line-height: 1.35; opacity: .85; min-height: 2.7em; white-space: pre-line; }

/* recent list */
.recent {
  background: rgba(255, 255, 255, .78);
  border-radius: 24px;
  padding: 14px 16px 8px;
  box-shadow: 0 4px 18px rgba(74, 52, 38, .07);
  margin-top: 6px;
}
.recent h2 { margin: 0 0 4px; font-size: 15px; font-weight: 400; color: var(--muted); }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }
.recent .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.recent .dot svg { width: 26px; height: 26px; }
.recent .dot.pee { background: #FFF1BF; }
.recent .dot.poop { background: #F6E0CC; }
.recent .what { font-size: 16px; }
.recent .when { margin-inline-start: auto; color: var(--muted); font-size: 14px; white-space: nowrap; }
.recent .tag { font-size: 12px; color: #A36A00; background: #FFF0CF; padding: 2px 8px; border-radius: 99px; }
.recent .del {
  border: 0; background: none; color: #CDB6A3;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
}
.recent .del:active { background: #F6E9DC; }
.recent .empty { margin: 4px 0 10px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.recent .empty[hidden] { display: none; }

/* toast */
.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  margin: 0 auto;
  max-width: 440px;
  background: #4A3426;
  color: #fff;
  border-radius: 18px;
  padding: 10px 10px 10px 10px;
  padding-inline-start: 16px;
  display: flex; align-items: center; gap: 12px;
  font-size: 16px;
  box-shadow: 0 12px 30px rgba(42, 26, 16, .28);
  transform: translateY(160%);
  transition: transform .28s cubic-bezier(.2, .9, .3, 1.15);
  z-index: 10;
}
.toast.show { transform: translateY(0); }
.toast button {
  margin-inline-start: auto;
  border: 0;
  background: #FFD45C;
  color: #4A3426;
  padding: 9px 16px;
  border-radius: 12px;
}
.toast button[hidden] { display: none; }

/* flying paws */
.particle {
  position: fixed; left: 0; top: 0;
  pointer-events: none;
  font-size: 24px;
  z-index: 20;
  animation: fly .9s cubic-bezier(.2, .7, .3, 1) forwards;
}

/* settings */
dialog {
  border: 0;
  border-radius: 26px;
  padding: 0;
  width: min(92vw, 440px);
  max-height: 90vh;
  color: var(--ink);
  background: #FFFBF5;
  box-shadow: 0 24px 60px rgba(42, 26, 16, .3);
}
dialog::backdrop { background: rgba(74, 52, 38, .38); }
dialog form { padding: 22px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-size: 24px; font-weight: 400; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
dialog input {
  font: inherit; font-size: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #EBD9C5;
  background: #fff;
  color: var(--ink);
  -webkit-user-select: text; user-select: text;
  width: 100%;
}
dialog input:focus { outline: none; border-color: var(--pee-2); }
dialog input[dir="ltr"] { text-align: left; }
.hint { margin: -4px 0 0; font-size: 14px; line-height: 1.45; padding: 10px 12px; border-radius: 12px; }
.hint[hidden] { display: none; }
.hint.good { background: #E9F7E4; color: #2F6B22; }
.hint.bad { background: #FDE8E4; color: #9B2F1D; }
.hint.wait { background: #F5EEE6; color: #7A6452; }
details { background: #FFF1DE; border-radius: 14px; padding: 10px 14px; font-size: 14px; line-height: 1.6; }
summary { cursor: pointer; font-size: 15px; }
details ol { margin: 8px 0 2px; padding-inline-start: 20px; }
details li { margin-bottom: 4px; }
details a { color: #9A5B00; }
.link { border: 0; background: none; padding: 0; color: #9A5B00; text-decoration: underline; font-size: inherit; }
.row { display: flex; gap: 10px; margin-top: 2px; }
.row button { border: 0; border-radius: 14px; padding: 13px 16px; font-size: 16px; }
.primary { flex: 1; background: var(--pee-2); color: var(--pee-ink); box-shadow: 0 4px 0 var(--pee-edge); }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pee-edge); }
.ghost { background: #F3E6D8; color: var(--ink); }

@keyframes tilt {
  0%, 72%, 100% { transform: rotate(0); }
  80% { transform: rotate(-9deg); }
  90% { transform: rotate(6deg); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-11deg) scale(1.07); }
  75% { transform: rotate(11deg) scale(1.07); }
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18) rotate(-6deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes fly {
  from { transform: translate(var(--x0), var(--y0)) scale(.5); opacity: 1; }
  to { transform: translate(calc(var(--x0) + var(--dx)), calc(var(--y0) + var(--dy))) rotate(var(--r)) scale(1.15); opacity: 0; }
}
@keyframes blink { 50% { opacity: .25; } }

@media (max-height: 700px) {
  .dog { width: 104px; height: 104px; }
  h1 { font-size: 30px; }
  .big { min-height: 206px; }
  .plate { width: 90px; height: 90px; }
  .plate .ico { width: 70px; height: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  .dog, .dog.happy, .big.bounce .plate { animation: none; }
}
details .ltr {
  display: block;
  margin: 6px 0 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .7);
  text-align: left;
  font-size: 13px;
  line-height: 1.55;
}
