:root {
  color-scheme: light;
  --paper: #f3efe4;
  --paper-deep: #e8e0ce;
  --ink: #173c32;
  --muted: #6f786e;
  --line: rgba(23, 60, 50, 0.14);
  --accent: #e66d4a;
  --accent-dark: #bd4e31;
  --white: #fffdf8;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { width: 100%; overflow-x: hidden; touch-action: pan-y; }
body { width: 100%; margin: 0; overflow-x: hidden; background: var(--paper); color: var(--ink); min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .35;
  background-image: radial-gradient(rgba(23,60,50,.12) .55px, transparent .55px);
  background-size: 5px 5px;
}

main { width: min(100%, 920px); margin: 0 auto; padding: 28px 22px 88px; animation: rise .45s ease both; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; min-width: 0; margin-bottom: 36px; }
.brand-heading { display: flex; flex: 1; align-items: flex-start; gap: 18px; min-width: 0; }
.brand-heading > div { min-width: 0; }
.header-logo { width: 68px; height: 68px; object-fit: contain; object-position: center; border-radius: 18px; box-shadow: 0 7px 22px rgba(47,57,42,.14); flex: 0 0 auto; }
h1, h2, p { margin: 0; }
h1 { font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(30px, 8vw, 48px); line-height: 1.12; overflow-wrap: anywhere; letter-spacing: -.04em; font-weight: 650; }
h2 { font-size: 22px; letter-spacing: -.03em; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 800; margin-bottom: 7px; }
.date-heading { display: flex; flex-wrap: wrap; gap: 4px 24px; letter-spacing: 0; }
.date-heading span { white-space: nowrap; }
.quiet-button, .light-button, .close-button { border: 0; background: transparent; color: var(--ink); min-height: 44px; padding: 0 12px; }
.quiet-button { border-bottom: 1px solid var(--ink); }
.statistics-link { display: inline-flex; align-items: center; text-decoration: none; }
.account-actions { display: flex; align-items: center; gap: 10px; }
.current-user { font-size: 12px; color: var(--muted); white-space: nowrap; }
.baby-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 15px; margin-top: 13px; color: var(--muted); font-size: 12px; font-weight: 650; }
.baby-meta > span { position: relative; }
.baby-meta > span + span::before { content: "·"; position: absolute; left: -10px; color: #aaa392; }
.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; }

.quick-section, .summary-section, .timeline-section { border-top: 1px solid var(--line); padding: 27px 0 30px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; }
.live-clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.quick-actions { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.quick-actions button { border: 0; background: transparent; color: var(--ink); min-height: 92px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; transition: transform .18s ease; }
.quick-actions button:hover { transform: translateY(-3px); }
.quick-actions span { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--white); border: 1px solid var(--line); font-family: Georgia, "Noto Serif SC", serif; font-size: 19px; box-shadow: 0 5px 18px rgba(47, 57, 42, .05); }
.quick-actions button:first-child span, .quick-actions button:nth-child(4) span { background: var(--accent); color: white; border-color: var(--accent); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); }
.metrics div { background: var(--paper); padding: 4px 16px 8px 0; }
.metrics strong { font-family: Georgia, serif; display: block; font-size: 32px; font-weight: 500; }
.metrics span { color: var(--muted); font-size: 12px; }
.diaper-breakdown { display: block; margin-top: 4px; }

.active-sleep { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--ink); color: white; margin-bottom: 28px; border-radius: 4px; }
.active-sleep div:nth-child(2) { flex: 1; }
.active-sleep p { opacity: .72; font-size: 12px; }
.active-sleep strong { font-size: 23px; font-variant-numeric: tabular-nums; }
.sleep-pulse { width: 11px; height: 11px; border-radius: 50%; background: #f3c972; box-shadow: 0 0 0 0 rgba(243,201,114,.5); animation: pulse 2s infinite; }
.light-button { color: white; border: 1px solid rgba(255,255,255,.35); border-radius: 3px; }

.timeline { min-height: 130px; }
.timeline-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); animation: insert .35s ease both; }
.event-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; padding-top: 3px; }
.event-copy strong { display: block; font-size: 15px; margin-bottom: 4px; }
.event-copy p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.event-author { display: inline-block; margin-top: 6px; color: #8d7465; font-size: 11px; font-weight: 700; }
.delete-button { border: 0; background: transparent; color: #9a8d7f; min-width: 44px; min-height: 44px; opacity: .55; }
.event-actions { display: flex; align-items: center; }
.edit-button { border: 0; background: transparent; color: var(--ink); min-width: 44px; min-height: 44px; padding: 0 6px; font-size: 12px; }
.event-copy { min-width: 0; overflow-wrap: anywhere; }
.empty { padding: 36px 0; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.count { font-size: 12px; color: var(--muted); }
#summary-title { font-size: 18px; line-height: 1.7; letter-spacing: 0; overflow-wrap: anywhere; }
.record-date-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 24px; }
.record-date-nav button { min-width: 40px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--white); color: var(--ink); }
.record-date-nav input { width: 154px; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 3px; padding: 0 8px; background: var(--white); color: var(--ink); font-size: 16px; }
.record-date-nav button:disabled { opacity: .4; cursor: default; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(16, 29, 24, .48); backdrop-filter: blur(3px); z-index: 10; animation: fade .2s ease; }
.record-sheet { position: fixed; z-index: 11; left: 50%; bottom: 0; width: min(100%, 560px); max-height: 88svh; overflow-y: auto; transform: translateX(-50%); background: var(--white); padding: 10px 24px calc(22px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; box-shadow: 0 -20px 60px rgba(16,29,24,.18); animation: sheet-in .28s cubic-bezier(.2,.8,.2,1); }
.sheet-handle { width: 38px; height: 4px; background: #d3cec1; border-radius: 9px; margin: 0 auto 20px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.close-button { font-size: 28px; color: var(--muted); }
.field { display: block; font-size: 12px; font-weight: 750; letter-spacing: .05em; margin-bottom: 18px; }
.field input, .field textarea, .field select { display: block; width: 100%; margin-top: 8px; border: 0; border-bottom: 1px solid #c9c3b5; border-radius: 0; background: transparent; padding: 11px 2px; color: var(--ink); outline: none; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 9px 0 18px; }
.food-choice { position: relative; display: inline-flex; }
.choice { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 9px 14px; min-height: 40px; }
.choice.selected { background: var(--ink); color: white; border-color: var(--ink); }
#note-choices .choice { max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.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 #d7cfc2; border-radius: 50%; background: var(--white); color: #8f7568; font-size: 16px; line-height: 1; box-shadow: 0 2px 6px rgba(23,60,50,.12); }
.food-choice-delete:hover { border-color: var(--accent); color: var(--accent-dark); }
.food-choice-delete:disabled { opacity: .45; cursor: wait; }
.primary { border: 0; background: var(--accent); color: white; min-height: 50px; padding: 0 22px; border-radius: 3px; font-weight: 800; box-shadow: 0 8px 22px rgba(230,109,74,.22); }
.primary:hover { background: var(--accent-dark); }
.wide { width: 100%; }

.setup { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.setup { z-index: 30; overflow-y: auto; background: var(--paper); }
.setup-panel { width: min(100%, 420px); padding: 30px 0; }
.setup-panel h1 { margin-bottom: 8px; }
.setup-panel > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; margin-bottom: 32px; }
.setup-panel label { display: block; margin: 18px 0; font-size: 13px; font-weight: 700; }
.setup-panel input { display: block; width: 100%; margin-top: 8px; padding: 14px 3px; border: 0; border-bottom: 1px solid var(--line); background: transparent; outline: none; }
.brand-logo { width: 82px; height: 82px; object-fit: cover; border-radius: 26px; margin-bottom: 28px; box-shadow: 0 12px 34px rgba(47,57,42,.16); }
.form-error { color: #a33e2d !important; background: rgba(230,109,74,.09); padding: 10px 12px; margin: 0 0 14px !important; font-size: 13px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: white; padding: 12px 18px; border-radius: 3px; box-shadow: 0 12px 40px rgba(0,0,0,.18); font-size: 13px; }

[hidden] { display: none !important; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translate(-50%, 22px); opacity: .7; } }
@keyframes insert { from { opacity: 0; transform: translateY(-7px); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(243,201,114,0); } 100% { box-shadow: 0 0 0 0 rgba(243,201,114,0); } }

@media (max-width: 640px) {
  main { padding: 24px 17px 70px; }
  .topbar { margin-bottom: 30px; }
  .topbar { gap: 14px; }
  .brand-heading { gap: 14px; }
  .header-logo { width: 60px; height: 60px; border-radius: 16px; }
  .account-actions { flex-direction: column; align-items: flex-end; gap: 2px; }
  .quiet-button { min-height: 34px; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); row-gap: 5px; }
  .metrics { grid-template-columns: repeat(2, 1fr); row-gap: 18px; background: transparent; }
  .metrics div { border-left: 1px solid var(--line); padding-left: 12px; }
  .timeline-item { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; }
  input, textarea, select { font-size: 16px; }
  .record-sheet { padding-inline: 20px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; } }
