:root {
  --bg: #f7f4ed;
  --card: #fff;
  --ink: #242423;
  --muted: #76756f;
  --line: #e8e3da;
  --green: #cce7cf;
  --blue: #cfe5f6;
  --orange: #f8d9ae;
  --pink: #f2d6dc;
  --shadow: 0 8px 28px rgba(42, 39, 31, .08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { color: inherit; font: inherit; }
button { touch-action: manipulation; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: auto;
  padding: max(22px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
  position: relative;
}
.auth-screen { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; overflow-y: auto; background: #e9e6df; }
.auth-card { width: min(100%, 410px); padding: 28px 24px; border-radius: 30px; background: var(--bg); box-shadow: 0 20px 70px rgba(30, 28, 22, .16); }
.auth-mark { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 16px; border-radius: 50%; background: #f4e9a9; }
.auth-mark img { width: 56px; height: 56px; }
.auth-card > small { color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.auth-card h1 { margin: 5px 0 7px; font-size: 28px; letter-spacing: -.04em; }
.auth-card > p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: 16px; background: #ebe8e0; }
.auth-tabs button { min-height: 42px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 850; cursor: pointer; }
.auth-tabs button.active { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(42, 39, 31, .08); }
.auth-submit { width: 100%; min-height: 52px; margin-top: 8px; border: 0; border-radius: 17px; color: #fff; background: #2f3b33; font-weight: 900; cursor: pointer; }
.auth-submit:disabled { opacity: .55; }
.auth-error { min-height: 18px; margin-top: 10px; color: #94505e; font-size: 12px; font-weight: 750; text-align: center; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; color: var(--muted); font-size: 11px; text-align: center; }
.auth-divider::before, .auth-divider::after { height: 1px; background: var(--line); content: ""; flex: 1; }
.account-details { padding: 14px; border-radius: 18px; background: #f7f5ef; }
.account-details strong, .account-details span { display: block; }
.account-details span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.invite-box { margin-top: 12px; padding: 15px; border: 1px dashed #b9b4a8; border-radius: 18px; text-align: center; }
.invite-box small { display: block; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .08em; }
.invite-box strong { display: block; margin-top: 5px; font-size: 24px; letter-spacing: .14em; }
.logout-button { width: 100%; min-height: 48px; margin-top: 14px; border: 0; border-radius: 16px; color: #94505e; background: #fff0f2; font-weight: 850; cursor: pointer; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 16px; }
.brand small { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.brand h1 { margin: 4px 0 0; font-size: 29px; letter-spacing: -.04em; }
.avatar { display: grid; place-items: center; width: 48px; height: 48px; padding: 4px; border: 0; border-radius: 50%; background: #f4e9a9; cursor: pointer; }
.avatar img { width: 42px; height: 42px; }

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }
.nap-status {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 72px; margin-bottom: 10px; padding: 13px 15px;
  border-radius: 22px; color: #fff; background: #2f3b33; box-shadow: var(--shadow);
}
.nap-status small { display: block; margin-top: 4px; color: #d8e0da; }
.pulse { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: #8ed39f; box-shadow: 0 0 0 5px rgba(142, 211, 159, .12); }
.timer { padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, .1); font-variant-numeric: tabular-nums; }
.now-summary {
  display: flex; align-items: center; justify-content: space-around; gap: 8px;
  min-height: 50px; margin-bottom: 14px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .62);
  color: var(--muted); font-size: 11px; font-weight: 650; text-align: center;
}
.now-summary strong { display: block; margin-top: 2px; color: var(--ink); font-size: 13px; }
.now-summary i { width: 1px; height: 25px; background: var(--line); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick {
  min-height: 137px; padding: 16px; overflow: hidden; border: 0; border-radius: 26px;
  text-align: left; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s ease, filter .12s ease;
}
.quick:active { transform: scale(.975); filter: brightness(.98); }
.quick-icon { display: grid; place-items: center; width: 57px; height: 57px; margin-bottom: 12px; border-radius: 19px; background: rgba(255, 255, 255, .72); font-size: 33px; }
.quick strong { display: block; font-size: 21px; letter-spacing: -.02em; }
.quick small { display: block; margin-top: 4px; opacity: .68; font-size: 12px; font-weight: 650; }
.poop { background: var(--orange); }
.nap { background: var(--blue); }
.feed { background: var(--green); }
.notable { background: var(--pink); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 3px 10px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head span { color: var(--muted); font-size: 12px; font-weight: 700; }
.section-head button { margin-left: auto; margin-right: 12px; padding: 0; border: 0; color: #2b6893; background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; }
.timeline { overflow: hidden; border-radius: 24px; background: var(--card); box-shadow: var(--shadow); }
.event { display: grid; grid-template-columns: 61px 42px 1fr; align-items: center; min-height: 66px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event-time { color: var(--muted); font-size: 12px; font-weight: 800; }
.event-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 12px; background: #f5f3ee; font-size: 19px; }
.event-title { font-size: 14px; font-weight: 800; text-transform: capitalize; }
.event-meta { margin-top: 3px; color: var(--muted); font-size: 11px; }
.event-copy { min-width: 0; }
.record-actions { display: flex; gap: 12px; margin-top: 5px; }
.record-actions button { padding: 0; border: 0; color: #2b6893; background: transparent; font-size: 11px; font-weight: 800; cursor: pointer; }
.record-actions .delete-record { color: #94505e; }
.empty { padding: 28px 18px; color: var(--muted); font-size: 13px; text-align: center; }

.health-hero { display: flex; align-items: end; justify-content: space-between; margin-bottom: 14px; padding: 20px; border-radius: 28px; color: #fff; background: #283136; box-shadow: var(--shadow); }
.health-hero small { color: #c9d2d5; font-size: 11px; font-weight: 800; }
.health-hero .weight { margin-top: 5px; font-size: 38px; font-weight: 900; letter-spacing: -.05em; }
.health-hero .weight small { font-size: 16px; }
.health-hero .trend { margin-top: 3px; color: #bfe6ca; font-size: 12px; }
.health-hero > span { font-size: 55px; }
.health-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.health-actions button { min-height: 102px; padding: 14px 5px; border: 0; border-radius: 20px; background: #fff; box-shadow: var(--shadow); cursor: pointer; }
.health-actions b, .health-actions span { display: block; }
.health-actions b { margin-bottom: 8px; font-size: 27px; }
.health-actions span { font-size: 12px; font-weight: 800; }
.health-card { margin-top: 13px; padding: 16px; border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.health-card h2 { margin: 0 0 8px; font-size: 16px; }
.health-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 1px; border-top: 1px solid var(--line); }
.health-row strong { font-size: 14px; }
.health-row small { display: block; margin-top: 3px; color: var(--muted); }
.record-icon { font-size: 22px; }
.weight-chart-card { margin-top: 13px; padding: 18px 14px 10px; border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.chart-head { display: flex; align-items: start; justify-content: space-between; gap: 8px; padding: 0 3px 8px; }
.chart-head small { display: block; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .08em; }
.chart-head strong { display: block; margin-top: 4px; font-size: 15px; }
.chart-ranges { display: flex; padding: 3px; border-radius: 11px; background: #f0eee8; }
.chart-ranges button { min-width: 31px; height: 29px; padding: 0 7px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 850; cursor: pointer; }
.chart-ranges button.active { color: #9b6123; background: #fff; box-shadow: 0 1px 5px rgba(42, 39, 31, .1); }
#weight-chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: #ece8df; stroke-width: 1; }
.chart-label { fill: #8a8983; font-size: 9px; font-weight: 700; }
.chart-line { fill: none; stroke: #d17a3f; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.chart-area { fill: url(#weight-gradient); }
.chart-dot { fill: #fff; stroke: #d17a3f; stroke-width: 2.5; }
.chart-empty { padding: 44px 10px 48px; color: var(--muted); font-size: 12px; text-align: center; }
.history-head { display: flex; align-items: center; gap: 13px; margin: 2px 2px 12px; }
.history-head small { color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .09em; }
.history-head h2 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.03em; }
.history-filters { position: sticky; z-index: 4; top: 0; display: flex; gap: 7px; margin: 0 -18px 14px; padding: 9px 18px 11px; overflow-x: auto; background: rgba(247, 244, 237, .94); backdrop-filter: blur(16px); scrollbar-width: none; }
.history-filters::-webkit-scrollbar { display: none; }
.history-filters button { flex: 0 0 auto; min-height: 35px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: 12px; font-weight: 800; cursor: pointer; }
.history-filters button.active { border-color: #2f3b33; color: #fff; background: #2f3b33; }
.history-day { margin: 0 0 18px; }
.history-day-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 8px; }
.history-day-head h3 { margin: 0; font-size: 16px; }
.history-day-head span { color: var(--muted); font-size: 11px; font-weight: 700; }
.load-more { display: block; width: 100%; min-height: 48px; margin-top: 12px; border: 0; border-radius: 17px; color: #2b6893; background: #fff; font-size: 13px; font-weight: 850; box-shadow: var(--shadow); cursor: pointer; }

.bottom-nav {
  position: fixed; z-index: 5; right: 0; bottom: 0; left: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 480px); min-height: 76px; margin: auto;
  padding: 7px 18px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(20px);
}
.bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 18px; color: #8a8983; background: transparent; font-size: 11px; font-weight: 800; cursor: pointer; }
.bottom-nav b { font-size: 23px; line-height: 1; }
.bottom-nav button.active { color: #387a4c; background: #edf6ef; }

.backdrop { position: fixed; z-index: 20; inset: 0; display: none; align-items: flex-end; justify-content: center; padding: 0; background: rgba(25, 25, 22, .34); }
.backdrop.show { display: flex; }
.sheet { width: min(100%, 480px); max-height: 88dvh; overflow-y: auto; padding: 12px 18px max(28px, env(safe-area-inset-bottom)); border-radius: 30px 30px 0 0; background: #fff; box-shadow: 0 -12px 60px rgba(0, 0, 0, .18); animation: rise .17s ease-out; }
@keyframes rise { from { transform: translateY(25px); opacity: .8; } }
.grabber { width: 44px; height: 5px; margin: 2px auto 15px; border-radius: 5px; background: #d8d5ce; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f3f1ec; font-size: 22px; cursor: pointer; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { min-height: 84px; padding: 12px; border: 1px solid var(--line); border-radius: 20px; background: #faf9f6; text-align: left; font-weight: 800; cursor: pointer; }
.choice b { display: block; margin-bottom: 6px; font-size: 25px; }
.choice small { display: block; margin-top: 3px; color: var(--muted); font-weight: 600; }
.choice.wide { grid-column: 1 / -1; }
.choice.danger { border-color: #efd0d0; background: #fff4f4; }
.choice.selected { outline: 3px solid #2f3b33; }
.field { margin: 11px 0; }
.field label { display: block; margin: 0 0 5px 3px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.field-help { display: block; margin: 6px 3px 0; color: var(--muted); font-size: 11px; }
.field input, .field textarea, .field select { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 16px; outline: 0; background: #faf9f6; }
.field textarea { min-height: 78px; resize: vertical; }
.sheet-foot { display: flex; gap: 9px; margin-top: 14px; }
.sheet-foot button { min-height: 52px; border: 0; border-radius: 18px; font-weight: 900; cursor: pointer; }
.secondary { flex: 1; background: #f0eee8; }
.primary { flex: 2; color: #fff; background: #2f3b33; }
.primary:disabled { opacity: .45; }
.toast { position: fixed; z-index: 30; bottom: calc(92px + env(safe-area-inset-bottom)); left: 50%; padding: 11px 16px; border-radius: 999px; color: #fff; background: #242b26; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; white-space: nowrap; font-size: 13px; font-weight: 800; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  body { background: #e9e6df; }
  .app-shell { margin-top: 24px; margin-bottom: 24px; border-radius: 38px; background: var(--bg); box-shadow: 0 20px 70px rgba(30, 28, 22, .16); }
  .bottom-nav { bottom: 24px; border-radius: 0 0 38px 38px; }
}
@media (max-width: 360px) {
  .app-shell { padding-right: 12px; padding-left: 12px; }
  .quick { min-height: 128px; padding: 13px; }
  .event { grid-template-columns: 54px 40px 1fr; padding-right: 10px; padding-left: 10px; }
}
