/* The Red Rose: calm, warm, readable. System fonts only (fast, no third-party requests). */
:root {
  --bg: #fbf7f6; --surface: #ffffff; --ink: #2b2430; --muted: #645a6b;
  --brand: #7a3e72; --brand-ink: #ffffff; --brand-soft: #f3e8f1;
  --accent: #2f7461; --accent-soft: #e3f1ec;
  --line: #e6dae2; --warn: #7a4300; --warn-soft: #fdf0dc; --danger: #a12b4a; --focus: #1b5fd1;
  --c-est: #a12b4a; --c-pro: #2f7461; --c-lh: #a35f00; --c-fsh: #3d5a9e;
  --ph-menstrual: #a12b4a; --ph-follicular: #3d5a9e; --ph-ovulation: #a35f00; --ph-luteal: #2f7461;
  --radius: 14px; --shadow: 0 1px 2px rgba(43,36,48,.06), 0 6px 20px rgba(43,36,48,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Tamil", "Nirmala UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17131a; --surface: #211b25; --ink: #f2ebf4; --muted: #b9aebf;
    --brand: #e0a8d8; --brand-ink: #2a1327; --brand-soft: #2f2234;
    --accent: #7fd0b5; --accent-soft: #1e2e29;
    --line: #3a3040; --warn: #f0c27a; --warn-soft: #352a17; --danger: #f08aa3; --focus: #8ab4ff;
    --c-est: #f08aa3; --c-pro: #7fd0b5; --c-lh: #f0b45c; --c-fsh: #8fa8e8;
    --ph-menstrual: #f08aa3; --ph-follicular: #8fa8e8; --ph-ovulation: #f0b45c; --ph-luteal: #7fd0b5;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #17131a; --surface: #211b25; --ink: #f2ebf4; --muted: #b9aebf;
  --brand: #e0a8d8; --brand-ink: #2a1327; --brand-soft: #2f2234;
  --accent: #7fd0b5; --accent-soft: #1e2e29;
  --line: #3a3040; --warn: #f0c27a; --warn-soft: #352a17; --danger: #f08aa3; --focus: #8ab4ff;
  --c-est: #f08aa3; --c-pro: #7fd0b5; --c-lh: #f0b45c; --c-fsh: #8fa8e8;
  --ph-menstrual: #f08aa3; --ph-follicular: #8fa8e8; --ph-ovulation: #f0b45c; --ph-luteal: #7fd0b5;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.65; font-size: 1.0625rem; }
img, svg { max-width: 100%; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; margin: 1.6em 0 .5em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin-top: .4em; }
h2 { font-size: 1.5rem; } h3 { font-size: 1.2rem; }
p { margin: .6em 0 1em; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.mt { margin-top: 16px; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 60ch; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--ink); }
.brand .logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: 1rem; }
.nav { display: flex; gap: 2px 10px; flex-wrap: wrap; margin-left: 4px; flex: 1 1 0; min-width: 0; }
.nav a { text-decoration: none; color: var(--ink); padding: 8px 4px; border-bottom: 2px solid transparent; font-size: .95rem; white-space: nowrap; }
.nav a:hover, .nav a[aria-current="page"] { border-bottom-color: var(--brand); }
.btn.menu-btn { display: none; }
.controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.controls select, .controls summary, .controls .exit { font: inherit; font-size: .9rem; }
select, input[type=text], input[type=email], input[type=number], input[type=date], textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; max-width: 100%;
}
.controls select { width: auto; padding: 6px 8px; }
textarea { resize: vertical; }
.settings { position: relative; }
.settings summary { cursor: pointer; list-style: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.settings summary::-webkit-details-marker { display: none; }
.settings .menu { position: absolute; right: 0; top: 110%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px; display: grid; gap: 8px; min-width: 210px; z-index: 30; }
.exit { background: var(--danger); color: #fff; border: 0; border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; }
:root[data-theme="dark"] .exit { color: #2a0f19; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .exit { color: #2a0f19; } }

/* Buttons, chips, badges */
.btn { display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--brand); background: var(--surface); color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn:hover { filter: brightness(.95); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-size: .95rem; }
.chip[aria-current="true"], .chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.badge.soon { background: var(--warn-soft); color: var(--warn); }

/* Layout blocks */
.hero { padding: 28px 0 8px; }
.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.chooser { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.two-col { display: grid; gap: 14px; grid-template-columns: 1fr; margin: 28px 0 0; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1.3fr 1fr; } .tracker-grid { grid-template-columns: 1fr 1fr !important; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: .2em; }
.card h3 a { text-decoration: none; color: var(--ink); }
.card h3 a:hover { text-decoration: underline; }
.card .meta { color: var(--muted); font-size: .9rem; margin: 0; }
button.choice { text-align: left; font: inherit; color: var(--ink); cursor: pointer; display: grid; gap: 4px; }
button.choice span { color: var(--muted); font-size: .92rem; }
button.choice[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.note { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 14px 0; }
.note.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--ink); }
.flag { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.phase-pill { display: inline-block; padding: 4px 14px; border-radius: 999px; color: #fff; font-weight: 700; }
.phase-pill.menstrual { background: var(--ph-menstrual); } .phase-pill.follicular { background: var(--ph-follicular); }
.phase-pill.ovulation { background: var(--ph-ovulation); } .phase-pill.luteal { background: var(--ph-luteal); }
:root[data-theme="dark"] .phase-pill { color: #1d1520; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .phase-pill { color: #1d1520; } }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.check, .check-row label { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 6px 0; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
input[type=range] { width: 100%; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0; padding: 8px 14px 12px; }
legend { font-weight: 700; padding: 0 6px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.opts label { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; margin: 4px 0; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input[type=email] { flex: 1; min-width: 200px; }
.field-row { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }

/* Stats */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 10px 0; }
.stat { background: var(--brand-soft); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .9rem; }
table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: .95rem; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--brand-soft); }
.table-wrap { overflow-x: auto; }

/* Calendar */
.cal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cal-head h3 { margin: 0; font-size: 1.1rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal .dow { text-align: center; font-size: .78rem; color: var(--muted); }
.cal button { aspect-ratio: 1; min-height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; font: inherit; font-size: .9rem; cursor: pointer; position: relative; padding: 0; }
.cal button.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal button.sel { outline: 3px solid var(--focus); outline-offset: 1px; }
.cal button.bleed { background: color-mix(in srgb, var(--danger) 22%, var(--surface)); }
.cal button.start { background: var(--danger); color: #fff; font-weight: 700; }
:root[data-theme="dark"] .cal button.start { color: #2a0f19; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cal button.start { color: #2a0f19; } }
.cal button.pred { border-style: dashed; border-width: 2px; border-color: var(--brand); }
.cal button.logged::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--muted); margin: 10px 0 0; padding: 0; list-style: none; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; border: 1px solid var(--line); }
.legend .l-start { background: var(--danger); } .legend .l-bleed { background: color-mix(in srgb, var(--danger) 22%, var(--surface)); }
.legend .l-pred { border: 2px dashed var(--brand); } .legend .l-log { background: var(--accent); border-radius: 50%; width: 9px; height: 9px; }

.cal button:disabled { opacity: .4; cursor: default; }
.plain-list { list-style: none; padding: 0; margin: 8px 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.chart .band { opacity: .13; }
.chart .band.menstrual { fill: var(--ph-menstrual); } .chart .band.follicular { fill: var(--ph-follicular); }
.chart .band.ovulation { fill: var(--ph-ovulation); } .chart .band.luteal { fill: var(--ph-luteal); }
.chart .here-label { fill: var(--ink); font-weight: 700; }
.legend svg { vertical-align: middle; margin-right: 5px; }
.legend svg line { stroke-width: 3; }
.range-hint { display: flex; justify-content: space-between; }
.opt-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

/* Phase timeline + charts */
.timeline { display: flex; height: 22px; border-radius: 11px; overflow: hidden; margin: 14px 0 4px; border: 1px solid var(--line); }
.timeline span { display: block; height: 100%; }
.timeline .menstrual { background: var(--ph-menstrual); } .timeline .follicular { background: var(--ph-follicular); }
.timeline .ovulation { background: var(--ph-ovulation); } .timeline .luteal { background: var(--ph-luteal); }
.tl-labels { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .86rem; color: var(--muted); }
.chart { width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .here { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; }
.ln.est { stroke: var(--c-est); } .ln.pro { stroke: var(--c-pro); stroke-dasharray: 8 4; }
.ln.lh { stroke: var(--c-lh); stroke-dasharray: 2 4; } .ln.fsh { stroke: var(--c-fsh); stroke-dasharray: 10 3 2 3; }
.ln.disp { stroke: var(--c-est); stroke-width: 3.4; } .ln.cup { stroke: var(--c-pro); stroke-dasharray: 8 4; }
.ln.cloth { stroke: var(--c-lh); stroke-dasharray: 2 4; } .ln.under { stroke: var(--c-fsh); stroke-dasharray: 10 3 2 3; }

/* Articles / prose */
.article-wrap { max-width: 800px; }
.prose { max-width: 70ch; overflow-wrap: break-word; }
.prose a, .prose li, .prose td { overflow-wrap: anywhere; }
.prose h2 { border-top: 1px solid var(--line); padding-top: 1em; margin-top: 1.8em; }
.prose li { margin: .3em 0; }
.prose code { background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; }
.prose blockquote { margin: 1.2em 0; padding: 12px 18px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 12px 12px 0; }
.prose blockquote.summary { background: var(--accent-soft); border-left-color: var(--accent); border: 1px solid var(--accent); border-left-width: 6px; border-radius: 12px; }
.prose blockquote p:first-child, .prose blockquote ul:first-child { margin-top: 0; } .prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { display: none; }
.prose .sources-note { font-size: .92rem; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 16px; margin: 16px 0; }
.toc summary { cursor: pointer; font-weight: 700; }
.toc ol { margin: 8px 0; padding-left: 20px; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: .92rem; }

/* Footer */
.site-footer { margin-top: 56px; background: var(--surface); border-top: 1px solid var(--line); padding: 28px 0; font-size: .95rem; }
.foot-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.site-footer h2 { font-size: 1rem; margin: 0 0 8px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; } .site-footer li { margin: 6px 0; }

/* Report (print only) */
#report { display: none; }
#report h1 { font-size: 1.6rem; }
@media print {
  body.print-report .site-header, body.print-report .site-footer, body.print-report main > *:not(#report) { display: none !important; }
  body.print-report #report { display: block; }
  body.print-report { background: #fff; color: #000; font-size: 11pt; }
  body.print-report th { background: #eee; }
}
@media (max-width: 980px) {
  .btn.menu-btn { display: inline-block; }
  .nav { display: none; flex: 1 1 100%; width: 100%; flex-direction: column; flex-wrap: nowrap; order: 5; margin: 0; gap: 0; }
  .nav a { white-space: normal; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .nav.open { display: flex; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
