:root{
  --bg: #FBF2EF;
  --surface: #FFFFFF;
  --surface-2: #FDF6F3;
  --ink: #3D1F2E;
  --ink-soft: #8A6874;
  --ink-faint: #C9AFB6;
  --rose: #B23A5C;
  --rose-deep: #8C2C48;
  --coral: #E8A79B;
  --coral-strong:#E0836F;
  --sage: #7C9A78;
  --sage-soft: #DCE7DA;
  --gold: #C9962B;
  --line: #EFE1DF;
  --shadow: 0 10px 30px -12px rgba(140, 44, 72, 0.25);
  --radius: 18px;
  --radius-sm: 12px;
}
*{box-sizing:border-box; -webkit-tap-highlight-color: transparent;}
html,body{margin:0;padding:0;}
body{
  background: radial-gradient(circle at 15% 0%, #FCE9E4 0%, var(--bg) 45%) fixed;
  font-family:'Plus Jakarta Sans', sans-serif;
  color:var(--ink);
  display:flex;
  justify-content:center;
  min-height:100vh;
}
#shell{
  width:100%;
  max-width:460px;
  min-height:100vh;
  background:var(--surface);
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  position:relative;
}
h1,h2,h3{ font-family:'Fraunces', serif; font-weight:600; margin:0; color:var(--ink); }
.topbar{
  display:flex; align-items:center; gap:10px;
  padding:20px 20px 14px;
  background: linear-gradient(180deg, #FFFFFF 0%, #FDF6F3 100%);
  border-bottom:1px solid var(--line);
}
.brand-mark{ width:34px; height:34px; flex:none; }
.brand-text{ display:flex; flex-direction:column; line-height:1.1; }
.brand-text b{ font-family:'Fraunces', serif; font-size:19px; font-weight:600; letter-spacing:0.2px; }
.brand-text span{ font-size:11px; color:var(--ink-soft); letter-spacing:0.4px; }
.topbar .logout-btn{ margin-left:auto; border:none; background:var(--surface-2); color:var(--ink-soft); font-size:11px; font-weight:700; padding:7px 11px; border-radius:999px; cursor:pointer; }

#view{ flex:1; padding:18px 18px 100px; overflow-y:auto; }

/* ---------- Auth screen ---------- */
.auth-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
.auth-card{ width:100%; max-width:380px; text-align:center; }
.auth-card .brand-mark{ width:56px; height:56px; margin:0 auto 16px; display:block; }
.auth-card h1{ font-size:24px; margin-bottom:8px; }
.auth-card p{ font-size:13px; color:var(--ink-soft); line-height:1.6; margin:0 0 22px; }
.auth-card input{ width:100%; border:1.5px solid var(--line); border-radius:var(--radius-sm); padding:13px 14px; font-size:14px; font-family:'Plus Jakarta Sans'; margin-bottom:10px; text-align:left; }
.auth-note{ font-size:11px; color:var(--ink-faint); margin-top:14px; line-height:1.6; }
.auth-error{ font-size:12px; color:var(--coral-strong); margin-top:10px; }
.auth-success{ font-size:12.5px; color:var(--sage); background:var(--sage-soft); border-radius:var(--radius-sm); padding:12px; margin-top:14px; line-height:1.6; }

/* ---------- Hero cycle ring ---------- */
.hero-card{
  background: linear-gradient(160deg, var(--rose-deep) 0%, var(--rose) 55%, var(--coral-strong) 100%);
  border-radius: var(--radius);
  padding:22px 20px;
  color:#fff;
  position:relative;
  overflow:hidden;
  margin-bottom:20px;
}
.hero-card::after{
  content:"";
  position:absolute; right:-40px; top:-40px; width:150px; height:150px;
  background: radial-gradient(circle, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0) 70%);
}
.hero-top{ display:flex; justify-content:space-between; align-items:center; gap:14px; }
.hero-ring-wrap{ position:relative; width:104px; height:104px; flex:none; }
.hero-ring-wrap svg{ width:100%; height:100%; transform: rotate(-90deg); }
.hero-ring-label{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.hero-ring-label .num{ font-family:'IBM Plex Mono', monospace; font-size:22px; font-weight:500; }
.hero-ring-label .lbl{ font-size:9.5px; opacity:0.85; letter-spacing:0.3px; text-align:center; }
.hero-info{ flex:1; }
.hero-info .eyebrow{ font-size:11px; letter-spacing:0.6px; text-transform:uppercase; opacity:0.85; margin-bottom:4px; }
.hero-info .headline{ font-family:'Fraunces', serif; font-size:19px; font-weight:600; line-height:1.25; }
.hero-sub{ margin-top:14px; font-size:12.5px; opacity:0.92; line-height:1.5; border-top:1px solid rgba(255,255,255,0.25); padding-top:12px; }
.confidence-pill{ display:inline-flex; align-items:center; gap:6px; margin-top:10px; background:rgba(255,255,255,0.18); border-radius:999px; padding:5px 10px; font-size:11px; }
.confidence-dot{ width:6px; height:6px; border-radius:50%; background:#fff; }

.section-label{ font-size:11px; letter-spacing:0.8px; text-transform:uppercase; color:var(--ink-soft); margin: 22px 0 10px; font-weight:600; }

/* ---------- Calendar ---------- */
.cal-nav{ display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.cal-nav button{ border:none; background:var(--surface-2); width:34px; height:34px; border-radius:50%; font-size:16px; color:var(--rose-deep); cursor:pointer; display:flex; align-items:center; justify-content:center; }
.cal-nav .month-title{ font-family:'Fraunces', serif; font-size:17px; font-weight:600; }
.cal-grid{ display:grid; grid-template-columns: repeat(7, 1fr); gap:4px; }
.cal-dow{ text-align:center; font-size:10.5px; color:var(--ink-faint); font-weight:600; padding-bottom:4px; letter-spacing:0.3px; }
.cal-cell{ position:relative; aspect-ratio:1/1; border-radius:10px; display:flex; align-items:center; justify-content:center; font-family:'IBM Plex Mono', monospace; font-size:13px; cursor:pointer; color:var(--ink); background:transparent; border:1.5px solid transparent; }
.cal-cell.out{ color:var(--ink-faint); opacity:0.45; }
.cal-cell.today{ border-color:var(--rose-deep); font-weight:600; }
.cal-cell.period{ background:var(--rose); color:#fff; font-weight:600; }
.cal-cell.predicted{ background:var(--coral); color:#fff; opacity:0.85; }
.cal-cell.fertile{ background:var(--sage-soft); color:var(--ink); }
.cal-cell.ovulation{ background:var(--sage); color:#fff; font-weight:600; }
.cal-cell .dot{ position:absolute; bottom:3px; width:4px; height:4px; border-radius:50%; background:var(--gold); }
.legend{ display:flex; flex-wrap:wrap; gap:10px; margin-top:14px; }
.legend-item{ display:flex; align-items:center; gap:5px; font-size:11px; color:var(--ink-soft); }
.legend-swatch{ width:10px; height:10px; border-radius:3px; }

.quick-btn{ margin-top:18px; width:100%; padding:13px; border:none; border-radius:var(--radius-sm); background:var(--rose-deep); color:#fff; font-family:'Plus Jakarta Sans'; font-weight:700; font-size:14px; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:8px; }

.card{ background:var(--surface-2); border:1px solid var(--line); border-radius:var(--radius-sm); padding:14px 16px; margin-bottom:10px; }
.card-row{ display:flex; justify-content:space-between; align-items:center; }
.card-title{ font-size:13.5px; font-weight:600; }
.card-sub{ font-size:11.5px; color:var(--ink-soft); margin-top:2px; }
.card-val{ font-family:'IBM Plex Mono', monospace; font-size:16px; font-weight:500; color:var(--rose-deep); }

label.field-label{ font-size:12.5px; font-weight:600; color:var(--ink-soft); display:block; margin:16px 0 8px; }
.toggle-row{ display:flex; align-items:center; justify-content:space-between; padding:12px 0; border-bottom:1px solid var(--line); }
.toggle-row:last-child{ border-bottom:none; }
.toggle-row .t-label{ font-size:13.5px; font-weight:600; }
.toggle-row .t-sub{ font-size:11px; color:var(--ink-soft); margin-top:2px; }
.switch{ position:relative; width:42px; height:24px; flex:none; }
.switch input{ opacity:0; width:0; height:0; }
.slider{ position:absolute; cursor:pointer; inset:0; background:#E3D5D9; border-radius:999px; transition:0.2s; }
.slider::before{ content:""; position:absolute; width:18px; height:18px; left:3px; top:3px; background:#fff; border-radius:50%; transition:0.2s; box-shadow:0 1px 3px rgba(0,0,0,0.25); }
input:checked + .slider{ background:var(--rose); }
input:checked + .slider::before{ transform:translateX(18px); }

.stepper{ display:flex; align-items:center; gap:14px; }
.stepper button{ width:38px; height:38px; border-radius:10px; border:1px solid var(--line); background:#fff; font-size:18px; color:var(--rose-deep); cursor:pointer; }
.stepper .val{ font-family:'IBM Plex Mono', monospace; font-size:18px; min-width:64px; text-align:center; }

.chip-group{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{ padding:8px 13px; border-radius:999px; border:1.5px solid var(--line); background:#fff; font-size:12.5px; cursor:pointer; color:var(--ink-soft); font-weight:600; }
.chip.active{ background:var(--rose); border-color:var(--rose); color:#fff; }
.chip.mood{ font-size:18px; padding:7px 10px; }
.chip.mood.active{ background:var(--gold); border-color:var(--gold); }

textarea, select{ width:100%; border:1.5px solid var(--line); border-radius:var(--radius-sm); padding:11px 12px; font-family:'Plus Jakarta Sans'; font-size:13.5px; color:var(--ink); background:#fff; resize:vertical; }
textarea{ min-height:70px; }

.btn-primary{ width:100%; padding:13px; border:none; border-radius:var(--radius-sm); background:var(--rose-deep); color:#fff; font-weight:700; font-size:14px; cursor:pointer; margin-top:18px; }
.btn-ghost{ width:100%; padding:12px; border:1.5px solid var(--line); border-radius:var(--radius-sm); background:#fff; color:var(--ink-soft); font-weight:700; font-size:13px; cursor:pointer; margin-top:8px; }
.btn-danger{ width:100%; padding:12px; border:1.5px solid #E0836F55; border-radius:var(--radius-sm); background:#fff; color:var(--coral-strong); font-weight:700; font-size:13px; cursor:pointer; margin-top:8px; }

.bottomnav{ position:sticky; bottom:0; display:flex; background:#fff; border-top:1px solid var(--line); padding:8px 6px calc(8px + env(safe-area-inset-bottom)); }
.nav-btn{ flex:1; background:none; border:none; display:flex; flex-direction:column; align-items:center; gap:4px; padding:6px 0; cursor:pointer; color:var(--ink-faint); font-size:10.5px; font-weight:600; font-family:'Plus Jakarta Sans'; }
.nav-btn svg{ width:20px; height:20px; }
.nav-btn.active{ color:var(--rose-deep); }

.modal-overlay{ position:fixed; inset:0; background:rgba(61,31,46,0.45); display:flex; align-items:flex-end; justify-content:center; z-index:50; }
.modal-overlay.center{ align-items:center; padding:20px; }
.modal-sheet{ background:#fff; width:100%; max-width:460px; border-radius:20px 20px 0 0; max-height:88vh; overflow-y:auto; padding:20px 20px calc(20px + env(safe-area-inset-bottom)); }
.modal-overlay.center .modal-sheet{ border-radius:20px; max-height:80vh; }
.modal-handle{ width:36px; height:4px; background:var(--line); border-radius:99px; margin:0 auto 14px; }
.modal-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:6px; }
.modal-head h2{ font-size:18px; }
.close-x{ border:none; background:var(--surface-2); width:30px; height:30px; border-radius:50%; font-size:15px; color:var(--ink-soft); cursor:pointer; }

.bars{ display:flex; align-items:flex-end; gap:8px; height:110px; margin-top:8px; }
.bar-col{ flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; height:100%; }
.bar{ width:100%; max-width:26px; border-radius:6px 6px 3px 3px; background:linear-gradient(180deg, var(--coral-strong), var(--rose-deep)); }
.bar-col .bnum{ font-size:9.5px; color:var(--ink-soft); margin-bottom:3px; font-family:'IBM Plex Mono', monospace; }
.bar-col .blabel{ font-size:9px; color:var(--ink-faint); margin-top:5px; }

.symptom-row{ display:flex; align-items:center; gap:10px; margin-bottom:9px; }
.symptom-row .sname{ font-size:12px; width:100px; flex:none; color:var(--ink-soft); }
.symptom-row .strack{ flex:1; height:7px; background:var(--surface-2); border-radius:99px; overflow:hidden; }
.symptom-row .sfill{ height:100%; background:var(--sage); border-radius:99px; }
.symptom-row .scount{ font-family:'IBM Plex Mono', monospace; font-size:11px; color:var(--ink-soft); width:16px; text-align:right; }

.empty-state{ text-align:center; padding:36px 10px; color:var(--ink-soft); }
.empty-state .em-icon{ font-size:34px; margin-bottom:10px; }
.empty-state p{ font-size:13px; line-height:1.6; margin:6px 0 0; }

.toast{ position:fixed; bottom:90px; left:50%; transform:translateX(-50%); background:var(--ink); color:#fff; padding:10px 18px; border-radius:999px; font-size:12.5px; z-index:100; opacity:0; transition:opacity 0.25s, transform 0.25s; pointer-events:none; box-shadow:0 8px 20px rgba(0,0,0,0.2); }
.toast.show{ opacity:1; transform:translateX(-50%) translateY(-6px); }

.spinner{ width:34px; height:34px; border:3px solid var(--line); border-top-color:var(--rose-deep); border-radius:50%; margin:60px auto; animation:spin 0.8s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

::-webkit-scrollbar{ width:0; height:0; }
button:focus-visible, .cal-cell:focus-visible, .chip:focus-visible{ outline:2px solid var(--rose-deep); outline-offset:2px; }
