:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #f0f6f4;
  --ink: #202327;
  --muted: #606a71;
  --line: #dce4df;
  --teal: #177e72;
  --teal-dark: #0d5e56;
  --coral: #e2625c;
  --rose: #f3a8a4;
  --gold: #e4ad3d;
  --green: #77b58e;
  --gray: #d9e1dd;
  --shadow: 0 18px 55px rgba(26, 42, 48, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 126, 114, 0.08), transparent 320px),
    var(--bg);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.workspace {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(220, 228, 223, 0.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.brand-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.3vw, 2.25rem);
  line-height: 1.05;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #bdd7cf;
  color: var(--teal-dark);
  background: #eef8f5;
  font-weight: 700;
  white-space: nowrap;
}

.privacy-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(23, 126, 114, 0.13);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
  min-height: 680px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: #fbfcfb;
  border-right: 1px solid var(--line);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.mode-toggle {
  display: grid;
  gap: 10px;
}

.mode-option {
  position: relative;
  display: flex;
  min-height: 74px;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.mode-option span {
  display: flex;
  width: 100%;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.mode-option strong {
  font-size: 0.98rem;
}

.mode-option small {
  color: var(--muted);
  font-weight: 600;
}

.mode-option input:checked + span {
  border-color: var(--teal);
  background: #eef8f5;
  box-shadow: inset 4px 0 0 var(--teal);
}

.mode-option input:focus-visible + span,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(228, 173, 61, 0.5);
  outline-offset: 2px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.range-row label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.field input:invalid:not(:placeholder-shown) {
  border-color: var(--coral);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.range-row input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--teal);
}

.range-row output {
  color: var(--teal-dark);
  font-size: 0.92rem;
  font-weight: 800;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 46px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  color: #ffffff;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.ghost-button {
  color: var(--teal-dark);
  background: #ffffff;
  border-color: #b8d4ce;
}

.ghost-button:hover {
  background: #eef8f5;
}

.fine-print {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.result-panel {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 24px;
  background: #ffffff;
}

.status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.35rem);
  line-height: 1.08;
}

.status-badge {
  flex: 0 0 auto;
  min-width: 116px;
  padding: 9px 12px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 0.84rem;
  font-weight: 900;
}

.status-badge.period {
  color: #963e45;
  background: #fff0f0;
  border-color: #f2c4c2;
}

.status-badge.fertile {
  color: #855b00;
  background: #fff6df;
  border-color: #efd690;
}

.status-badge.peak {
  color: #9b382f;
  background: #fff0ed;
  border-color: #e9b2aa;
}

.status-badge.safe {
  color: var(--teal-dark);
  background: #eef8f5;
  border-color: #bdd7cf;
}

.status-message {
  margin: 0;
  max-width: 760px;
  color: #343a40;
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
  line-height: 1.6;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--line);
  gap: 1px;
}

.insight {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
  background: #ffffff;
}

.insight span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.insight strong {
  font-size: 1rem;
  line-height: 1.25;
}

.cycle-visual {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  background: #fbfcfb;
}

.cycle-ring {
  position: relative;
  width: 210px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--gray) 0turn 1turn);
  box-shadow: inset 0 0 0 1px rgba(32, 35, 39, 0.08);
}

.cycle-ring::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.cycle-ring::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--ink);
  transform: translateX(-50%) rotate(var(--marker-angle, 0deg)) translateY(-99px);
  transform-origin: 50% 107px;
  z-index: 2;
  box-shadow: 0 0 0 5px rgba(32, 35, 39, 0.12);
}

.cycle-core {
  position: absolute;
  inset: 52px;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
}

.cycle-core span {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}

.cycle-core small {
  color: var(--muted);
  font-weight: 800;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.legend i {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.legend-period {
  background: var(--rose);
}

.legend-fertile {
  background: var(--gold);
}

.legend-peak {
  background: var(--coral);
}

.legend-safe {
  background: var(--green);
}

.calendar-shell {
  border: 1px solid var(--line);
}

.calendar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.calendar-top h3,
.calendar-top p {
  margin: 0;
}

.calendar-top h3 {
  font-size: 1rem;
}

.calendar-top p {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.day-cell {
  min-height: 72px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 9px 8px;
  background: #ffffff;
  border: 0;
}

.day-cell strong {
  font-size: 0.92rem;
}

.day-cell span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.day-cell.period {
  background: #fff5f5;
  box-shadow: inset 0 4px 0 var(--rose);
}

.day-cell.fertile {
  background: #fff9ea;
  box-shadow: inset 0 4px 0 var(--gold);
}

.day-cell.peak {
  background: #fff2ef;
  box-shadow: inset 0 4px 0 var(--coral);
}

.day-cell.safe {
  background: #f2faf6;
  box-shadow: inset 0 4px 0 var(--green);
}

.day-cell.today {
  outline: 3px solid rgba(32, 35, 39, 0.16);
  outline-offset: -3px;
}

.advice-box {
  padding: 16px 18px;
  border-left: 5px solid var(--teal);
  background: #eef8f5;
}

.advice-box strong {
  display: block;
  margin-bottom: 6px;
}

.advice-box p {
  margin: 0;
  color: #2d4c48;
  line-height: 1.55;
}

.reference-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 16px;
  padding: 16px 18px;
  color: #394147;
  background: #eaf0ed;
  border: 1px solid var(--line);
}

.reference-band p {
  margin: 0;
  line-height: 1.55;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}

.source-links a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 10px;
  color: var(--teal-dark);
  background: #ffffff;
  border: 1px solid #bdd7cf;
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
}

.source-links a:hover {
  border-color: var(--teal);
}

@media (max-width: 940px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reference-band {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .brand-strip,
  .status-head,
  .calendar-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .privacy-pill {
    white-space: normal;
  }

  .control-panel,
  .result-panel {
    padding: 16px;
  }

  .actions,
  .insight-grid,
  .legend {
    grid-template-columns: 1fr;
  }

  .cycle-visual {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .calendar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .day-cell {
    min-height: 68px;
  }
}

@media (max-width: 420px) {
  .brand-lockup {
    align-items: flex-start;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .calendar-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cycle-ring {
    width: min(210px, 100%);
  }
}
