:root {
  color-scheme: light;
  --bg: #fff7f2;
  --card: #ffffff;
  --ink: #3a2a35;
  --ink-2: #7a6670;
  --ink-3: #a8959e;
  --line: #f1e3e0;
  --period: #e8466f;
  --period-soft: #fde4ea;
  --fertile: #1fa595;
  --fertile-soft: #d9f4ef;
  --ovu: #7b5cf0;
  --ovu-soft: #ebe5ff;
  --test: #e8961e;
  --test-soft: #fff0d9;
  --accent: #ff6f91;
  --accent-2: #ffb38a;
  --hero: linear-gradient(135deg, #ff8fab 0%, #ffb38a 55%, #ffd88a 100%);
  --radius: 22px;
  --shadow: 0 6px 24px rgba(232, 70, 111, 0.09);
}
body.soft {
  --accent: #9a8ab8;
  --accent-2: #c6b8d9;
  --hero: linear-gradient(135deg, #b7a9d6 0%, #cfc3e3 60%, #e6def0 100%);
  --bg: #f7f5fa;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
.wrap > *, .card, .hero { min-width: 0; }
.est .n, .sub, .line { overflow-wrap: anywhere; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', ui-rounded, -apple-system, 'SF Pro Rounded', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  transition: background 0.4s;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.wrap { max-width: 560px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px 24px; }
header.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 24px; letter-spacing: -0.02em; color: var(--accent); }
.logo svg { width: 32px; height: 32px; }
.hi { color: var(--ink-2); font-size: 14px; text-align: right; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 17px; margin: 0 0 4px; font-weight: 800; }
.card h3 { font-size: 15px; margin: 14px 0 6px; font-weight: 800; }
.sub { color: var(--ink-2); font-size: 14px; margin: 0 0 12px; }
.muted { color: var(--ink-3); font-size: 13px; }

.hero { background: var(--hero); color: #fff; border-radius: 28px; padding: 22px 20px; margin-bottom: 14px; position: relative; overflow: hidden; box-shadow: 0 10px 30px rgba(255, 111, 145, 0.25); }
body.soft .hero { box-shadow: 0 10px 30px rgba(130, 110, 170, 0.2); }
.hero .eyebrow { font-size: 13px; font-weight: 800; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.06em; }
.hero .big { font-size: 27px; font-weight: 900; line-height: 1.15; margin: 6px 0 8px; letter-spacing: -0.01em; }
.hero .line { font-size: 15px; opacity: 0.95; }
.hero .pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero .pill { background: rgba(255, 255, 255, 0.25); backdrop-filter: blur(6px); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; }
.hero .deco { position: absolute; right: -18px; top: -18px; font-size: 92px; opacity: 0.18; transform: rotate(12deg); pointer-events: none; }
.why { background: rgba(255, 255, 255, 0.3); border: 0; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800; color: #fff; margin-left: 6px; }

.estimates { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 14px; }
.est { background: var(--card); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.est .k { font-size: 12px; font-weight: 800; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.est .v { font-size: 17px; font-weight: 900; margin-top: 2px; }
.est .n { font-size: 12px; color: var(--ink-2); }
.est.mira .k { color: var(--ovu); }
.est.cal .k { color: var(--fertile); }

/* calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { margin: 0; }
.nav { display: flex; gap: 6px; }
.nav button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--period-soft); color: var(--period); font-weight: 900; font-size: 18px; }
body.soft .nav button { background: var(--ovu-soft); color: var(--ovu); }
.dow, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow div { text-align: center; font-size: 12px; font-weight: 800; color: var(--ink-3); padding-bottom: 4px; }
.day {
  aspect-ratio: 1 / 1.12; border: 0; background: transparent; border-radius: 14px; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 5px; min-width: 0;
}
.day .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.day.out { opacity: 0.35; }
.day.today .num { outline: 2.5px solid var(--ink); outline-offset: 1px; }
.day.period .num { background: var(--period); color: #fff; }
.day.ppred .num { border: 2px dashed var(--period); color: var(--period); }
.day.fertile { background: var(--fertile-soft); }
.day.fertile-cal { background: repeating-linear-gradient(135deg, var(--fertile-soft) 0 5px, #fff 5px 9px); }
.day.ovu .num { background: var(--ovu); color: #fff; }
.day.ovu-cal .num { border: 2px solid var(--ovu); color: var(--ovu); }
.day .marks { display: flex; gap: 2px; font-size: 10px; line-height: 1; margin-top: 2px; height: 11px; }
.day .tp { position: absolute; bottom: 3px; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 900; color: var(--test); }
.day.testday { box-shadow: inset 0 0 0 2px var(--test-soft); }
.day:focus-visible { outline: 3px solid var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.sw.period { background: var(--period); }
.sw.ppred { border: 2px dashed var(--period); }
.sw.fertile { background: var(--fertile-soft); border: 1px solid var(--fertile); border-radius: 4px; }
.sw.fertile-cal { background: repeating-linear-gradient(135deg, var(--fertile-soft) 0 3px, #fff 3px 5px); border: 1px solid var(--fertile); border-radius: 4px; }
.sw.ovu { background: var(--ovu); }
.sw.ovu-cal { border: 2px solid var(--ovu); }

/* test-day strip */
.tests { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; align-items: end; height: 120px; margin-top: 6px; }
.tests .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.tests .bar { width: 100%; max-width: 22px; background: var(--test); border-radius: 4px 4px 0 0; min-height: 2px; }
.tests .col.now .bar { background: var(--accent); }
.tests .lab { font-size: 11px; color: var(--ink-2); font-weight: 700; }
.tests .val { font-size: 10px; color: var(--ink-2); }

/* bottom tabs */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 10;
}
nav.tabs .in { display: flex; width: 100%; max-width: 560px; justify-content: space-around; }
nav.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 800; color: var(--ink-3); padding: 4px 10px; border-radius: 14px; }
nav.tabs button .ic { font-size: 22px; filter: grayscale(0.6); opacity: 0.8; }
nav.tabs button.on { color: var(--accent); background: var(--period-soft); }
body.soft nav.tabs button.on { background: var(--ovu-soft); }
nav.tabs button.on .ic { filter: none; opacity: 1; }

/* sheets */
.scrim { position: fixed; inset: 0; background: rgba(58, 42, 53, 0.35); z-index: 20; display: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-radius: 28px 28px 0 0; z-index: 21;
  max-height: 92vh; overflow-y: auto; padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform 0.28s ease, visibility 0s 0.28s; visibility: hidden;
  max-width: 600px; margin: 0 auto;
}
.sheet.open { transform: none; visibility: visible; transition: transform 0.28s ease; }
.scrim.open { display: block; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 0 0 4px; font-size: 21px; font-weight: 900; }
.sheet .info { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.tag { border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800; background: var(--card); box-shadow: var(--shadow); }
.tag.p { color: var(--period); } .tag.f { color: var(--fertile); } .tag.o { color: var(--ovu); } .tag.t { color: var(--test); }

.field { margin-bottom: 16px; }
.field > label, .field > .lbl { display: block; font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 700;
  transition: transform 0.1s;
}
.chip:active { transform: scale(0.95); }
.chip.on { border-color: var(--accent); background: var(--period-soft); color: var(--period); }
.chip.big { font-size: 22px; padding: 6px 10px; }
.heart { display: flex; align-items: center; gap: 12px; border: 2px solid var(--line); background: var(--card); border-radius: 18px; padding: 12px 16px; width: 100%; font-weight: 800; }
.heart .h { font-size: 28px; filter: grayscale(1); opacity: 0.5; transition: all 0.2s; }
.heart.on { border-color: var(--accent); background: var(--period-soft); }
.heart.on .h { filter: none; opacity: 1; transform: scale(1.15); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px; font-size: 16px;
}
textarea { min-height: 70px; resize: vertical; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.btn { border: 0; border-radius: 999px; padding: 13px 20px; font-weight: 900; font-size: 16px; background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(255, 111, 145, 0.3); }
.btn.full { width: 100%; }
.btn.ghost { background: var(--card); color: var(--accent); box-shadow: none; border: 2px solid var(--line); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.danger { background: var(--card); color: var(--period); border: 2px solid var(--period-soft); box-shadow: none; }

.help { background: var(--ovu-soft); color: #4a3a8a; border-radius: 14px; padding: 10px 12px; font-size: 13px; margin-top: 8px; }
.loss { border: 2px solid var(--line); border-radius: 18px; padding: 12px; margin-bottom: 10px; background: var(--card); }
.loss .top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--bg); border-radius: 16px; padding: 12px; text-align: center; }
.tile .v { font-size: 24px; font-weight: 900; color: var(--accent); }
.tile .k { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.bignum { font-size: 44px; font-weight: 900; color: var(--accent); line-height: 1; letter-spacing: -0.02em; }
.bignum small { font-size: 16px; color: var(--ink-2); font-weight: 700; letter-spacing: 0; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 900; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--ink-2); font-family: inherit; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; }
.tip {
  position: fixed; pointer-events: none; z-index: 40; background: var(--ink); color: #fff; font-size: 13px; padding: 7px 10px;
  border-radius: 10px; opacity: 0; transition: opacity 0.12s; max-width: 220px; line-height: 1.3;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 900; }
.mult { display: grid; grid-template-columns: 1fr; gap: 6px; }
.mult h4 { margin: 8px 0 0; font-size: 13px; font-weight: 800; color: var(--ink-2); }

.factor { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.factor .e { font-weight: 900; white-space: nowrap; }
.factor .e.down { color: var(--period); } .factor .e.up { color: var(--fertile); }
.src { font-size: 12px; color: var(--ink-2); margin: 4px 0; }
.disclaimer { font-size: 12px; color: var(--ink-3); margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: 14px; opacity: 0; transition: all 0.25s; z-index: 50; white-space: nowrap; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; font-style: normal; font-size: 24px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.empty { text-align: center; padding: 18px 8px; color: var(--ink-2); }
.empty .e { font-size: 40px; }
code.copy { display: block; background: var(--bg); border-radius: 12px; padding: 10px; font-size: 12px; word-break: break-all; margin: 6px 0; }
.hidden { display: none !important; }
@media (max-width: 380px) { .tiles { grid-template-columns: repeat(2, 1fr); } .hero .big { font-size: 23px; } }

/* journey timeline */
.jgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.jm { border-radius: 12px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.jm .ji { font-size: 18px; line-height: 1; }
.jm .jn { font-size: 10px; font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.jm.now { outline: 2.5px solid var(--ink); outline-offset: 1px; }
.ygrid { display: grid; grid-template-columns: 34px repeat(12, minmax(0, 1fr)); gap: 3px; align-items: center; }
.ygrid .yh { text-align: center; font-size: 11px; font-weight: 800; color: var(--ink-3); }
.ygrid .yl { font-size: 11px; font-weight: 800; color: var(--ink-2); }
.ygrid .yc { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 14px; cursor: default; }
.ygrid .yc.blank { background: var(--bg); opacity: 0.6; }
.ygrid .yc.now { outline: 2px solid var(--ink); outline-offset: 1px; }
.preg { display: grid; grid-template-columns: 30px 1fr 70px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.preg:last-child { border-bottom: 0; }
.preg .pn { width: 28px; height: 28px; border-radius: 50%; background: var(--period-soft); color: var(--period); font-weight: 900; display: grid; place-items: center; }
.preg .pbar, .progress { background: var(--bg); border-radius: 999px; height: 10px; overflow: hidden; position: relative; }
.preg .pbar i, .progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progress { height: 18px; margin-top: 12px; }
.progress span { position: absolute; right: 8px; top: 0; font-size: 12px; font-weight: 900; line-height: 18px; color: var(--ink); }
