/* 经期小助手 */
:root {
  --rose: #f43f5e;
  --rose-soft: #ffe4ea;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --orange: #f97316;
  --purple: #8b5cf6;
  --bg: #fff7f9;
  --card: #ffffff;
  --text: #3f3a44;
  --muted: #9b93a3;
  --line: #f3e7ec;
  --shadow: 0 6px 24px rgba(244, 63, 94, .08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button, .cell, .tab { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
html, body { margin: 0; padding: 0; }
body {
  background: linear-gradient(180deg, #fff1f5 0%, var(--bg) 30%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.err { color: var(--rose); }

#app { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
header { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 4px 14px; }
.brand { font-size: 20px; font-weight: 700; color: #d6336c; }

.card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); }
.sec-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 20px 4px 8px; }

/* ---------- 圆环 ---------- */
.ring-card { position: relative; padding: 22px; display: flex; justify-content: center; }
#ring-wrap { width: min(72vw, 264px); }
#ring-wrap svg { display: block; width: 100%; height: auto; }
#ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 6px; pointer-events: none;
}
#rc-small { font-size: 13px; }
#rc-big { font-size: 30px; font-weight: 800; letter-spacing: .5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: #fff;
  background: var(--muted); border-radius: 999px; padding: 4px 12px;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.85); }

#status-line { text-align: center; font-size: 14px; margin: 14px 8px; line-height: 1.6; }

/* ---------- 阶段小贴士 ---------- */
.tip-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin: 0 0 14px;
  font-size: 13px; line-height: 1.7; color: #6b6472;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
}
.tip-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted); }

/* ---------- 信息卡 ---------- */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 14px; }
.info-grid.three { grid-template-columns: repeat(3, 1fr); }
.card.info { padding: 12px 10px; text-align: center; }
.card.info .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.card.info .v { font-size: 15.5px; font-weight: 700; }

/* ---------- 按钮 ---------- */
.primary-btn {
  display: block; width: 100%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #fb7185, #e11d48);
  color: #fff; font-size: 16px; font-weight: 700;
  padding: 14px; border-radius: 16px; box-shadow: 0 8px 20px rgba(225, 29, 72, .28);
  transition: transform .08s ease, box-shadow .2s;
}
.primary-btn:active { transform: scale(.98); }
.primary-btn.big { margin: 6px 0 4px; }
.ghost-btn {
  display: block; width: 100%; border: 1px solid var(--line); cursor: pointer;
  background: #fff; color: var(--text); font-size: 14.5px; font-weight: 600;
  padding: 11px; border-radius: 12px; margin-top: 8px;
}
.icon-btn {
  border: 0; background: #fff; width: 38px; height: 38px; border-radius: 12px;
  font-size: 20px; color: #d6336c; cursor: pointer; box-shadow: var(--shadow);
}

/* ---------- 日历 ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 12px; }
#cal-title { font-size: 17px; font-weight: 700; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cal-week .wknd { color: #f0a5b8; }
#cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cell {
  position: relative; aspect-ratio: 1; border-radius: 14px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500; cursor: pointer; border: 1.5px solid transparent;
}
.cell.other { color: #d9cdd4; background: transparent; cursor: default; }
.cell.rec { background: var(--rose); color: #fff; font-weight: 700; box-shadow: 0 4px 10px rgba(244,63,94,.25); }
.cell.pred { background: var(--rose-soft); color: #d6336c; font-weight: 700; border-style: dashed; border-color: #f9b8c6; }
.cell.fertile::after { content: ""; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--amber); }
.cell.ovu { border-color: var(--orange); }
.cell.ovu::after { content: "✦"; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--orange); }
.cell.today { outline: 2.5px solid #d6336c; outline-offset: -2.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 12px 14px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.lg-rec { background: var(--rose); }
.lg-pred { background: var(--rose-soft); border: 1.5px dashed #f9b8c6; }
.lg-fer { background: #fff; border: 1px solid var(--line); position: relative; }
.lg-fer::after { content: ""; position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--amber); }
.lg-ovu { background: #fff; border: 1.5px solid var(--orange); }
.lg-today { background: #fff; outline: 2px solid #d6336c; outline-offset: -2px; }

/* ---------- 历史 ---------- */
#history-list { display: flex; flex-direction: column; gap: 10px; }
.h-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
}
.h-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rose); flex: none; }
.h-main { flex: 1; }
.h-date { font-weight: 700; font-size: 15px; }
.h-len { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.h-chip { font-size: 12px; color: #d6336c; background: var(--rose-soft); border-radius: 999px; padding: 3px 10px; }
.h-chip.warn { color: #b45309; background: #fef3c7; }
.empty-tip { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; }

/* ---------- 设置 ---------- */
.card.form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.form label { font-size: 13.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.card.form input {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; color: var(--text);
  background: #fffafa; width: 100%;
}
.card.about { padding: 14px 16px; line-height: 1.8; }
.card.about p { margin: 0; }

/* ---------- 底部标签 ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); z-index: 30;
}
.tab {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
}
.tab .ico { font-size: 20px; filter: grayscale(1) opacity(.6); }
.tab.active { color: #d6336c; font-weight: 700; }
.tab.active .ico { filter: none; }

/* ---------- 底部面板 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(63, 58, 68, .45); z-index: 50;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
#sheet-mask { align-items: flex-end; }
#sheet {
  width: 100%; max-width: 520px; background: #fff;
  border-radius: 24px 24px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  animation: up .18s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
#sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
#sheet-title { margin: 0 0 4px; font-size: 17px; }
#sheet-sub { margin: 0 0 14px; }
#sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.sheet-btn {
  border: 1.5px solid var(--line); background: #fffafa; border-radius: 12px;
  padding: 13px; font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer; text-align: center;
}
.sheet-btn.danger { color: #e11d48; border-color: #fecdd3; background: #fff5f6; }
.sheet-btn:disabled { opacity: .45; cursor: default; }

/* ---------- 口令解锁 ---------- */
.lock-card {
  width: min(86vw, 340px); background: #fff; border-radius: 24px; padding: 28px 24px;
  display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: var(--shadow);
}
.lock-emoji { font-size: 40px; }
.lock-card h2 { margin: 0; font-size: 18px; }
.lock-card input {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; font-size: 18px;
  text-align: center; letter-spacing: 4px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: rgba(63, 58, 68, .92); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; z-index: 99; white-space: nowrap;
  pointer-events: none;
  animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 460px) {
  #rc-big { font-size: 34px; }
}
