:root, [data-theme="rose"] {
  --bg: #fdeef2; --bg2: #fff7f9; --card: #ffffff; --line: #f3cfd9;
  --text: #2e0a14; --muted: #7a4352; --accent: #b3123f; --accent-ink: #ffffff;
  --period: #c8174a; --period-soft: #f6bccb; --fertile: #ffd9e3; --fertile-ink: #8a0f33;
  --ovul: #6d0a26; --today: #2e0a14;
}
[data-theme="lilac"] {
  --bg: #f3eefb; --bg2: #faf7fe; --card: #ffffff; --line: #ddd0f0;
  --text: #22123a; --muted: #5f4c7d; --accent: #7a3db8; --accent-ink: #ffffff;
  --period: #8e3fc9; --period-soft: #dcc4f2; --fertile: #e9dcfa; --fertile-ink: #55248a;
  --ovul: #3e1670; --today: #22123a;
}
[data-theme="sage"] {
  --bg: #edf5ee; --bg2: #f7fbf7; --card: #ffffff; --line: #cfe3d3;
  --text: #102a18; --muted: #4a6652; --accent: #2f7a45; --accent-ink: #ffffff;
  --period: #b5364f; --period-soft: #f1c6cf; --fertile: #d3ecd9; --fertile-ink: #1f5c32;
  --ovul: #164a26; --today: #102a18;
}
[data-theme="night"] {
  --bg: #1a1219; --bg2: #221822; --card: #2a1e29; --line: #46303f;
  --text: #f7e8ee; --muted: #c4a5b3; --accent: #ff7aa2; --accent-ink: #2a0d18;
  --period: #ff5f8f; --period-soft: #6b2a40; --fertile: #4a2a3a; --fertile-ink: #ffc2d4;
  --ovul: #ffb3c9; --today: #f7e8ee;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background .25s, color .25s;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.2; }
a { color: var(--accent); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 18px; }

/* Header */
header.top { padding: 18px 0 6px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand svg { width: 42px; height: 42px; }
.brand b { font-family: Georgia, serif; font-size: 1.45rem; letter-spacing: .2px; }
.themes { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hero { padding: 18px 0 8px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0 0 8px; }
.hero p { margin: 0; color: var(--muted); max-width: 620px; }
.private { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: .9rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; color: var(--muted); }

/* Card + form */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; margin: 20px 0;
  box-shadow: 0 6px 24px -18px rgba(0,0,0,.35); }
.card h2 { margin: 0 0 4px; font-size: 1.35rem; }
.hint { color: var(--muted); font-size: .92rem; margin: 0 0 16px; }
.dates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .dates { grid-template-columns: 1fr; } }
label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 5px; }
label small { font-weight: 400; color: var(--muted); }
input[type=date], input[type=number] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px;
}
input:focus { outline: none; border-color: var(--accent); }
[data-theme="night"] input { color-scheme: dark; }
details.more { margin-top: 16px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .95rem; }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 12px; }
@media (max-width: 640px) { .opts { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
button.go {
  font: inherit; font-weight: 700; background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 12px; padding: 12px 26px; cursor: pointer;
}
button.go:hover { filter: brightness(1.07); }
button.link { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; text-decoration: underline; padding: 4px; }
.err { color: var(--period); font-weight: 600; margin-top: 12px; min-height: 1em; }

/* Results */
#results[hidden] { display: none; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0 6px; }
@media (max-width: 640px) { .summary { grid-template-columns: 1fr; } }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat .k { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .v { font-family: Georgia, serif; font-size: 1.35rem; margin-top: 2px; }
.stat .s { font-size: .85rem; color: var(--muted); }
.stat.hl { background: var(--fertile); border-color: transparent; }
.stat.hl .v, .stat.hl .k, .stat.hl .s { color: var(--fertile-ink); }
.note { font-size: .92rem; color: var(--muted); }
.note.warn { color: var(--text); background: var(--bg2); border-left: 4px solid var(--accent); padding: 10px 12px; border-radius: 8px; }
table.cycles { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .95rem; }
table.cycles th, table.cycles td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
table.cycles th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }

/* Calendar */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; color: var(--muted); margin: 18px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 680px) { .months { grid-template-columns: 1fr; max-width: 360px; margin: 0 auto; } }
.calnav { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 2px; }
.navbtn { font: inherit; font-size: 1.4rem; line-height: 1; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: var(--bg2); color: var(--accent); border: 1px solid var(--line); }
.navbtn:disabled { opacity: .35; cursor: default; }
.month h3 { font-size: 1.05rem; margin: 6px 0 8px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.dow { font-size: .72rem; text-align: center; color: var(--muted); padding-bottom: 2px; }
.d { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: .85rem; border-radius: 8px; position: relative; }
.d.out { visibility: hidden; }
.d { flex-direction: column; line-height: 1.05; }
.d i { font-style: normal; font-size: .6rem; font-weight: 700; opacity: .85; margin-top: 1px; }
.agerow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
@media (max-width: 640px) { .agerow { grid-template-columns: 1fr; } }
.d.fertile { background: var(--fertile); color: var(--fertile-ink); font-weight: 600; }
.d.peak { background: var(--fertile); color: var(--fertile-ink); font-weight: 800; box-shadow: inset 0 0 0 2px var(--fertile-ink); }
.d.ovul { background: var(--ovul); color: var(--bg); font-weight: 800; }
.d.period { background: var(--period); color: #fff; font-weight: 600; }
.d.pperiod { background: transparent; color: var(--period); font-weight: 600; box-shadow: inset 0 0 0 2px var(--period); border: 0; background-image: repeating-linear-gradient(135deg, var(--period-soft) 0 3px, transparent 3px 7px); }
.d.today { outline: 2px solid var(--today); outline-offset: -2px; }

/* Content */
section.info h2 { font-size: 1.35rem; margin-top: 34px; }
section.info p, section.info li { color: var(--text); }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.disclaimer { font-size: .88rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 36px; padding-top: 16px; }
footer { padding: 18px 0 40px; font-size: .85rem; color: var(--muted); }
@media print { header.top .themes, .actions, details.more, section.info, footer { display: none; } body { background: #fff; } }

/* Articles */
.navlinks { display: flex; gap: 16px; font-size: .95rem; }
.navlinks a { color: var(--text); text-decoration: none; font-weight: 600; }
.navlinks a:hover { color: var(--accent); }
article.card h1 { margin-top: 0; font-size: clamp(1.7rem, 4.5vw, 2.3rem); }
article.card h2 { font-size: 1.3rem; margin-top: 28px; }
article.card p, article.card li { max-width: 68ch; }
.lede { font-size: 1.08rem; color: var(--muted); }
.cta { background: var(--fertile); color: var(--fertile-ink); border-radius: 14px; padding: 14px 18px; margin: 22px 0; }
.cta a { color: var(--fertile-ink); font-weight: 700; }
.sources { font-size: .88rem; color: var(--muted); }
.sources li { margin: 4px 0; }
.guides { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 12px 0 4px; padding: 0; list-style: none; }
.guides a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--text); height: 100%; }
.guides a:hover { border-color: var(--accent); }
.guides b { display: block; color: var(--accent); margin-bottom: 2px; }
.guides span { font-size: .88rem; color: var(--muted); }

section.info h3 { font-size: 1.05rem; margin: 18px 0 4px; color: var(--muted); }
article .note.warn { margin: 18px 0; }

/* Daily chance bar chart */
:root, [data-theme="rose"] { --g1: #ffc9d6; --g2: #e0457b; --g3: #6d0a26; }
[data-theme="lilac"] { --g1: #e4d2fb; --g2: #9b5de5; --g3: #3e1670; }
[data-theme="sage"] { --g1: #d3ecd9; --g2: #45a866; --g3: #164a26; }
[data-theme="night"] { --g1: #5a2338; --g2: #ff7aa2; --g3: #ffd6e2; }
.chart { --ch: 170px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 14px 14px 10px; margin: 8px 0 18px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; font-size: .92rem; }
.chart-head span { color: var(--muted); font-size: .85rem; }
.chart-body { display: flex; gap: 6px; }
.chart-y { position: relative; height: var(--ch); min-width: 28px; font-size: .68rem; color: var(--muted); }
.chart-y span { position: absolute; right: 0; transform: translateY(50%); line-height: 1; }
.chart-plot { position: relative; flex: 1; height: var(--ch); border-bottom: 1px solid var(--line); }
.chart-grid { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(var(--line), var(--line)) 0 0 / 100% 1px no-repeat,
              linear-gradient(var(--line), var(--line)) 0 33.33% / 100% 1px no-repeat,
              linear-gradient(var(--line), var(--line)) 0 66.67% / 100% 1px no-repeat; }
.bars, .chart-x { display: flex; gap: 0; }
.curve { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.bars { position: absolute; inset: 0; }
.b { flex: 1 1 0; min-width: 0; height: 100%; position: relative; cursor: pointer; }
.b .dot { position: absolute; left: 50%; width: 11px; height: 11px; margin: 0 0 -5.5px -5.5px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--g3); box-shadow: 0 1px 4px rgba(0,0,0,.25); opacity: 0; transition: opacity .12s; pointer-events: none; }
.b:hover .dot, .b.sel .dot { opacity: 1; }
.b em { position: absolute; left: 50%; transform: translate(-50%, -8px); font-style: normal; font-size: .7rem; font-weight: 800; color: var(--g3);
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; white-space: nowrap; pointer-events: none; z-index: 2; margin-bottom: 8px; }
.b.sel::after, .b:hover::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px solid color-mix(in srgb, var(--g3) 45%, transparent); pointer-events: none; }
.b.pd::before, .b.pp::before { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 4px; }
.b.pd::before { background: var(--period); }
.b.pp::before { background: repeating-linear-gradient(90deg, var(--period) 0 2px, transparent 2px 4px); }
.b.now { background: linear-gradient(to right, transparent calc(50% - 1px), color-mix(in srgb, var(--today) 40%, transparent) calc(50% - 1px), color-mix(in srgb, var(--today) 40%, transparent) calc(50% + 1px), transparent calc(50% + 1px)); }
.chart-x { margin: 9px 0 0 34px; font-size: .66rem; color: var(--muted); }
.chart-x span { flex: 1 1 0; min-width: 0; text-align: center; white-space: nowrap; }
.chart-x span.now { color: var(--text); font-weight: 800; }
@media (max-width: 640px) {
  .chart { --ch: 130px; padding: 12px 8px 8px; }
  .b em { font-size: .62rem; padding: 0 3px; }
  .chart-x span:nth-child(even) { visibility: hidden; }
}

/* Calculator pages */
select { width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px; }
.toolform { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 18px 0; }
.toolform .actions { margin-top: 14px; }
#out h2 { margin-top: 26px; }
table.cycles tr.past td { color: var(--muted); opacity: .7; }
table.cycles tr.nowrow td { background: var(--fertile); color: var(--fertile-ink); font-weight: 600; }
.progress { position: relative; height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 18px 0 4px; }
.progress .bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--g1), var(--g2) 60%, var(--g3)); transition: width .6s ease; }
.progress span { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--card); }
.progress-lbl { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }
.navlinks { flex-wrap: wrap; }
@media (max-width: 640px) { .navlinks { gap: 12px; font-size: .88rem; } }
