/* ========== 全局样式 ========== */
:root {
  --primary: #FF6B8A;
  --primary-light: #FFB8C6;
  --primary-bg: #FFF0F3;
  --accent: #4ECDC4;
  --accent-light: #A8E6D4;
  --warning: #FFB347;
  --bg: #FFF5F5;
  --card-bg: #FFFFFF;
  --text: #333333;
  --text-secondary: #888888;
  --text-light: #AAAAAA;
  --border: #F0E0E0;
  --shadow: 0 2px 12px rgba(255, 107, 138, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ========== 页面切换 ========== */
.page {
  display: none;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 70px);
}

.page.active { display: flex; flex-direction: column; }

/* ========== 头部 ========== */
.header {
  padding: calc(var(--safe-top) + 16px) 20px 16px;
  text-align: center;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
  border-radius: 0 0 24px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-date {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 2px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-baby {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

/* ========== 首页内容 ========== */
.home-content {
  padding: 16px;
  flex: 1;
}

/* 概览卡片 */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.summary-card:active { transform: scale(0.97); }

.card-icon { font-size: 28px; }

.card-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* 快捷操作 */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.action-btn {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:active {
  transform: scale(0.95);
  background: var(--primary-bg);
}

.action-icon { font-size: 24px; }

/* 时间线 */
.timeline-section { margin-bottom: 16px; }

.timeline-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.timeline-icon { font-size: 24px; flex-shrink: 0; }

.timeline-info { flex: 1; min-width: 0; }

.timeline-title {
  font-size: 14px;
  font-weight: 600;
}

.timeline-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.timeline-time {
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
}

.no-record {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ========== 记录页 ========== */
.record-content {
  padding: 16px;
  flex: 1;
}

.date-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.date-arrow {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--card-bg);
  border-radius: 50%;
  font-size: 22px;
  color: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-text {
  font-size: 16px;
  font-weight: 700;
  min-width: 120px;
  text-align: center;
}

/* ========== 统计页 ========== */
.stats-content {
  padding: 16px;
  flex: 1;
}

.stats-tabs {
  display: flex;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.stats-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.stats-tab.active {
  background: var(--primary);
  color: white;
}

.stats-period {
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.chart-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.chart-container h4 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text);
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
}

.stats-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-summary-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-summary-card .ssc-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-summary-card .ssc-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* ========== 我的页 ========== */
.mine-content {
  padding: 16px;
  flex: 1;
}

.baby-profile {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  cursor: pointer;
}

.baby-avatar {
  font-size: 40px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  border-radius: 50%;
}

.baby-detail { flex: 1; }

.baby-name {
  font-size: 16px;
  font-weight: 600;
}

.baby-age {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.arrow {
  font-size: 20px;
  color: var(--text-light);
}

.mine-menu {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: none;
  background: transparent;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.menu-item:last-child { border-bottom: none; }

.menu-item:active { background: var(--primary-bg); }

.menu-item .arrow { margin-left: auto; }

.about-section {
  text-align: center;
  padding: 24px;
  color: var(--text-light);
  font-size: 13px;
  line-height: 1.8;
}

/* ========== 底部导航 ========== */
.tab-bar {
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(var(--safe-bottom) + 4px);
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-icon { font-size: 22px; transition: transform 0.2s; }

.tab-label {
  font-size: 10px;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.tab-btn.active .tab-label { color: var(--primary); font-weight: 600; }

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

/* ========== 模态层 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  animation: fadeIn 0.2s;
}

.modal-overlay.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--card-bg);
  border-radius: 24px 24px 0 0;
  z-index: 201;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal.active { display: block; }

@keyframes slideUp {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #F5F5F5;
  border-radius: 50%;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 0 20px 32px;
}

/* 计时器 */
.timer-display {
  text-align: center;
  font-size: 48px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  padding: 24px 0;
  letter-spacing: 2px;
}

.breast-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.breast-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  background: white;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.breast-btn.active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}

.breast-durations {
  display: flex;
  justify-content: space-around;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.breast-durations b { color: var(--primary); }

.timer-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.btn-timer {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

#btnBfStart, #btnSleepStart {
  background: var(--accent);
  color: white;
}

.btn-pause {
  background: var(--warning);
  color: white;
}

.btn-save {
  background: var(--primary);
  color: white;
}

.btn-save-full {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.15s;
}

.btn-save-full:active, .btn-timer:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* 毫升输入 */
.amount-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.amount-input {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.amount-input:focus { border-color: var(--primary); }

.amount-unit {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 600;
}

.quick-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.quick-amounts button {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  background: white;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-amounts button:active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}

/* 食物类型 */
.food-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.food-type-btn {
  padding: 10px;
  border: 1.5px solid var(--border);
  background: white;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.food-type-btn.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.food-type-btn:active { border-color: var(--primary); }

/* 通用输入 */
.modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.modal-input:focus { border-color: var(--primary); }

.input-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

/* 性别切换 */
.gender-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.gender-toggle .breast-btn { flex: 1; }

/* 生长记录历史 */
.growth-history {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.growth-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.growth-item-date {
  color: var(--text-secondary);
  font-size: 13px;
}

.growth-item-data {
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 999;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, -50%) scale(1);
}

/* 滚动条隐藏 */
::-webkit-scrollbar { display: none; }

/* iOS input 修正 */
input[type="date"] {
  -webkit-appearance: none;
  min-height: 44px;
}
