:root {
  --primary: #4F46E5;
  --bg: #F8FAFC;
  --card-bg: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background: var(--bg); color: var(--text); padding-bottom: 80px; }

.app-header {
  background: #fff;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.baby-summary { min-width: 0; flex: 1; }
.baby-summary h1 { font-size: 1.25rem; font-weight: 700; }
.baby-summary p { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

.sync-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.sync-btn:disabled { opacity: 0.6; cursor: wait; }
.sync-btn.syncing #syncBtnIcon { display: inline-block; animation: spin 0.8s linear infinite; }
.sync-btn.ok { border-color: #86efac; background: #f0fdf4; color: #166534; }
.sync-btn.err { border-color: #fca5a5; background: #fef2f2; color: #b91c1c; }
@keyframes spin { to { transform: rotate(360deg); } }

.tab-content { display: none; padding: 16px; max-width: 600px; margin: 0 auto; }
.tab-content.active { display: block; }

.banner-notice { background: #EEF2FF; color: var(--primary); padding: 12px 16px; border-radius: var(--radius); font-size: 0.9rem; font-weight: 600; margin-bottom: 16px; }

.card { background: var(--card-bg); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; border: 1px solid var(--border); }
.card h3 { font-size: 1rem; margin-bottom: 12px; font-weight: 700; }
.sub-text { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }

.quick-slider {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 14px;
  margin: 0 -16px 16px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}
.quick-slider::-webkit-scrollbar { display: none; }
.grid-btn {
  flex: 0 0 auto;
  min-width: 72px;
  width: auto;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 12px;
  font-size: 1.35rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.grid-btn span { font-size: 0.72rem; font-weight: 600; color: var(--text); line-height: 1.2; white-space: nowrap; }
.grid-btn:active { background: #f1f5f9; transform: scale(0.97); }
.grid-btn.sleeping { background: #EEF2FF; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2); }
.grid-btn.sleeping span { color: var(--primary); }

.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item { font-size: 0.85rem; padding: 8px 10px; background: #F8FAFC; border-radius: 8px; }
.record-item.ongoing { background: #EEF2FF; border: 1px dashed var(--primary); }
.record-item-detail { font-size: 0.75rem; color: var(--text-muted); }

.record-list { display: flex; flex-direction: column; gap: 10px; }
.record-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: #F8FAFC; border-radius: 8px; font-size: 0.9rem; }
.empty-msg { font-size: 0.85rem; color: var(--text-muted); text-align: center; padding: 20px 0; }

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border); display: flex; height: 65px; z-index: 20; }
.nav-item { flex: 1; border: none; background: none; font-size: 0.8rem; color: var(--text-muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.nav-item.active { color: var(--primary); font-weight: bold; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 30; align-items: flex-end; }
.modal-overlay.active { display: flex; }
.bottom-sheet { background: #fff; width: 100%; max-width: 600px; margin: 0 auto; border-radius: 20px 20px 0 0; padding: 20px; animation: slideUp 0.2s ease-out; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.close-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; }

.form-group { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea, textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; background: #fff; }
.form-group select { appearance: auto; }
.btn-group { display: flex; gap: 10px; margin-top: 16px; }
.primary-btn, .submit-btn { width: 100%; background: var(--primary); color: #fff; border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.cancel-btn { width: 40%; background: #E2E8F0; color: var(--text); border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; }

.filter-group { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-btn { flex: 1; padding: 8px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-size: 0.85rem; }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.pattern-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background: #F8FAFC; padding: 12px; border-radius: 8px; text-align: center; }
.stat-box h4 { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-box p { font-size: 1.1rem; font-weight: bold; color: var(--primary); }
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.card-header-row h3 { margin-bottom: 0; }
.sub-hint { font-size: 0.75rem; color: var(--text-muted); }

.record-day-header { position: relative; }
.record-day-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.record-day-nav h3 {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}
.day-nav-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}
.day-nav-btn:active { background: #f1f5f9; }
.cal-btn {
  width: 36px;
  height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.cal-btn:active { background: #f1f5f9; }
.record-day-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  right: 0;
  top: 100%;
}
.delete-btn { width: 30%; background: #FEE2E2; color: #DC2626; border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.record-item { cursor: pointer; }
.record-item:active { background: #E2E8F0; }

.ai-answer-text { font-size: 0.9rem; line-height: 1.65; color: var(--text); }
.ai-answer-text .ai-section-title { font-weight: 700; font-size: 0.95rem; margin: 14px 0 6px; color: var(--primary); }
.ai-answer-text .ai-section-title:first-child { margin-top: 0; }
.ai-answer-text .ai-list { margin: 4px 0 8px 18px; padding: 0; }
.ai-answer-text .ai-list li { margin-bottom: 4px; }
.ai-answer-text .ai-para { margin: 4px 0; color: var(--text-muted); }
.ai-answer-text strong { color: var(--text); font-weight: 600; }