:root {
  --bg: #fff5f8;
  --card: #ffffff;
  --primary: #e8a3bd;
  --primary-dark: #d97ea3;
  --accent: #f7c6d9;
  --accent-light: #fce6ee;
  --text: #4a3b42;
  --text-light: #9a8790;
  --border: #f3d9e3;
  --flow: #d9607d;
  --fertile: #b7d9c2;
  --ovulation: #f0b26b;
  --danger: #d9607d;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* Auth */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(217, 126, 163, 0.15);
}
.logo { font-size: 1.5rem; margin: 0 0 8px; color: var(--primary-dark); }
.auth-subtitle { color: var(--text-light); margin-bottom: 20px; }
.auth-error { color: var(--danger); min-height: 1.2em; margin-top: 12px; font-size: 0.9rem; }

input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { background: var(--primary-dark); }

.btn-icon {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--primary-dark);
  cursor: pointer;
  padding: 6px 12px;
}

/* App shell */
.app { min-height: 100vh; padding-bottom: 76px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .logo { margin: 0; }

main#views { padding: 16px; max-width: 480px; margin: 0 auto; }

.view { animation: fadein 0.15s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Prediction card */
.prediction-card {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  line-height: 1.6;
}
.prediction-card b { color: var(--primary-dark); }

/* Calendar */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-header h2 { font-size: 1.1rem; margin: 0; text-transform: capitalize; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
}
.cal-dow { text-align: center; font-size: 0.75rem; color: var(--text-light); padding-bottom: 6px; }
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  position: relative;
  cursor: pointer;
  color: var(--text);
}
.cal-day.empty { cursor: default; }
.cal-day.today { border: 2px solid var(--primary-dark); font-weight: 700; }
.cal-day.flow { background: var(--flow); color: white; }
.cal-day.fertile { background: var(--fertile); }
.cal-day.ovulation { background: var(--ovulation); color: white; }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-light);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-flow { background: var(--flow); }
.dot-fertile { background: var(--fertile); }
.dot-ovulation { background: var(--ovulation); }

/* Day nav / journal */
.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.day-nav h2 { font-size: 1rem; margin: 0; text-transform: capitalize; }

.card-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
}
.card-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 14px 0 8px;
  font-weight: 600;
}
.card-form label:first-child { margin-top: 0; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: white; }

.field-row { display: flex; gap: 12px; }
.field { flex: 1; }
.field label { margin-top: 0; }

#energy-slider { margin-bottom: 4px; }

/* Measurements list */
.section-title { font-size: 1rem; margin: 24px 0 12px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}
.list-item .date { color: var(--text-light); font-size: 0.78rem; }
.list-item .del-btn { background: none; border: none; color: var(--danger); font-size: 1.1rem; cursor: pointer; }

/* Stats */
.chart {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.stats-summary {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.8;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  color: var(--text-light);
  cursor: pointer;
}
.nav-btn span { font-size: 1.2rem; }
.nav-btn.active { color: var(--primary-dark); font-weight: 600; }
