:root {
  color-scheme: light;
  --paper: #f7f4eb;
  --outer: #eeeadf;
  --ink: #263623;
  --muted: #546445;
  --line: #d6d5c4;
  --lime: #e9efbb;
  --lime-strong: #dce69a;
  --feed: #fae3cb;
  --diaper: #e2ead6;
  --sleep: #ebdeed;
  --green: #2f4a2a;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", Georgia, serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  --numbers: Georgia, "Noto Serif", serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--outer);
  color: var(--ink);
  font-family: var(--sans);
  font-synthesis: style weight;
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
body:has(dialog[open]) { overflow: hidden; }
h1, h2, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, a, input, textarea { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; border: 0; padding: 0; background: none; }
button:disabled { cursor: default; opacity: .48; }
a { text-decoration: none; }
:focus-visible { outline: 2px solid #536f37; outline-offset: 3px; }
img, svg { display: block; }
img { object-fit: contain; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  position: relative;
  width: 100%;
  max-width: 510px;
  min-height: 100dvh;
  margin-inline: auto;
  background: var(--paper);
  box-shadow: 0 0 38px #35341d0c;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 67px;
  padding: calc(9px + env(safe-area-inset-top, 0px)) 19px 9px;
}

.wordmark { display: inline-flex; align-items: center; gap: 9px; font: 800 24px/1 var(--serif); }
.brand-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #e6edb4;
  color: #577731;
}
.brand-icon svg { width: 23px; height: 23px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon-button svg { width: 27px; height: 27px; }
.icon-button:active { background: #e8e7d7; }

main { padding: 1px 16px calc(84px + var(--safe-bottom)); }
.page-title { padding: 4px 4px 13px; }
.page-title p { color: var(--muted); font-size: 14px; }
h1, h2 { font-family: var(--serif); }
h1 { font-size: clamp(36px, 9.4vw, 45px); font-weight: 800; line-height: 1.18; }
.page-title h1 { display: flex; align-items: center; gap: 9px; margin-top: 4px; }
.page-title h1 svg { width: 28px; height: 28px; color: var(--muted); }
h2 { font-size: 22px; font-weight: 800; line-height: 1.3; }

.forecast {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 145px;
  padding: 13px 15px;
  border-radius: 17px;
  background: var(--lime);
}
.forecast-art {
  position: absolute;
  z-index: -1;
  inset: 7px 6px 6px auto;
  width: 36%;
  height: calc(100% - 13px);
  max-width: 158px;
  pointer-events: none;
}
.forecast-content { width: 66%; }
.forecast h2 { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.forecast h2 svg { width: 17px; height: 17px; }
.forecast-main { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; }
.forecast-value {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font: 700 clamp(39px, 12vw, 61px)/1.03 var(--numbers);
  letter-spacing: -.025em;
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}
.forecast-value small { font: 700 11px/1 var(--sans); letter-spacing: 0; }
.forecast-main strong { font: 800 16px/1.25 var(--serif); white-space: nowrap; }
.forecast-overdue .forecast-main { margin-top: 8px; flex-wrap: wrap; gap: 5px 8px; }
.forecast-overdue .forecast-value, .forecast-empty { font: 800 22px/1.24 var(--serif); letter-spacing: 0; }
.forecast-empty { display: block; margin-top: 8px; }
.forecast-range { font-size: 13px; color: #435638; line-height: 1.45; margin-top: 4px; }
.forecast-other { padding-top: 6px; margin-top: 7px; border-top: 1px solid #85935a83; font-size: 13px; font-weight: 650; }

.page-section { margin-top: 17px; }
.page-section > h2, .section-heading { padding-inline: 4px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.section-heading > span { color: var(--muted); font-size: 14px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 9px; }
.feed { --tint: var(--feed); }
.diaper { --tint: var(--diaper); }
.sleep { --tint: var(--sleep); }
.quick {
  min-height: 94px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--tint);
  border-radius: 14px;
  font: 800 17px/1.25 var(--serif);
  transition: transform 130ms ease, filter 130ms ease;
}
.quick img { width: 58px; height: 54px; }
.quick:active { transform: scale(.97); filter: saturate(1.15); }
.empty { margin: 8px 4px 0; padding: 16px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

.timeline { margin-top: 6px; }
.timeline li { display: flex; align-items: stretch; position: relative; }
.timeline li::before {
  position: absolute;
  z-index: 1;
  content: "";
  width: 7px;
  height: 7px;
  top: 25px;
  left: 6px;
  border-radius: 50%;
  background: #909e75;
  pointer-events: none;
}
.timeline li:not(:last-child)::after {
  position: absolute;
  content: "";
  top: 28px;
  bottom: -28px;
  left: 9px;
  width: 1px;
  background: #a6af8e;
  pointer-events: none;
}
.event {
  display: grid;
  position: relative;
  grid-template-columns: 37px minmax(0, 1fr) auto;
  align-items: start;
  width: 100%;
  min-height: 55px;
  gap: 10px;
  text-align: left;
  padding: 7px 4px 7px 21px;
  border-radius: 8px;
}
.event:active { background: #eae8da; }
.timeline li:not(:last-child) .event::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 68px;
  right: 4px;
  border-bottom: 1px solid var(--line);
}
.event-illustration {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 37px;
  height: 37px;
  border-radius: 50%;
  background: var(--tint);
}
.event-illustration img { width: 24px; height: 25px; }
.event-copy { display: grid; align-self: center; gap: 1px; min-width: 0; }
.event-copy strong { font: 800 17px/1.28 var(--serif); }
.event-copy small { font-size: 13px; color: var(--muted); }
.event-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event time { padding-top: 10px; font: 400 16px/1 var(--numbers); font-variant-numeric: tabular-nums; }

.tabbar {
  position: fixed;
  z-index: 2;
  width: min(100%, 510px);
  inset: auto 0 0;
  margin-inline: auto;
  min-height: 58px;
  padding: 3px 8px calc(3px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--paper);
}
.tabbar a { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 50px; color: var(--muted); font-size: 12px; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current] { color: var(--green); font-weight: 800; }
.tabbar a:focus-visible { outline-offset: -2px; border-radius: 9px; }

.date-row { display: flex; gap: 10px; margin: 2px 0 12px; }
.date-row input { flex: 1 1 0; text-align: center; }
.date-arrow { flex: 0 0 44px; height: 44px; border-radius: 12px; background: var(--lime); display: grid; place-items: center; }
.date-arrow svg { width: 21px; height: 21px; }
.date-arrow:active:not(:disabled) { background: var(--lime-strong); }
.filters { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px clamp(7px, 2.35vw, 14px);
  border-radius: 30px;
  font-size: 13px;
  background: var(--tint, #eeecdf);
}
.chip img { width: 17px; height: 18px; }
.chip[aria-pressed="true"] { background: var(--lime); box-shadow: inset 0 0 0 1px #a3b272; font-weight: 750; }
.text-button { min-height: 44px; padding: 6px 10px; font-size: 14px; border-radius: 8px; text-decoration: underline; text-underline-offset: 3px; }
.lock-button { display: block; margin: 24px auto 0; color: var(--muted); }

.chart-panel { padding: 14px 12px 12px; border-radius: 16px; background: #f0efdf; }
.chart-panel .filters { margin-top: 9px; }
.chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-top: 19px; }
.chart li { display: grid; text-align: center; gap: 6px; color: var(--muted); }
.chart li small { font: 600 11px/1.3 var(--numbers); }
.chart-column { position: relative; display: flex; justify-content: center; align-items: end; height: 112px; border-bottom: 1px solid var(--line); }
.chart-bar { height: max(2px, calc((100% - 19px) * var(--fraction, 0))); background: #dbe69e; border-radius: 7px 7px 2px 2px; width: min(70%, 32px); position: relative; }
.chart-bar span { position: absolute; inset: auto 0 calc(100% + 3px); color: var(--ink); font: 700 13px/1.2 var(--numbers); }
.prediction-list ul { display: grid; gap: 6px; margin-top: 8px; }
.prediction-list li { display: flex; gap: 8px; align-items: center; padding: 6px 9px; min-height: 48px; border-radius: 12px; background: #eeefde; }
.prediction-list strong { font: 800 16px/1.3 var(--serif); }
.prediction-status { margin-left: auto; text-align: right; font-size: 13px; }
.forecast-footnote { padding: 10px 4px 0; font-size: 12px; color: var(--muted); }

input:not([type="radio"]), textarea {
  color: var(--ink);
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #a8af91;
  border-radius: 10px;
  background: #fbf8f0;
  font-size: 16px;
}
input::placeholder, textarea::placeholder { color: #667358; }
input[type="date"], input[type="datetime-local"] { appearance: none; -webkit-appearance: none; }
input::-webkit-date-and-time-value { text-align: start; }
.date-row input::-webkit-date-and-time-value { text-align: center; }
textarea { display: block; width: 100%; resize: vertical; }
.primary {
  width: 100%;
  min-height: 51px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--green);
  color: #fffdf1;
  font-size: 17px;
  font-weight: 750;
}
.primary:active { background: #20391d; }
.loading, .noscript { padding: 28px 6px; color: var(--muted); text-align: center; font-size: 14px; }
.load-error { display: grid; gap: 16px; max-width: 310px; margin: 48px auto; text-align: center; }
.login { max-width: 325px; margin: clamp(30px, 9dvh, 92px) auto 0; text-align: center; }
.login-art { width: 138px; height: 132px; margin: 0 auto 17px; }
.login h1 { font-size: clamp(29px, 7.5vw, 37px); }
.login form { display: grid; gap: 8px; margin-top: 23px; text-align: left; }
.login label { font-size: 14px; font-weight: 700; }
.login .primary { margin-top: 7px; }

dialog {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 510px);
  max-width: none;
  max-height: 93dvh;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: #24271c75; }
dialog[open] { animation: sheet-in 190ms ease-out both; }
@keyframes sheet-in { from { transform: translateY(16px); opacity: .75; } }
.sheet { padding: 9px 17px calc(16px + var(--safe-bottom)); }
.sheet-handle { height: 4px; width: 34px; border-radius: 4px; background: #c4c5b3; margin: 0 auto 6px; }
.sheet-header { display: flex; align-items: center; gap: 9px; min-height: 53px; margin-bottom: 10px; }
.sheet-header .event-illustration { width: 43px; height: 43px; }
.sheet-header img { width: 28px; height: 29px; }
.sheet-header .icon-button { margin-left: auto; }
.sheet-header .icon-button svg { width: 22px; height: 22px; }
.form-row { display: grid; grid-template-columns: minmax(92px, max-content) minmax(0, 1fr); align-items: center; gap: 7px; margin-bottom: 10px; }
.form-row label, .note-label, .amount-presets > span { font-size: 14px; font-weight: 650; }
.segments {
  padding: 3px;
  margin: 0 0 10px;
  border: 0;
  border-radius: 12px;
  background: #eeeddd;
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
}
.segments label { cursor: pointer; position: relative; }
.segments input { position: absolute; opacity: 0; }
.segments span { display: grid; min-height: 44px; place-items: center; border-radius: 9px; font-size: 15px; }
.segments :checked + span { background: var(--lime); font-weight: 750; }
.segments :focus-visible + span { outline: 2px solid #536f37; outline-offset: -2px; }
.amount-presets { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: -2px; margin-bottom: 9px; }
.amount-presets > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.amount-presets button { min-width: 44px; min-height: 44px; border-radius: 22px; padding: 4px 8px; background: #ebeed4; font: 700 15px/1 var(--numbers); }
.amount-presets [aria-pressed="true"] { background: var(--lime-strong); box-shadow: inset 0 0 0 1px #9fae6b; }
.note-label { display: inline-block; margin-bottom: 5px; }
.sheet .primary { margin-top: 12px; }
.form-error { font-size: 13px; margin: 7px 0 0; color: #a53d30; }
.danger-text, .danger { color: #923529; }
#delete-slot { text-align: center; }
.delete-prompt { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 5px; font-size: 14px; }
.danger { min-height: 44px; padding: 5px 10px; border-radius: 8px; background: #f9e0d9; font-weight: 750; }

.toast {
  position: fixed;
  z-index: 3;
  inset: auto 0 calc(68px + var(--safe-bottom));
  width: max-content;
  max-width: calc(100% - 40px);
  margin: auto;
  padding: 9px 15px;
  border-radius: 22px;
  color: #fffdf1;
  background: var(--green);
  font-size: 14px;
}
.toast:empty { display: none; }

@media (min-width: 440px) {
  main { padding-inline: 22px; }
  .masthead { padding-inline: 24px; }
  .forecast { min-height: 158px; padding-inline: 18px; }
  .quick { min-height: 110px; }
  .event { min-height: 60px; }
}
@media (max-width: 520px) and (max-height: 740px) {
  .masthead { min-height: 54px; padding-block: calc(5px + env(safe-area-inset-top, 0px)) 5px; }
  .page-title { padding-block: 3px 9px; }
  .page-title h1 { font-size: 35px; margin-top: 2px; }
  .forecast { min-height: 129px; padding-block: 10px; }
  .forecast-art { inset-block: 5px; height: calc(100% - 10px); }
  .page-section { margin-top: 12px; }
  .quick-grid { margin-top: 7px; }
  .quick { min-height: 84px; }
  .quick img { width: 53px; height: 47px; }
  .timeline { margin-top: 3px; }
  .event { min-height: 48px; padding-block: 5px; }
  .timeline li::before { top: 20px; }
  .timeline li:not(:last-child)::after { top: 23px; bottom: -23px; }
}
@media (max-width: 355px) {
  main { padding-inline: 12px; }
  .forecast { padding-inline: 11px; }
  .forecast-main strong { font-size: 14px; }
  .forecast-value { gap: 4px; }
  .chip img { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
