:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #17221e;
  --muted: #67756f;
  --line: #dfe7e3;
  --teal: #0f766e;
  --teal-soft: #dff2ef;
  --sky: #0369a1;
  --sky-soft: #e0f0fb;
  --amber: #b45309;
  --amber-soft: #fdeeda;
  --rose: #be123c;
  --rose-soft: #fde5ec;
  --violet: #6d28d9;
  --violet-soft: #eee7fb;
  --shadow: 0 8px 24px rgba(23, 34, 30, 0.08);
  --radius: 8px;
  --nav-h: 64px;
  --ease-ios: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes overlay-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes sheet-down {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(246, 248, 247, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.baby-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 700;
}

.baby-meta {
  min-width: 0;
}

.baby-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.baby-name-row h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.baby-meta p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.22s var(--ease-spring), background-color 0.18s ease;
}

.icon-btn:active {
  transform: scale(0.86);
}

.icon-btn[data-fallback]::before,
.delete-btn[data-fallback]::before {
  content: attr(data-fallback);
  font-size: 12px;
  font-weight: 600;
}

body.icons-ready .icon-btn[data-fallback]::before,
body.icons-ready .delete-btn[data-fallback]::before {
  display: none;
}

.icon-btn.small {
  width: 26px;
  height: 26px;
  flex-basis: 26px;
  background: transparent;
}

.icon-btn svg,
.quick-icon svg,
.stat-icon svg,
.nav-btn svg,
.date-chip svg,
.list-item-icon svg,
.guide-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.icon-btn.small svg {
  width: 15px;
  height: 15px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.view-stack {
  padding: 14px 16px 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

@media (prefers-reduced-motion: no-preference) {
  .view.active {
    animation: view-in 0.32s var(--ease-ios);
  }
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.26s var(--ease-spring), box-shadow 0.22s ease;
  will-change: transform;
}

.quick-btn:active {
  transform: scale(0.9);
}

.quick-btn:active .quick-icon {
  transform: scale(1.06);
}

.quick-icon {
  width: 38px;
  height: 38px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 24%;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68), inset 0 -3px 5px rgba(0, 0, 0, 0.1), 0 5px 12px rgba(23, 34, 30, 0.14);
  transition: transform 0.26s var(--ease-spring);
}

.quick-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 52%);
  pointer-events: none;
}

.quick-icon.feed {
  background: linear-gradient(145deg, #fbbf24, #b45309);
  color: #fff;
}

.quick-icon.sleep {
  background: linear-gradient(145deg, #8b5cf6, #6d28d9);
  color: #fff;
}

.quick-icon.diaper {
  background: linear-gradient(145deg, #38bdf8, #0369a1);
  color: #fff;
}

.quick-icon.temp {
  background: linear-gradient(145deg, #fb7185, #be123c);
  color: #fff;
}

.quick-icon.growth {
  background: linear-gradient(145deg, #2dd4bf, #0f766e);
  color: #fff;
}

.quick-icon.other {
  background: linear-gradient(145deg, #94a3b8, #475569);
  color: #fff;
}

.stat-icon.feed,
.list-item-icon.feed {
  background: var(--amber-soft);
  color: var(--amber);
}

.stat-icon.sleep,
.list-item-icon.sleep {
  background: var(--violet-soft);
  color: var(--violet);
}

.stat-icon.diaper,
.list-item-icon.diaper {
  background: var(--sky-soft);
  color: var(--sky);
}

.stat-icon.temp,
.list-item-icon.temp {
  background: var(--rose-soft);
  color: var(--rose);
}

.stat-icon.growth,
.list-item-icon.growth {
  background: var(--teal-soft);
  color: var(--teal);
}

.stat-icon.other,
.list-item-icon.other {
  background: var(--surface-2);
  color: var(--muted);
}

.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-head {
  margin-bottom: 10px;
}

.section-head h2,
.panel-head h2,
.guide-current h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 24%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62), 0 3px 8px rgba(23, 34, 30, 0.1);
}

.stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-card div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-card strong {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.stat-card span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-head {
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-2);
}

.segmented.wide {
  display: flex;
  width: 100%;
}

.seg {
  min-width: 48px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.segmented.wide .seg {
  flex: 1;
  white-space: nowrap;
}

.seg.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(23, 34, 30, 0.12);
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  height: 120px;
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}

.chart-bar {
  width: 100%;
  max-width: 28px;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: var(--teal);
}

.chart-bar.alt {
  background: var(--violet);
}

.chart-value {
  margin-bottom: 4px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.chart-label {
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.count-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.timeline,
.record-list {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.list-item-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 24%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62), 0 3px 8px rgba(23, 34, 30, 0.1);
}

.list-item-icon svg {
  width: 18px;
  height: 18px;
}

.list-item-body {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.list-item-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.delete-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.delete-btn svg {
  width: 16px;
  height: 16px;
}

.empty-state {
  padding: 18px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.records-toolbar {
  margin-bottom: 12px;
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.22s var(--ease-spring);
}

.chip:active {
  transform: scale(0.94);
}

.chip.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 600;
}

.record-list .timeline-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.record-list .timeline-item:last-child {
  border-bottom: 1px solid var(--line);
}

.guide-current {
  border-color: transparent;
  background: var(--teal-soft);
}

.guide-current .guide-age {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.guide-current p {
  margin: 8px 0 0;
  font-size: 13px;
}

.guide-current-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.guide-current-list li {
  position: relative;
  margin: 0 0 6px;
  padding-left: 12px;
  font-size: 13px;
}

.guide-current-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
}

.accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accordion-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.accordion-item.current {
  border-color: var(--teal);
}

.accordion-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 0;
  background: transparent;
  text-align: left;
}

.guide-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 24%;
  background: var(--teal-soft);
  color: var(--teal);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62), 0 3px 8px rgba(23, 34, 30, 0.1);
}

.guide-icon svg {
  width: 18px;
  height: 18px;
}

.accordion-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
}

.accordion-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.accordion-head > svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: 0 0 18px;
  transition: transform 0.28s var(--ease-spring);
}

.accordion-item.open .accordion-head > svg {
  transform: rotate(180deg);
}

.accordion-body {
  display: none;
  padding: 0 12px 12px 56px;
}

.accordion-item.open .accordion-body {
  display: block;
}

.accordion-body ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.accordion-body li {
  position: relative;
  margin: 0 0 6px;
  padding-left: 12px;
  font-size: 13px;
  color: #3f4d47;
}

.accordion-body li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  max-width: 720px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  transform: translateX(-50%);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  transition: transform 0.22s var(--ease-spring), color 0.18s ease;
}

.nav-btn svg {
  transition: transform 0.3s var(--ease-spring);
}

.nav-btn:active {
  transform: scale(0.9);
}

.nav-btn.active {
  color: var(--teal);
  font-weight: 600;
}

.nav-btn.active svg {
  transform: translateY(-1px) scale(1.16);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(12, 20, 17, 0.45);
}

.overlay[hidden] {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .overlay:not([hidden]) {
    animation: overlay-in 0.2s ease;
  }

  .overlay:not([hidden]) .sheet {
    animation: sheet-up 0.42s var(--ease-spring);
  }

  .overlay.closing {
    animation: overlay-out 0.18s ease forwards;
  }

  .overlay.closing .sheet {
    animation: sheet-down 0.24s var(--ease-ios) forwards;
  }
}

.sheet {
  width: 100%;
  max-width: 720px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 14px 14px 0 0;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #c8d1cd;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field.hidden,
.hidden {
  display: none;
}

.field label,
.split-field label {
  font-size: 13px;
  font-weight: 600;
}

.split-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  align-items: center;
}

.split-field label {
  align-self: end;
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.input-with-unit input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}

.input-with-unit span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="datetime-local"] {
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  outline: 0;
  font-size: 15px;
}

.field textarea {
  resize: vertical;
  min-height: 96px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  outline: 0;
  font-size: 15px;
}

.primary-btn {
  height: 48px;
  border: 0;
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.22s var(--ease-spring), opacity 0.18s ease;
}

.primary-btn:active {
  transform: scale(0.98);
  opacity: 0.92;
}

@media (min-width: 600px) {
  .view-stack {
    padding: 20px 24px 28px;
  }

  .quick-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

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