/* Meno — warm paper, deep plum ink, cranberry period, ochre fertile window */
:root {
  --paper: #f6efe6;
  --paper-2: #efe5d8;
  --card: #fbf7f1;
  --ink: #2b1a22;
  --ink-2: #6b5560;
  --ink-3: #a3929a;
  --line: #e2d5c8;
  --period: #a3273d;
  --period-soft: #f0d2d6;
  --predict: #d98a9a;
  --fertile: #d9a441;
  --fertile-soft: #f4e3bd;
  --luteal: #c9b8a8;
  --follicular: #e8dccc;
  --pms: #b98ea0;
  --ok: #5f8a6e;
  --shadow: 0 18px 40px -20px rgba(43, 26, 34, .35);
  --radius: 22px;
  --display: "Fraunces", "Iowan Old Style", "Palatino", Georgia, serif;
  --body: "Instrument Sans", "Helvetica Neue", "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1418;
    --paper-2: #241b20;
    --card: #2a2026;
    --ink: #f4ebe3;
    --ink-2: #c3b3ba;
    --ink-3: #7f6f77;
    --line: #3a2d34;
    --period: #d94a63;
    --period-soft: #4a2530;
    --predict: #a75c6c;
    --fertile: #e2b055;
    --fertile-soft: #4a3b1f;
    --luteal: #5a4c52;
    --follicular: #3a2f35;
    --pms: #8f6a7a;
    --shadow: 0 18px 40px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 500px at 80% -10%, color-mix(in oklab, var(--period) 8%, transparent), transparent 60%),
    radial-gradient(800px 400px at -10% 30%, color-mix(in oklab, var(--fertile) 9%, transparent), transparent 60%);
}
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }
.muted { color: var(--ink-2); }
.tiny { font-size: .8rem; color: var(--ink-3); }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* top bar */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 22px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 65% 40%, var(--paper) 0 34%, transparent 36%), var(--ink);
  box-shadow: inset -6px 0 0 -2px var(--ink);
}
.brand-name { font-family: var(--display); font-size: 1.35rem; font-weight: 500; }
.topbar-date { font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* view */
.view {
  flex: 1;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 96px);
  animation: rise .35s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stack > * + * { margin-top: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.card-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.card-title h3 { font-size: 1.05rem; }

/* today ring */
.hero { text-align: center; padding: 6px 0 4px; }
.ring-wrap { position: relative; width: min(280px, 72vw); margin: 0 auto; }
.ring { width: 100%; height: auto; display: block; transform: rotate(-90deg); }
.ring circle.track { fill: none; stroke: var(--paper-2); stroke-width: 14; }
.ring circle.seg { fill: none; stroke-width: 14; stroke-linecap: butt; }
.ring circle.marker { fill: var(--ink); stroke: var(--paper); stroke-width: 3; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.ring-center .kicker { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.ring-center .big { font-family: var(--display); font-size: 4.6rem; line-height: 1; font-weight: 300; font-variation-settings: "opsz" 144, "SOFT" 50; margin: 2px 0; }
.ring-center .phase { font-size: .95rem; color: var(--ink-2); font-style: italic; font-family: var(--display); }
.hero .headline { font-family: var(--display); font-size: 1.45rem; margin-top: 14px; font-weight: 400; }
.hero .headline em { font-style: italic; color: var(--period); }
.hero .sub { color: var(--ink-2); margin-top: 4px; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 12px; font-size: .78rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 12px 20px; cursor: pointer; transition: transform .12s ease, background .2s ease, border-color .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--period); color: #fff; border-color: transparent; font-weight: 600; padding: 16px 28px; font-size: 1.05rem; box-shadow: 0 12px 24px -12px var(--period); }
.btn.primary.end { background: var(--ink); color: var(--paper); box-shadow: 0 12px 24px -12px var(--ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--period); border-color: color-mix(in oklab, var(--period) 40%, var(--line)); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.link { background: none; border: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 6px; cursor: pointer; }
.actions { text-align: center; margin-top: 12px; }

/* log editor */
.field { margin-top: 14px; }
.field-label { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; display: flex; justify-content: space-between; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 13px; font-size: .9rem;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip.flow.on { background: var(--period); border-color: var(--period); color: #fff; }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--period); opacity: .35; vertical-align: 0; }
.chip.flow[data-v="spotting"] .dot { opacity: .3; }
.chip.flow[data-v="light"] .dot { opacity: .55; }
.chip.flow[data-v="medium"] .dot { opacity: .8; }
.chip.flow[data-v="heavy"] .dot { opacity: 1; }
.chip.flow.on .dot { background: #fff; opacity: 1; }
textarea.note {
  width: 100%; min-height: 64px; resize: vertical; border: 1px solid var(--line); border-radius: 14px;
  background: transparent; color: inherit; font: inherit; padding: 10px 12px;
}
textarea.note:focus, input:focus { outline: 2px solid color-mix(in oklab, var(--period) 45%, transparent); outline-offset: 1px; }
input[type=date] { border: 1px solid var(--line); border-radius: 12px; background: transparent; color: inherit; font: inherit; padding: 10px 12px; width: 100%; }
.saved { font-size: .75rem; color: var(--ok); opacity: 0; transition: opacity .3s; }
.saved.show { opacity: 1; }

/* calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h2 { font-size: 1.6rem; }
.cal-head .nav { display: flex; gap: 6px; }
.cal-head .nav .btn { width: 40px; height: 40px; padding: 0; }
.dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day {
  aspect-ratio: 1 / 1.05; border-radius: 14px; border: 0; background: transparent; position: relative;
  display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; cursor: pointer;
  font-size: .95rem; color: var(--ink);
}
.day.pad { visibility: hidden; }
.day.future { color: var(--ink-3); }
.day .n { position: relative; z-index: 1; }
.day.fertile { background: var(--fertile-soft); }
.day.ov::before { content: ""; position: absolute; top: 6px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--fertile); }
.day.period { background: var(--period); color: #fff; }
.day.predicted { box-shadow: inset 0 0 0 1.5px var(--predict); border-style: none; }
.day.predicted .n { color: var(--period); }
.day.logged::after { content: ""; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .55; }
.day.today { outline: 2px solid var(--ink); outline-offset: -2px; font-weight: 700; }
.day.pms { background: color-mix(in oklab, var(--pms) 22%, transparent); }
.cal-legend { margin-top: 12px; }

/* insights */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--paper-2); border-radius: 16px; padding: 12px 14px; }
.stat .v { font-family: var(--display); font-size: 1.9rem; font-weight: 400; line-height: 1.1; }
.stat .v small { font-size: .95rem; color: var(--ink-2); font-family: var(--body); margin-left: 3px; }
.stat .l { font-size: .78rem; color: var(--ink-2); margin-top: 2px; }
.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart .bar { fill: var(--period); opacity: .85; }
.chart .bar.short { fill: var(--pms); }
.chart .avg { stroke: var(--ink); stroke-dasharray: 3 4; stroke-width: 1; }
.chart text { font-family: var(--body); font-size: 10px; fill: var(--ink-2); }
.corr { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: center; }
.corr .name { font-size: .95rem; }
.corr .name small { display: block; color: var(--ink-3); font-size: .75rem; }
.heat { display: grid; grid-template-columns: repeat(5, 22px); gap: 3px; }
.heat i { display: block; height: 22px; border-radius: 6px; background: var(--ink); opacity: .06; }
.heat-legend { display: grid; grid-template-columns: 1fr auto; margin-top: 10px; }
.heat-legend .heat span { font-size: .55rem; text-align: center; color: var(--ink-3); display: block; }
.empty { text-align: center; padding: 26px 10px; color: var(--ink-2); }
.empty h3 { margin-bottom: 6px; }
.cycles-list { list-style: none; margin: 0; padding: 0; }
.cycles-list li { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.cycles-list li:first-child { border-top: 0; }
.cycles-list .len { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* settings */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting p { margin: 0; font-size: .9rem; color: var(--ink-2); }
.setting strong { display: block; font-weight: 600; color: var(--ink); font-size: .98rem; }

/* tabs */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: min(520px - 36px, calc(100% - 36px));
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in oklab, var(--ink) 94%, transparent); color: var(--paper);
  border-radius: 999px; padding: 6px; box-shadow: 0 20px 40px -16px rgba(0,0,0,.5);
  backdrop-filter: blur(10px);
}
.tab { background: transparent; border: 0; border-radius: 999px; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: color-mix(in oklab, var(--paper) 60%, transparent); }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab span { font-size: .68rem; letter-spacing: .04em; }
.tab.active { color: var(--paper); background: color-mix(in oklab, var(--paper) 14%, transparent); }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20, 10, 15, .45); z-index: 20; animation: fade .2s both; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(520px, 100%);
  background: var(--card); border-radius: 26px 26px 0 0; z-index: 21; max-height: 88dvh; overflow: auto;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px); box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  animation: up .28s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0 } to { transform: translate(-50%, 0); opacity: 1 } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { font-size: 1.45rem; }
.sheet .sub { color: var(--ink-2); margin: 2px 0 10px; }
.pill { display: inline-block; font-size: .75rem; padding: 3px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); margin-left: 8px; vertical-align: 2px; }
.pill.period { background: var(--period-soft); color: var(--period); }
.pill.fertile { background: var(--fertile-soft); color: #8a6317; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 84px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: .9rem; z-index: 30; animation: up .25s both; }
.offline { text-align: center; font-size: .8rem; color: var(--period); padding: 6px; }

/* login */
body.locked .tabs, body.locked .topbar-date { display: none; }
.login { padding-top: 6vh; }
.login-hero { text-align: center; margin-bottom: 18px; }
.login-hero .brand-mark.big { width: 56px; height: 56px; margin: 0 auto 12px; box-shadow: inset -18px 0 0 -6px var(--ink); }
.login-hero h1 { font-size: 2.6rem; font-weight: 400; }
.login-hero p { max-width: 30ch; margin: 6px auto 0; }
.login-form input { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: transparent; color: inherit; font: inherit; padding: 12px 14px; }
.login-form input.code { font-family: var(--display); font-size: 2rem; letter-spacing: .5em; text-align: center; padding: 8px 0 8px .5em; }
.login-error { color: var(--period); font-size: .9rem; min-height: 1.2em; margin: 10px 0 0; }
