/* Lume design tokens: restyle the whole app from here. */
:root {
  --bg: #FBF1F3;
  --bg-2: #F5E8F1;
  --wash-1: #F6D7E3;
  --wash-2: #EBDDF3;
  --surface: #FFFAFB;
  --surface-2: #F4E9EC;
  --ink: #3D2433;
  --muted: #74606B;
  --line: #EADCE1;

  --mist: #F7E6EA;
  --mist-ink: #8C4A60;
  --drizzle: #F3CBD4;
  --drizzle-ink: #6E2A43;
  --shower: #E49BAE;
  --shower-ink: #3E1022;
  --downpour: #A64B6B;
  --downpour-ink: #FFF3F6;

  --fertile: #DCEBDC;
  --fertile-ink: #345B39;
  --predicted: #CF7E95;
  --today: #3D2433;

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Figtree', -apple-system, system-ui, sans-serif;
  --radius-lg: 28px;
  --radius-md: 20px;
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.serif { font-family: var(--serif); font-variation-settings: 'SOFT' 100, 'opsz' 144; font-weight: 400; }
[hidden] { display: none !important; }

.app {
  position: relative;
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 22px calc(env(safe-area-inset-bottom) + 96px);
  background:
    radial-gradient(120% 60% at 110% 100%, var(--wash-2) 0%, transparent 55%),
    radial-gradient(90% 50% at -20% 0%, var(--wash-1) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  overflow-x: hidden;
}
.top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.brand { font-family: var(--serif); font-variation-settings: 'SOFT' 100; font-size: 24px; }

/* Month header */
.month-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 14px; }
.month-head h1 { margin: 0; font-size: 40px; line-height: 1.05; letter-spacing: -0.5px; }
.month-nav { display: flex; gap: 4px; }
.icon-btn { width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Calendar */
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { margin-bottom: 6px; }
.weekdays span { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.grid { row-gap: 6px; touch-action: none; user-select: none; -webkit-user-select: none; }
.cell { position: relative; height: 48px; display: grid; place-items: center; }
.cell.f::before {
  content: ''; position: absolute; inset: 4px 0; background: var(--fertile);
}
.cell.f-s::before { left: 3px; border-radius: 999px 0 0 999px; }
.cell.f-e::before { right: 3px; border-radius: 0 999px 999px 0; }
.cell.f-s.f-e::before { border-radius: 999px; }
.day {
  position: relative; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: transparent; font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
}
.cell.f .day { color: var(--fertile-ink); }
.day.mist { background: var(--mist); color: var(--mist-ink); box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3px var(--mist-ink); }
.day.drizzle { background: var(--drizzle); color: var(--drizzle-ink); }
.day.shower { background: var(--shower); color: var(--shower-ink); }
.day.downpour { background: var(--downpour); color: var(--downpour-ink); }
.day.pred { outline: 1.5px dashed var(--predicted); outline-offset: -3px; }
.day.today { box-shadow: 0 0 0 2px var(--today); }
.day.today.mist { box-shadow: 0 0 0 2px var(--today), inset 0 0 0 2px var(--surface), inset 0 0 0 3px var(--mist-ink); }
.day.future { color: var(--ink); }
.day .dot { position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.day.sel { box-shadow: 0 0 0 3px var(--predicted); }
.cell.pad .day { visibility: hidden; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 14px 2px 0; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.legend .lg-p { background: var(--shower); }
.legend .lg-f { background: var(--fertile); }
.legend .lg-x { border: 1.5px dashed var(--predicted); }

/* Summary */
.summary { margin: 26px 2px 0; }
.summary .eyebrow { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.summary h2 { margin: 0; font-size: 22px; }
.summary .big { color: var(--ink); font-size: 46px; line-height: 1.05; margin: 2px 0 4px; letter-spacing: -0.5px; }
.summary p { margin: 0; color: var(--muted); font-size: 15px; }
.summary .fert { margin-top: 10px; color: var(--fertile-ink); font-weight: 500; }

/* Quick log for today */
.quick { margin: 28px 0 0; padding: 18px 16px 14px; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface) 80%, transparent); }
.quick h2 { margin: 0 0 14px; font-size: 24px; text-align: center; }
.flows { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.flow { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; border-radius: 18px; }
.flow .orb { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; transition: transform .2s ease; }
.flow:active .orb { transform: scale(.94); }
.flow .orb svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.flow .lbl { font-size: 15px; font-weight: 600; }
.flow .sub { font-size: 12px; color: var(--muted); margin-top: -4px; min-height: 15px; }
.flow.spotting .orb { background: var(--mist); color: var(--mist-ink); }
.flow.light .orb { background: var(--drizzle); color: var(--drizzle-ink); }
.flow.medium .orb { background: var(--shower); color: var(--shower-ink); }
.flow.heavy .orb { background: var(--downpour); color: var(--downpour-ink); }
.flow[aria-pressed="true"] .orb { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.pill { display: block; margin: 12px auto 0; min-height: var(--tap); padding: 0 24px; border: 0; border-radius: 999px; background: var(--surface-2); font-weight: 600; }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.logged-line { text-align: center; margin: 10px 0 0; color: var(--muted); font-size: 14px; min-height: 18px; }

/* Today insight */
.today-insight { margin: 18px 0 0; }
.today-insight strong { font-weight: 700; }

/* Quiet quick-log outside a period */
.quick.quiet { display: grid; gap: 4px; padding: 16px; }
.quick.quiet .pill { margin-top: 6px; }

/* Notes */
.backup-note { display: grid; gap: 10px; }
.backup-note .pill { margin: 0; justify-self: start; }
.note { margin: 16px 0 0; padding: 14px 16px; border-radius: var(--radius-md); background: var(--surface); font-size: 15px; line-height: 1.45; }

/* Onboarding */
.welcome { margin-top: 40px; }
.welcome h1 { font-size: 40px; line-height: 1.1; margin: 0 0 10px; }
.welcome p { color: var(--muted); line-height: 1.5; margin: 0 0 22px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; font-weight: 600; }
.field input { font: inherit; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn { min-height: 50px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--ink); color: var(--surface); font-weight: 700; width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--ink); margin-top: 10px; }

/* History on the calendar */

.cell.f-est .day { color: var(--ink); }
.day.ov::after { content: ''; position: absolute; bottom: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--fertile-ink); }
.day.inferred { outline: 2px dotted var(--predicted); outline-offset: -4px; color: var(--muted); }
.legend .lg-o { width: 8px; height: 8px; background: var(--fertile-ink); margin: 2px; }
.legend .lg-i { border: 2px dotted var(--predicted); }

/* Welcome calendar */
.onboarding .tabs { display: none; }
.onboarding .app { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.welcome { margin-top: 24px; }
.w-grid .cell { height: 44px; }
.w-q { font-size: 18px; margin: 4px 0 2px; }
.w-hint { margin: 0 0 6px !important; }
.month-head.small { margin: 6px 0 8px; }
.month-head.small h3 { margin: 0; font-size: 26px; }
.w-grid { touch-action: manipulation; margin-bottom: 18px; }
.day:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.btn:disabled { opacity: .45; cursor: default; }

/* Patterns */
.page-title { margin: 18px 0 2px; font-size: 38px; line-height: 1.1; }
.page-sub { margin: 0 0 18px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px 16px; border-radius: var(--radius-md); background: var(--surface); }
.stat .k { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat .v { font-family: var(--serif); font-variation-settings: 'SOFT' 100; font-size: 34px; margin-top: 4px; }
.stat .v small { font-family: var(--sans); font-size: 16px; color: var(--muted); margin-left: 4px; }
.stat .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.section-h { margin: 24px 2px 10px; font-size: 17px; font-weight: 700; }
.bars { display: grid; gap: 12px; padding: 16px; border-radius: var(--radius-md); background: var(--surface); }
.bar-row { display: grid; grid-template-columns: 54px 1fr 42px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .m { color: var(--muted); font-weight: 600; }
.bar-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.track { position: relative; height: 12px; border-radius: 999px; background: var(--surface-2); }
.track b { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.track .p { background: var(--shower); left: 0; }
.track .fw { background: var(--fertile); }
.track .o { width: 8px; height: 8px; top: 2px; background: var(--fertile-ink); border-radius: 50%; }
.track.open { background: repeating-linear-gradient(90deg, var(--surface-2) 0 6px, transparent 6px 10px); }
.bars-key { display: flex; gap: 16px; font-size: 12px; color: var(--muted); padding-top: 4px; }
.bars-key i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.insight { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; padding: 16px; border-radius: var(--radius-md); background: var(--fertile); color: var(--fertile-ink); line-height: 1.45; }
.footnote { margin: 12px 2px 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Settings */
.list { display: grid; gap: 2px; border-radius: var(--radius-md); overflow: hidden; margin-top: 18px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 16px; background: var(--surface); border: 0; width: 100%; text-align: left; font-size: 16px; }
.row small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.row.danger { color: #9B2C3F; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
.switch:checked { background: var(--fertile-ink); }
.switch:checked::after { transform: translateX(20px); }

.row.paste { display: grid; gap: 10px; padding: 14px 16px; }
.row.paste textarea { width: 100%; font: 13px/1.4 ui-monospace, monospace; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); resize: vertical; }
.row.paste .pill { margin: 0; justify-self: start; }

/* Tabs */
.tabs {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 8px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: var(--tap); justify-content: center; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] svg { fill: var(--ink); stroke: var(--ink); }
.tabs a[data-tab="patterns"][aria-current="page"] svg { fill: none; stroke-width: 2.6; }
.tabs a[data-tab="settings"][aria-current="page"] svg { fill: none; stroke-width: 2.4; }

/* Sheet */
.scrim { position: fixed; inset: 0; background: rgb(61 36 51 / .28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 10; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 11;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--surface); border-radius: 32px 32px 0 0; box-shadow: 0 -12px 40px rgb(61 36 51 / .15);
  animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { transform: translate(-50%, 40px); opacity: 0; } }
.grabber { width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { text-align: center; margin: 0 0 18px; font-size: 26px; }
.extras { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.chip { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 14px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 10px 10px 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--surface); font-size: 15px; box-shadow: 0 8px 24px rgb(61 36 51 / .25);
}
.toast button { border: 0; background: var(--surface); color: var(--ink); border-radius: 999px; min-height: 36px; padding: 0 14px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1F1720; --bg-2: #241A26; --wash-1: #3A2232; --wash-2: #2C2240;
    --surface: #2C2129; --surface-2: #3A2C36; --ink: #F7E9EE; --muted: #C6AEBA; --line: #4A3944;
    --mist: #3E2C36; --mist-ink: #F2C3D0; --drizzle: #6B3E52; --drizzle-ink: #FBE3EA;
    --shower: #C77790; --shower-ink: #23101A; --downpour: #F0A3B7; --downpour-ink: #2A1220;
    --fertile: #2F4434; --fertile-ink: #BFE3C2; --predicted: #E59AAE; --today: #F7E9EE;
  }
}
