:root {
  --bg0: #dff0ea;
  --bg1: #f3faf6;
  --ink: #24352f;
  --ink-soft: #5a7066;
  --line: rgba(36, 53, 47, 0.1);
  --card: rgba(255, 255, 255, 0.78);
  --accent: #ff8f6b;
  --accent-2: #7ec8b4;
  --accent-soft: rgba(255, 143, 107, 0.18);
  --mint: #b8e4d4;
  --butter: #ffe7b8;
  --sky: #c9e4ff;
  --band: rgba(126, 200, 180, 0.22);
  --band-mid: rgba(126, 200, 180, 0.34);
  --curve: #3d8f78;
  --shadow: 0 16px 36px rgba(61, 110, 90, 0.1);
  --radius: 22px;
  --font-display: "Ma Shan Zheng", "ZCOOL XiaoWei", "Songti SC", serif;
  --font-body: "Noto Serif SC", "Songti SC", Georgia, serif;
  --font-ui: "DM Sans", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 8% -8%, #ffe8d6 0%, transparent 52%),
    radial-gradient(800px 420px at 100% 0%, #d4f0e6 0%, transparent 48%),
    radial-gradient(700px 380px at 50% 100%, #dcecff 0%, transparent 50%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  line-height: 1.55;
  position: relative;
  overflow-x: hidden;
}

/* soft floating deco blobs */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(2px);
}

body::before {
  width: 140px;
  height: 140px;
  top: 12vh;
  right: -30px;
  background: radial-gradient(circle at 35% 35%, #fff6, transparent 55%),
    var(--butter);
  opacity: 0.55;
  animation: bob 7s ease-in-out infinite;
}

body::after {
  width: 110px;
  height: 110px;
  bottom: 18vh;
  left: -24px;
  background: radial-gradient(circle at 40% 40%, #fff8, transparent 55%),
    var(--sky);
  opacity: 0.5;
  animation: bob 9s ease-in-out infinite reverse;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-14px) scale(1.04);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(-4deg);
  }
  50% {
    transform: rotate(5deg);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

button {
  cursor: pointer;
}

.app {
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 80px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-block {
  min-width: 0;
  position: relative;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gourd-badge {
  width: 52px;
  height: 64px;
  flex-shrink: 0;
  animation: wiggle 4.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 12px rgba(61, 110, 90, 0.18));
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 8vw, 4.1rem);
  line-height: 1;
  letter-spacing: 0.04em;
  margin: 0;
  background: linear-gradient(120deg, #2d5c4c 10%, #ff8f6b 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed rgba(255, 143, 107, 0.45);
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.age-line {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn,
.primary-btn,
.ghost-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 10px 16px;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 14px rgba(61, 110, 90, 0.06);
}

.icon-btn:hover,
.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(61, 110, 90, 0.12);
}

.primary-btn {
  background: linear-gradient(135deg, #ff9a74, #ff7d5c);
  color: #fffaf7;
  border-color: transparent;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.55);
}

.panel {
  display: none;
  animation: rise 0.38s ease;
}

.panel.active {
  display: block;
}

.hero-chart {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px 16px 14px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
  animation: pop-in 0.45s ease;
}

.hero-chart::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--mint), transparent 70%);
  opacity: 0.7;
  pointer-events: none;
}

.chart-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.chart-tab {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink-soft);
  transition: transform 0.15s ease, background 0.15s ease;
}

.chart-tab:hover {
  transform: translateY(-1px);
}

.chart-tab.active {
  background: var(--accent-soft);
  color: var(--ink);
  border-color: rgba(255, 143, 107, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 143, 107, 0.12);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: min(42vh, 320px);
  z-index: 1;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--ink-soft);
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}

.legend .who::before {
  background: var(--band-mid);
}

.legend .p50::before {
  background: transparent;
  border: 1.5px dashed var(--curve);
  border-radius: 0;
  height: 0;
  width: 14px;
  vertical-align: 3px;
}

.legend .baby::before {
  background: var(--accent);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
}

.section-head h2 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0;
}

.section-head h2::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px rgba(255, 143, 107, 0.15);
  vertical-align: 1px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.month-card {
  text-align: left;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  animation: pop-in 0.4s ease both;
}

.month-card:nth-child(2) {
  animation-delay: 0.05s;
}
.month-card:nth-child(3) {
  animation-delay: 0.1s;
}
.month-card:nth-child(4) {
  animation-delay: 0.15s;
}

.month-card::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--butter), #ffd39a);
  opacity: 0.85;
  box-shadow: inset -3px -3px 0 rgba(255, 255, 255, 0.35);
}

.month-card:hover {
  transform: translateY(-4px) rotate(-0.4deg);
  border-color: rgba(255, 143, 107, 0.4);
  box-shadow: 0 20px 36px rgba(61, 110, 90, 0.14);
}

.month-card .sticker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(184, 228, 212, 0.65);
  color: #2f5f50;
  margin-bottom: 8px;
}

.month-card .label {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1;
}

.month-card .sub {
  color: var(--ink-soft);
  font-size: 0.86rem;
  margin: 6px 0 12px;
}

.month-card .stats {
  font-size: 0.9rem;
  display: grid;
  gap: 5px;
}

.month-card .stats div {
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.month-card .empty {
  color: var(--ink-soft);
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.detail-head h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 2.8rem);
  margin: 0;
  line-height: 1;
}

.block {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 22px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  position: relative;
}

.block h3 {
  margin: 0 0 12px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.block h3 .chip {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #b85a3c;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 11px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(255, 143, 107, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 143, 107, 0.15);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.65;
  font-family: var(--font-body);
}

.milestone-list {
  display: grid;
  gap: 8px;
}

.milestone-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.75), rgba(184, 228, 212, 0.28));
  border: 1px solid rgba(126, 200, 180, 0.25);
}

.milestone-item input {
  margin-top: 4px;
  accent-color: #ff8f6b;
}

.milestone-item span {
  flex: 1;
}

.milestone-item .remove {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 0 4px;
}

.add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.add-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.9);
}

.save-bar {
  position: sticky;
  bottom: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  z-index: 5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #2d5c4c;
  color: #f7faf7;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
  font-size: 0.9rem;
  box-shadow: 0 12px 28px rgba(45, 92, 76, 0.28);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--curve);
  margin-right: 6px;
}

.status-dot.warn {
  background: var(--accent);
}

.foot-hint {
  margin-top: 18px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

@media (max-width: 640px) {
  .app {
    width: calc(100% - 20px);
    padding-top: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .gourd-badge {
    width: 44px;
    height: 54px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 260px;
  }

  .save-bar {
    bottom: 8px;
  }

  .save-bar .primary-btn,
  .save-bar .ghost-btn {
    flex: 1;
  }
}
