:root {
  color-scheme: light;
  --bg: #fdfaf4;
  --card: #ffffff;
  --ink: #2b4a6f;
  --ink-2: #5d7089;
  --muted: #98a3b1;
  --line: #ece6da;
  --soft: #f6f2ea;
  --navy: #2f5480;
  --accent: #f26b2a;
  --danger: #d9502b;
  --on-tone: #24405f;
  --shadow: 0 1px 2px rgba(43, 74, 111, .06), 0 4px 14px rgba(43, 74, 111, .06);

  --t-feed: #fdd250;  --t-feed-2: #f2a03d;
  --t-pump: #f6a99a;
  --t-diaper: #ece6d6;
  --t-sleep: #bfe1f0;
  --t-health: #d9cdf3;
  --t-activity: #f9d0b0;
  --t-milestone: #a9dfe4;
  --t-growth: #b6e08f;

  /* chart series (validated categorical palette) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-7: #6250d6;
  --grid: #e9e4da;

  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  --tabbar: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121821; --card: #1b2430; --ink: #e8eef6; --ink-2: #a8b5c6; --muted: #6f7d8f; --line: #2a3544; --soft: #222d3a;
    --navy: #4f7fb8; --accent: #f07a3e; --danger: #f07a5a; --on-tone: #121a24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --t-feed: #d8b443; --t-feed-2: #d98a2f; --t-pump: #d08f81; --t-diaper: #bdb6a4; --t-sleep: #8db7cb; --t-health: #a99cd0;
    --t-activity: #d0a582; --t-milestone: #7fbac0; --t-growth: #8fbd68;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-7: #9085e9;
    --grid: #2a3544;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121821; --card: #1b2430; --ink: #e8eef6; --ink-2: #a8b5c6; --muted: #6f7d8f; --line: #2a3544; --soft: #222d3a;
  --navy: #4f7fb8; --accent: #f07a3e; --danger: #f07a5a; --on-tone: #121a24;
  --t-feed: #d8b443; --t-feed-2: #d98a2f; --t-pump: #d08f81; --t-diaper: #bdb6a4; --t-sleep: #8db7cb; --t-health: #a99cd0;
  --t-activity: #d0a582; --t-milestone: #7fbac0; --t-growth: #8fbd68;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-7: #9085e9;
  --grid: #2a3544;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
body.sheet-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: .45; }
a { color: var(--navy); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: -.01em; }
small { color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.splash { min-height: 100vh; display: grid; place-items: center; font-size: 56px; }
.page { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px); }
.page-title { font-size: 34px; margin: 8px 0 16px; }

/* ---------- header ---------- */
.app-header { position: relative; display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.baby-head { display: flex; align-items: center; gap: 14px; text-align: left; flex: 1; min-width: 0; }
.baby-head .avatar { box-shadow: 0 0 0 3px var(--card), 0 0 0 4px var(--line); }
.baby-head-text { display: flex; flex-direction: column; min-width: 0; }
.baby-name { font-family: var(--serif); font-size: 34px; line-height: 1.05; display: flex; align-items: center; gap: 6px; }
.chev { font-family: var(--sans); font-size: 22px; color: var(--ink-2); transform: translateY(-4px); }
.baby-sub { color: var(--ink-2); font-size: 15px; margin-top: 2px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.live-dot.on { background: #3fae6a; box-shadow: 0 0 0 3px rgba(63, 174, 106, .18); }
.live-dot.off { background: var(--muted); }
.baby-menu { position: absolute; top: 72px; left: 0; z-index: 30; background: var(--card); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.18); padding: 6px; min-width: 240px; }
.baby-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border-radius: 12px; text-align: left; }
.baby-menu button span { display: flex; flex-direction: column; }
.baby-menu button.on { background: var(--soft); }

.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 600; flex: none; object-fit: cover; letter-spacing: .02em; }

/* ---------- category cards ---------- */
.cards { display: flex; flex-direction: column; gap: 22px; }
.cat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cat-head { position: relative; background: var(--tone); color: var(--on-tone); padding: 14px 20px 12px; min-height: 58px; }
.cat-head h2 { font-size: 30px; line-height: 1.1; }
.plus { position: absolute; right: 18px; bottom: -26px; width: 54px; height: 54px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 34px; line-height: 1; font-weight: 300; box-shadow: 0 3px 10px rgba(47, 84, 128, .3); display: grid; place-items: center; z-index: 2; }
.plus:active { transform: scale(.94); }
.cat-body { padding: 4px 0; }
.summary, .first, .growth-row, .running-row { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 18px 20px; }
.summary { min-height: 96px; }
.summary-icon { width: 54px; height: 54px; border-radius: 50%; background: color-mix(in srgb, var(--tone) 55%, transparent); display: grid; place-items: center; font-size: 28px; flex: none; }
.summary-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.summary-label { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.summary-sub { color: var(--ink-2); font-size: 15px; margin-top: 2px; }
.summary-big { display: flex; flex-direction: column; align-items: flex-end; flex: none; max-width: 45%; }
.big-value { font-family: var(--serif); font-size: 48px; line-height: .95; letter-spacing: -.02em; white-space: nowrap; }
.big-value sup { font-size: 18px; vertical-align: top; margin-left: 2px; position: relative; top: 4px; }
.summary-big small { font-family: var(--serif); font-size: 17px; color: var(--ink); margin-top: 4px; }
.cat-foot { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 15px 20px; border-top: 1px solid var(--line); color: var(--navy); font-size: 16px; }
.cat-foot span:last-child { font-size: 22px; color: var(--ink-2); }
.cat-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px 14px; border-top: 1px solid var(--line); }
.cat-actions .hint { margin: 0; }
.chev-r { color: var(--ink-2); font-size: 22px; flex: none; }
.row-value { color: var(--ink); font-size: 17px; white-space: nowrap; }
.growth-row + .growth-row { border-top: 1px solid var(--line); }
.growth-row .summary-icon { width: 46px; height: 46px; font-size: 22px; }
.first-photo { display: block; max-width: 60%; max-height: 260px; margin: 0 20px 18px 90px; border: 8px solid var(--card); box-shadow: 0 0 0 1px var(--line); object-fit: cover; }
.running-row { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.running-clock { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 600; color: var(--accent); }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.6s infinite; margin: 0 21px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242, 107, 42, .5); } 70% { box-shadow: 0 0 0 12px rgba(242, 107, 42, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 107, 42, 0); } }

.feed-list { border-top: 1px solid var(--line); }
.feed-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 20px; text-align: left; }
.feed-row + .feed-row { border-top: 1px solid var(--line); }
.feed-row-main { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.feed-row-main strong { font-size: 19px; font-weight: 500; }
.bar-line { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.bar { display: block; height: 9px; border-radius: 5px; background: var(--t-feed); max-width: 60%; }
.bar.alt { background: var(--t-feed-2); }

.tone-feed { --tone: var(--t-feed); } .tone-pump { --tone: var(--t-pump); } .tone-diaper { --tone: var(--t-diaper); }
.tone-sleep { --tone: var(--t-sleep); } .tone-health { --tone: var(--t-health); } .tone-activity { --tone: var(--t-activity); }
.tone-milestone { --tone: var(--t-milestone); } .tone-growth { --tone: var(--t-growth); }

/* ---------- generic cards / lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-title { font-size: 22px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.card h4 { font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin: 18px 0 8px; }
.hint { color: var(--ink-2); font-size: 14px; margin: 6px 0; }
.hint.center, .center { text-align: center; }
.danger { color: var(--danger) !important; }
.error { color: var(--danger); margin: 4px 0; font-size: 15px; }
.muted { opacity: .55; }
.notice { background: var(--soft); border-radius: 12px; padding: 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.entry-list { display: flex; flex-direction: column; }
.entry-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; text-align: left; width: 100%; border-bottom: 1px solid var(--line); }
.entry-row:last-child { border-bottom: 0; }
.entry-row.live { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 10px; }
.entry-time { width: 66px; flex: none; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink-2); display: flex; flex-direction: column; }
.entry-time small { font-size: 12px; }
.entry-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-text strong { font-weight: 600; font-size: 15px; }
.entry-text span { font-size: 14px; color: var(--ink-2); }
.entry-text em { font-size: 13px; color: var(--ink-2); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.has-photo { font-size: 14px; }
.type-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 17px; background: color-mix(in srgb, var(--tone) 70%, transparent); }
.type-icon.big { width: 58px; height: 58px; font-size: 30px; }
.pct-badge { font-size: 13px; background: var(--soft); border-radius: 10px; padding: 3px 8px; color: var(--ink-2); }

.day { margin-bottom: 18px; }
.day-head { font-size: 20px; display: flex; flex-direction: column; gap: 2px; margin: 18px 4px 6px; }
.day-head small { font-family: var(--sans); font-size: 13px; }
.day .entry-list { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 2px 12px; }
.loading-more { text-align: center; color: var(--ink-2); padding: 20px; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty-icon { font-size: 44px; margin-bottom: 8px; }
.empty h3 { color: var(--ink); font-size: 22px; margin-bottom: 6px; }

.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.li-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.li-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.me-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.me-row div { display: flex; flex-direction: column; }
.steps { padding-left: 20px; margin: 0; line-height: 1.7; }

/* ---------- controls ---------- */
.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 999px; font-weight: 600; text-decoration: none; font-size: 15px; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.secondary { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost { background: none; }
.btn.small { padding: 7px 13px; font-size: 14px; }
.btn.big { padding: 15px 20px; font-size: 17px; }
.btn.full { width: 100%; margin-top: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.link { color: var(--navy); font-size: 15px; }
.link.strong { font-weight: 700; }
.link.small { font-family: var(--sans); font-size: 14px; }
.icon-btn { font-size: 22px; width: 36px; height: 36px; display: grid; place-items: center; }

input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 16px; min-width: 0;
}
textarea { resize: vertical; }
input.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.inline { display: flex; gap: 8px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field.row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.field.row > :last-child { max-width: 65%; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
.form { border: 0; padding: 0; margin: 0; min-width: 0; }

.segmented { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { flex: 1; padding: 9px 6px; border-radius: 10px; font-size: 15px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.segmented button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.segmented.small button { padding: 7px 6px; font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 8px; padding: 2px 16px 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.compact { margin-top: 8px; gap: 6px; }
.chip { padding: 7px 13px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); font-size: 14px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--navy); color: #fff; box-shadow: none; }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }

.stepper { display: flex; align-items: center; background: var(--soft); border-radius: 12px; overflow: hidden; }
.stepper button { width: 44px; height: 44px; font-size: 22px; color: var(--navy); flex: none; }
.stepper input { text-align: center; border: 0 !important; background: transparent !important; padding: 8px 0 !important; font-size: 18px !important; font-variant-numeric: tabular-nums; }
.stepper .suffix { color: var(--ink-2); font-size: 14px; padding-right: 4px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.time-field { display: flex; gap: 8px; align-items: center; }
.time-field input { flex: 1; }
.time-field.compact { justify-content: flex-end; }
.time-field.compact input { border: 0; background: transparent; text-align: right; padding: 6px 0; width: auto; flex: 0 1 auto; color: var(--ink); font-size: 16px; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 6px 0; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked + i { background: #3fae6a; }
.toggle input:checked + i::after { transform: translateX(20px); }
.toggle input:focus-visible + i { outline: 2px solid var(--navy); outline-offset: 2px; }

.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 32px; height: 32px; border-radius: 50%; }
.colors button.on { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }

.photo-field { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.photo-field img { max-width: 100%; max-height: 260px; border-radius: 12px; }
.photo-row { padding: 18px 0 4px; display: flex; justify-content: center; }
.photo-row .btn { padding: 12px 34px; font-size: 16px; }

/* ---------- sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20, 28, 40, .42); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: calc(100vh - env(safe-area-inset-top) - 24px); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .24s cubic-bezier(.2, .8, .2, 1); overflow: hidden; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; max-height: 88vh; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.sheet-head[class*="bg-"] { background: var(--tone); color: var(--on-tone); border-bottom: 0; }
.sheet-head[class*="bg-"] .link, .sheet-head[class*="bg-"] .icon-btn { color: var(--on-tone); }
.bg-feed { --tone: var(--t-feed); } .bg-pump { --tone: var(--t-pump); } .bg-diaper { --tone: var(--t-diaper); } .bg-sleep { --tone: var(--t-sleep); }
.bg-health { --tone: var(--t-health); } .bg-activity { --tone: var(--t-activity); } .bg-milestone { --tone: var(--t-milestone); } .bg-growth { --tone: var(--t-growth); }
.sheet-head h2 { text-align: center; font-size: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head .link.strong { justify-self: end; font-size: 17px; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 0 0 calc(env(safe-area-inset-bottom) + 24px); -webkit-overflow-scrolling: touch; }
.sheet-body > .form, .sheet-body > p, .sheet-body > input, .sheet-body > .btn-row, .sheet-body > .notice, .sheet-body > .field { margin-left: 18px; margin-right: 18px; }
.sheet-body > .notice { margin-top: 14px; }
.sheet-body > .btn.full { width: calc(100% - 36px); margin: 10px 18px 0; }
.meta-line { text-align: center; color: var(--ink); font-size: 15px; margin: 22px 18px 4px; }

.rows { border: 0; margin: 0; padding: 0; min-width: 0; background: var(--card); }
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); min-height: 64px; }
.row-item.stack { flex-direction: column; align-items: stretch; gap: 10px; }
.row-label { font-family: var(--serif); font-size: 21px; flex: none; }
.row-control { min-width: 0; }
.row-item:not(.stack) .row-control { display: flex; justify-content: flex-end; }
.photo-row { background: var(--bg); }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 18px 12px 22px; background: var(--card); border-bottom: 1px solid var(--line); }
.side-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.last-side { font-family: var(--serif); font-size: 19px; padding: 4px 26px; border-radius: 6px; background: color-mix(in srgb, var(--t-feed) 32%, transparent); visibility: hidden; }
.last-side.show { visibility: visible; }
.side-clock { display: flex; align-items: baseline; gap: 2px; min-height: 64px; position: relative; font-family: var(--serif); font-variant-numeric: tabular-nums; }
.side-clock.center { justify-content: center; }
.side-clock .big { font-size: 60px; line-height: 1; font-weight: 300; }
.side-clock small { font-size: 16px; margin-right: 10px; color: var(--ink); }
.pencil { position: absolute; right: -28px; top: 8px; font-size: 22px; color: var(--ink); }
.side-toggle { padding: 13px 0; width: 150px; border-radius: 999px; font-size: 18px; font-weight: 600; box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); }
.side-toggle.on { background: var(--accent); color: #fff; box-shadow: none; }
.side-toggle.wide { width: 220px; }
.interval { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 22px 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.side-col .pair { width: 100%; grid-template-columns: 1fr; }

.action-menu { background: var(--card); width: 100%; max-width: 640px; border-radius: 22px 22px 0 0; padding: 10px 0 calc(env(safe-area-inset-bottom) + 10px); animation: up .22s cubic-bezier(.2, .8, .2, 1); }
@media (min-width: 700px) { .action-menu { border-radius: 22px; } }
.action-menu button[role=menuitem] { display: flex; align-items: center; gap: 22px; width: 100%; padding: 14px 26px; font-family: var(--serif); font-size: 26px; text-align: left; }
.menu-cancel { width: 100%; padding: 16px; color: var(--ink-2); font-size: 16px; border-top: 1px solid var(--line); margin-top: 6px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); background: #1f2b3a; color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 80; display: flex; gap: 16px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100% - 32px); font-size: 15px; animation: fade .2s; }
.toast .link { color: #ffd166; }
.offline-bar { position: sticky; top: 0; z-index: 40; background: #5d6a7c; color: #fff; text-align: center; font-size: 13px; padding: calc(env(safe-area-inset-top) + 4px) 12px 5px; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 4px calc(env(safe-area-inset-bottom) + 4px); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; padding: 4px 0; }
.tabbar a.on { color: var(--navy); }
.tab-icon { height: 28px; display: grid; place-items: center; }

/* ---------- history ---------- */
.history-bar, .range-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.history-bar > .segmented { flex: 0 1 220px; }
.pager { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.range-bar .segmented { flex: 1 1 260px; }
.toolbar { margin-bottom: 8px; }
.search { border-radius: 999px !important; padding-left: 16px !important; }

.week { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 8px; }
.wk-head { display: grid; grid-template-columns: 44px repeat(7, 1fr); border-bottom: 1px solid var(--line); position: relative; }
.wk-month { position: absolute; left: 6px; top: 4px; font-size: 12px; color: var(--ink-2); }
.wk-day { display: flex; flex-direction: column; align-items: center; padding: 18px 0 8px; gap: 2px; }
.wk-day:first-of-type { grid-column: 2; }
.wk-day small { font-weight: 600; color: var(--ink); font-size: 13px; }
.wk-day strong { font-size: 22px; font-weight: 400; }
.wk-day.today strong { color: var(--accent); }
.wk-day.on { background: var(--navy); color: #fff; }
.wk-day.on small { color: #fff; }
.wk-day.on.today strong { color: #fff; }
.wk-scroll { max-height: 56vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wk-body { position: relative; background: var(--card); }
.wk-night { position: absolute; left: 0; right: 0; background: var(--soft); }
.wk-hour { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--grid); }
.wk-hour span { position: absolute; left: 4px; top: 2px; font-size: 11px; color: var(--ink-2); width: 36px; text-align: center; line-height: 1.1; }
.wk-cols { position: absolute; top: 0; bottom: 0; left: 44px; right: 0; }
.wk-block { position: absolute; border-radius: 3px; background: var(--tone, var(--t-feed)); min-height: 7px; }
.wk-block.alt { background: var(--t-feed-2); }
.wk-block.dot { background: color-mix(in srgb, var(--t-diaper) 70%, var(--ink) 30%); height: 6px !important; border-radius: 3px; width: calc(100% / 7 - 26px) !important; margin-left: 9px; }
.wk-block.live { background: var(--accent); }
.fill-feed { --tone: var(--t-feed); } .fill-pump { --tone: var(--t-pump); } .fill-diaper { --tone: var(--t-diaper); } .fill-sleep { --tone: var(--t-sleep); }
.fill-health { --tone: var(--t-health); } .fill-activity { --tone: var(--t-activity); } .fill-milestone { --tone: var(--t-milestone); } .fill-growth { --tone: var(--t-growth); }
.wk-now { position: absolute; height: 0; border-top: 2px solid var(--navy); }
.wk-now::after { content: ''; position: absolute; right: -2px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); }

/* ---------- charts ---------- */
.chart-card { padding-bottom: 10px; }
.chart-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.chart-head .card-title { margin-bottom: 0; }
.chart-readout { font-size: 13px; color: var(--ink-2); min-height: 18px; }
.chart-readout strong { color: var(--ink); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--ink-2); font-size: 9.5px; font-family: var(--sans); }
.chart .hovered path { opacity: .8; }
.chart .rhythm-row { fill: var(--soft); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin: 2px 0 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.dot { border-radius: 50%; }
.table-view { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.table-view summary { cursor: pointer; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.insights { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.insights div { display: flex; flex-direction: column; }
.insights dt { font-size: 13px; color: var(--ink-2); }
.insights dd { margin: 0; font-family: var(--serif); font-size: 22px; }
.growth-chart .pct-line { fill: none; stroke: var(--muted); stroke-width: 1; opacity: .7; }
.growth-chart .pct-line.median { stroke-width: 1.6; opacity: 1; }
.growth-chart .pct-band { fill: color-mix(in srgb, var(--t-growth) 30%, transparent); }
.growth-chart .data-line { fill: none; stroke: var(--series-1); stroke-width: 2; }
.growth-chart .data-dot { fill: var(--series-1); stroke: var(--card); stroke-width: 2; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 28px 22px; }
.auth-card .logo { font-size: 48px; text-align: center; }
.auth-card h1 { text-align: center; font-size: 32px; margin: 6px 0 4px; }

@media (max-width: 380px) {
  .baby-name { font-size: 28px; }
  .cat-head h2 { font-size: 26px; }
  .big-value { font-size: 40px; }
  .side-clock .big { font-size: 50px; }
  .side-toggle { width: 130px; font-size: 16px; }
  .action-menu button[role=menuitem] { font-size: 22px; }
}

.time-compact { position: relative; display: inline-block; font-size: 17px; color: var(--ink); padding: 6px 0; cursor: pointer; }
.time-compact input { position: absolute; inset: 0; opacity: 0; width: 100% !important; cursor: pointer; padding: 0 !important; }
.time-compact input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.summary { padding-top: 26px; }
.btn.danger.armed { background: var(--danger); color: #fff !important; }
.link.danger.armed { font-weight: 700; }
