:root {
  --rose-500: #ec4899;
  --rose-600: #db2777;
  --rose-400: #f472b6;
  --rose-100: #fce7f3;
  --rose-50: #fdf2f8;
  --pink-200: #fbcfe8;
  --purple-500: #a855f7;
  --purple-300: #c084fc;
  --amber-400: #fbbf24;
  --bg: #fbf3f7;
  --card: #ffffff;
  --border: #f2d8e4;
  --txt: #3c2430;
  --txt-dim: #8a5a6e;
  --txt-faint: #bd93a6;
  --shadow: 0 12px 30px -18px rgba(219, 39, 119, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(50% 45% at 12% 0%, rgba(236, 72, 153, .12), transparent 70%),
    radial-gradient(45% 40% at 92% 8%, rgba(168, 85, 247, .10), transparent 70%),
    var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px 90px;
}

/* ---------------- Auth screen ---------------- */
.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 30px 26px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center;
  margin-bottom: 22px;
}
.auth-logo .emoji { font-size: 42px; }
.auth-logo h1 {
  margin: 8px 0 2px;
  font-size: 24px;
  letter-spacing: -.01em;
  background: linear-gradient(120deg, #db2777, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-logo p { margin: 0; color: var(--txt-dim); font-size: 13px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--txt-dim);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--txt);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.field input:focus {
  border-color: var(--rose-400);
  box-shadow: 0 0 0 4px rgba(236, 72, 153, .12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(120deg, var(--rose-500), var(--purple-500));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s, box-shadow .18s, filter .18s;
}
.btn:hover { filter: brightness(1.04); box-shadow: 0 10px 20px -12px var(--rose-500); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost {
  background: #fff;
  color: var(--rose-600);
  border: 1px solid var(--border);
}
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--txt-dim);
}
.auth-toggle a { color: var(--rose-600); font-weight: 600; text-decoration: none; }
.msg {
  text-align: center;
  font-size: 12.5px;
  color: #e11d48;
  min-height: 18px;
  margin-top: 8px;
}

/* ---------------- Header ---------------- */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.app-title { display: flex; align-items: center; gap: 8px; }
.app-title .emoji { font-size: 26px; }
.app-title h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.01em;
  background: linear-gradient(120deg, #db2777, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.spacer { flex: 1; }
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rose-600);
  background: var(--rose-50);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.logout {
  background: none;
  border: none;
  color: var(--txt-faint);
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
}
.logout:hover { color: #e11d48; }

/* ---------------- Today card ---------------- */
.today {
  position: relative;
  background: linear-gradient(135deg, #fdf2f8, #faf5ff);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.today::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(40% 60% at 90% 0%, rgba(236, 72, 153, .10), transparent 70%);
  pointer-events: none;
}
.today-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.today-date { font-size: 13px; color: var(--txt-dim); font-weight: 600; }
.phase-chip {
  margin-left: auto;
  padding: 4px 11px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--rose-500), var(--purple-500));
  border-radius: 999px;
  box-shadow: 0 6px 12px -6px var(--rose-500);
}
.today-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 13px;
}
.stat .k { font-size: 11.5px; color: var(--txt-faint); letter-spacing: .02em; }
.stat .v { margin-top: 4px; font-size: 16px; font-weight: 700; color: var(--txt); }
.stat .v.big { font-size: 21px; }
.stat .s { font-size: 11px; color: var(--txt-dim); margin-top: 2px; }
.today-tips {
  position: relative;
  margin-top: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--txt-dim);
  background: rgba(236, 72, 153, .06);
  border-radius: 12px;
}

/* ---------------- Calendar ---------------- */
.cal-card {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 14px;
  box-shadow: var(--shadow);
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.cal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 17px;
  color: var(--rose-600);
  cursor: pointer;
}
.cal-nav:hover { background: var(--rose-50); }
.cal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--txt);
}
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
}
.cal-week span {
  text-align: center;
  font-size: 11px;
  color: var(--txt-faint);
  padding: 4px 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--txt);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}
.cal-cell.empty { cursor: default; }
.cal-cell .d { position: relative; z-index: 1; }
.cal-cell.today {
  box-shadow: inset 0 0 0 2px var(--rose-500);
}
.cal-cell.period .d {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--rose-500), var(--rose-400));
  color: #fff;
  border-radius: 50%;
  font-weight: 650;
}
.cal-cell.predicted .d {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--rose-400);
  color: var(--rose-600);
  border-radius: 50%;
}
.cal-cell.ovulation .d {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--purple-500);
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
}
.cal-cell.fertile .d {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: #f3e8ff;
  border-radius: 50%;
}
.cal-cell.fertile { color: var(--purple-500); }

/* ---------------- Legend ---------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  padding: 2px 4px;
  font-size: 11.5px;
  color: var(--txt-dim);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
}
.legend i.p { background: linear-gradient(135deg, var(--rose-500), var(--rose-400)); }
.legend i.pr { border: 1.5px dashed var(--rose-400); }
.legend i.o { background: var(--purple-500); }
.legend i.f { background: #f3e8ff; border: 1px solid var(--purple-300); }

/* ---------------- Logs ---------------- */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 4px 10px;
}
.section-title h2 { margin: 0; font-size: 15px; color: var(--txt); }
.section-title .hint { font-size: 12px; color: var(--txt-faint); }

.logs { display: flex; flex-direction: column; gap: 8px; }
.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.log-dates { flex: 1; min-width: 0; }
.log-dates .range { font-size: 14px; font-weight: 650; }
.log-dates .meta { font-size: 11.5px; color: var(--txt-dim); margin-top: 2px; }
.log-actions { display: flex; gap: 6px; }
.log-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--txt-dim);
  font-size: 12px;
  padding: 6px 9px;
  cursor: pointer;
}
.log-actions button:hover { color: var(--rose-600); border-color: var(--rose-400); }
.log-actions button.del:hover { color: #e11d48; border-color: #e11d48; }

/* ---------------- Modal ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(60, 36, 48, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 22px 18px 26px;
  animation: slideUp .22s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .flow-options {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.flow-opt {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  font-size: 12px;
  color: var(--txt-dim);
  background: var(--rose-50);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.flow-opt.active {
  color: #fff;
  background: linear-gradient(120deg, var(--rose-500), var(--rose-400));
  border-color: transparent;
}
.modal .btns { display: flex; gap: 10px; margin-top: 18px; }

.empty-state {
  text-align: center;
  color: var(--txt-faint);
  font-size: 13px;
  padding: 24px 10px;
}

/* ---------------- Floating add button ---------------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--rose-500), var(--purple-500));
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 24px -10px var(--rose-500);
  z-index: 40;
}
.fab:hover { filter: brightness(1.05); }

@media (max-width: 480px) {
  .today-grid { grid-template-columns: 1fr 1fr; }
}
