/* Care with Love — warm, calm, thumb-friendly */
:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #2d2a26;
  --muted: #8a7f74;
  --line: #ece3d6;
  --accent: #b3541e;      /* warm terracotta */
  --accent-soft: #f7e8d8;
  --accent-ink: #7c3a12;
  --ok: #2f7d4f;
  --ok-soft: #e2f2e7;
  --warn: #b7791f;
  --warn-soft: #fbf0d9;
  --bad: #b3372f;
  --bad-soft: #fbe3e1;
  --pet: #6a5acd;
  --pet-soft: #e9e6fb;
  --radius: 16px;
  --tabbar-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(250, 246, 240, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-heart { color: var(--accent); font-size: 20px; }
.top-actions { display: flex; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 8px 12px; font-size: 13px; min-height: 36px;
}
.chip.ghost { background: transparent; }
#view { max-width: 640px; margin: 0 auto; padding: 16px 16px 24px; }
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--card); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; min-height: var(--tabbar-h);
}
.tab-ico { font-size: 20px; }
.tab.active { color: var(--accent); font-weight: 700; }

h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .04);
}
.dose-card { display: flex; gap: 12px; align-items: flex-start; }
.dose-time {
  flex: 0 0 58px; text-align: center; font-weight: 700; font-size: 15px; color: var(--accent-ink);
  background: var(--accent-soft); border-radius: 12px; padding: 8px 4px;
}
.dose-body { flex: 1; min-width: 0; }
.dose-who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dose-med { font-weight: 700; font-size: 16px; margin: 2px 0; }
.dose-meta { font-size: 13px; color: var(--muted); }
.dose-actions { display: flex; gap: 8px; margin-top: 10px; }
.badge {
  display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; font-weight: 600;
}
.badge.pet { background: var(--pet-soft); color: var(--pet); }
.badge.person { background: var(--accent-soft); color: var(--accent-ink); }
.badge.prn { background: #e8f0fe; color: #2b5cb8; }
.badge.vitamin { background: #fef3c7; color: #92600a; }

.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 600; min-height: 48px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.plain { background: transparent; }
.btn:disabled { opacity: .55; }

.status-pill { font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.status-pill.pending { background: var(--warn-soft); color: var(--warn); }
.status-pill.done { background: var(--ok-soft); color: var(--ok); }
.status-pill.missed { background: var(--bad-soft); color: var(--bad); }
.status-pill.skipped { background: #eee; color: var(--muted); }

.done-banner {
  background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: 10px 14px;
  font-size: 14px; margin-bottom: 10px;
}
.demo-banner {
  background: #e8f0fe; color: #2b5cb8; border-radius: 12px; padding: 10px 14px;
  font-size: 13px; margin-bottom: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 14px; }
.field input {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 15px; background: #fff;
}
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(45, 42, 38, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--card); border-radius: 20px 20px 0 0; padding: 20px;
  width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
}
.modal-card h2 { margin-top: 0; }
.identity-pick {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 14px; font-size: 16px;
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 44px;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: #fff;
}
.avatar.person { background: var(--accent); }
.avatar.pet { background: var(--pet); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px;
  z-index: 60; max-width: 90vw; text-align: center;
}
.toast.hidden { display: none; }

.er-sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.er-sheet h3 { margin: 0 0 8px; font-size: 18px; }
.er-grid { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; font-size: 14px; }
.er-grid dt { color: var(--muted); }
.er-grid dd { margin: 0; }
.er-meds { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.print-btn { position: sticky; bottom: calc(var(--tabbar-h) + 12px); width: 100%; margin-top: 8px; }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

@media (min-width: 700px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 20px; }
}

/* ---- print: only the ER sheets ---- */
@media print {
  #topbar, #tabbar, .modal, #toast, .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  #view { max-width: none; padding: 0; }
  .er-sheet { break-inside: avoid; border: 1px solid #999; box-shadow: none; margin-bottom: 12px; }
}
