/* Ciclo — iOS-inspired, mobile-first */
:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-press: 0 2px 12px rgba(0, 0, 0, 0.08);
  --transition: 0.28s cubic-bezier(0.25, 0.8, 0.25, 1);
  --tap-scale: 0.97;

  --bg: #f2f2f7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #636366;
  --separator: rgba(60, 60, 67, 0.12);
  --accent: #007aff;
  --period: #ff6b7a;
  --period-soft: rgba(255, 107, 122, 0.22);
  --fertile: #7dd3a8;
  --fertile-soft: rgba(125, 211, 168, 0.28);
  --ovulation: #7b68ee;
  --ovulation-soft: rgba(123, 104, 238, 0.3);
  --neutral: #e5e5ea;
  --neutral-text: #8e8e93;
  --header-bg: rgba(242, 242, 247, 0.82);
  --modal-overlay: rgba(0, 0, 0, 0.38);
  --try-heart: #ff2d55;
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --text: #f2f2f7;
  --text-secondary: #98989d;
  --separator: rgba(84, 84, 88, 0.48);
  --accent: #0a84ff;
  --period: #ff6b7a;
  --period-soft: rgba(255, 107, 122, 0.35);
  --fertile: #5ecf9a;
  --fertile-soft: rgba(94, 207, 154, 0.28);
  --ovulation: #9b8cff;
  --ovulation-soft: rgba(155, 140, 255, 0.35);
  --neutral: #3a3a3c;
  --neutral-text: #aeaeb2;
  --header-bg: rgba(28, 28, 30, 0.82);
  --modal-overlay: rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-press: 0 2px 12px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

.safe-top {
  padding-top: env(safe-area-inset-top, 12px);
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 12px);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--separator);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 14px;
}

.app-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), background var(--transition);
}

.icon-btn:active {
  transform: scale(var(--tap-scale));
}

.icon-btn:hover {
  background: var(--separator);
}

.theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-icon-moon {
  display: none;
}

[data-theme="dark"] .theme-icon-sun {
  display: inline;
}

.app-main {
  flex: 1;
  padding: 16px 16px 8px;
}

.screen {
  animation: screenIn 0.4s var(--transition) both;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hidden,
[hidden] {
  display: none !important;
}

.card-ios {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  border: 1px solid var(--separator);
}

.privacy-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0 0 16px;
  line-height: 1.35;
}

.privacy-note-footer {
  margin-top: 20px;
}

.onboarding-heading {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.onboarding-sub {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.auth-switch {
  display: flex;
  gap: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--separator);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}

.auth-tab {
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform 0.15s ease, border-color var(--transition);
}

.auth-tab:active {
  transform: scale(var(--tap-scale));
}

.auth-tab.is-active {
  background: var(--surface);
  color: var(--text);
  border-color: rgba(10, 132, 255, 0.35);
  box-shadow: var(--shadow-press);
}

.auth-error {
  margin: 0 0 14px;
  background: rgba(255, 45, 85, 0.12);
  color: #d91b48;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  padding: 10px 12px;
}

[data-theme="dark"] .auth-error {
  color: #ff8ca8;
}

.auth-success {
  margin: 0 0 14px;
  background: rgba(52, 199, 89, 0.14);
  color: #2b8f4a;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  padding: 10px 12px;
}

[data-theme="dark"] .auth-success {
  color: #7ae4a0;
}

.password-field {
  position: relative;
}

.password-field .input-ios {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
}

.password-toggle:active {
  transform: translateY(-50%) scale(var(--tap-scale));
}

.form-ios .field-ios {
  margin-bottom: 16px;
}

.field-ios label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.field-ios-nomargin {
  margin-bottom: 0;
}

.input-ios {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), transform 0.15s ease;
}

.input-ios::placeholder {
  color: var(--neutral-text);
}

.input-ios:hover {
  border-color: rgba(0, 122, 255, 0.35);
}

.input-ios:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

[data-theme="light"] .input-ios:focus {
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.textarea-ios {
  resize: vertical;
  min-height: 88px;
}

.btn-ios {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow var(--transition), opacity var(--transition);
}

.btn-ios:active {
  transform: scale(var(--tap-scale));
}

.btn-ios-primary,
.btn-ios-cta {
  background: linear-gradient(180deg, var(--accent), #0056c8);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.35);
  margin-top: 8px;
}

[data-theme="dark"] .btn-ios-primary,
[data-theme="dark"] .btn-ios-cta {
  background: linear-gradient(180deg, var(--accent), #0060d1);
  box-shadow: 0 6px 20px rgba(10, 132, 255, 0.35);
}

.btn-ios-primary:hover,
.btn-ios-cta:hover {
  filter: brightness(1.05);
}

.btn-ios-ghost {
  background: transparent;
  color: var(--accent);
  margin-top: 10px;
  box-shadow: none;
}

.btn-ios-ghost:hover {
  background: var(--separator);
}

.btn-try-heart {
  background: linear-gradient(180deg, #ff6b8a, #ff2d55);
  color: #fff;
  margin-top: 16px;
  box-shadow: 0 6px 18px rgba(255, 45, 85, 0.35);
}

.btn-try-heart.is-active {
  opacity: 0.85;
  box-shadow: none;
}

.try-status {
  text-align: center;
  font-size: 0.85rem;
  color: var(--try-heart);
  margin: 10px 0 0;
  font-weight: 500;
}

.dashboard-greeting {
  margin-bottom: 16px;
  padding: 0 4px;
}

.greet-line {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cycle-summary-line {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.prediction-strip {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

@media (min-width: 380px) {
  .prediction-strip {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
  }
}

.prediction-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prediction-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prediction-value {
  font-size: 0.95rem;
  font-weight: 600;
}

.prediction-value-sm {
  font-size: 0.82rem;
  line-height: 1.3;
}

.fertility-gauge {
  margin-bottom: 14px;
}

.fertility-gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.fertility-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--fertile-soft);
  color: var(--text);
}

.fertility-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--neutral);
  overflow: hidden;
}

.fertility-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--fertile), var(--ovulation));
  transition: width 0.5s var(--transition);
}

.fertility-hint {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 12px;
  padding: 0 4px;
}

.cal-month-label {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: capitalize;
}

.btn-cal-nav {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-press);
  border: 1px solid var(--separator);
  transition: transform 0.15s ease;
}

.btn-cal-nav:active {
  transform: scale(var(--tap-scale));
}

.calendar-wrap {
  padding: 16px;
  margin-bottom: 14px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  aspect-ratio: 1;
  max-height: 52px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow var(--transition);
  background: var(--neutral);
  color: var(--text);
}

.cal-day:disabled {
  opacity: 0.35;
  cursor: default;
  background: transparent;
  box-shadow: none;
}

.cal-day:not(:disabled):hover {
  transform: scale(1.04);
  box-shadow: var(--shadow-press);
}

.cal-day:not(:disabled):active {
  transform: scale(var(--tap-scale));
}

.cal-day--period {
  background: var(--period-soft);
  color: #c41e3a;
}

[data-theme="dark"] .cal-day--period {
  color: #ffb3bc;
}

.cal-day--fertile {
  background: var(--fertile-soft);
  color: #1a6b45;
}

[data-theme="dark"] .cal-day--fertile {
  color: #b8f5d9;
}

.cal-day--ovulation {
  background: var(--ovulation-soft);
  color: #4b3f9e;
  box-shadow: 0 0 0 2px var(--ovulation);
}

[data-theme="dark"] .cal-day--ovulation {
  color: #e0dcff;
}

.cal-day--today {
  box-shadow: 0 0 0 2px var(--accent);
}

.cal-day--try::after {
  content: "❤️";
  position: absolute;
  bottom: 2px;
  font-size: 0.55rem;
  line-height: 1;
}

.cal-day-num {
  position: relative;
  z-index: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  justify-content: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-period {
  background: var(--period);
}

.dot-fertile {
  background: var(--fertile);
}

.dot-ovulation {
  background: var(--ovulation);
}

.dot-try {
  font-size: 0.65rem;
  width: auto;
  height: auto;
  background: none;
}

.monthly-stats {
  margin-bottom: 8px;
}

.stats-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-cell {
  text-align: center;
  padding: 12px 6px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.stat-num {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
  line-height: 1.25;
}

.app-footer {
  text-align: center;
  padding: 12px 16px 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.app-footer p {
  margin: 0;
}

/* Modals */
.modal-ios-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--transition);
  z-index: 100;
}

.modal-ios-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-ios {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.modal-ios:not([hidden]) {
  pointer-events: auto;
}

.modal-ios-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 20px 24px;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-ios.is-open .modal-ios-sheet {
  transform: translateY(0);
}

.modal-ios-handle {
  width: 36px;
  height: 5px;
  background: var(--separator);
  border-radius: 3px;
  margin: 8px auto 16px;
}

.modal-ios-title {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-ios-phase {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.mood-section {
  margin-bottom: 16px;
}

.section-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.mood-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mood-btn {
  width: 48px;
  height: 48px;
  border: 2px solid var(--separator);
  border-radius: 14px;
  background: var(--bg);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, border-color var(--transition), background var(--transition);
}

.mood-btn:hover {
  border-color: var(--accent);
}

.mood-btn:active {
  transform: scale(var(--tap-scale));
}

.mood-btn.is-selected {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.12);
}

[data-theme="light"] .mood-btn.is-selected {
  background: rgba(0, 122, 255, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
