:root {
  --rose: #e8829c;
  --rose-dark: #d1607e;
  --rose-soft: #fbe4ea;
  --lavender: #a78bd6;
  --lavender-soft: #ede4f9;
  --gold: #e0a94f;
  --bg: #fdf6f5;
  --card: #ffffff;
  --text: #4a2c3d;
  --text-muted: #8c7381;
  --border: #f3dde3;
  --danger: #d1607e;
  --success: #5fa88a;
  --input-bg: #fffdfd;
  --toast-bg: #3d2a35;
  --chart-grid: rgba(74, 44, 61, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(210, 130, 155, 0.12);
  --font-heading: "Quicksand", sans-serif;
  --font-body: "Nunito", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rose-soft: #40222c;
    --lavender-soft: #2a2340;
    --bg: #1e1520;
    --card: #2a1e2c;
    --text: #f3e6ec;
    --text-muted: #bda2b2;
    --border: #3d2c3f;
    --input-bg: #241a26;
    --toast-bg: #14100f;
    --chart-grid: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --rose-soft: #40222c;
  --lavender-soft: #2a2340;
  --bg: #1e1520;
  --card: #2a1e2c;
  --text: #f3e6ec;
  --text-muted: #bda2b2;
  --border: #3d2c3f;
  --input-bg: #241a26;
  --toast-bg: #14100f;
  --chart-grid: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-heading); color: var(--text); margin: 0 0 8px; }
p { line-height: 1.5; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ============================= LANDING PAGE ============================= */
.landing {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 0%, var(--rose-soft) 0%, transparent 40%),
    radial-gradient(circle at 90% 15%, var(--lavender-soft) 0%, transparent 40%),
    var(--bg);
  background-size: 130% 130%, 130% 130%, 100% 100%;
  animation: bg-drift 16s ease-in-out infinite;
}

.landing-decor { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.decor-item {
  position: absolute;
  font-size: 2rem;
  opacity: 0.35;
  filter: saturate(0.9);
  animation: decor-float 9s ease-in-out infinite;
}
.decor-item.d1 { top: 10%; left: 6%; font-size: 2.4rem; animation-duration: 8s; }
.decor-item.d2 { top: 18%; right: 10%; font-size: 1.4rem; animation-duration: 6s; animation-delay: 0.6s; }
.decor-item.d3 { top: 55%; left: 4%; font-size: 1.8rem; animation-duration: 10s; animation-delay: 1.2s; }
.decor-item.d4 { top: 72%; right: 7%; font-size: 1.6rem; animation-duration: 7s; animation-delay: 0.3s; }
.decor-item.d5 { top: 38%; right: 18%; font-size: 1.7rem; animation-duration: 11s; animation-delay: 1.8s; }
@keyframes decor-float {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-22px) rotate(6deg); }
}
.landing-nav, .landing-hero, .landing-features, .landing-privacy, .landing-footer { position: relative; z-index: 1; }
@media (max-width: 640px) {
  .decor-item { display: none; }
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.landing-hero {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 24px 20px;
  animation: card-enter 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.beta-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--rose-soft), var(--lavender-soft));
  color: var(--rose-dark);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 999px;
  margin-bottom: 18px;
  animation: float-icon 5s ease-in-out infinite;
}

.landing-hero h1 {
  font-size: 2.3rem;
  line-height: 1.25;
  color: var(--rose-dark);
  margin: 0 0 16px;
}

.landing-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 560px;
  margin: 0 auto 26px;
}

.landing-cta-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.landing-cta { padding: 14px 28px; font-size: 1rem; }

.landing-features {
  max-width: 1100px;
  margin: 50px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.feature-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: card-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.landing-features .feature-card:nth-child(1) { animation-delay: 0.05s; }
.landing-features .feature-card:nth-child(2) { animation-delay: 0.1s; }
.landing-features .feature-card:nth-child(3) { animation-delay: 0.15s; }
.landing-features .feature-card:nth-child(4) { animation-delay: 0.2s; }
.landing-features .feature-card:nth-child(5) { animation-delay: 0.25s; }
.landing-features .feature-card:nth-child(6) { animation-delay: 0.3s; }
.feature-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(210, 130, 155, 0.2); }
.feature-card:hover .feature-icon { animation-play-state: running; }
.feature-icon {
  font-size: 1.8rem; display: block; margin-bottom: 10px;
  animation: float-icon 4.5s ease-in-out infinite;
}
.landing-features .feature-card:nth-child(2n) .feature-icon { animation-delay: 0.4s; }
.landing-features .feature-card:nth-child(3n) .feature-icon { animation-delay: 0.8s; }
.feature-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.feature-card p { color: var(--text-muted); font-size: 0.9rem; margin: 0; line-height: 1.5; }

.landing-privacy {
  max-width: 1100px;
  margin: 0 auto 50px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.landing-privacy .feature-icon { margin-bottom: 0; }
.landing-privacy h3 { margin-bottom: 6px; }

.landing-footer {
  text-align: center;
  padding: 20px 24px 60px;
  max-width: 560px;
  margin: 0 auto;
}
.landing-disclaimer {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 24px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .landing-hero h1 { font-size: 1.7rem; }
  .landing-cta-row { flex-direction: column; align-items: stretch; }
}

/* ============================= AUTH SCREEN ============================= */
@keyframes bg-drift {
  0%, 100% { background-position: 15% 10%, 85% 90%, 0 0; }
  50% { background-position: 20% 15%, 80% 85%, 0 0; }
}
@keyframes float-icon {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}
@keyframes card-enter {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, var(--rose-soft) 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, var(--lavender-soft) 0%, transparent 45%),
    var(--bg);
  background-size: 140% 140%, 140% 140%, 100% 100%;
  animation: bg-drift 12s ease-in-out infinite;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 36px 30px;
  animation: card-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

.btn-back-home {
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 4px 0;
  margin-bottom: 8px;
  transition: color 0.15s ease, transform 0.15s ease;
}
.btn-back-home:hover { color: var(--rose-dark); transform: translateX(-2px); }

.brand { text-align: center; margin-bottom: 24px; }
.brand-icon { font-size: 2.4rem; display: inline-block; animation: float-icon 4s ease-in-out infinite; }
.brand h1 { font-size: 1.8rem; margin: 4px 0 2px; color: var(--rose-dark); }
.brand-tagline { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.tabs {
  display: flex;
  background: var(--rose-soft);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  border-radius: 999px;
  font-weight: 600;
  color: var(--rose-dark);
  transition: all 0.2s ease;
}
.tab-btn:hover:not(.active) { background: rgba(232, 130, 156, 0.15); }
.tab-btn.active { background: var(--rose); color: #fff; box-shadow: 0 4px 10px rgba(209,96,126,0.3); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; font-weight: 600; color: var(--text-muted); }
.form-row { display: flex; align-items: flex-start; gap: 12px; }
.form-row label { flex: 1 1 0; min-width: 0; }
.form-row input { width: 100%; }

#form-profile label,
#form-password label,
#mfa-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
}
#form-profile .form-row,
#form-password .form-row { margin: 0 0 2px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="date"], input[type="number"], textarea, select {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* evita lo zoom automatico di iOS Safari al focus */
  color: var(--text);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--rose); box-shadow: 0 0 0 4px rgba(232, 130, 156, 0.15); transform: translateY(-1px); }

.auth-form label { animation: card-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.auth-form label:nth-child(1) { animation-delay: 0.04s; }
.auth-form label:nth-child(2) { animation-delay: 0.08s; }
.auth-form label:nth-child(3) { animation-delay: 0.12s; }
.auth-form label:nth-child(4) { animation-delay: 0.16s; }
.auth-form label:nth-child(5) { animation-delay: 0.2s; }
.auth-form label:nth-child(6) { animation-delay: 0.24s; }

.checkbox-row { flex-direction: row !important; align-items: flex-start; gap: 8px !important; font-weight: 400 !important; font-size: 0.8rem !important; }
.checkbox-row input { margin-top: 3px; }

.register-success { text-align: center; padding: 8px 0; animation: card-enter 0.4s cubic-bezier(0.22, 1, 0.36, 1); }
.register-success-icon { font-size: 2.8rem; display: inline-block; margin-bottom: 12px; animation: float-icon 3.5s ease-in-out infinite; }
.register-success h3 { color: var(--rose-dark); margin-bottom: 10px; }
.register-success p { color: var(--text-muted); font-size: 0.92rem; margin: 0 0 22px; line-height: 1.5; }

.btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-link, .btn-icon {
  border: none;
  border-radius: 999px;
  font-weight: 700;
  padding: 12px 20px;
  font-size: 0.95rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn-primary { background: linear-gradient(135deg, var(--rose), var(--rose-dark)); color: #fff; box-shadow: 0 6px 16px rgba(209,96,126,0.35); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(209,96,126,0.42); }
.btn-primary:active { transform: translateY(0) scale(0.97); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-icon { transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease; }
.btn-secondary:active, .btn-danger:active, .btn-ghost:active, .btn-icon:active { transform: scale(0.94); }
.btn-secondary { background: var(--lavender-soft); color: var(--lavender); }
.btn-secondary:hover { background: var(--lavender); color: #fff; transform: translateY(-1px); }
.btn-danger { background: #fbe4ea; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); border-radius: 999px; padding: 8px 16px; }
.btn-ghost:hover { border-color: var(--rose); color: var(--rose-dark); background: var(--rose-soft); }
.btn-link { background: none; color: var(--rose-dark); text-decoration: underline; padding: 4px; align-self: center; font-weight: 600; font-size: 0.85rem; }
.btn-link:hover { color: var(--rose); }
.btn-icon { background: var(--rose-soft); color: var(--rose-dark); width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 1.1rem; line-height: 1; }
.btn-icon:hover { background: var(--rose); color: #fff; transform: scale(1.08); }

.password-hint { color: var(--text-muted); font-size: 0.78rem; margin: -8px 0 0; }
.password-hint.valid { color: var(--success); }
#mfa-qr-container img, #mfa-qr-container svg { max-width: 180px; border-radius: 12px; background: #fff; padding: 8px; }
#mfa-secret-text { background: var(--rose-soft); padding: 2px 8px; border-radius: 6px; font-size: 0.85rem; word-break: break-all; }
.form-error { color: var(--danger); font-size: 0.85rem; margin: 0; min-height: 1em; }
.form-success { color: var(--success); font-size: 0.85rem; margin: 0; min-height: 1em; }

.turnstile-slot { min-height: 65px; display: flex; justify-content: center; }

/* ============================= APP SHELL ============================= */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "topbar topbar" "side main";
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { font-family: var(--font-heading); font-weight: 700; font-size: 1.2rem; color: var(--rose-dark); display: flex; align-items: center; gap: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.sidenav {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  background: var(--card);
  border-right: 1px solid var(--border);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  font-size: 0.95rem;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-item:hover { background: var(--rose-soft); color: var(--rose-dark); transform: translateX(2px); }
.nav-item.active { background: var(--rose); color: #fff; }
.nav-item.active:hover { background: var(--rose-dark); transform: translateX(2px); }
.nav-icon { font-size: 1.1rem; transition: transform 0.18s ease; }
.nav-item:hover .nav-icon { transform: scale(1.15); }

.main-content { grid-area: main; padding: 26px 32px 90px; max-width: 1100px; }

@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.view { animation: view-fade-in 0.28s ease; }

.bottomnav { display: none; }

.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }

.dashboard-greeting {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--rose-dark);
  margin-bottom: 6px;
  animation: card-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.dashboard-greeting-icon { font-size: 1.5rem; display: inline-block; animation: float-icon 4s ease-in-out infinite; }
.dashboard-greeting strong { color: var(--text); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

/* Dashboard */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.widget {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.widget:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(210, 130, 155, 0.2); }
.widget { animation: card-enter 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.dashboard-grid .widget:nth-child(1) { animation-delay: 0.02s; }
.dashboard-grid .widget:nth-child(2) { animation-delay: 0.06s; }
.dashboard-grid .widget:nth-child(3) { animation-delay: 0.1s; }
.dashboard-grid .widget:nth-child(4) { animation-delay: 0.14s; }
.dashboard-grid .widget:nth-child(5) { animation-delay: 0.18s; }
.dashboard-grid .widget:nth-child(6) { animation-delay: 0.22s; }
.dashboard-grid .widget:nth-child(7) { animation-delay: 0.26s; }
.widget::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--rose), var(--lavender));
}
.widget-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.widget-value { font-size: 1.6rem; font-weight: 700; color: var(--rose-dark); font-family: var(--font-heading); }
.widget-sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.widget.wide { grid-column: span 2; }

.customize-panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-top: 16px; }
.customize-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.customize-row:last-child { border-bottom: none; }
.customize-actions { display: flex; gap: 6px; }

/* Cycle phase banner + range form */
.phase-banner { display: flex; align-items: center; gap: 14px; animation: card-enter 0.4s cubic-bezier(0.22, 1, 0.36, 1); }
.phase-banner .phase-icon { font-size: 2rem; animation: float-icon 3.5s ease-in-out infinite; }
.phase-banner .phase-title { font-weight: 700; color: var(--rose-dark); font-family: var(--font-heading); font-size: 1.1rem; }
.phase-banner .phase-desc { color: var(--text-muted); font-size: 0.88rem; margin-top: 2px; }

.cycle-range-form h3 { margin-bottom: 4px; }
.cycle-range-form .form-row { margin: 12px 0; }
.cycle-range-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.cycle-range-form select {
  padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 16px; color: var(--text); background: var(--input-bg);
}

/* Calendar */
.month-nav { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.calendar-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; font-size: 0.85rem; color: var(--text-muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-period { background: var(--rose); }
.dot-predicted { background: var(--rose-soft); border: 1.5px dashed var(--rose); }
.dot-fertile { background: var(--lavender-soft); border: 1.5px solid var(--lavender); }
.dot-ovulation { background: var(--gold); }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-weekday { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); padding-bottom: 4px; }
.calendar-day {
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--card);
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.calendar-day:not(.empty):hover { transform: scale(1.08); box-shadow: 0 6px 14px rgba(210, 130, 155, 0.25); z-index: 2; }
.calendar-day.empty { visibility: hidden; }
.calendar-day.today { border-color: var(--rose); border-width: 2px; }
.calendar-day.period { background: var(--rose); color: #fff; border-color: var(--rose); }
.calendar-day.predicted { background: var(--rose-soft); border-style: dashed; border-color: var(--rose); }
.calendar-day.fertile { background: var(--lavender-soft); border-color: var(--lavender); }
.calendar-day.ovulation::after {
  content: "★"; position: absolute; top: 2px; right: 4px; font-size: 0.6rem; color: var(--gold);
}
.calendar-day.has-symptom::before {
  content: ""; position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--lavender);
}

/* Symptoms */
.symptom-form h3 { margin-top: 14px; font-size: 0.95rem; }
.symptom-form h3:first-child { margin-top: 0; }
.flow-toggle { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; }
.flow-toggle label { display: flex; align-items: center; gap: 5px; font-weight: 500; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: var(--rose); transform: translateY(-2px); }
.chip.selected { background: var(--rose); color: #fff; border-color: var(--rose); }
.chip.selected:hover { background: var(--rose-dark); }

#pain-level { width: 100%; accent-color: var(--rose); }
.symptom-form textarea, .symptom-form input[type="number"] { width: 100%; }

.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.section-title { margin-top: 26px; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item { background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.history-item:hover { transform: translateX(4px); box-shadow: 0 10px 22px rgba(210, 130, 155, 0.18); }
.history-item-date { font-weight: 700; color: var(--rose-dark); }
.history-item-tags { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chart-card h3 { font-size: 0.95rem; }

.insight-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.insight-row:last-child { border-bottom: none; }
.insight-icon { font-size: 1.3rem; }
.chart-wrap { position: relative; height: 240px; }

/* Toast */
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--toast-bg); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 0.9rem; box-shadow: 0 8px 20px rgba(0,0,0,0.2); z-index: 999;
  animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Onboarding tutorial (primo accesso) */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(74, 44, 61, 0.45);
  backdrop-filter: blur(3px);
  animation: toast-in 0.25s ease-out;
}
.onboarding-card {
  position: relative;
  width: 100%; max-width: 420px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(74, 44, 61, 0.3);
  padding: 32px 28px 26px;
  text-align: center;
  animation: card-enter 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.onboarding-skip {
  position: absolute; top: 16px; right: 18px;
  background: none; border: none; color: var(--text-muted);
  font-size: 0.8rem; font-weight: 600; padding: 4px;
}
.onboarding-skip:hover { color: var(--rose-dark); }
.onboarding-step-icon {
  font-size: 2.6rem; margin-bottom: 14px; display: inline-block;
  animation: float-icon 3.5s ease-in-out infinite;
}
.onboarding-step h3 { font-size: 1.15rem; margin-bottom: 8px; }
.onboarding-step p { color: var(--text-muted); font-size: 0.92rem; margin: 0; }
.onboarding-dots { display: flex; justify-content: center; gap: 7px; margin: 22px 0 20px; }
.onboarding-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); transition: all 0.25s ease; }
.onboarding-dot.active { background: var(--rose); width: 20px; border-radius: 4px; }
.onboarding-actions { display: flex; gap: 10px; justify-content: center; }
.onboarding-actions .btn-primary, .onboarding-actions .btn-ghost { flex: 1; }

/* ============================= RESPONSIVE / MOBILE ============================= */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidenav { display: none; }
  .main-content { padding: 18px 16px 100px; }
  .bottomnav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 50;
  }
  .bottomnav .nav-item { flex-direction: column; padding: 6px 10px; font-size: 0.65rem; background: none; }
  .bottomnav .nav-item.active { background: var(--rose-soft); color: var(--rose-dark); }
  .bottomnav .nav-icon { font-size: 1.3rem; }
  .widget.wide { grid-column: span 1; }
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .form-row { flex-direction: column; }
}

@media (max-width: 860px) {
  .calendar-day { font-size: 0.9rem; }
  .chip { padding: 10px 16px; }
  .btn-primary, .btn-secondary, .btn-danger, .btn-ghost { padding: 13px 20px; }
  .btn-icon { width: 40px; height: 40px; }
  input[type="text"], input[type="email"], input[type="password"],
  input[type="tel"], input[type="date"], input[type="number"], textarea,
  .cycle-range-form select {
    padding: 13px 14px;
  }
}

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