:root {
  color-scheme: light;
  --ink: #17152a;
  --ink-2: #343149;
  --paper: #f6f5fa;
  --paper-2: #efedf6;
  --white: #ffffff;
  --line: #dedbe9;
  --line-strong: #c6c1d6;
  --muted: #706c82;
  --poppy: #f24e63;
  --poppy-deep: #cb3248;
  --poppy-pale: #fff0f2;
  --cobalt: #5d5fef;
  --cobalt-deep: #4244c8;
  --lilac: #c6bfff;
  --lilac-pale: #f1efff;
  --amber: #f6b84a;
  --teal: #2f9a91;
  --danger: #b6223a;
  --shadow: 0 22px 65px rgba(34, 27, 74, 0.09);
  --shadow-tight: 0 10px 32px rgba(34, 27, 74, 0.1);
  --radius-xl: 1.65rem;
  --radius-lg: 1.1rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(93, 95, 239, 0.028) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 5rem;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }

h1, h2, h3, h4, p { overflow-wrap: anywhere; }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-tight);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.app-shell {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 2rem 1.4rem 1.4rem;
  background: var(--ink);
  color: var(--white);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: 50% 50% 50% 16%;
  background: var(--poppy-deep);
  font-family: "Avenir Next", Avenir, sans-serif;
  font-size: 1rem;
  box-shadow: 0 0 0 5px rgba(242, 78, 99, 0.1);
}

.nav-list { display: grid; gap: 0.45rem; margin-top: 4rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  min-height: 3.1rem;
  padding: 0.68rem 0.85rem;
  border: 0;
  border-radius: 0.82rem;
  background: transparent;
  color: #cbc8d8;
  text-align: left;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}
.nav-item:hover, .nav-item:focus-visible { background: rgba(255, 255, 255, 0.08); color: var(--white); }
.nav-item.is-active { background: var(--white); color: var(--ink); }
.nav-item:active { transform: scale(0.98); }
.nav-icon { display: grid; width: 1.4rem; min-width: 1.4rem; height: 1.4rem; place-items: center; font-size: 1.2rem; line-height: 1; }
.nav-icon-calendar { width: 1.15rem; height: 1.1rem; margin-inline: 0.12rem; border: 1.5px solid currentColor; border-radius: 0.2rem; }
.nav-icon-calendar::before { content: ""; width: 100%; border-top: 1.5px solid currentColor; }

.privacy-note {
  display: flex;
  gap: 0.7rem;
  margin-top: auto;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1rem;
  color: #cbc8d8;
  font-size: 0.78rem;
  line-height: 1.35;
}
.privacy-note p { margin: 0; }
.privacy-note strong { display: block; margin-bottom: 0.2rem; color: var(--white); font-size: 0.84rem; }
.privacy-dot { flex: 0 0 auto; width: 0.55rem; height: 0.55rem; margin-top: 0.25rem; border-radius: 50%; background: var(--lilac); box-shadow: 0 0 0 4px rgba(198, 191, 255, 0.12); }

.main {
  width: 100%;
  max-width: 106rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 4rem);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.77rem;
  font-weight: 750;
  letter-spacing: 0.085em;
}

.topbar h1 {
  max-width: 48rem;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.05rem, 3.35vw, 4rem);
  font-weight: 400;
  line-height: 1.03;
  letter-spacing: -0.045em;
}

.icon-button, .close-button {
  display: grid;
  width: 2.85rem;
  height: 2.85rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
}
.icon-button:hover, .close-button:hover { border-color: var(--cobalt); color: var(--cobalt-deep); }
.mobile-log-shortcut { display: none; }

.view[hidden] { display: none; }
.view.is-active { animation: view-in 0.28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(0.35rem); } to { opacity: 1; transform: none; } }

.dashboard {
  display: grid;
  grid-template-columns: minmax(18rem, 0.78fr) minmax(34rem, 1.5fr);
  gap: 1.25rem;
  align-items: stretch;
}

.panel, .cycle-card, .calendar-card, .metric-card {
  border: 1px solid rgba(93, 95, 239, 0.12);
  border-radius: var(--radius-xl);
  background: var(--white);
  box-shadow: var(--shadow);
}

.cycle-card {
  position: relative;
  overflow: hidden;
  display: flex;
  min-height: 36rem;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1.5rem, 3vw, 2.5rem);
}
.cycle-card::before {
  content: "";
  position: absolute;
  inset: -25% -40% auto;
  height: 19rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(198, 191, 255, 0.38), rgba(198, 191, 255, 0) 68%);
  pointer-events: none;
}

.cycle-orbit {
  --cycle-progress: 8%;
  position: relative;
  display: grid;
  width: min(17rem, 72vw);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--poppy) 0 var(--cycle-progress), var(--lilac) var(--cycle-progress) 76%, #eceaf4 76% 100%);
  box-shadow: inset 0 0 0 1px rgba(23, 21, 42, 0.05);
  transition: background 0.4s ease;
}
.cycle-orbit::after { content: ""; position: absolute; inset: -0.45rem; border: 1px dashed rgba(93, 95, 239, 0.28); border-radius: inherit; animation: slow-turn 38s linear infinite; }
@keyframes slow-turn { to { transform: rotate(360deg); } }
.cycle-orbit-inner {
  display: grid;
  width: 79%;
  aspect-ratio: 1;
  place-items: center;
  align-content: center;
  border-radius: inherit;
  background: var(--white);
  text-align: center;
  box-shadow: 0 16px 40px rgba(41, 35, 84, 0.12);
}
.cycle-orbit-inner span { color: var(--muted); font-size: 0.9rem; }
.cycle-orbit-inner strong { font-family: Georgia, "Times New Roman", serif; font-size: 4.5rem; font-weight: 400; line-height: 1; letter-spacing: -0.06em; }
.cycle-orbit-inner small { max-width: 9.5rem; margin-top: 0.35rem; color: var(--cobalt); font-size: 0.77rem; font-weight: 800; line-height: 1.3; }

.cycle-copy { position: relative; width: 100%; margin-top: 2rem; }
.cycle-copy h2, .card-heading h2, .panel h2, .insight-callout h2, .dialog-header h2, .setting-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.035em;
}
.cycle-copy h2 { font-size: clamp(1.6rem, 2.2vw, 2.3rem); line-height: 1.13; }
.cycle-copy > p:not(.eyebrow) { margin: 0.8rem 0 1.4rem; color: var(--muted); }

.primary-button, .secondary-button, .danger-button, .text-button, .danger-text-button {
  border-radius: 0.92rem;
  font-weight: 750;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  min-height: 3.15rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.05rem;
}
.primary-button { width: 100%; border: 0; background: var(--ink); color: var(--white); }
.primary-button:hover { background: var(--poppy-deep); transform: translateY(-1px); }
.primary-button:disabled { opacity: .52; cursor: not-allowed; transform: none; }
.primary-button.auto-width { width: auto; min-width: 8rem; }
.secondary-button { border: 1px solid var(--line-strong); background: var(--white); color: var(--ink); }
.secondary-button:hover { border-color: var(--cobalt); color: var(--cobalt-deep); transform: translateY(-1px); }
.secondary-button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.small-button { min-height: 2.6rem; padding: 0.45rem 0.8rem; border-radius: 0.78rem; font-size: 0.87rem; }
.danger-button { border: 1px solid rgba(182, 34, 58, 0.25); background: var(--poppy-pale); color: var(--danger); }
.danger-button:hover { border-color: var(--danger); background: #ffe3e8; }
.text-button, .danger-text-button { padding: 0.4rem; border: 0; background: transparent; color: var(--cobalt-deep); }
.text-button:hover { text-decoration: underline; text-underline-offset: 0.2rem; }
.danger-text-button { color: var(--danger); }
.danger-text-button:hover { background: var(--poppy-pale); }
.danger-text-button[hidden] { display: none; }

.calendar-card { padding: clamp(1.35rem, 3vw, 2.25rem); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; }
.card-heading h2 { font-size: 2rem; }
.compact-heading { margin-bottom: 1.2rem; }
.compact-heading h2 { font-size: 1.65rem; }
.month-controls { display: flex; gap: 0.35rem; }
.month-controls button {
  display: grid;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--white);
  cursor: pointer;
}
.month-controls button:hover { border-color: var(--cobalt); color: var(--cobalt-deep); }
.calendar-actions { display: flex; align-items: center; gap: 0.7rem; }

.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { margin-bottom: 0.5rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; font-weight: 700; text-align: center; text-transform: uppercase; }
.calendar-grid { gap: 0.45rem; }
.calendar-day {
  position: relative;
  display: grid;
  min-height: 4.7rem;
  place-items: start center;
  padding: 0.68rem 0.2rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  background: transparent;
  cursor: pointer;
}
.calendar-day:hover, .calendar-day:focus-visible { border-color: var(--lilac); outline: 0; }
.calendar-day.is-outside { color: #696477; }
.calendar-day.is-today { border-color: var(--ink); }
.calendar-day.is-selected { border-color: var(--cobalt); background: var(--lilac-pale); box-shadow: inset 0 0 0 1px var(--cobalt); }
.calendar-day .day-number { display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: 50%; font-weight: 750; }
.calendar-day.is-period .day-number { background: var(--poppy-deep); color: var(--white); }
.calendar-day.is-spotting .day-number { color: var(--poppy-deep); box-shadow: inset 0 0 0 2px var(--poppy); }
.calendar-day.is-predicted .day-number { background: repeating-linear-gradient(135deg, rgba(242,78,99,.16) 0 4px, rgba(242,78,99,.04) 4px 8px); color: var(--poppy-deep); box-shadow: inset 0 0 0 1px rgba(206, 51, 74, 0.25); }
.calendar-day.is-period.is-predicted .day-number { background: var(--poppy-deep); color: var(--white); box-shadow: none; }
.calendar-day.has-log::after { content: ""; position: absolute; bottom: 0.54rem; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--cobalt); }
.calendar-day .flow-word { display: none; }
.calendar-key { display: flex; flex-wrap: wrap; gap: 0.8rem 1.35rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.79rem; }
.calendar-key span { display: inline-flex; align-items: center; gap: 0.4rem; }
.key-dot { width: 0.66rem; height: 0.66rem; border-radius: 50%; }
.key-dot.period { background: var(--poppy); }
.key-dot.spotting { border: 2px solid var(--poppy); }
.key-dot.predicted { background: repeating-linear-gradient(135deg, rgba(242,78,99,.32) 0 2px, rgba(242,78,99,.05) 2px 4px); border: 1px solid rgba(206,51,74,.25); }
.key-dot.logged { background: var(--cobalt); }

.today-lower-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-top: 1.25rem; }
.today-entry-card, .pattern-card { min-height: 14.5rem; padding: 1.5rem; box-shadow: none; }
.empty-inline, .pattern-content { color: var(--muted); }
.empty-inline p, .pattern-content p { margin: 0 0 1rem; }
.today-summary { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.summary-pill { display: inline-flex; align-items: center; min-height: 2.35rem; padding: 0.42rem 0.72rem; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); font-size: 0.87rem; font-weight: 700; }
.summary-pill.flow { background: var(--poppy-pale); color: var(--poppy-deep); }
.today-note { width: 100%; margin-top: 0.7rem; padding-top: 0.8rem; border-top: 1px solid var(--line); color: var(--muted); white-space: pre-wrap; }

.care-note {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-top: 1.25rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid #edcf8c;
  border-radius: 1rem;
  background: #fff9e9;
  color: #5c4923;
}
.care-note p { margin: 0; }
.care-note strong { color: #332712; }
.care-mark { display: grid; width: 1.7rem; height: 1.7rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--amber); color: var(--ink); font-weight: 900; }

.calendar-workspace { display: grid; grid-template-columns: minmax(36rem, 1fr) minmax(17rem, 22rem); gap: 1.25rem; align-items: start; }
.full-calendar { box-shadow: var(--shadow); }
.large-grid .calendar-day { min-height: clamp(4.8rem, 7vw, 7.2rem); align-content: start; }
.large-grid .calendar-day.has-log::after { bottom: 0.75rem; }
.day-detail { position: sticky; top: 2rem; min-height: 26rem; padding: 1.6rem; box-shadow: var(--shadow); }
.day-detail h2 { font-size: 2rem; line-height: 1.15; }
.day-detail .primary-button { margin-top: 1rem; }
.empty-day { min-height: 14rem; color: var(--muted); }
.day-record { min-height: 14rem; padding-top: 1rem; }
.day-record dl { display: grid; gap: 0.9rem; margin: 0; }
.day-record div { display: grid; gap: 0.12rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
.day-record dt { color: var(--muted); font-size: 0.8rem; }
.day-record dd { margin: 0; font-weight: 700; white-space: pre-wrap; }

.insight-callout {
  position: relative;
  overflow: hidden;
  padding: clamp(1.7rem, 4vw, 3.2rem);
  border-radius: var(--radius-xl);
  background: var(--ink);
  color: var(--white);
}
.insight-callout::after { content: "∿"; position: absolute; right: 2rem; top: -2.5rem; color: rgba(198,191,255,.18); font-family: Georgia, serif; font-size: 13rem; line-height: 1; transform: rotate(-8deg); }
.insight-callout .eyebrow { color: var(--lilac); }
.insight-callout h2 { position: relative; z-index: 1; max-width: 42rem; font-size: clamp(2rem, 3.5vw, 3.5rem); line-height: 1.03; }
.insight-callout > p:last-child { position: relative; z-index: 1; max-width: 43rem; margin: 0.8rem 0 0; color: #cbc8d8; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.metric-card { display: grid; min-height: 10rem; align-content: center; padding: 1.4rem; box-shadow: none; }
.metric-card > span { color: var(--muted); font-size: 0.85rem; }
.metric-card strong { margin-block: 0.15rem; font-family: Georgia, serif; font-size: clamp(2.15rem, 4vw, 3.7rem); font-weight: 400; line-height: 1; letter-spacing: -0.05em; }
.metric-card small { color: var(--muted); font-size: 0.77rem; }

.insights-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 1.25rem; margin-top: 1.25rem; }
.chart-panel, .symptom-panel, .recent-panel { padding: 1.55rem; box-shadow: none; }
.recent-panel { margin-top: 1.25rem; }
.empty-chart { display: grid; min-height: 13rem; place-items: center; border: 1px dashed var(--line-strong); border-radius: 1rem; color: var(--muted); text-align: center; }
.empty-chart p { max-width: 24rem; margin: 0; padding: 1rem; }
.bar-chart { display: grid; min-height: 13rem; align-items: end; grid-template-columns: repeat(var(--bar-count), minmax(2.2rem, 1fr)); gap: 0.65rem; padding-top: 1rem; }
.cycle-bar { display: grid; height: 100%; grid-template-rows: 1fr auto auto; gap: 0.35rem; align-items: end; text-align: center; }
.cycle-bar-fill { width: min(3.2rem, 88%); min-height: 1rem; margin-inline: auto; border-radius: 0.65rem 0.65rem 0.2rem 0.2rem; background: var(--lilac); }
.cycle-bar strong { font-size: 0.82rem; }
.cycle-bar small { color: var(--muted); font-size: 0.69rem; }
.symptom-bars { display: grid; gap: 0.85rem; width: 100%; min-height: 13rem; align-content: center; }
.symptom-bar-row { display: grid; grid-template-columns: minmax(6rem, .7fr) minmax(8rem, 1.3fr) auto; gap: 0.7rem; align-items: center; }
.symptom-bar-row > span { font-size: 0.86rem; font-weight: 700; }
.symptom-track { height: 0.58rem; overflow: hidden; border-radius: 999px; background: var(--paper-2); }
.symptom-track i { display: block; height: 100%; border-radius: inherit; background: var(--cobalt); }
.symptom-bar-row small { color: var(--muted); font-size: 0.73rem; }
.recent-list { display: grid; gap: 0; }
.recent-row { display: grid; grid-template-columns: minmax(8.5rem, .7fr) minmax(0, 1.3fr) auto; gap: 1rem; align-items: center; padding: 0.95rem 0; border-bottom: 1px solid var(--line); }
.recent-row:last-child { border-bottom: 0; }
.recent-row time { font-weight: 750; }
.recent-row p { margin: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-row button { border: 0; background: transparent; color: var(--cobalt-deep); font-weight: 750; cursor: pointer; }

.settings-grid { display: grid; max-width: 64rem; gap: 1.25rem; }
.settings-panel { padding: clamp(1.4rem, 3vw, 2rem); box-shadow: none; }
.setting-heading { display: grid; grid-template-columns: minmax(12rem, .8fr) minmax(16rem, 1.2fr); gap: 2rem; padding-bottom: 1.3rem; border-bottom: 1px solid var(--line); }
.setting-heading h2 { font-size: 1.9rem; }
.setting-heading > p { margin: 0; color: var(--muted); }
.settings-form { display: grid; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: 5.5rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.field-row > span:first-child { display: grid; }
.field-row strong { font-size: 0.97rem; }
.field-row small { color: var(--muted); }
.number-field { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 0.8rem; background: var(--white); }
.number-field input { width: 4.2rem; min-height: 2.8rem; padding: 0.5rem; border: 0; background: transparent; text-align: right; font-weight: 800; }
.number-field span { padding-right: 0.7rem; color: var(--muted); font-size: 0.8rem; }
.field-row select { min-width: 8.5rem; min-height: 2.8rem; padding: 0.45rem 2rem 0.45rem 0.75rem; border: 1px solid var(--line-strong); border-radius: 0.8rem; background: var(--white); color: var(--ink); }
.settings-save { width: auto; justify-self: end; margin-top: 1.2rem; }

.switch { position: relative; display: inline-flex; align-items: center; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch > span { position: relative; display: block; width: 3.15rem; height: 1.8rem; border-radius: 999px; background: var(--line-strong); transition: background 0.18s ease; }
.switch > span::after { content: ""; position: absolute; top: 0.25rem; left: 0.25rem; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--white); box-shadow: 0 2px 7px rgba(23,21,42,.18); transition: transform 0.18s ease; }
.switch input:checked + span { background: var(--cobalt); }
.switch input:checked + span::after { transform: translateX(1.35rem); }
.switch input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: 3px; }

.data-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.35rem; }
.sensitive-hint { margin: 1rem 0 0; color: var(--muted); font-size: 0.82rem; }
.privacy-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.privacy-list li { display: grid; grid-template-columns: 2rem 1fr; gap: 0.65rem; padding: 1.05rem 0; border-bottom: 1px solid var(--line); }
.privacy-list li:last-child { border-bottom: 0; }
.privacy-list li > span { display: grid; width: 1.65rem; height: 1.65rem; place-items: center; border-radius: 50%; background: var(--lilac-pale); color: var(--cobalt-deep); font-weight: 900; }
.privacy-list p { display: grid; margin: 0; color: var(--muted); }
.privacy-list strong { color: var(--ink); }
.danger-panel { border-color: rgba(182,34,58,.2); }
.danger-panel .danger-button { margin-top: 1.25rem; }
.recovery-panel > .secondary-button { margin-top: 1.25rem; }

dialog {
  width: min(52rem, calc(100vw - 2rem));
  max-height: min(92vh, 58rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 1.45rem;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 28px 100px rgba(15, 11, 35, 0.36);
}
dialog::backdrop { background: rgba(16, 13, 33, 0.62); backdrop-filter: blur(5px); }
dialog[open] { animation: dialog-in 0.2s ease both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(0.7rem) scale(0.985); } to { opacity: 1; transform: none; } }
.log-dialog form, .confirm-dialog form { display: grid; max-height: inherit; grid-template-rows: auto minmax(0, 1fr) auto; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.4rem 1.55rem 1.15rem; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 2rem; line-height: 1.1; }
.close-button { width: 2.5rem; height: 2.5rem; font-size: 1.55rem; line-height: 1; }
.dialog-scroll { overflow-y: auto; overscroll-behavior: contain; }
.form-section { padding: 1.55rem; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.2rem; }
.form-section-heading > div { display: flex; align-items: baseline; gap: 0.65rem; }
.section-kicker { color: var(--poppy-deep); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.74rem; font-weight: 800; }
.form-section h3 { margin: 0; font-family: Georgia, serif; font-size: 1.55rem; font-weight: 400; letter-spacing: -0.025em; }
.form-section-heading > p { max-width: 21rem; margin: 0; color: var(--muted); font-size: 0.79rem; text-align: right; }

.flow-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.55rem; }
.flow-options input, .mood-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.flow-options label > span { display: grid; min-height: 4.8rem; place-items: center; align-content: center; gap: 0.45rem; border: 1px solid var(--line); border-radius: 0.9rem; color: var(--muted); font-size: 0.79rem; font-weight: 750; cursor: pointer; }
.flow-options input:checked + span { border-color: var(--poppy); background: var(--poppy-pale); color: var(--poppy-deep); box-shadow: inset 0 0 0 1px var(--poppy); }
.flow-options input:focus-visible + span, .mood-options input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: 3px; }
.flow-mark { display: block; border-radius: 50% 50% 55% 42%; background: var(--poppy); transform: rotate(45deg); }
.flow-mark.none { width: 1.1rem; height: 0.15rem; border-radius: 999px; background: var(--line-strong); transform: none; }
.flow-mark.spotting { width: 0.45rem; height: 0.45rem; }
.flow-mark.light { width: 0.68rem; height: 0.68rem; }
.flow-mark.medium { width: 0.9rem; height: 0.9rem; }
.flow-mark.heavy { width: 1.12rem; height: 1.12rem; }
.period-start-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: 0.95rem; border-radius: 0.9rem; background: var(--paper); }
.period-start-row > span:first-child { display: grid; }
.period-start-row small { color: var(--muted); font-size: 0.78rem; }

.symptom-group + .symptom-group { margin-top: 1.25rem; }
.symptom-group h4 { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
.symptom-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.55rem; }
.symptom-chip { display: flex; min-height: 3rem; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 0.82rem; background: var(--white); text-align: left; cursor: pointer; }
.symptom-chip:hover { border-color: var(--lilac); }
.symptom-chip.is-active { border-color: var(--cobalt); background: var(--lilac-pale); color: var(--cobalt-deep); }
.severity-dots { display: flex; flex: 0 0 auto; gap: 0.18rem; }
.severity-dots i { width: 0.34rem; height: 0.34rem; border-radius: 50%; background: var(--line-strong); }
.symptom-chip[data-severity="1"] .severity-dots i:nth-child(1),
.symptom-chip[data-severity="2"] .severity-dots i:nth-child(-n+2),
.symptom-chip[data-severity="3"] .severity-dots i { background: var(--cobalt); }

.mood-fieldset, .import-choice { margin: 0; padding: 0; border: 0; }
.mood-fieldset legend, .import-choice legend { margin-bottom: 0.6rem; font-weight: 750; }
.mood-options { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.mood-options label > span { display: block; padding: 0.6rem 0.85rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.84rem; font-weight: 700; cursor: pointer; }
.mood-options input:checked + span { border-color: var(--cobalt); background: var(--lilac-pale); color: var(--cobalt-deep); }
.range-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; margin-top: 1.35rem; }
.range-field { display: grid; gap: 0.6rem; padding: 1rem; border-radius: 1rem; background: var(--paper); }
.range-field > span, .notes-field > span { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.range-field output { color: var(--cobalt-deep); font-size: 0.78rem; font-weight: 750; }
.range-field input { width: 100%; accent-color: var(--cobalt); }
.range-field small { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.69rem; }
.notes-field { display: grid; gap: 0.55rem; margin-top: 1.35rem; }
.notes-field small { color: var(--muted); }
.notes-field textarea { width: 100%; resize: vertical; padding: 0.85rem; border: 1px solid var(--line-strong); border-radius: 0.9rem; background: var(--white); color: var(--ink); line-height: 1.5; }
.notes-field textarea::placeholder { color: #9a96aa; }

.dialog-footer { display: flex; align-items: center; gap: 0.65rem; padding: 1rem 1.55rem; border-top: 1px solid var(--line); background: var(--white); }
.footer-spacer { flex: 1; }
.confirm-dialog { width: min(34rem, calc(100vw - 2rem)); }
.confirm-body { padding: 1.45rem 1.55rem; }
.confirm-body > p { margin: 0 0 1.2rem; color: var(--muted); }
.import-choice { display: grid; gap: 0.6rem; }
.import-choice label { display: flex; gap: 0.7rem; padding: 0.85rem; border: 1px solid var(--line); border-radius: 0.85rem; cursor: pointer; }
.import-choice label:has(input:checked) { border-color: var(--cobalt); background: var(--lilac-pale); }
.import-choice input { margin-top: 0.25rem; accent-color: var(--cobalt); }
.import-choice label > span { display: grid; }
.import-choice small { color: var(--muted); }
.confirm-check { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.9rem; border-radius: 0.8rem; background: var(--poppy-pale); color: var(--danger); }
.confirm-check input { margin-top: 0.25rem; accent-color: var(--danger); }

.toast-region { position: fixed; right: 1rem; bottom: 1rem; z-index: 250; display: grid; width: min(25rem, calc(100vw - 2rem)); gap: 0.55rem; pointer-events: none; }
.toast { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 1rem; border-radius: 0.9rem; background: var(--ink); color: var(--white); box-shadow: var(--shadow-tight); pointer-events: auto; animation: toast-in 0.22s ease both; }
.toast.is-error { background: var(--danger); }
.toast button { padding: 0.25rem 0.4rem; border: 0; background: transparent; color: var(--lilac); font-weight: 800; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.6rem); } to { opacity: 1; transform: none; } }

:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

@media (max-width: 1260px) {
  .app-shell { grid-template-columns: 5.3rem minmax(0, 1fr); }
  .rail { padding-inline: 0.85rem; align-items: center; }
  .brand > span:last-child, .nav-item > span:last-child, .privacy-note { display: none; }
  .nav-item { justify-content: center; padding-inline: 0; }
  .nav-list { width: 100%; }
  .dashboard { grid-template-columns: 1fr; }
  .cycle-card { min-height: 0; display: grid; grid-template-columns: minmax(13rem, .7fr) minmax(18rem, 1.3fr); gap: 2.2rem; }
  .cycle-copy { margin-top: 0; }
  .calendar-workspace { grid-template-columns: minmax(32rem, 1fr) minmax(16rem, 19rem); }
}

@media (min-width: 681px) and (max-height: 820px) {
  .main { padding-top: 2rem; padding-bottom: 2rem; }
  .topbar { margin-bottom: 1.45rem; }
  .topbar h1 { font-size: clamp(2rem, 3vw, 3.25rem); }
  .cycle-card { min-height: 29.5rem; }
  .cycle-orbit { width: min(13.8rem, 72vw); }
  .cycle-orbit-inner strong { font-size: 3.7rem; }
  .cycle-copy { margin-top: 1.1rem; }
  .cycle-copy h2 { font-size: clamp(1.45rem, 2vw, 2rem); }
  .cycle-copy > p:not(.eyebrow) { margin-block: 0.55rem 0.9rem; }
  .calendar-card { padding-top: 1.6rem; padding-bottom: 1.25rem; }
  .card-heading { margin-bottom: 1.15rem; }
  .calendar-day { min-height: 3.85rem; padding-block: 0.45rem; }
  .calendar-day.has-log::after { bottom: 0.38rem; }
}

@media (max-width: 1000px) {
  .calendar-workspace { grid-template-columns: 1fr; }
  .day-detail { position: static; min-height: 0; }
  .empty-day, .day-record { min-height: 7rem; }
  .insights-grid { grid-template-columns: 1fr; }
  .setting-heading { grid-template-columns: 1fr; gap: 0.5rem; }
}

@media (max-width: 680px) {
  .app-shell { display: block; padding-bottom: calc(5.2rem + env(safe-area-inset-bottom)); }
  .rail {
    position: fixed;
    inset: auto 0 0;
    z-index: 80;
    width: auto;
    height: calc(4.7rem + env(safe-area-inset-bottom));
    flex-direction: row;
    padding: 0.5rem max(0.7rem, env(safe-area-inset-right)) calc(0.5rem + env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
    box-shadow: 0 -10px 35px rgba(23, 21, 42, 0.2);
  }
  .brand, .privacy-note { display: none; }
  .nav-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.24rem; width: 100%; margin: 0; }
  .nav-item { min-height: 3.55rem; flex-direction: column; gap: 0.1rem; padding: 0.28rem 0.15rem; border-radius: 0.7rem; font-size: 0.68rem; }
  .nav-item > span:last-child { display: block; }
  .nav-icon { font-size: 1.05rem; }
  .nav-icon-calendar { width: 1rem; height: 0.9rem; margin-block: 0.15rem; }
  .main { padding: 1.2rem 1rem 2rem; }
  .topbar { align-items: center; margin-bottom: 1.35rem; }
  .topbar > div { min-width: 0; }
  .topbar h1 { max-width: 19rem; font-size: 2.15rem; }
  .settings-shortcut { display: none; }
  .mobile-log-shortcut { display: grid; border: 0; background: var(--poppy-deep); color: var(--white); box-shadow: 0 8px 22px rgba(203, 50, 72, .23); }
  .mobile-log-shortcut[hidden] { display: none; }
  .cycle-card { display: flex; min-height: 0; gap: 0; padding: 1.35rem; }
  .cycle-orbit { width: min(12.75rem, 64vw); }
  .cycle-orbit-inner strong { font-size: 3.6rem; }
  .cycle-copy { margin-top: 2rem; }
  .calendar-card { padding: 1.1rem 0.75rem 1.3rem; border-radius: 1.25rem; }
  .card-heading { padding-inline: 0.35rem; }
  .calendar-grid { gap: 0.08rem; }
  .calendar-day { min-height: 3.55rem; padding: 0.42rem 0.1rem; border-radius: 0.65rem; }
  .calendar-day .day-number { width: 1.85rem; height: 1.85rem; font-size: 0.88rem; }
  .large-grid .calendar-day { min-height: 3.85rem; }
  .calendar-key { padding-inline: 0.35rem; }
  .calendar-actions { gap: 0.4rem; }
  .today-lower-grid, .metric-grid { grid-template-columns: 1fr; }
  .care-note { font-size: 0.9rem; }
  .insight-callout { padding: 1.5rem; }
  .insight-callout::after { right: -2rem; font-size: 9rem; }
  .metric-card { min-height: 8rem; }
  .setting-heading { display: block; }
  .setting-heading > p { margin-top: 0.6rem; }
  .field-row { align-items: flex-start; }
  .field-row > :last-child { flex: 0 0 auto; }
  .settings-save { width: 100%; }
  .recent-row { grid-template-columns: 1fr auto; gap: 0.35rem 0.7rem; }
  .recent-row p { grid-column: 1 / -1; grid-row: 2; }
  .symptom-bar-row { grid-template-columns: minmax(6rem, .85fr) minmax(6rem, 1.15fr) auto; gap: 0.45rem; }
  dialog { width: 100vw; max-width: none; max-height: calc(100vh - 0.4rem); margin: auto 0 0; border-radius: 1.25rem 1.25rem 0 0; }
  .dialog-header, .form-section, .dialog-footer, .confirm-body { padding-inline: 1rem; }
  .form-section-heading { display: block; }
  .form-section-heading > p { margin-top: 0.35rem; text-align: left; }
  .flow-options { grid-template-columns: repeat(5, minmax(3.3rem, 1fr)); gap: 0.28rem; overflow-x: auto; padding-bottom: 0.25rem; }
  .flow-options label > span { min-height: 4.5rem; font-size: 0.7rem; }
  .symptom-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .range-grid { grid-template-columns: 1fr; }
  .dialog-footer { flex-wrap: wrap; }
  .dialog-footer .secondary-button, .dialog-footer .primary-button, .dialog-footer .danger-button { min-height: 2.8rem; padding-block: 0.55rem; }
  .toast-region { bottom: calc(5.3rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 390px) {
  .main { padding-inline: 0.75rem; }
  .topbar { gap: .65rem; }
  .topbar h1 { font-size: 1.82rem; }
  .calendar-card { padding-inline: 0.45rem; }
  .calendar-day { min-height: 3.25rem; }
  .calendar-day.has-log::after { bottom: 0.35rem; }
  .today-entry-card, .pattern-card, .settings-panel, .chart-panel, .symptom-panel, .recent-panel, .day-detail { padding: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-contrast: more) {
  :root { --line: #8e899f; --line-strong: #5e596f; --muted: #4f4b5f; }
  .panel, .cycle-card, .calendar-card, .metric-card { border-color: var(--line-strong); }
}
