:root {
  color-scheme: light;
  --paper: #f6f7f2;
  --paper-deep: #e9eee7;
  --ink: #173d34;
  --ink-soft: #315b50;
  --muted: #75827b;
  --line: #dfe6df;
  --accent: #df704f;
  --accent-dark: #bd5235;
  --accent-pale: #fff0e9;
  --white: #fffefa;
  --shadow: 0 16px 42px rgba(30, 55, 46, .10);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html { width: 100%; min-width: 320px; overflow-x: hidden; touch-action: pan-y; }
body { width: 100%; margin: 0; min-height: 100vh; overflow-x: hidden; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(223,112,79,.32); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

main { width: min(100%, 1000px); margin: 0 auto; padding: 34px 28px 88px; animation: page-in .42s ease both; }
h1, h2 { color: var(--ink); }
h1 { font-family: Georgia, "Noto Serif SC", "Songti SC", serif; font-size: clamp(30px, 4vw, 42px); line-height: 1.12; letter-spacing: -.045em; font-weight: 650; }
h2 { font-size: 20px; letter-spacing: -.025em; line-height: 1.35; }
.eyebrow { margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Beijing-time night palette; the daytime palette stays unchanged. */
:root[data-theme="night"] {
  color-scheme: dark;
  --paper: #111e1c;
  --paper-deep: #20332e;
  --ink: #e0ece4;
  --ink-soft: #b4cec0;
  --muted: #9aafa4;
  --line: #30453c;
  --accent: #c4694d;
  --accent-dark: #f3a48a;
  --accent-pale: #3a2925;
  --white: #192a25;
  --shadow: 0 16px 42px rgba(0,0,0,.3);
}
.night-moon { display: none; }
:root[data-theme="night"] .night-moon {
  display: grid; place-items: center; position: absolute; z-index: 0;
  top: 174px; left: 63%; right: auto; z-index: 2;
  width: 52px; height: 52px; pointer-events: none;
}
.night-moon span {
  display: block; width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #eee9c9, #d2c995 65%, #a9ae91);
  box-shadow: 0 0 14px rgba(243,225,171,.24), 0 0 34px rgba(216,223,184,.1), inset -6px -4px 10px rgba(74,95,76,.28);
  animation: moon-breathe 5s ease-in-out infinite alternate;
}
.night-moon span::after {
  content: ""; display: block; width: 7px; height: 7px; margin: 12px 0 0 11px; border-radius: 50%;
  background: rgba(125,139,103,.15); box-shadow: 15px 11px 0 1px rgba(125,139,103,.12), 3px 20px 0 -1px rgba(125,139,103,.2);
}
@keyframes moon-breathe { to { filter: brightness(1.08); box-shadow: 0 0 28px rgba(243,225,171,.48), 0 0 60px rgba(216,223,184,.2), inset -6px -4px 10px rgba(74,95,76,.25); } }
.topbar, .statistics-header { position: relative; }
.topbar { isolation:isolate; overflow:visible; z-index:2; }
.topbar > :not(.night-moon) { position:relative; z-index:1; }
:root[data-theme="night"] .topbar::before {
  content:""; position:absolute; inset:0; z-index:0; pointer-events:none; opacity:.75;
  background:
    radial-gradient(circle at 12% 25%, rgba(255,255,220,.9) 0 1px, transparent 2px),
    radial-gradient(circle at 38% 18%, rgba(255,255,220,.7) 0 1px, transparent 2px),
    radial-gradient(circle at 64% 72%, rgba(255,255,220,.8) 0 1px, transparent 2px),
    radial-gradient(circle at 82% 26%, rgba(255,255,220,.75) 0 1px, transparent 2px),
    radial-gradient(circle at 91% 78%, rgba(255,255,220,.8) 0 1px, transparent 2px);
  animation: stars-twinkle 2.8s ease-in-out infinite alternate;
}
:root[data-theme="night"] .topbar::after {
  content:""; position:absolute; z-index:2; top:-28px; left:calc(100% - 20px); width:76px; height:2px;
  pointer-events:none; opacity:0; border-radius:999px; transform:rotate(24deg);
  background:linear-gradient(90deg, transparent, rgba(255,248,211,.75));
  box-shadow:0 0 8px rgba(255,248,211,.65), -130px 92px 0 -0.4px rgba(255,248,211,.7), -245px 178px 0 -0.6px rgba(255,248,211,.62), -70px 230px 0 -0.5px rgba(255,248,211,.55);
  animation:meteor-fall 7s ease-in-out infinite;
}
@keyframes stars-twinkle { 0%,100% { opacity:.42; } 50% { opacity:1; } }
:root[data-theme="night"] body::before {
  content:""; position:fixed; inset:0; z-index:9998; pointer-events:none; opacity:.72; mix-blend-mode:screen;
  background:
    radial-gradient(circle at 7% 12%, rgba(255,255,225,.9) 0 1px, transparent 2px), radial-gradient(circle at 16% 38%, rgba(255,255,225,.75) 0 1px, transparent 2px), radial-gradient(circle at 24% 76%, rgba(255,255,225,.82) 0 1px, transparent 2px), radial-gradient(circle at 33% 20%, rgba(255,255,225,.76) 0 1px, transparent 2px), radial-gradient(circle at 42% 58%, rgba(255,255,225,.9) 0 1px, transparent 2px), radial-gradient(circle at 51% 9%, rgba(255,255,225,.7) 0 1px, transparent 2px), radial-gradient(circle at 59% 84%, rgba(255,255,225,.78) 0 1px, transparent 2px), radial-gradient(circle at 68% 32%, rgba(255,255,225,.85) 0 1px, transparent 2px), radial-gradient(circle at 76% 68%, rgba(255,255,225,.72) 0 1px, transparent 2px), radial-gradient(circle at 84% 17%, rgba(255,255,225,.88) 0 1px, transparent 2px), radial-gradient(circle at 91% 48%, rgba(255,255,225,.76) 0 1px, transparent 2px), radial-gradient(circle at 96% 90%, rgba(255,255,225,.84) 0 1px, transparent 2px);
  animation:full-stars-twinkle 3.6s ease-in-out infinite alternate;
}
@keyframes full-stars-twinkle { 0%,100% { opacity:.32; filter:brightness(.8); } 35% { opacity:.9; filter:brightness(1.15); } 68% { opacity:.48; filter:brightness(.95); } }
@keyframes meteor-fall { 0%,58% { opacity:0; transform:translate(0,0) rotate(125deg); } 64% { opacity:1; } 76%,100% { opacity:0; transform:translate(-240px,300px) rotate(125deg); } }
:root[data-theme="night"] body::after {
  content:""; position:fixed; z-index:9999; top:-24px; right:-80px; width:86px; height:2px;
  pointer-events:none; opacity:0; border-radius:999px; transform:rotate(125deg);
  background:linear-gradient(90deg, transparent, rgba(255,248,211,.82));
  box-shadow:0 0 9px rgba(255,248,211,.72), -180px 180px 0 -0.4px rgba(255,248,211,.66), -360px 380px 0 -0.6px rgba(255,248,211,.58), -80px 520px 0 -0.5px rgba(255,248,211,.55);
  animation:global-meteor-fall 6s ease-in-out infinite;
}
@keyframes global-meteor-fall { 0%,52% { opacity:0; transform:translate(0,0) rotate(125deg); } 58% { opacity:1; } 78%,100% { opacity:0; transform:translate(-70vw,90vh) rotate(125deg); } }
:root[data-theme="night"] .weather-widget,
:root[data-theme="night"] .summary-section,
:root[data-theme="night"] .statistics-metrics,
:root[data-theme="night"] .stats-sk-metrics,
:root[data-theme="night"] .loading-summary { background: #1b2e28; border-color: var(--line); }
:root[data-theme="night"] .weather-refresh,
:root[data-theme="night"] .record-date-nav button,
:root[data-theme="night"] .record-date-nav input { background: var(--white); border-color: var(--line); }
:root[data-theme="night"] .quick-actions span { background: #273d32; }
:root[data-theme="night"] .quick-actions button:first-child span,
:root[data-theme="night"] .quick-actions button:nth-child(4) span { background: var(--accent-pale); }
:root[data-theme="night"] .metrics > div,
:root[data-theme="night"] .statistics-metrics > *,
:root[data-theme="night"] .field input,
:root[data-theme="night"] .field textarea,
:root[data-theme="night"] .field select,
:root[data-theme="night"] .choice,
:root[data-theme="night"] .record-sheet { border-color: var(--line); }
:root[data-theme="night"] .choice.selected { background: var(--ink-soft); color: var(--paper); }
:root[data-theme="night"] .choice:hover:not(.selected),
:root[data-theme="night"] .edit-button:hover,
:root[data-theme="night"] .range-tabs button:hover { background: var(--paper-deep); }
:root[data-theme="night"] .event-copy p,
:root[data-theme="night"] .event-author,
:root[data-theme="night"] .delete-button { color: var(--muted); }
:root[data-theme="night"] .active-sleep { background: #244136; border-color: #456452; }
:root[data-theme="night"] .primary:hover { background: #a9553e; }
:root[data-theme="night"] .toast { background: #304b3e; color: var(--ink); }
:root[data-theme="night"] .form-error { color: #f3a48a !important; }
:root[data-theme="night"] .sheet-handle,
:root[data-theme="night"] .horizontal-track { background: var(--line); }
:root[data-theme="night"] .setup-panel input { color: var(--ink); }
:root[data-theme="night"] .skeleton-block { background: linear-gradient(100deg, #20352d 20%, #2b4036 42%, #20352d 64%); background-size: 220% 100%; }
:root[data-theme="night"] .weather-effect-layer { opacity: .12; }
:root[data-theme="night"] .weather-effect-sunshine { display: none; }
:root[data-theme="night"] .trend-track { background: repeating-linear-gradient(to top, transparent 0, transparent 45px, rgba(211,234,220,.09) 46px, transparent 47px); }

/* Header and orientation */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.brand-heading { display: flex; flex: 1; align-items: center; gap: 16px; min-width: 0; }
.brand-heading > div { min-width: 0; }
.header-logo { width: 76px; height: 76px; flex: 0 0 auto; object-fit: cover; border-radius: 15px; }
.avatar-control { position: relative; flex: 0 0 auto; border-radius: 15px; overflow: hidden; }
.avatar-button { display: block; padding: 0; border: 0; border-radius: inherit; background: transparent; overflow: hidden; }
.avatar-button .header-logo { display: block; }
.avatar-edit { position: absolute; inset: auto 0 0; width: 100%; border: 0; min-height: 24px; padding: 3px 0; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; text-align: center; }
.avatar-edit:disabled { opacity: .6; cursor: wait; }
.avatar-control button:focus-visible { outline-offset: -3px; }
.avatar-preview { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--white); color: var(--ink); }
.avatar-preview::backdrop { background: rgba(5,15,12,.85); backdrop-filter: blur(4px); }
.avatar-preview img { display: block; width: 100%; max-height: calc(100dvh - 100px); object-fit: contain; border-radius: 12px; }
.avatar-crop { width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: var(--white); color: var(--ink); box-shadow: var(--shadow); }
.avatar-crop::backdrop { background: rgba(5,15,12,.75); backdrop-filter: blur(4px); }
.avatar-crop p { margin: 8px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.avatar-crop canvas { display: block; width: min(100%, 46dvh); height: auto; margin: 0 auto; border-radius: 12px; touch-action: none; cursor: grab; }
.avatar-crop canvas:active { cursor: grabbing; }
.crop-zoom { display: flex; align-items: center; gap: 14px; margin: 20px 0; color: var(--ink-soft); font-size: 13px; }
.crop-zoom input { flex: 1; min-width: 0; height: 30px; accent-color: var(--accent); }
.crop-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.date-heading { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 6px; letter-spacing: .04em; }
.date-heading span { white-space: nowrap; }
.baby-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; margin-top: 9px; color: var(--muted); font-size: 12px; font-weight: 600; }
.baby-meta > span { position: relative; }
.baby-meta > span + span::before { content: "·"; position: absolute; left: -10px; color: #a8b1a9; }
.account-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
.current-user { margin-right: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.quiet-button, .light-button, .close-button { border: 0; background: transparent; color: var(--ink); }
.quiet-button { min-height: 40px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 650; transition: background .18s ease, color .18s ease; }
.quiet-button:hover { background: var(--paper-deep); color: var(--ink); }
.statistics-link { display: inline-flex; align-items: center; text-decoration: none; }

/* Current weather */
.weather-widget {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(120px, 1fr) auto auto auto;
  grid-template-areas: "icon copy temperature details action";
  align-items: center;
  gap: 4px 16px;
  margin: -12px 0 28px;
  padding: 14px 18px;
  border-radius: 16px;
  background: #edf2ec;
}
.weather-icon { grid-area: icon; color: #d58a43; font-size: 38px; line-height: 1; text-align: center; animation: weather-drift 3.5s ease-in-out infinite; }
.weather-icon-rain { color: #668d9b; animation-duration: 2.4s; }
.weather-copy { grid-area: copy; min-width: 0; }
.weather-location { overflow: hidden; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .06em; text-overflow: ellipsis; white-space: nowrap; }
.weather-condition { color: var(--ink); font-size: 14px; font-weight: 700; }
.weather-temperature { grid-area: temperature; display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.weather-temperature strong { color: var(--ink); font-family: Georgia, "Noto Serif SC", serif; font-size: 32px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.weather-temperature span, .weather-details { color: var(--muted); font-size: 11px; }
.weather-details { grid-area: details; display: grid; gap: 4px; white-space: nowrap; }
.weather-refresh { grid-area: action; min-height: 36px; padding: 0 12px; border: 1px solid #d5dfd5; border-radius: 10px; background: rgba(255,254,250,.75); color: var(--ink-soft); font-size: 12px; font-weight: 700; white-space: nowrap; }
.weather-refresh:hover:not(:disabled) { border-color: #b7c8b8; background: var(--white); }
.weather-refresh:disabled { cursor: wait; opacity: .65; }
.quick-heading-tools { display: flex; align-items: center; gap: 12px; }
.home-refresh { min-height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--white); color: var(--ink-soft); font-size: 12px; font-weight: 750; }
.home-refresh:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.home-refresh:disabled { cursor: wait; opacity: .6; }
.weather-effect-layer { position: fixed; z-index: 8; inset: 0; display: block; width: 100vw; height: 100vh; height: 100dvh; opacity: .72; pointer-events: none; }
.weather-effect-sunshine { background-image: radial-gradient(ellipse 56% 36% at 87% 8%, rgba(255,222,164,.38), transparent 80%), radial-gradient(ellipse 68% 46% at 100% 23%, rgba(248,205,139,.28), transparent 82%), radial-gradient(ellipse 54% 50% at 16% 72%, rgba(255,246,221,.16), transparent 84%); background-size: 112% 110%; animation: sunshine-glow 26s ease-in-out infinite alternate; }
.weather-effect-clouds { --weather-drift-distance: 150vw; background-image: radial-gradient(ellipse 24% 16% at 25% 20%, rgba(255,255,255,.78) 0 36%, rgba(181,194,187,.26) 64%, transparent 88%), radial-gradient(ellipse 30% 18% at 74% 26%, rgba(255,255,255,.82) 0 36%, rgba(181,194,187,.28) 66%, transparent 90%), radial-gradient(ellipse 24% 16% at 50% 72%, rgba(255,255,255,.72) 0 34%, rgba(181,194,187,.22) 64%, transparent 88%); background-size: 150vw 100vh; background-repeat: repeat-x; animation: weather-cloud-drift 7s linear infinite; filter: drop-shadow(0 2px 8px rgba(100,119,109,.28)); }
.weather-effect-snow { filter: drop-shadow(0 0 2px rgba(83,111,120,.68)); }
.weather-effect-fog { --weather-drift-distance: 220vw; background-image: radial-gradient(ellipse 20% 22% at 24% 34%, rgba(224,231,227,.34), rgba(250,251,249,.42) 48%, transparent 88%), radial-gradient(ellipse 23% 28% at 51% 66%, rgba(247,249,247,.52), rgba(216,225,220,.3) 56%, transparent 90%), radial-gradient(ellipse 21% 24% at 78% 39%, rgba(222,230,225,.36), rgba(249,250,248,.4) 50%, transparent 88%); background-size: 220vw 100vh; background-repeat: repeat-x; animation: weather-cloud-drift 5s linear infinite; }
.weather-effect-layer[hidden] { display: none; }
.app-attribution { margin-top: 24px; color: var(--muted); font-size: 10px; text-align: right; }
.app-attribution a { color: inherit; }
.app-attribution a:hover { color: var(--ink-soft); }

/* Quick records */
.quick-section { padding: 4px 0 28px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 17px; }
.section-heading h2 { font-size: 21px; }
.live-clock { color: var(--muted); font-size: 20px; font-variant-numeric: tabular-nums; }
.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quick-actions button { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 64px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--white); color: var(--ink); font-size: 14px; font-weight: 700; text-align: left; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.quick-actions button:hover { transform: translateY(-2px); border-color: #c5d3c9; box-shadow: 0 8px 18px rgba(28,59,49,.07); }
.quick-actions button:active { transform: translateY(0) scale(.985); }
.quick-actions span { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; background: #edf3ed; color: var(--ink-soft); font-family: "Noto Serif SC", "Songti SC", serif; font-size: 17px; }
.quick-actions button:first-child span, .quick-actions button:nth-child(4) span { background: var(--accent-pale); color: var(--accent-dark); }

/* Today's overview */
.active-sleep { display: flex; align-items: center; gap: 14px; margin: 0 0 18px; padding: 15px 18px; border: 1px solid #315e50; border-radius: 16px; background: var(--ink); color: white; }
.active-sleep div:nth-child(2) { flex: 1; }
.active-sleep p { color: rgba(255,255,255,.72); font-size: 12px; }
.active-sleep strong { font-size: 23px; font-variant-numeric: tabular-nums; }
.sleep-pulse { width: 10px; height: 10px; border-radius: 50%; background: #f4c985; box-shadow: 0 0 0 0 rgba(244,201,133,.45); animation: pulse 2s infinite; }
.light-button { min-height: 40px; padding: 0 15px; border: 1px solid rgba(255,255,255,.32); border-radius: 10px; color: white; font-size: 13px; font-weight: 700; }
.light-button:hover { background: rgba(255,255,255,.1); }
.summary-section { margin: 2px 0 32px; padding: 20px 22px 22px; border: 1px solid #e4e9e2; border-radius: 20px; background: #eef2eb; }
.record-date-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 19px; }
.record-date-nav button { min-width: 40px; height: 40px; padding: 0 12px; border: 1px solid #d8e1d8; border-radius: 10px; background: rgba(255,254,250,.85); color: var(--ink); font-size: 13px; font-weight: 650; transition: background .18s ease, border-color .18s ease; }
.record-date-nav button:hover:not(:disabled) { border-color: #b8cbbd; background: var(--white); }
.record-date-nav input { width: 158px; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid #d8e1d8; border-radius: 10px; background: rgba(255,254,250,.85); color: var(--ink); font-size: 14px; }
.record-date-nav button:disabled { opacity: .42; cursor: default; }
.summary-section > .section-heading { align-items: flex-start; margin-bottom: 12px; }
.summary-section #summary-title { max-width: 690px; color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.6; letter-spacing: 0; overflow-wrap: anywhere; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.metrics > div { min-width: 0; padding: 6px 18px 4px; border-left: 1px solid #d8e1d8; }
.metrics > div:first-child { padding-left: 0; border-left: 0; }
.metrics strong { display: block; overflow-wrap: anywhere; color: var(--ink); font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(28px, 3.5vw, 36px); line-height: 1.15; font-weight: 500; font-variant-numeric: tabular-nums; }
.metrics span { color: var(--muted); font-size: 12px; }
.diaper-breakdown { display: block; margin-top: 5px; }

/* Timeline */
.timeline-section { padding-top: 0; }
.timeline-section > .section-heading { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.timeline-section .eyebrow { margin-bottom: 5px; }
.count { color: var(--muted); font-size: 12px; }
.timeline { min-height: 130px; }
.timeline-item { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 14px; padding: 17px 4px; border-bottom: 1px solid var(--line); animation: row-in .3s ease both; }
.event-time { padding-top: 3px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.event-copy { min-width: 0; overflow-wrap: anywhere; }
.event-copy strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 15px; }
.event-copy p { color: #65756c; font-size: 13px; line-height: 1.55; }
.event-author { display: inline-block; margin-top: 6px; color: #8a796b; font-size: 11px; font-weight: 650; }
.event-actions { display: flex; align-items: center; }
.edit-button, .delete-button { min-width: 40px; min-height: 40px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; font-size: 12px; }
.edit-button { color: var(--ink-soft); }
.edit-button:hover { background: #e9eee7; }
.delete-button { color: #9b8d83; font-size: 20px; opacity: .65; }
.delete-button:hover { background: var(--accent-pale); color: var(--accent-dark); opacity: 1; }
.empty { padding: 42px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; text-align: center; }

/* Record and member sheets */
.sheet-backdrop { position: fixed; z-index: 10; inset: 0; background: rgba(18, 38, 31, .44); backdrop-filter: blur(4px); animation: fade-in .2s ease; }
.record-sheet { position: fixed; z-index: 11; top: 50%; left: 50%; width: min(560px, calc(100% - 36px)); max-height: min(88svh, 780px); overflow-y: auto; transform: translate(-50%, -50%); padding: 15px 28px 26px; border: 1px solid rgba(255,255,255,.72); border-radius: 22px; background: var(--white); box-shadow: var(--shadow); animation: dialog-in .24s cubic-bezier(.2,.8,.2,1) both; overscroll-behavior: contain; }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 20px; border-radius: 9px; background: #d9dfd7; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.sheet-head h2 { font-family: Georgia, "Noto Serif SC", serif; font-size: 25px; }
.close-button { width: 40px; height: 40px; border-radius: 10px; color: var(--muted); font-size: 27px; line-height: 1; }
.close-button:hover { background: var(--paper); color: var(--ink); }
.field { display: block; margin-bottom: 16px; color: var(--ink-soft); font-size: 12px; font-weight: 750; letter-spacing: .035em; }
.field input, .field textarea, .field select { display: block; width: 100%; margin-top: 6px; padding: 11px 2px; border: 0; border-bottom: 1px solid #d9e0d8; border-radius: 0; background: transparent; color: var(--ink); outline: 0; transition: border-color .18s ease; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field input::placeholder, .field textarea::placeholder { color: #a0aaa2; }
.datetime-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field textarea { min-height: 64px; resize: vertical; }
.choice-row { display: flex; flex-wrap: wrap; gap: 9px; margin: 9px 0 18px; }
.food-choice { position: relative; display: inline-flex; max-width: 100%; }
.choice { max-width: 100%; min-height: 40px; padding: 8px 14px; border: 1px solid #dce4dc; border-radius: 999px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; overflow-wrap: anywhere; transition: background .16s ease, border-color .16s ease, color .16s ease; }
.choice:hover { border-color: #adc4b4; background: #f2f6f1; }
.choice.selected { border-color: var(--ink); background: var(--ink); color: white; }
#note-choices .choice { white-space: pre-wrap; }
.food-choice-delete { position: absolute; z-index: 1; top: -6px; right: -5px; display: grid; place-items: center; width: 21px; height: 21px; padding: 0; border: 1px solid #d7ded7; border-radius: 50%; background: var(--white); color: #8f7568; font-size: 16px; line-height: 1; box-shadow: 0 2px 6px rgba(23,60,50,.10); }
.food-choice-delete:hover { border-color: var(--accent); color: var(--accent-dark); }
.food-choice-delete:disabled { opacity: .45; cursor: wait; }
.primary { min-height: 50px; padding: 0 22px; border: 0; border-radius: 12px; background: var(--accent); color: white; font-weight: 800; box-shadow: 0 7px 16px rgba(223,112,79,.17); transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.primary:hover { transform: translateY(-1px); background: var(--accent-dark); box-shadow: 0 10px 20px rgba(223,112,79,.22); }
.primary:active { transform: scale(.99); }
.wide { width: 100%; }

/* Setup, login, notices */
.setup { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 24px; background: var(--paper); }
.setup-panel { width: min(100%, 420px); padding: 30px 0; }
.setup-panel h1 { margin-bottom: 8px; font-size: 34px; }
.setup-panel > p:not(.eyebrow) { margin-bottom: 28px; color: var(--muted); line-height: 1.6; }
.setup-panel label { display: block; margin: 18px 0; color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.setup-panel input { display: block; width: 100%; margin-top: 7px; padding: 13px 2px; border: 0; border-bottom: 1px solid var(--line); background: transparent; outline: 0; }
.brand-logo { width: 72px; height: 72px; margin-bottom: 22px; border-radius: 22px; object-fit: cover; }
.form-error { margin: 0 0 14px !important; padding: 11px 13px; border-radius: 10px; background: var(--accent-pale); color: #a33e2d !important; font-size: 13px; }
.toast { position: fixed; z-index: 20; bottom: max(22px, env(safe-area-inset-bottom)); left: 50%; max-width: calc(100% - 32px); padding: 12px 17px; transform: translateX(-50%); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: var(--ink); color: white; box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: 13px; text-align: center; }

/* Statistics page shares the same quiet visual system */
.statistics-page { max-width: 1000px; }
.statistics-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "back back" "title action"; align-items: center; column-gap: 14px; row-gap: 10px; margin-bottom: 22px; }
.statistics-header h1 { font-size: 32px; letter-spacing: -.035em; }
.statistics-header .back-link { grid-area: back; justify-self: start; }
.statistics-title-group { grid-area: title; display: flex; align-items: center; gap: 14px; min-width: 0; }
.statistics-title-group > div { min-width: 0; }
.statistics-header #reload { grid-area: action; justify-self: end; }
.statistics-header .header-logo { width: 76px; height: 76px; border-radius: 15px; }
.back-link { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; color: var(--ink); font-size: 23px; text-decoration: none; }
.back-link:hover { background: var(--paper-deep); }
.range-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.range-tabs button { min-height: 42px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 650; transition: color .16s ease, background .16s ease, border-color .16s ease; }
.range-tabs button[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--ink); }
.range-tabs button:hover { background: #eef2eb; color: var(--ink); }
.custom-range { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin-top: 18px; }
.custom-range label { display: grid; flex: 1; min-width: 130px; gap: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.custom-range input, .chart-heading select { min-width: 0; max-width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); color: var(--ink); }
.custom-range .primary { min-height: 42px; }
#statistics-status { margin-top: 20px; color: var(--muted); }
.statistics-skeleton { margin-top: 22px; }
.stats-sk-caption { width: 275px; max-width: 55%; height: 14px; margin-bottom: 16px; border-radius: 6px; }
.stats-sk-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 24px; padding: 18px 20px; border: 1px solid #e4e9e2; border-radius: 18px; background: #eef2eb; }
.stats-sk-metrics > span { height: 72px; margin: 4px 14px; border-radius: 8px; }
.stats-sk-chart { display: grid; gap: 14px; }
.stats-sk-heading { width: 130px; height: 22px; border-radius: 7px; }
.stats-sk-bars { display: flex; height: 225px; align-items: end; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stats-sk-bars > i { flex: 1; height: 48%; border-radius: 7px 7px 2px 2px; }
.stats-sk-bars > i:nth-child(3n + 1) { height: 77%; }
.stats-sk-bars > i:nth-child(3n + 2) { height: 62%; }
.stats-sk-bars > i:nth-child(4n) { height: 35%; }
.stats-sk-line { width: 100%; height: 14px; border-radius: 7px; }
.stats-sk-line:nth-of-type(3) { width: 82%; }
.stats-sk-line:nth-of-type(4) { width: 66%; }
.range-caption { margin: 22px 0 16px; color: var(--muted); font-size: 12px; }
.statistics-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 24px; padding: 18px 20px; border: 1px solid #e4e9e2; border-radius: 18px; background: #eef2eb; }
.statistics-metrics > * { min-width: 0; padding: 4px 14px; border-left: 1px solid #d8e1d8; }
.statistics-metrics > *:first-child { padding-left: 0; border-left: 0; }
.stat-value { display: block; overflow-wrap: anywhere; color: var(--ink); font-family: Georgia, "Noto Serif SC", serif; font-size: 29px; line-height: 1.15; }
.stat-label, .stat-average { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.stat-split { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.chart-section { padding: 24px 0; border-top: 1px solid var(--line); }
.chart-section h2 { font-size: 18px; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.trend-scroll { overflow-x: auto; padding-bottom: 8px; scrollbar-color: #c3d0c5 transparent; }
.trend-bars { display: flex; min-width: 100%; height: 230px; align-items: stretch; gap: 8px; }
.trend-column { display: grid; flex: 1 0 44px; grid-template-rows: 22px 184px 22px; gap: 3px; color: var(--muted); font-size: 10px; text-align: center; }
.trend-track { display: flex; align-items: end; justify-content: center; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0, transparent 45px, rgba(23,60,50,.055) 46px, transparent 47px); }
.trend-bar { width: 58%; max-width: 42px; border-radius: 7px 7px 2px 2px; background: var(--ink-soft); transition: height .22s ease; }
.horizontal-chart { display: grid; gap: 14px; margin-top: 20px; }
.horizontal-row { display: grid; grid-template-columns: minmax(60px, 130px) minmax(0, 1fr) 56px; align-items: center; gap: 12px; font-size: 12px; }
.horizontal-row > span:first-child { overflow-wrap: anywhere; color: var(--ink-soft); }
.horizontal-track { height: 10px; overflow: hidden; border-radius: 999px; background: #e7ece6; }
.horizontal-bar { height: 100%; border-radius: inherit; background: var(--accent); }
.horizontal-row:nth-child(3n + 2) .horizontal-bar { background: #688c77; }
.horizontal-row:nth-child(3n) .horizontal-bar { background: #b7a58a; }
.horizontal-row > span:last-child { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.statistics-empty { padding: 24px 0; color: var(--muted); font-size: 13px; }

/* Loading skeletons */
.skeleton-block { display: block; overflow: hidden; border-radius: 8px; background: linear-gradient(100deg, #e7ece6 20%, #f5f6f1 42%, #e7ece6 64%); background-size: 220% 100%; animation: skeleton-shimmer 1.45s ease-in-out infinite; }
.app-loading { width: min(100%, 1000px); margin: 0 auto; padding: 34px 28px 88px; }
.loading-header { display: flex; align-items: center; gap: 16px; margin-bottom: 30px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.loading-avatar { width: 76px; height: 76px; flex: 0 0 auto; border-radius: 15px; }
.loading-brand { display: grid; flex: 1; justify-items: start; gap: 8px; }
.loading-small { width: 96px; height: 11px; border-radius: 6px; }
.loading-title { width: min(270px, 80%); height: 39px; border-radius: 9px; }
.loading-meta { width: 170px; height: 12px; border-radius: 6px; }
.loading-menu { width: 110px; height: 32px; border-radius: 9px; }
.loading-weather { height: 96px; margin: -12px 0 28px; border-radius: 16px; }
.loading-section-heading { display: grid; justify-items: start; gap: 9px; margin-bottom: 15px; }
.loading-subtitle { width: 205px; height: 22px; border-radius: 7px; }
.loading-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.loading-actions > span { height: 64px; border: 1px solid var(--line); border-radius: 15px; background-color: var(--white); }
.loading-summary { margin: 2px 0 32px; padding: 20px 22px 22px; border: 1px solid #e4e9e2; border-radius: 20px; background: #eef2eb; }
.loading-date { width: 275px; max-width: 100%; height: 40px; margin-bottom: 19px; border-radius: 10px; }
.loading-summary > .loading-small { width: 84px; margin-bottom: 17px; }
.loading-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.loading-metrics > span { height: 69px; margin-right: 18px; border-radius: 8px; }
.loading-timeline > .loading-small { margin-bottom: 12px; }
.loading-timeline > .loading-subtitle { margin-bottom: 8px; }
.loading-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 14px; padding: 17px 4px; border-bottom: 1px solid var(--line); }
.loading-row > .skeleton-block { width: 40px; height: 14px; margin-top: 3px; }
.loading-row > span:last-child { display: grid; gap: 8px; }
.loading-row i { width: 42%; height: 13px; border-radius: 6px; }
.loading-row i + i { width: 27%; height: 11px; }
.weather-widget.is-loading > :not(.weather-skeleton) { visibility: hidden; }
.weather-skeleton { position: absolute; inset: 0; display: none; grid-template-columns: 54px minmax(120px, 1fr) auto auto auto; grid-template-areas: "icon copy temperature details action"; align-items: center; gap: 4px 16px; padding: 14px 18px; }
.weather-widget.is-loading .weather-skeleton { display: grid; }
.weather-sk-icon { grid-area: icon; width: 38px; height: 38px; justify-self: center; border-radius: 50%; }
.weather-sk-copy { grid-area: copy; display: grid; gap: 9px; }
.weather-sk-copy i { width: min(165px, 90%); height: 12px; border-radius: 6px; }
.weather-sk-copy i + i { width: min(125px, 72%); height: 17px; }
.weather-sk-temperature { grid-area: temperature; width: 62px; height: 33px; border-radius: 8px; }
.weather-sk-details { grid-area: details; width: 108px; height: 15px; border-radius: 6px; }
.weather-sk-action { grid-area: action; width: 98px; height: 40px; border-radius: 11px; }

@keyframes page-in { from { opacity: 0; transform: translateY(7px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: .7; transform: translate(-50%, calc(-50% + 14px)); } }
@keyframes sheet-in { from { opacity: .75; transform: translate(-50%, 24px); } }
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(244,201,133,0); } 100% { box-shadow: 0 0 0 0 rgba(244,201,133,0); } }
@keyframes weather-drift { 50% { transform: translateY(-3px); } }
@keyframes skeleton-shimmer { to { background-position-x: -220%; } }
@keyframes sunshine-glow { from { background-position: 0% 0%; filter: brightness(.98); } to { background-position: 6% 4%; filter: brightness(1.02); } }
@keyframes weather-cloud-drift { from { background-position: 0px 50%; } to { background-position: var(--weather-drift-distance) 50%; } }

@media (max-width: 700px) {
  main { padding: 23px 18px 70px; }
  .app-loading { padding: 23px 18px 70px; }
  .loading-header { align-items: flex-start; gap: 12px; margin-bottom: 21px; padding-bottom: 17px; }
  .loading-avatar { width: 70px; height: 70px; border-radius: 18px; }
  .loading-title { height: 32px; }
  .loading-menu { width: 72px; height: 30px; }
  .loading-weather { height: 112px; margin: -6px 0 21px; border-radius: 17px; }
  .loading-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
  .loading-actions > span { height: 58px; border-radius: 13px; }
  .loading-summary { margin: 0 0 25px; padding: 15px 15px 17px; border-radius: 17px; }
  .loading-date { height: 38px; margin-bottom: 15px; }
  .loading-summary > .loading-small { margin-bottom: 12px; }
  .loading-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .loading-metrics > span { height: 60px; margin-right: 9px; }
  .loading-row { grid-template-columns: 46px minmax(0, 1fr); gap: 8px; padding: 14px 0; }
  .weather-skeleton { grid-template-columns: 42px minmax(0, 1fr) auto; grid-template-areas: "icon copy temperature" "icon details action"; gap: 5px 11px; padding: 13px 14px; }
  .weather-sk-icon { width: 32px; height: 32px; }
  .weather-sk-temperature { width: 48px; height: 29px; }
  .weather-sk-details { width: 115px; max-width: 100%; height: 12px; }
  .weather-sk-action { width: 84px; height: 32px; }
  .statistics-page { padding-top: 10px; }
  .topbar { align-items: flex-start; gap: 12px; margin-bottom: 21px; padding-bottom: 17px; }
  .brand-heading { align-items: flex-start; gap: 12px; }
  .header-logo { width: 70px; height: 70px; border-radius: 18px; }
  .topbar h1 { font-size: clamp(26px, 7vw, 34px); }
  .baby-meta { gap: 6px 14px; margin-top: 7px; font-size: 11px; }
  .account-actions { flex-wrap: wrap; gap: 2px; max-width: 124px; }
  .current-user { display: none; }
  .quiet-button { min-height: 34px; padding: 0 8px; font-size: 12px; }
  .weather-widget { grid-template-columns: 42px minmax(0, 1fr) auto; grid-template-areas: "icon copy temperature" "icon details action"; gap: 5px 11px; margin: -6px 0 21px; padding: 13px 14px; }
  .weather-icon { font-size: 33px; }
  .weather-temperature { gap: 5px; }
  .weather-temperature strong { font-size: 28px; }
  .weather-details { grid-template-columns: auto auto; gap: 8px; font-size: 10px; }
  .weather-refresh { min-height: 32px; padding-inline: 9px; font-size: 11px; }
  .quick-section { padding-bottom: 20px; }
  .section-heading { margin-bottom: 13px; }
  .section-heading h2 { font-size: 18px; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .quick-actions button { min-height: 58px; padding: 8px 10px; border-radius: 13px; font-size: 13px; }
  .quick-actions span { width: 34px; height: 34px; border-radius: 11px; font-size: 16px; }
  .summary-section { margin: 0 0 25px; padding: 15px 15px 17px; border-radius: 17px; }
  .record-date-nav { gap: 6px; margin-bottom: 14px; }
  .record-date-nav button { min-width: 38px; height: 38px; padding: 0 9px; border-radius: 9px; }
  .record-date-nav input { width: 150px; height: 38px; padding: 0 7px; font-size: 13px; }
  .summary-section > .section-heading { margin-bottom: 9px; }
  .summary-section #summary-title { font-size: 12px; }
  .metrics { row-gap: 13px; }
  .metrics > div { padding: 3px 9px; }
  .metrics > div:first-child { padding-left: 0; }
  .metrics strong { font-size: 29px; }
  .metrics span { font-size: 11px; }
  .diaper-breakdown { font-size: 10px !important; }
  .timeline-section > .section-heading { padding-bottom: 12px; }
  .timeline-item { grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; padding: 14px 0; }
  .event-time { font-size: 12px; }
  .event-copy strong { font-size: 14px; }
  .event-copy p { font-size: 12px; }
  .edit-button, .delete-button { min-width: 36px; min-height: 38px; padding: 0 5px; }
  .record-sheet { top: auto; bottom: 0; width: 100%; max-height: 90svh; padding: 9px 20px calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 0); border-radius: 22px 22px 0 0; border-bottom: 0; animation: sheet-in .25s cubic-bezier(.2,.8,.2,1) both; }
  .sheet-handle { margin-bottom: 15px; }
  .sheet-head { margin-bottom: 17px; }
  .sheet-head h2 { font-size: 23px; }
  .field { margin-bottom: 13px; }
  .choice-row { gap: 8px; }
  .statistics-header { gap: 8px; margin-bottom: 16px; }
  .statistics-header h1 { font-size: 26px; }
  .statistics-header .header-logo { width: 56px; height: 56px; border-radius: 10px; }
  .range-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
  .range-tabs button { min-height: 40px; padding: 0 3px; font-size: 11px; }
  .statistics-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; padding: 15px; border-radius: 15px; }
  .stats-sk-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; padding: 15px; border-radius: 15px; }
  .stats-sk-metrics > span { height: 60px; margin: 3px 10px; }
  .statistics-metrics > * { padding: 3px 10px; }
  .statistics-metrics > *:nth-child(odd) { padding-left: 0; border-left: 0; }
  .statistics-metrics > *:nth-child(even) { border-left: 1px solid #d8e1d8; }
  .chart-section { padding: 20px 0; }
  .chart-section h2 { font-size: 17px; }
  .horizontal-row { grid-template-columns: 74px minmax(0, 1fr) 42px; gap: 8px; font-size: 11px; }
}

@media (max-width: 390px) {
  main { padding-inline: 14px; }
  .app-loading { padding-inline: 14px; }
  .header-logo { width: 70px; height: 70px; border-radius: 18px; }
  .account-actions { max-width: 102px; }
  .account-actions .quiet-button { padding-inline: 6px; }
  .weather-widget { grid-template-columns: 34px minmax(0, 1fr) auto; column-gap: 8px; padding-inline: 11px; }
  .weather-skeleton { grid-template-columns: 34px minmax(0, 1fr) auto; column-gap: 8px; padding-inline: 11px; }
  .weather-sk-details { width: 90px; }
  .weather-icon { font-size: 29px; }
  .weather-temperature { display: grid; justify-items: end; gap: 2px; }
  .weather-temperature strong { font-size: 25px; }
  .weather-details { grid-template-columns: 1fr; gap: 2px; }
  .record-date-nav input { width: 139px; }
  .summary-section { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-block { animation: none; background: #e9eee8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
