:root {
  --bg: #f7f1ea;
  --card: #fffdf9;
  --ink: #2d211c;
  --muted: #7a655b;
  --line: #eadfd6;
  --feed: #d9896a;
  --pee: #e0b34e;
  --poop: #b07a4a;
  --both: #8b6aae;
  --ok: #2f6f4e;
  --bad: #b2402e;
  --shadow: 0 8px 24px rgba(80, 50, 30, 0.08);
  --tap: 56px;
  font-family: "Noto Sans TC", "PingFang HK", "Hiragino Sans CNS", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.hidden { display: none !important; }

.kicker, .gate-kicker {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}
h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 1.1rem; }

.top, .log-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.top { margin: 8px 0 16px; }

.who { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--muted); }
.who select, .gate-card input {
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 16px;
}

.last-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.last-row article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 8px;
  box-shadow: var(--shadow);
  min-height: 76px;
}
.last-row .label { margin: 0 0 6px; font-size: 0.72rem; color: var(--muted); }
.last-row .value { margin: 0; font-size: 0.92rem; font-weight: 650; line-height: 1.25; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.action {
  min-height: 84px;
  border: 0;
  border-radius: 18px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: var(--shadow);
}
.action span { font-size: 0.8rem; font-weight: 500; opacity: 0.9; }
.action.feed { background: var(--feed); }
.action.pee { background: var(--pee); color: #3d2c10; }
.action.poop { background: var(--poop); }
.action.both { background: var(--both); }
.action:active { transform: scale(0.98); }

.log-wrap { margin-top: 8px; }
.log-head { margin-bottom: 8px; }
.log-head p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.log { display: flex; flex-direction: column; gap: 8px; }
.day-label {
  margin: 10px 0 2px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 10px 10px 12px;
}
.row .time { font-weight: 700; }
.row .meta { margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}
.pill.feed { background: var(--feed); }
.pill.pee { background: var(--pee); color: #3d2c10; }
.pill.poop { background: var(--poop); }
.pill.pee_poop { background: var(--both); }
.delete {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  border-radius: 10px;
}
.delete:active { background: #f3e7df; color: var(--bad); }

.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  z-index: 20;
  max-width: calc(100% - 32px);
}

.gate {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gate-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}
.gate-help { color: var(--muted); line-height: 1.5; }
.gate-card form { display: flex; flex-direction: column; gap: 10px; }
.btn {
  min-height: var(--tap);
  border: 0;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
}
.btn.primary { background: var(--ink); color: #fff; }
.error { color: var(--bad); margin: 10px 0 0; }

@media (max-width: 380px) {
  .last-row { grid-template-columns: 1fr; }
  .row { grid-template-columns: 64px 1fr auto; }
}
