:root {
  --bg: #f6efe4;
  --card: #fffaf2;
  --ink: #2b2118;
  --muted: #7a6a58;
  --line: #e8dcc8;
  --accent: #b5702f;      /* caramel, Louie's coat */
  --accent-ink: #ffffff;
  --accent-soft: #f3e1c9;
  --ok: #2f8a55;
  --ok-soft: #dcf0e2;
  --warn: #b7791f;
  --warn-soft: #fbedd0;
  --bad: #c0392b;
  --bad-soft: #f9dcd8;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1914;
    --card: #28221b;
    --ink: #f3e9dc;
    --muted: #b3a28d;
    --line: #3d342a;
    --accent: #d99150;
    --accent-ink: #1d1914;
    --accent-soft: #4a3523;
    --ok: #5cc184;
    --ok-soft: #1f3a2a;
    --warn: #e6b04f;
    --warn-soft: #43361d;
    --bad: #ef7b6e;
    --bad-soft: #472421;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

main { max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
.loading { text-align: center; font-size: 40px; padding: 30vh 0; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.top-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.louie-av {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  background: var(--accent-soft) center/cover no-repeat; display: grid; place-items: center; font-size: 26px;
  border: 2px solid var(--card); box-shadow: var(--shadow);
}
.top h1 { font-size: 22px; margin: 0; line-height: 1.1; }
.top .sub { color: var(--muted); font-size: 14px; }
.top .grow { flex: 1; min-width: 0; }
.me {
  border: 0; background: var(--card); border-radius: 999px; padding: 4px 4px 4px 12px;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); cursor: pointer; font-size: 14px;
}
.dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; flex: none; }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 6;
  display: flex; justify-content: center; gap: 4px;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs a {
  flex: 1; max-width: 180px; text-decoration: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; font-size: 13px; padding: 4px; border-radius: 12px;
}
.tabs a .ti { font-size: 22px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--ink); font-weight: 600; background: var(--accent-soft); }
.tabs a.on .ti { filter: none; opacity: 1; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card h2 { font-size: 18px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .act { margin-inline-start: auto; font-size: 14px; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 14px; padding: 12px 18px; cursor: pointer; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; transition: transform .08s;
}
.btn:active { transform: scale(.97); }
.btn.big { width: 100%; font-size: 18px; min-height: 58px; border-radius: 16px; }
.btn.ghost { background: var(--accent-soft); color: var(--ink); }
.btn.plain { background: transparent; color: var(--accent); padding: 8px 10px; min-height: 0; font-weight: 500; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px; font-size: 14px; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 2px 8px; line-height: 1; }

/* ---------- feeding ---------- */
.meals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meal {
  border-radius: 16px; padding: 14px 12px; text-align: center; background: var(--bg); border: 2px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 150px; justify-content: center;
}
.meal .em { font-size: 30px; line-height: 1; }
.meal .nm { font-weight: 600; font-size: 17px; }
.meal.done { background: var(--ok-soft); border: 2px solid transparent; }
.meal.done .st { color: var(--ok); font-weight: 600; }
.meal .btn { width: 100%; min-height: 44px; padding: 8px; }

/* ---------- walks ---------- */
.since { text-align: center; padding: 4px 0 14px; }
.since .big { font-size: 30px; font-weight: 700; line-height: 1.2; }
.since.ok .big { color: var(--ok); }
.since.warn .big { color: var(--warn); }
.since.bad .big { color: var(--bad); }
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.list li .t { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 46px; }
.list li .grow { flex: 1; min-width: 0; }

/* ---------- status pills ---------- */
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.none { background: var(--bg); color: var(--muted); }
.banner { border-radius: 14px; padding: 12px 14px; font-weight: 600; margin-bottom: 12px; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

.summary-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; text-decoration: none; color: inherit; }
.summary-line + .summary-line { border-top: 1px solid var(--line); }
.summary-line .grow { flex: 1; }

/* week grid */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 12.5px; }
.week .d { color: var(--muted); }
.week .d.today { color: var(--ink); font-weight: 700; }
.week .c { height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--bg); font-size: 13px; }
.week .c.y { background: var(--ok-soft); color: var(--ok); }
.week .c.n { background: var(--bad-soft); color: var(--bad); }
.week .lbl { grid-column: 1 / -1; text-align: start; color: var(--muted); margin-top: 4px; }

/* vaccines */
.vk { padding: 10px 0; border-top: 1px solid var(--line); }
.vk:first-of-type { border-top: 0; padding-top: 0; }
.vk summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.vk summary::-webkit-details-marker { display: none; }
.vk .name { font-weight: 600; }
.vk .grow { flex: 1; }

/* notes */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 4px; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 5px 12px; cursor: pointer; white-space: nowrap; font-size: 14px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.note { border-top: 1px solid var(--line); padding: 10px 0; }
.note .title { font-weight: 600; }
.note .body { white-space: pre-wrap; margin-top: 4px; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- photos ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 -8px; }
.grid a { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--accent-soft); }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .badge {
  position: absolute; bottom: 4px; inset-inline-start: 4px; background: rgba(0,0,0,.55); color: #fff;
  border-radius: 999px; font-size: 11.5px; padding: 1px 7px;
}
.upload-q { font-size: 14px; }
.upload-q .bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.upload-q .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .em { font-size: 54px; }

.viewer { margin: 0 -16px; background: #000; position: relative; min-height: 240px; display: grid; place-items: center; touch-action: pan-y; user-select: none; }
.viewer img { max-width: 100%; max-height: 72vh; display: block; }
.viewer .nav {
  position: absolute; top: 50%; transform: translateY(-50%); border: 0; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff; font-size: 22px; cursor: pointer;
}
.viewer .nav.prev { inset-inline-start: 8px; }
.viewer .nav.next { inset-inline-end: 8px; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.photo-actions .btn { flex: 1; min-width: 0; padding: 10px; font-size: 15px; }
.heart.on { background: var(--bad-soft); color: var(--bad); }
.comment { padding: 10px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.comment .grow { flex: 1; min-width: 0; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.compose { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.compose textarea { flex: 1; min-height: 46px; max-height: 140px; resize: vertical; }

/* ---------- forms & sheets ---------- */
label.f { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
.in, select.in, textarea.in {
  width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 12px; outline: none;
}
.in:focus { border-color: var(--accent); }
.radios { display: flex; flex-wrap: wrap; gap: 6px; }
.radios input { position: absolute; opacity: 0; pointer-events: none; }
.radios label { border: 1.5px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.radios input:checked + label { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.radios input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggles input { position: absolute; opacity: 0; pointer-events: none; }
.toggles label { border: 1.5px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px; text-align: center; cursor: pointer; font-size: 17px; }
.toggles input:checked + label { background: var(--ok-soft); border-color: var(--ok); }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 12, 4, .45); animation: fade .15s; }
.sheet {
  position: relative; background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 6px; font-size: 20px; }
.sheet .actions { display: flex; gap: 8px; margin-top: 18px; }
.sheet .actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); text-align: center; animation: up .2s;
}

/* ---------- login ---------- */
.login { text-align: center; padding-top: 12vh; }
.login .logo { font-size: 72px; line-height: 1; }
.login h1 { font-size: 34px; margin: 8px 0 4px; }
.login form { max-width: 320px; margin: 28px auto 0; }
.login .in { text-align: center; font-size: 20px; letter-spacing: .5px; }
.who-grid { display: grid; gap: 10px; max-width: 320px; margin: 24px auto 0; }
.who-grid button {
  display: flex; align-items: center; gap: 14px; border: 0; background: var(--card); padding: 14px 16px; border-radius: 16px;
  font-size: 20px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}
.who-grid .dot { width: 44px; height: 44px; font-size: 20px; }
.err { color: var(--bad); margin-top: 10px; min-height: 1.5em; }

@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(4, 1fr); margin: 0; }
  .viewer { margin: 0; border-radius: var(--radius); overflow: hidden; }
}

/* ---------- Barak's artwork in the design ---------- */
.mood {
  position: relative; height: 190px; margin: 4px 0 12px; border-radius: var(--radius); overflow: hidden;
  background: var(--accent-soft) center/cover no-repeat; box-shadow: var(--shadow);
}
.mood::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(40, 20, 5, .72), rgba(40, 20, 5, 0) 55%); }
.mood-line {
  position: absolute; z-index: 1; bottom: 12px; inset-inline: 16px; color: #fff; font-weight: 600; font-size: 20px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .45);
}
.family-hero { display: block; width: min(100%, 440px); margin: 0 auto -6px; filter: drop-shadow(0 6px 14px rgba(60, 40, 20, .18)); }
.login:has(.family-hero) { padding-top: 6vh; }
.face-big { width: 132px; height: 132px; border-radius: 50%; object-fit: cover; border: 4px solid var(--card); box-shadow: var(--shadow); }
.family-strip { display: block; width: 100%; max-width: 480px; margin: 0 auto -18px; position: relative; z-index: 1; filter: drop-shadow(0 6px 12px rgba(60, 40, 20, .16)); }
.id-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.id-photo { width: 76px; height: 76px; border-radius: 16px; object-fit: cover; flex: none; border: 3px solid var(--accent-soft); }
.id-name { font-size: 22px; font-weight: 700; }
.empty-art { display: block; width: 100%; max-width: 360px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius); margin: 0 auto 14px; }
