/* ============ 孕期日历 · 暖色主题 ============ */
:root {
  --bg:        #FDF6EE;
  --bg-2:      #FFF3E7;
  --card:      #FFFFFF;
  --peach:     #FFE3D1;
  --pink:      #FFDCE4;
  --lavender:  #E9DEF7;
  --warm:      #F2C4A6;
  --cream:     #F4EDE1;
  --text:      #6B4A3A;
  --text-soft: #A98C7C;
  --accent:    #E88B72;
  --accent-deep: #D96C52;
  --accent-2:  #C9A0DC;
  --danger:    #E0654B;
  --ok:        #7FBF7F;
  --radius:    18px;
  --shadow:    0 6px 20px rgba(214, 156, 120, 0.14);
  --shadow-lg: 0 -8px 32px rgba(214, 156, 120, 0.22);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px calc(24px + env(safe-area-inset-bottom));
  animation: fadeIn .5s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px 12px;
  background: linear-gradient(180deg, var(--bg) 85%, rgba(253,246,238,0));
  backdrop-filter: blur(4px);
}
.app-title { display: flex; align-items: center; gap: 10px; }
.title-heart { font-size: 26px; }
.app-title h1 { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.title-sub { font-size: 12px; color: var(--text-soft); display: block; margin-top: 1px; }
.header-actions { display: flex; gap: 10px; }

.icon-btn {
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--card); color: var(--text);
  font-size: 18px; cursor: pointer; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
.icon-btn:active { transform: scale(.92); }
#btnMusic.on { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,139,114,.5);} 50% { box-shadow: 0 0 0 10px rgba(232,139,114,0);} }

/* ---------- 问候 ---------- */
.greeting-card {
  background: linear-gradient(135deg, #FFD9C9 0%, #FFE7D9 55%, #FFDCE4 100%);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.greeting-date { font-size: 13px; color: rgba(107,74,58,.75); margin-bottom: 6px; }
.greeting-text { font-size: 17px; font-weight: 600; line-height: 1.5; }

/* ---------- 今日卡片 ---------- */
.today-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  position: relative;
}
.today-week { display: flex; flex-direction: column; align-items: center; margin-bottom: 12px; }
.week-label { font-size: 13px; color: var(--text-soft); }
.week-num { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; }
.week-num #todayWeeks { font-size: 52px; font-weight: 800; color: var(--accent-deep); line-height: 1.1; }
.week-num em { font-style: normal; font-size: 18px; font-weight: 700; color: var(--text); }
.week-num .week-days { font-size: 20px; font-weight: 700; color: var(--accent); }
.week-desc { font-size: 13px; color: var(--text-soft); margin-top: 4px; }
.today-meta {
  display: flex; justify-content: space-around;
  background: #FBF3E9; border-radius: 12px; padding: 10px 6px; margin-bottom: 12px;
}
.meta-item { font-size: 13px; color: var(--text-soft); }
.meta-item b { color: var(--text); font-size: 15px; }
.progress-track {
  height: 10px; border-radius: 999px; background: var(--cream); overflow: hidden; margin-bottom: 12px;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--peach), var(--pink) 45%, var(--lavender));
  transition: width .6s ease;
  width: 0%;
}
.stage-tag {
  position: absolute; top: 14px; right: 14px;
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  background: var(--peach); color: var(--accent-deep);
}
.stage-tag.tag-early { background: var(--peach); color: var(--accent-deep); }
.stage-tag.tag-mid   { background: var(--pink);  color: #C2537A; }
.stage-tag.tag-late  { background: var(--lavender); color: #7A5BA8; }
.stage-tag.tag-overdue { background: var(--warm); color: #A64B2E; }
.stage-tag.tag-before { background: var(--cream); color: var(--text-soft); }

/* ---------- 图例 ---------- */
.legend {
  display: flex; flex-wrap: wrap; gap: 8px;
  background: var(--card); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.lg { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-soft); }
.lg .dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* ---------- 年份切换 ---------- */
.year-nav {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-bottom: 10px;
}
.year-btn {
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: var(--card); color: var(--text); font-size: 14px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .15s;
}
.year-btn:active { transform: scale(.9); }
#yearLabel { font-size: 17px; font-weight: 800; min-width: 90px; text-align: center; }

/* ---------- 横向日历 ---------- */
.calendar-scroller {
  display: flex; gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 4px 14px;
}
.calendar-scroller::-webkit-scrollbar { display: none; }

.month-card {
  flex: 0 0 min(92vw, 480px);
  scroll-snap-align: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 12px 12px;
  box-shadow: var(--shadow);
}
.month-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; padding: 0 4px; }
.month-head .m-name { font-size: 18px; font-weight: 800; }
.month-head .m-sub { font-size: 12px; color: var(--text-soft); }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.week-head {
  text-align: center; font-size: 11px; color: var(--text-soft);
  padding: 4px 0 6px; font-weight: 600;
}
.week-head:nth-child(6), .week-head:nth-child(7) { color: var(--accent); }

.day-cell {
  position: relative;
  min-height: 62px;
  border-radius: 10px;
  background: var(--cream);
  padding: 4px 3px;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  user-select: none;
}
.day-cell:active { transform: scale(.94); }
.day-cell.blank { background: transparent; cursor: default; pointer-events: none; }
.day-cell.stage-early   { background: var(--peach); }
.day-cell.stage-mid     { background: var(--pink); }
.day-cell.stage-late    { background: var(--lavender); }
.day-cell.stage-overdue { background: var(--warm); }
.day-cell.weekend .day-num { color: var(--accent-deep); }
.day-cell.today {
  outline: 2.5px solid var(--accent);
  box-shadow: 0 4px 14px rgba(232,139,114,.35);
  z-index: 1;
}
/* 当前孕周区间高亮（本周范围，与"今天"的外圈不冲突） */
.day-cell.this-week {
  box-shadow: inset 0 0 0 2px rgba(232,139,114,.45);
}
/* 点击"第X周"徽章选中的孕周区间 */
.day-cell.week-selected {
  background: rgba(232,139,114,.16) !important;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.week-badge.selected {
  background: var(--accent-deep);
  color: #fff;
}
.day-cell.today .day-num {
  width: 24px; height: 24px; line-height: 24px; text-align: center;
  background: var(--accent); color: #fff; border-radius: 50%; font-size: 13px;
}
.day-num { font-size: 14px; font-weight: 700; color: var(--text); }
.day-lunar { font-size: 9.5px; color: var(--text-soft); line-height: 1.2; margin-top: 1px; white-space: nowrap; overflow: hidden; max-width: 100%; }
.day-lunar.fest { color: var(--danger); font-weight: 600; }
.day-lunar.workday { color: #8A93A6; }
.week-badge {
  font-size: 9px; font-weight: 700; line-height: 1;
  margin-top: 2px; padding: 2px 5px; border-radius: 999px;
  background: rgba(255,255,255,.75); color: var(--accent-deep);
  white-space: nowrap;
}
.week-badge.edd { background: var(--warm); color: #A64B2E; }
.week-badge.current {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
}
.day-dots { position: absolute; right: 5px; bottom: 5px; display: flex; gap: 3px; }
.day-dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.day-dots i.s { background: var(--accent); }
.day-dots i.n { background: var(--ok); }

/* ---------- 日程区 ---------- */
.schedule-section { margin-top: 6px; }
.section-title { font-size: 15px; font-weight: 800; margin: 12px 2px 8px; }
.section-title.small { margin-top: 16px; font-size: 13.5px; color: var(--text-soft); }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.section-title-row .section-title.small { margin-top: 0; }
.view-all-btn {
  border: 1.5px solid var(--accent); background: var(--card); color: var(--accent-deep);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.view-all-btn:active { transform: scale(.96); }
.schedule-list { display: flex; flex-direction: column; gap: 8px; }
.empty {
  font-size: 13px; color: var(--text-soft);
  background: var(--card); border-radius: 12px; padding: 14px; text-align: center; box-shadow: var(--shadow);
}
.sched-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
  font-size: 14px;
}
.sched-item .time { font-weight: 800; color: var(--accent-deep); white-space: nowrap; }
.sched-item .time .date { font-size: 12px; font-weight: 600; color: var(--text-soft); margin-right: 2px; }
.sched-item .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-item .del {
  border: none; background: #FBE9E4; color: var(--danger);
  border-radius: 8px; font-size: 12px; padding: 5px 10px; cursor: pointer; font-weight: 700;
}
.sched-item.done .txt { text-decoration: line-through; color: var(--text-soft); }

/* 全部日程弹层 */
.all-sched-sheet { max-height: 84vh; display: flex; flex-direction: column; }
.all-sched-list { overflow-y: auto; margin-top: 4px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.all-sched-date { font-size: 12.5px; font-weight: 800; color: var(--accent-deep); margin: 12px 2px 6px; }
.all-sched-date:first-child { margin-top: 0; }
.all-sched-list .sched-item { box-shadow: none; border: 1px solid #F3E3D5; }

/* ---------- 海报预览 ---------- */
.poster-sheet { text-align: center; }
.poster-box {
  margin: 10px auto 12px;
  max-height: 62vh; overflow-y: auto;
  display: flex; justify-content: center;
  -webkit-overflow-scrolling: touch;
}
.poster-box img {
  width: 100%; max-width: 400px; border-radius: 16px;
  box-shadow: var(--shadow);
  display: block;
}

.app-footer { text-align: center; font-size: 12px; color: var(--text-soft); margin-top: 22px; padding-bottom: 8px; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(107,74,58,.35);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal-sheet {
  width: 100%; max-width: 560px;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,.72,.32,1);
  box-shadow: var(--shadow-lg);
  max-height: 88vh; overflow-y: auto;
}
.modal-mask.show .modal-sheet { transform: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.sheet-date { font-size: 18px; font-weight: 800; }
.sheet-sub { font-size: 13px; color: var(--text-soft); margin-top: 3px; }
.sheet-week {
  font-size: 13px; font-weight: 700; border-radius: 10px; padding: 8px 12px; margin-bottom: 14px;
  background: var(--peach); color: var(--accent-deep);
}
.sheet-week.week-early { background: var(--peach); color: var(--accent-deep); }
.sheet-week.week-mid   { background: var(--pink);  color: #C2537A; }
.sheet-week.week-late  { background: var(--lavender); color: #7A5BA8; }
.sheet-week.week-overdue { background: var(--warm); color: #A64B2E; }
.sheet-week.week-before { background: var(--cream); color: var(--text-soft); }
.sheet-block { margin-bottom: 16px; }
.block-title { font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.day-schedules { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.day-schedules .sched-item { box-shadow: none; border: 1px solid #F3E3D5; padding: 10px 12px; }
.add-row { display: flex; gap: 8px; }
.add-row input[type="text"] { flex: 1; min-width: 0; }
input[type="text"], input[type="time"], input[type="date"], textarea {
  border: 1.5px solid #EFDFCE; border-radius: 12px;
  padding: 11px 12px; font-size: 15px; color: var(--text);
  background: var(--card); outline: none; font-family: inherit;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; resize: vertical; line-height: 1.6; }

.primary-btn {
  border: none; border-radius: 12px; padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform .15s; font-family: inherit;
}
.primary-btn:active { transform: scale(.96); }
.primary-btn.small-btn { padding: 10px 16px; border-radius: 12px; font-size: 14px; white-space: nowrap; }
.primary-btn.full-btn { width: 100%; margin-top: 4px; }
.ghost-btn {
  border: 1.5px solid var(--accent); background: transparent; color: var(--accent-deep);
  border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-group { display: flex; gap: 12px; margin-top: 6px; }
.btn-group .primary-btn, .btn-group .ghost-btn { flex: 1; }
.hint { font-size: 12.5px; color: var(--text-soft); margin-top: 6px; line-height: 1.6; }

.music-sheet, .remind-sheet { text-align: center; }
.music-emoji { font-size: 44px; margin: 6px 0 4px; animation: float 2.4s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-6px);} }
.music-title { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.remind-text { font-size: 15px; line-height: 1.7; color: var(--text); margin: 6px 0 14px; background: var(--card); border-radius: 12px; padding: 14px; text-align: left; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(74,52,42,.92); color: #fff;
  font-size: 14px; padding: 12px 22px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 200;
  max-width: 82vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
