/* ==========================================================
   月记 · 样式表
   设计基调：暖白底 + 墨黑字 + 低饱和梅子色点缀（简约、耐看）
   移动优先：所有尺寸按 iPhone 屏幕设计，按钮 ≥ 48px 高
   ========================================================== */

:root {
  /* ---- 颜色 ---- */
  --bg:        #FAF9F7;   /* 页面底色，暖白 */
  --card:      #FFFFFF;   /* 卡片 */
  --ink:       #1C1B1A;   /* 主文字，近黑 */
  --muted:     #8A8580;   /* 次要文字 */
  --line:      #EAE6E1;   /* 分割线 / 描边 */
  --accent:    #8E5F73;   /* 主色：低饱和梅子 */
  --accent-soft:#F2E9EC;  /* 主色浅底 */

  /* ---- 四个阶段的颜色（第 3 步会用） ---- */
  --phase-period:   #B4546A;  /* 月经期 */
  --phase-follicle: #6E8F7B;  /* 卵泡期 */
  --phase-ovu:      #4E7C9B;  /* 排卵期 */
  --phase-luteal:   #A8813F;  /* 黄体期 */

  /* ---- 尺寸 ---- */
  --radius: 16px;
  --gap: 14px;

  /* iPhone 刘海 / 底部横条的安全区 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;   /* 防止整页橡皮筋 */
}

/* ================= 整体布局 ================= */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;                /* dvh：随地址栏收起自动调整 */
}

/* ================= 顶部标题 ================= */
.topbar {
  flex: none;
  padding: calc(var(--safe-top) + 18px) 20px 12px;
  background: var(--bg);
}

.topbar-title {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .5px;
}

.topbar-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .3px;
}

/* ================= 内容区 ================= */
.main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 20px calc(96px + var(--safe-bottom));
}

/* 每个 Tab 的页面，默认隐藏 */
.view { display: none; }
.view.is-active { display: block; animation: fadeIn .18s ease-out; }

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

/* ================= 卡片 ================= */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: var(--gap);
}

.card-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ================= 按钮 ================= */
.btn {
  display: block;
  width: 100%;
  min-height: 52px;             /* 拇指友好 */
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .5px;
  cursor: pointer;
  margin-bottom: var(--gap);
  transition: transform .08s ease, opacity .15s ease;
}

.btn:active { transform: scale(.985); opacity: .9; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

/* ================= 占位（第 1 步用，后面会替换） ================= */
.placeholder-area {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: #FCFBFA;
}

.placeholder-block {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  padding: 6px 0;
}

.placeholder-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--phase-luteal);
}

/* ================= 免责声明 ================= */
.disclaimer {
  margin: 4px 2px 18px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #8A6C3A;
  background: #FBF6EA;
  border: 1px solid #F0E4C8;
  border-radius: 10px;
}

/* ================= 底部导航 ================= */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}

.tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 8px 0 6px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: .5px;
  cursor: pointer;
  transition: color .15s ease;
}

.tab svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.is-active { color: var(--accent); }

/* ================= 列表（记录页） ================= */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.li-main { flex: 1; min-width: 0; }

.li-title { font-size: 17px; font-weight: 500; }

.li-tag { margin-left: 8px; font-size: 12px; color: var(--muted); }

.li-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }

.li-del {
  border: none;
  background: none;
  color: #B4546A;
  font-family: inherit;
  font-size: 14px;
  min-width: 48px;
  min-height: 44px;
  padding: 10px 4px;
  cursor: pointer;
}

.li-del:active { opacity: .55; }

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

/* ================= 底部弹出层 ================= */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
}

.sheet[hidden] { display: none; }

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  opacity: 0;
  transition: opacity .22s ease;
}

.sheet.is-open .sheet-mask { opacity: 1; }

.sheet-panel {
  position: relative;
  width: 100%;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}

.sheet.is-open .sheet-panel { transform: none; }

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 6px auto 14px;
  border-radius: 2px;
  background: var(--line);
}

.sheet-title { margin: 0 0 4px; font-size: 18px; }

.sheet-hint { margin: 0 0 14px; font-size: 13px; color: var(--muted); }

.date-input {
  width: 100%;
  min-height: 52px;
  margin-bottom: 16px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
}

.sheet-actions { display: flex; gap: 10px; }

.sheet-actions .btn { flex: 1; margin-bottom: 0; }

.btn-ghost {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* ================= 轻提示 ================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translate(-50%, 8px);
  z-index: 60;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(28, 27, 26, .92);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

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

.no-scroll { overflow: hidden; }

/* ================= 深色模式（系统跟随） ================= */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:   #141312;
    --card: #1D1B1A;
    --ink:  #F2EFEC;
    --muted:#9A938C;
    --line: #2E2A27;
    --accent:#C98EA4;
    --accent-soft:#2A2226;
  }
  .tabbar { background: rgba(20, 19, 18, .92); }
  .placeholder-area { background: #1A1817; }
  .disclaimer { background: #241F14; border-color: #3A3120; color: #C9A96A; }
  .date-input { background: #141312; }
  .li-del { color: #E08CA0; }
  .toast { background: rgba(242, 239, 236, .94); color: #1C1B1A; }
}

/* ==========================================================
   今天页：阶段卡 / 月历 / 时间轴（第 3 步新增）
   ========================================================== */

/* ---- 阶段卡 ---- */
.phase-card { padding: 18px; }

.phase-row { display: flex; align-items: center; gap: 10px; }

.phase-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); flex: none;
}
.dot-period    { background: var(--phase-period); }
.dot-follicle  { background: var(--phase-follicle); }
.dot-ovulation { background: var(--phase-ovu); }
.dot-luteal    { background: var(--phase-luteal); }

.phase-name { font-size: 22px; font-weight: 600; }
.phase-day  { margin-left: auto; font-size: 13px; color: var(--muted); }
.phase-hint { margin-top: 10px; font-size: 16px; }
.phase-hint.is-late { color: #B4546A; }
.phase-meta { margin-top: 4px; font-size: 12.5px; color: var(--muted); }

/* ---- 月历 ---- */
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title { font-size: 15px; font-weight: 600; letter-spacing: .5px; }

.cal-nav {
  width: 44px; height: 44px; border: none; border-radius: 12px;
  background: none; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.cal-nav:active { background: var(--accent-soft); }

.cal-week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 11.5px; color: var(--muted);
  margin-bottom: 4px;
}

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 12px;
  background: none; color: var(--ink);
  font-family: inherit; font-size: 14.5px;
  cursor: pointer;
}
.cal-cell.is-blank { pointer-events: none; }

/* 已记录：当天是开始日（深） */
.cal-cell.is-start {
  background: var(--phase-period);
  color: #fff;
  font-weight: 600;
}
/* 经期其余几天（浅） */
.cal-cell.is-period {
  background: rgba(180, 84, 106, .16);
  color: #8E3E52;
  font-weight: 500;
}
/* 预测经期（虚线框） */
.cal-cell.is-pred {
  background: rgba(180, 84, 106, .06);
  box-shadow: inset 0 0 0 1px rgba(180, 84, 106, .45);
  color: #8E3E52;
}
/* 排卵窗口：数字下方一个小点 */
.cal-cell.is-ovu::after {
  content: '';
  position: absolute;
  bottom: 5px; left: 50%;
  width: 4px; height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--phase-ovu);
}
/* 今天：描边 */
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--accent); }

.cal-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-top: 12px; font-size: 11.5px; color: var(--muted);
}
.cal-legend .lg {
  display: inline-block; width: 10px; height: 10px;
  margin-right: 5px; border-radius: 3px; vertical-align: -1px;
}
.lg-period { background: rgba(180, 84, 106, .55); }
.lg-pred   { box-shadow: inset 0 0 0 1px rgba(180, 84, 106, .55); }
.lg-ovu    { background: var(--phase-ovu); border-radius: 50%; }
.lg-today  { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---- 时间轴 ---- */
.timeline {
  position: relative;
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--line);
}
.tl-seg { height: 100%; }
.tl-period    { background: var(--phase-period); }
.tl-follicle  { background: var(--phase-follicle); }
.tl-ovulation { background: var(--phase-ovu); }
.tl-luteal    { background: var(--phase-luteal); }

.tl-marker {
  position: absolute; top: 0; bottom: 0;
  width: 2px; margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}

.tl-labels { display: flex; margin-top: 8px; }
.tl-label {
  flex: 1; min-width: 0; text-align: center;
  font-size: 10px; line-height: 1.35; color: var(--muted);
}
.tl-label b { display: block; font-size: 11px; font-weight: 600; color: var(--ink); }
.tl-label i { display: block; font-style: normal; }

.tl-note { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---- 设置页表单 ---- */
.field {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.field:last-of-type { border-bottom: none; }
.field label { font-size: 15px; }

.num-input {
  width: 86px; min-height: 44px;
  text-align: center;
  font-family: inherit; font-size: 16px;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.field-note { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* ---- 空状态 ---- */
.empty-card { text-align: center; padding: 26px 18px; }
.empty-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.empty-text { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); }
.empty-card .btn { margin-bottom: 0; }

/* ---- 深色模式补充 ---- */
@media (prefers-color-scheme: dark) {
  .cal-cell.is-period { color: #E7B7C3; }
  .cal-cell.is-pred   { color: #E7B7C3; }
  .cal-cell.is-start  { color: #141312; }
  .num-input { background: #141312; }
}
/* ---- 时间轴明细行（替代挤在一起的比例标签） ---- */
.tl-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.tl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.tl-row .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
}

.tl-row .nm {
  width: 3.4em;
  flex: none;
  color: var(--ink);
  font-weight: 500;
}

.tl-row .rg { flex: 1; }

.tl-row .dy {
  flex: none;
  font-variant-numeric: tabular-nums;
}
/* ==========================================================
   建议卡片（第 4 步）
   ========================================================== */
.advice-card { padding: 18px; }

.adv-head { display: flex; align-items: center; gap: 8px; }

.adv-head .dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
}

.adv-name { font-size: 18px; font-weight: 600; }

.adv-tagline {
  margin: 6px 0 16px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.adv-sec { margin-bottom: 14px; }
.adv-sec:last-child { margin-bottom: 0; }

.adv-sec-title {
  margin: 0 0 5px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
}

.adv-list {
  margin: 0;
  padding-left: 17px;
}

.adv-list li {
  margin-bottom: 4px;
  font-size: 13.5px;
  line-height: 1.65;
}

.adv-list li::marker { color: var(--accent); }

.adv-more {
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.adv-more:active { opacity: .7; }

@media (prefers-color-scheme: dark) {
  .adv-more { background: #141312; }
}
/* ---- 计算方式分段控件 ---- */
.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.seg-btn {
  min-height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.seg-btn.is-active {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

@media (prefers-color-scheme: dark) {
  .seg-btn.is-active { background: #2A2624; }
}
/* ==========================================================
   特殊事件（第 5 步）
   ========================================================== */

/* 次要按钮 */
.btn-secondary {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--line);
}

/* 类型选择胶囊 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* 备注输入框 */
.text-input {
  width: 100%;
  min-height: 50px;
  margin-bottom: 16px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
}

.text-input::placeholder { color: var(--muted); }

/* 事件行 */
.li-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.li-title-sm { font-size: 16px; }

.ev-badge {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  line-height: 1.6;
}

/* 月历上「有事件」的小标记：右上角一个墨点 */
.cal-cell.has-event::before {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-cell.is-start.has-event::before { background: #fff; }

@media (prefers-color-scheme: dark) {
  .btn-secondary { background: #1D1B1A; }
  .text-input { background: #141312; }
  .chip { background: #141312; }
  .chip.is-active { background: var(--accent); color: #141312; }
}
/* ---- 事件影响标签 / 提示行 / 周期干扰提醒 ---- */
.chip-hint {
  margin: -4px 0 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.ev-effect {
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.warn-card {
  margin-bottom: var(--gap);
  padding: 12px 14px;
  border-radius: 12px;
  background: #FBF6EA;
  border: 1px solid #F0E4C8;
  color: #8A6C3A;
  font-size: 12.5px;
  line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
  .warn-card { background: #241F14; border-color: #3A3120; color: #C9A96A; }
  .ev-effect { background: #141312; }
}
/* ---- .ics 下载按钮做成链接样式 ---- */
.btn-link {
  display: block;
  text-align: center;
  line-height: 52px;
  text-decoration: none;
}
.btn-link.is-disabled { opacity: .45; pointer-events: none; }
/* ---- 导入步骤说明 ---- */
.steps {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--muted);
}
.steps li { margin-bottom: 3px; }