:root {
  --bg: #fbf6ef;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --text: #2b241d;
  --muted: #8a7d6e;
  --line: #e8dfd2;
  --accent: #f08a3c;       /* hungry orange */
  --accent-ink: #ffffff;
  --accent-soft: #fde4cf;
  --done: #3fa774;         /* fed green */
  --done-soft: #d9f1e3;
  --late: #e0533d;
  --late-soft: #fbdcd5;
  --tintin: #e8a33d;
  --luna: #7d7fd6;
  --shadow: 0 10px 30px rgba(110, 80, 40, .12);
  --shadow-sm: 0 1px 3px rgba(110, 80, 40, .06), 0 8px 24px rgba(110, 80, 40, .09);
  --shadow-xs: 0 1px 2px rgba(110, 80, 40, .06), 0 4px 12px rgba(110, 80, 40, .08);
  --radius: 20px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
svg.lucide { width: 1.2em; height: 1.2em; stroke-width: 2.2; flex: none; }
.muted { color: var(--muted); }

/* ---------- Layout ---------- */
#app { display: flex; flex-direction: column; min-height: 100dvh; }
main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px calc(96px + env(safe-area-inset-bottom));
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 480px; width: 100%; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.15rem; }
.brand svg { color: var(--accent); }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: none; border-radius: 999px; box-shadow: var(--shadow-xs);
  padding: 6px 12px; font-weight: 800; font-size: .9rem;
}

/* ---------- Home ---------- */
.slot-head { text-align: center; margin: 12px 0 18px; }
.slot-label { font-size: 1.9rem; font-weight: 900; letter-spacing: -.01em; }
.slot-sub { color: var(--muted); margin-top: 2px; }

/* Paw-shaped button: a halo layer (soft outline) under a fill layer, each made of 1 pad + 4 toe beans. */
.feed-btn {
  --c: var(--accent); --ink: var(--accent-ink); --ring: var(--accent-soft);
  position: relative; display: block;
  width: min(76vw, 280px); aspect-ratio: 1; margin: 8px auto 0;
  border: none; background: none; padding: 0; color: var(--ink);
  transition: transform .15s ease;
  touch-action: manipulation;
}
.feed-btn:active:not(:disabled) { transform: scale(.94); }
.paw { position: absolute; inset: 0; pointer-events: none; }
.paw i { position: absolute; display: block; transition: background .25s ease, box-shadow .25s ease; }
.paw .pad   { left: 14%; top: 43%; width: 72%; height: 55%; border-radius: 48% 48% 44% 44% / 56% 56% 44% 44%; }
.paw .toe   { width: 19%; height: 25%; border-radius: 50%; }
.paw .toe1  { left: 3%;  top: 25%; transform: rotate(-28deg); }
.paw .toe2  { left: 24%; top: 4%;  transform: rotate(-9deg); }
.paw .toe3  { right: 24%; top: 4%; transform: rotate(9deg); }
.paw .toe4  { right: 3%; top: 25%; transform: rotate(28deg); }
.paw.halo i { background: var(--ring); box-shadow: 0 0 0 12px var(--ring); }
.paw.fill i { background: var(--c); }
.paw.fill .pad { box-shadow: 0 14px 28px rgba(110, 80, 40, .18); }
.feed-content {
  position: absolute; left: 14%; top: 43%; width: 72%; height: 55%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding-top: 4%;
}
.feed-btn .feed-icon svg { width: 48px; height: 48px; stroke-width: 2.2; }
.feed-text { font-size: 1.1rem; font-weight: 900; padding: 0 12px; text-align: center; line-height: 1.15; }
.feed-btn:active:not(:disabled) .paw.fill .toe { animation: wiggle .3s ease; }
.feed-btn.is-fed { --c: var(--done); --ink: #fff; --ring: var(--done-soft); }
.feed-btn.is-late { --c: var(--late); --ink: #fff; --ring: var(--late-soft); }
.feed-btn.is-late .paw.halo { animation: pulse 1.6s ease-in-out infinite; }
.feed-btn.is-idle { --c: var(--surface-2); --ink: var(--muted); --ring: transparent; cursor: default; }
.feed-btn.is-idle .paw.fill .pad { box-shadow: none; }
.feed-btn.is-saving { opacity: .75; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: .7; }
}
@keyframes wiggle {
  50% { translate: 0 -6px; }
}
@media (prefers-reduced-motion: reduce) {
  .feed-btn.is-late .paw.halo, .feed-btn:active .paw.fill .toe { animation: none; }
}

.status { text-align: center; margin-top: 26px; min-height: 1.4em; font-weight: 800; }
.status .who { color: var(--done); }
.undo {
  display: flex; align-items: center; gap: 6px; margin: 8px auto 0;
  background: var(--surface); border: none; border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow-xs);
  color: var(--muted); font-weight: 800;
}

.portion {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0 8px;
}
.cat {
  background: var(--surface); border: none; border-radius: 18px; box-shadow: var(--shadow-sm);
  padding: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-align: center;
}
.cat-name { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.cat-name svg { color: var(--cat); }
.cat-amount { font-size: 1.6rem; font-weight: 900; }
.cat-amount small { font-size: .95rem; color: var(--muted); font-weight: 700; }
.cat-extra { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: .9rem; }
.cat.tintin { --cat: var(--tintin); }
.cat.luna { --cat: var(--luna); }

.day { margin-top: 18px; }
.day-title { font-weight: 900; margin-bottom: 10px; }
.timeline {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.tl {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; padding: 4px 0; width: 100%;
}
.tl-dot {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); border: 2px solid transparent;
}
.tl-dot svg { width: 20px; height: 20px; }
.tl-time { font-size: .78rem; color: var(--muted); font-weight: 800; }
.tl-who { font-size: .72rem; color: var(--muted); min-height: 1em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl.fed .tl-dot { background: var(--done); color: #fff; }
.tl.missed .tl-dot { background: var(--late-soft); color: var(--late); }
.tl.current .tl-dot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tl.current.fed .tl-dot { border-color: var(--done); background: var(--done); color: #fff; }

/* ---------- Schedule ---------- */
.page-title { margin: 8px 0 16px; }
.page-title h2 { margin: 0; font-size: 1.5rem; font-weight: 900; }
.page-title p { margin: 4px 0 0; }
.meal {
  background: var(--surface); border: none; border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px; margin-bottom: 14px;
}
.meal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.meal-title { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.1rem; }
.meal-title svg { color: var(--accent); }
.meal input[type="time"] {
  font: inherit; font-weight: 800; color: var(--text);
  background: var(--surface-2); border: none; border-radius: 10px; padding: 6px 10px;
}
.amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.amount { display: flex; flex-direction: column; gap: 6px; }
.amount-name { display: flex; align-items: center; gap: 6px; font-size: .9rem; font-weight: 800; }
.amount-name svg { color: var(--cat); }
.amount.tintin { --cat: var(--tintin); }
.amount.luna { --cat: var(--luna); }
.stepper {
  display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; overflow: hidden;
}
.stepper button {
  width: 40px; height: 42px; border: none; background: none; display: grid; place-items: center; color: var(--muted);
}
.stepper input {
  flex: 1; min-width: 0; width: 100%; text-align: center; border: none; background: none;
  font: inherit; font-weight: 900; font-size: 1.1rem; color: var(--text);
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.extra-field { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); }
.extra-field input {
  flex: 1; font: inherit; color: var(--text); border: none; border-bottom: 1px dashed var(--line);
  background: none; padding: 6px 2px; min-width: 0;
}
.save { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); margin-top: 6px; box-shadow: 0 10px 30px rgba(240, 138, 60, .35); }
.save:disabled { display: none; } /* only appears once something changed */

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -6px 24px rgba(110, 80, 40, .08);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; max-width: 200px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; border-radius: 14px; padding: 8px 0;
  color: var(--muted); font-weight: 800; font-size: .8rem;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- Login ---------- */
.login {
  max-width: 380px; margin: 0 auto; padding: calc(56px + env(safe-area-inset-top)) 16px 32px;
  text-align: center;
}
.login-logo {
  width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 28px;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow);
}
.login-logo svg { width: 56px; height: 56px; }
.login h1 { margin: 0; font-size: 2rem; font-weight: 900; }
.login p { margin: 4px 0 24px; }
.people { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.person {
  background: var(--surface); border: none; border-radius: 16px; box-shadow: var(--shadow-sm);
  padding: 14px 6px; font-weight: 900; font-size: 1.05rem;
  transition: background .2s ease, color .2s ease, transform .15s ease;
}
.person:active { transform: scale(.96); }
.person[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.field {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--surface); border: none; border-radius: 14px; padding: 0 14px; box-shadow: var(--shadow-sm);
  color: var(--muted);
}
.field input {
  flex: 1; border: none; background: none; padding: 14px 0; font: inherit; color: var(--text); min-width: 0;
}
.field input:focus { outline: none; }
.field:focus-within { box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); }
.error { color: var(--late); margin: 10px 0 0; }
.btn-primary {
  width: 100%; margin-top: 16px; border: none; border-radius: 14px; padding: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 1.05rem;
  box-shadow: var(--shadow);
}
.btn-primary:disabled { opacity: .45; box-shadow: none; cursor: default; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); border-radius: 999px; padding: 10px 18px;
  font-weight: 800; transition: all .25s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
