/* Colour block: warm off-white (near-black in dark mode), hot pink lead, and one
   bold colour per feature. --rose/--rose-fill/--water/--lavender are kept as names
   so older rules pick up the new palette. */
:root {
  --bg: #F6F3EE;
  --card: #FFFFFF;
  --ink: #141414;
  --ink-2: #6B6560;
  --pink: #FF3E8A;
  --blue: #2D5BFF;
  --orange: #FF8A1E;
  --lime: #C6F432;
  --purple: #7C5CFF;
  --teal: #12C7A5;
  --chip: #ECE7E0;
  --rose: var(--pink);
  --rose-fill: var(--chip);
  --water: var(--blue);
  --lavender: var(--purple);
  --line: rgba(20, 20, 20, 0.08);
  --on-rose: #FFFFFF;
  --dark-btn: #141414;
  --on-dark-btn: #FFFFFF;
  --serif: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --tab-h: 64px;
  color-scheme: light dark;
}

/* Dark mode is "night neon": near-black, with the blocks turned into dark cards
   lit by an electric accent instead of solid colour. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111015;
    --card: #1C1A22;
    --ink: #F4F2F7;
    --ink-2: #9C97A8;
    --chip: #2A2733;
    --pink: #FF4F95;
    --blue: #3BD5FF;
    --orange: #FFB547;
    --purple: #B49CFF;
    --teal: #3BD5FF;
    --line: rgba(255, 255, 255, 0.08);
    --dark-btn: #F4F2F7;
    --on-dark-btn: #111015;
    --on-rose: #111015;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body.hidden-app #app, body.hidden-app #tabs { filter: blur(24px); }

#app {
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 560px;
  margin: 0 auto;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 800; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 32px; line-height: 1.1; letter-spacing: -0.03em; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.caption { font-size: 12px; color: var(--ink-2); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row > .grow { flex: 1; min-width: 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 16px; }
.topbar .back { font-size: 16px; }

.card {
  background: var(--card);
  border-radius: 22px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card.tint { background: var(--lime); color: #141414; }

/* Colour blocks: one bold colour per feature. */
.block { border-radius: 24px; padding: 16px; display: flex; flex-direction: column; gap: 10px; border: 0; width: 100%; text-align: left; font: inherit; }
.block.pink { background: var(--pink); color: #fff; }
.block.blue { background: var(--blue); color: #fff; }
.block.orange { background: var(--orange); color: #141414; }
.block.lime { background: var(--lime); color: #141414; }
.block.purple { background: var(--purple); color: #fff; }
.block .label { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.block .big { font-family: var(--serif); font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.block .mid { font-family: var(--serif); font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.block .sub { font-size: 14px; font-weight: 600; opacity: 0.9; }
.block h3 { color: inherit; }
.block .chip { background: rgba(255, 255, 255, 0.2); color: inherit; }
.block.orange .chip, .block.lime .chip { background: rgba(20, 20, 20, 0.1); }
.block .chip.on { background: #fff; color: #141414; }
.block .link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.meter { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: #fff; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.on-block { background: #fff; color: #141414; }
.welcome-mark { filter: brightness(0) invert(1); }

button.card, a.card { text-align: left; border: 0; color: inherit; font: inherit; width: 100%; cursor: pointer; text-decoration: none; }

button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  background: var(--chip);
  color: var(--ink);
  font-weight: 700;
}
.btn.primary { background: var(--rose); color: var(--on-rose); }
.btn.dark { background: var(--dark-btn); color: var(--on-dark-btn); }
.btn.block { width: 100%; padding: 15px 16px; font-size: 17px; text-align: center; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn.danger { background: transparent; color: #C0392B; }
.btn:disabled { opacity: 0.45; }
.link { background: none; border: 0; color: var(--rose); padding: 0; font-weight: 500; }
.icon-btn { background: none; border: 0; color: var(--ink-2); padding: 6px; font-size: 22px; line-height: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  background: var(--chip);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}
.chip.on { background: var(--rose); color: var(--on-rose); }

.seg { display: flex; background: var(--rose-fill); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 7px 4px;
  font-size: 14px;
  color: var(--ink);
}
.seg button.on { background: var(--card); color: var(--rose); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

.section-title { font-size: 13px; color: var(--ink-2); text-transform: none; margin: 8px 4px -4px; }

.list { background: var(--card); border-radius: 22px; overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  color: inherit;
  font: inherit;
}
.list-row .grow { flex: 1; min-width: 0; }
.chev { color: var(--ink-2); }

input[type=text], input[type=tel], input[type=number], input[type=password], textarea, select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
}
textarea { min-height: 96px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--rose-fill); border-radius: 30px; transition: background 0.2s; }
.switch span::after { content: ""; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch input:checked + span { background: var(--rose); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Hero ring */
.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 4px 0 6px; }
.ring { position: relative; width: 196px; height: 196px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .big { font-family: var(--serif); font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; }
.phase { color: var(--purple); font-weight: 700; font-size: 15px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  background: var(--card);
  border: 0;
  border-radius: 20px;
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 500;
}
.tile .ico { font-size: 20px; color: var(--pink); font-weight: 800; }

.meals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.meal {
  border: 0;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: inherit;
}
.meal .box {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  background: rgba(20, 20, 20, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: rgba(20, 20, 20, 0.55);
  font-size: 13px;
}
.meal .box.done { color: #141414; background: rgba(255, 255, 255, 0.55); font-size: 22px; font-weight: 800; }
.meal .box img { width: 100%; height: 100%; object-fit: cover; }

.mini-ring { width: 46px; height: 46px; flex: none; }

.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: var(--rose-fill); }
.photo { width: 100%; border-radius: 14px; display: block; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px 2px; text-align: center; }
.cal-grid .dow { font-size: 12px; color: var(--ink-2); font-weight: 600; padding-bottom: 4px; }
.day {
  border: 0;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 15px;
  color: var(--ink);
}
.day .num { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.day.period .num { background: var(--rose); color: var(--on-rose); }
.day.spot .num { box-shadow: inset 0 0 0 2px var(--rose); }
.day.predicted .num { outline: 1.5px dashed var(--rose); outline-offset: -2px; }
.day.fertile .num { background: color-mix(in srgb, var(--teal) 28%, transparent); }
.day.ovulation .num { background: var(--teal); color: #fff; }
.day.today .num { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.day .dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
.day.has .dot { background: var(--ink-2); }
.day:disabled { opacity: 0.55; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); justify-content: center; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 56px; gap: 8px; align-items: center; font-size: 14px; }
.bar { height: 10px; border-radius: 6px; background: var(--rose); }
.bar.water { background: var(--water); }
.vbars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.vbars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 11px; color: var(--ink-2); }
.vbars .fill { width: 100%; border-radius: 6px 6px 3px 3px; background: var(--water); min-height: 3px; }
.vbars .fill.dim { opacity: 0.45; }

/* Tabs */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabs button {
  flex: 1;
  height: var(--tab-h);
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-2);
}
.tabs button .ico { font-size: 21px; line-height: 1; }
.tabs button.on { color: var(--pink); }
.tabs button { font-weight: 600; }

/* Bottom sheet */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(30, 20, 25, 0.35);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.2s ease;
}
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: rise 0.25s ease;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0.6; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 14px;
  z-index: 50;
  max-width: 90vw;
}

/* Lock */
.lock {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
}
.pin-dots { display: flex; gap: 14px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--rose); }
.pin-dots i.on { background: var(--rose); }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px; }
.keypad button { height: 72px; border-radius: 50%; border: 0; background: var(--card); font-size: 26px; font-weight: 700; }
.keypad button.blank { background: none; }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* Breathing */
.breath { position: relative; width: 190px; height: 190px; margin: 0 auto; }
.breath .base, .breath .pulse { position: absolute; inset: 0; border-radius: 50%; }
.breath .base { background: color-mix(in srgb, var(--purple) 18%, transparent); }
.breath .pulse { background: var(--purple); opacity: 0.55; transform: scale(0.45); }
.breath .label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; }

.note-quote { font-size: 17px; font-weight: 600; }
.banner { background: var(--lime); color: #141414; border-radius: 16px; padding: 12px 14px; font-size: 14px; }

/* Doctor report (also used for printing) */
.report { background: #fff; color: #222; font: 12px/1.45 var(--sans); padding: 20px; border-radius: 12px; }
.report h1 { font-size: 20px; color: #222; }
.report h2 { font-size: 15px; color: #A04A5E; border-bottom: 1px solid #E5C9CF; padding-bottom: 3px; margin: 18px 0 8px; }
.report table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.report th, .report td { text-align: left; padding: 4px 6px; vertical-align: top; }
.report th { font-weight: 600; border-bottom: 1px solid #ddd; }
.report tr:nth-child(even) td { background: #F7F5F3; }
.report tr.flag td { background: #FBEAED; }
.report ul { margin: 4px 0 8px; padding-left: 18px; }
.report .rbar { display: inline-block; height: 8px; background: #C46A7E; border-radius: 4px; vertical-align: middle; }
.report .photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.report .photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.report .disclaimer { font-style: italic; color: #666; }

@media print {
  body { background: #fff; }
  #tabs, #sheet-root, .toast, .no-print { display: none !important; }
  #app { padding: 0; max-width: none; }
  .report { padding: 0; border-radius: 0; }
  .report h2 { break-after: avoid; }
  .report tr, .report .photos img { break-inside: avoid; }
}

.add-chip { background: transparent !important; box-shadow: inset 0 0 0 1.5px currentColor; }

/* Cycle ring on Today */
.hero-ring { align-items: center; padding: 18px 14px; gap: 12px; }
.ring-wrap { position: relative; width: 260px; max-width: 100%; aspect-ratio: 1; }
.cycle-ring { width: 100%; height: auto; display: block; }
.ring-centre { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-label { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.ring-big { font-family: var(--serif); font-size: 40px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.ring-sub { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.phase-pill { background: var(--phase); color: #fff; font-weight: 800; font-size: 14px; padding: 7px 14px; border-radius: 999px; }
.ring-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.ring-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* Welcome tour */
.tour {
  position: fixed; inset: 0;
  z-index: 90;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 20px);
  max-width: 560px;
  margin: 0 auto;
  overflow-y: auto;
}
.tour-top { display: flex; justify-content: space-between; align-items: center; }
.tour-count { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.tour-card { flex: 1; justify-content: center; gap: 14px; padding: 24px 22px; }
.tour-title { font-size: 30px; line-height: 1.1; letter-spacing: -0.03em; color: inherit; }
.tour-text { font-size: 17px; line-height: 1.45; }
.tour-mark { filter: brightness(0) invert(1); }
.tour-dots { display: flex; justify-content: center; gap: 6px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--chip); }
.tour-dots i.on { width: 22px; border-radius: 4px; background: var(--pink); }
.tour-nav { display: flex; gap: 10px; }
.tour-nav .grow { flex: 1; }
.tour-nav .btn { padding: 15px 18px; font-size: 17px; }

/* Night neon overrides; kept last so they win over the daytime rules above. */
@media (prefers-color-scheme: dark) {
  .block.pink, .block.blue, .block.orange, .block.purple { background: var(--card); color: var(--ink); }
  .block.pink { --accent: var(--pink); box-shadow: inset 0 0 0 1px rgba(255, 79, 149, 0.35); }
  .block.blue { --accent: var(--blue); }
  .block.orange { --accent: var(--orange); }
  .block.purple { --accent: var(--purple); }
  .block .label { color: var(--accent); opacity: 1; }
  .block .sub { color: var(--accent); opacity: 1; }
  .block .meter { background: rgba(255, 255, 255, 0.08); }
  .block .meter > i { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
  .block .chip, .block.orange .chip { background: rgba(255, 255, 255, 0.07); color: var(--ink); }
  .block .chip.on { background: var(--accent); color: #111015; }
  .block.lime { background: linear-gradient(90deg, #FF3E8A, #7C5CFF); color: #fff; }
  .block .meal { color: var(--ink-2); }
  .meal .box { background: rgba(255, 255, 255, 0.07); color: var(--ink-2); }
  .meal .box.done { background: rgba(255, 181, 71, 0.18); color: var(--orange); }
  .on-block { background: var(--accent); color: #111015; }
  .welcome-mark { filter: none; }
  .banner { background: linear-gradient(90deg, #FF3E8A, #7C5CFF); color: #fff; }
  .card.tint { background: linear-gradient(90deg, #FF3E8A, #7C5CFF); color: #fff; }
  .tour-mark { filter: none; }
  .tour-card .tour-text strong { color: var(--accent); }
  .block.lime.tour-card .tour-text strong { color: inherit; }
  .phase-pill { color: #111015; box-shadow: 0 0 14px var(--phase); }
}
