/* ═══════════════════════════════════════════
   LUNA — Ultra Premium Period Tracker v2
   Cormorant Garamond + DM Sans
   Full Light / Dark theme support
═══════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;0,700;1,400;1,600&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ── LIGHT THEME (default) ── */
:root {
  --rose:         #B5446E;
  --rose-mid:     #C96090;
  --rose-light:   #F0B8CF;
  --rose-glow:    rgba(181,68,110,0.18);
  --sage:         #4A9B72;
  --sage-light:   #C2E8D5;
  --amber:        #D4803A;
  --violet:       #7A52B8;
  --gold:         #C4922A;

  --bg:           #FBF5F8;
  --bg-2:         #F5EBF1;
  --surface:      #FFFFFF;
  --surface-2:    #FDF0F5;
  --surface-3:    #F8E8F0;
  --border:       rgba(181,68,110,0.14);
  --border-strong:rgba(181,68,110,0.28);

  --text-h:       #1E0A14;
  --text:         #3D1828;
  --text-2:       #6B3A52;
  --text-muted:   #9B7080;
  --text-inv:     #FFFFFF;

  --shadow-xs: 0 1px 3px rgba(100,20,50,0.06);
  --shadow-sm: 0 2px 10px rgba(100,20,50,0.08);
  --shadow-md: 0 6px 24px rgba(100,20,50,0.12);
  --shadow-lg: 0 12px 48px rgba(100,20,50,0.16);
  --shadow-xl: 0 24px 80px rgba(100,20,50,0.22);

  --glass:        rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.90);
  --glass-blur:   blur(20px);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius:    18px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --sidebar-w: 260px;
  --font-h: 'Cormorant Garamond', 'Georgia', serif;
  --font:   'DM Sans', system-ui, sans-serif;

  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ── DARK THEME ── */
[data-theme="dark"] {
  --rose:         #E07AA0;
  --rose-mid:     #C96090;
  --rose-light:   #5A2040;
  --rose-glow:    rgba(224,122,160,0.22);

  --bg:           #0E0810;
  --bg-2:         #130B15;
  --surface:      #1C1020;
  --surface-2:    #231428;
  --surface-3:    #2A1830;
  --border:       rgba(224,122,160,0.12);
  --border-strong:rgba(224,122,160,0.28);

  --text-h:       #F8E8F2;
  --text:         #E8D0E0;
  --text-2:       #C0A0B8;
  --text-muted:   #806078;
  --text-inv:     #0E0810;

  --shadow-xs: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --shadow-xl: 0 24px 80px rgba(0,0,0,0.6);

  --glass:        rgba(28,16,32,0.75);
  --glass-border: rgba(224,122,160,0.14);

  --sage:         #5EC490;
  --sage-light:   #1A3A28;
  --amber:        #E49050;
  --violet:       #9B7BC0;
  --gold:         #D4A240;
}

/* ── RESET & BASE ── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  transition: background var(--transition), color var(--transition);
}
::selection { background: var(--rose-glow); color: var(--rose); }
img { max-width: 100%; }
a { color: inherit; }

/* ══ SCROLLBAR ══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

/* ══ APP LAYOUT ══ */
.app-layout { display: flex; min-height: 100vh; }

/* ══ SIDEBAR ══ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; top:0; left:0; bottom:0;
  z-index: 200;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-md);
  transition: background var(--transition), border-color var(--transition);
}
.sidebar-logo {
  padding: 28px 24px 22px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.logo-mark {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--rose), var(--violet));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; box-shadow: 0 4px 12px var(--rose-glow);
  flex-shrink: 0;
}
.logo-text {
  font-family: var(--font-h);
  font-size: 1.55rem; font-weight: 700;
  color: var(--text-h); letter-spacing: -0.5px;
}
.logo-text sub { font-size: 0.55rem; font-weight: 400; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; vertical-align: bottom; margin-left: 2px; }

.sidebar-nav { flex:1; padding: 16px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500; font-size: 0.875rem;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--rose), var(--rose-mid));
  color: #fff;
  box-shadow: 0 4px 16px var(--rose-glow);
}
.nav-item.active .nav-icon { filter: none; }
.nav-icon {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.nav-divider { height: 1px; background: var(--border); margin: 8px 12px; }
.nav-admin { color: var(--violet) !important; }
.nav-admin:hover { background: rgba(122,82,184,0.08) !important; color: var(--violet) !important; }

.sidebar-footer { padding: 14px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.user-ava {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--rose), var(--violet));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
  font-family: var(--font-h);
}
.user-meta { flex:1; min-width:0; }
.user-name { font-weight: 600; font-size: 0.83rem; color: var(--text-h); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-controls { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.theme-toggle {
  flex: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: transparent;
  cursor: pointer; transition: all var(--transition); color: var(--text-muted);
  font-family: var(--font); font-size: 0.78rem; font-weight: 600;
}
.theme-toggle:hover { background: var(--surface-2); border-color: var(--rose); color: var(--text); }
.theme-icon { font-size: 1rem; }
.logout-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: transparent;
  cursor: pointer; color: var(--text-muted); text-decoration: none;
  transition: all var(--transition); font-size: 0.9rem;
}
.logout-btn:hover { background: rgba(200,50,70,0.08); border-color: #e05070; color: #e05070; }

/* ══ MAIN CONTENT ══ */
.main-content {
  /* Base — overridden by responsive block below */
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 36px 40px;
  min-height: 100vh;
}

/* ══ MOBILE NAV ══ */
.mobile-topbar { display: none; }
.mobile-nav { display: none; }

/* ══ PAGE HEADER ══ */
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-family: var(--font-h);
  font-size: 2.2rem; font-weight: 700;
  color: var(--text-h); line-height: 1.15;
  letter-spacing: -0.5px; margin-bottom: 5px;
}
.page-sub { color: var(--text-muted); font-size: 0.9rem; font-weight: 400; }

/* ══ CARDS ══ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card h3 {
  font-family: var(--font-h); font-size: 1.2rem; font-weight: 600;
  color: var(--text-h); margin-bottom: 18px; letter-spacing: -0.2px;
}

/* ══ PHASE CARD ══ */
.phase-card {
  background: linear-gradient(var(--phase-grad, 135deg, #8b2a52, #c2547a));
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  color: white;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
  box-shadow: 0 16px 50px -8px rgba(100,20,50,0.4);
  position: relative; overflow: hidden;
}
.phase-card::before {
  content: ''; position: absolute;
  top: -60px; right: -60px;
  width: 250px; height: 250px;
  background: rgba(255,255,255,0.07);
  border-radius: 50%;
  pointer-events: none;
}
.phase-card::after {
  content: ''; position: absolute;
  bottom: -80px; left: 40%;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  pointer-events: none;
}
.phase-emoji { font-size: 3.2rem; line-height: 1; position: relative; z-index: 1; }
.phase-info { position: relative; z-index: 1; }
.phase-badge {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(10px);
  padding: 4px 12px; border-radius: 30px;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  margin-bottom: 8px;
}
.phase-name { font-family: var(--font-h); font-size: 1.65rem; font-weight: 700; margin-bottom: 4px; line-height: 1.2; }
.phase-tip { font-size: 0.85rem; opacity: 0.82; max-width: 340px; }
.phase-ring-wrap { position: relative; z-index: 1; }
.cycle-ring-svg { width: 88px; height: 88px; }
.ring-track { fill: none; stroke: rgba(255,255,255,0.18); stroke-width: 7; }
.ring-fill  {
  fill: none; stroke: white; stroke-width: 7; stroke-linecap: round;
  /* Rotate so ring starts at 12 o'clock: offset = circ/4 = 66, rotation via transform */
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dasharray 0.8s ease;
}
.ring-num   { font-size: 18px; font-weight: 700; fill: white; dominant-baseline: middle; }
.ring-of    { font-size: 9px; fill: rgba(255,255,255,0.7); }

/* ══ STATS ROW ══ */
.stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 24px; }
.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}
.stat-pill:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--rose-glow); }
.stat-dot {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-dot.red    { background: rgba(181,68,110,0.12); }
.stat-dot.green  { background: rgba(74,155,114,0.12); }
.stat-dot.violet { background: rgba(122,82,184,0.12); }
.stat-val { font-family: var(--font-h); font-size: 1.05rem; font-weight: 700; color: var(--text-h); line-height: 1.2; }
.stat-lbl { font-size: 0.73rem; color: var(--text-muted); margin-top: 2px; }

/* ══ FERTILE BANNER ══ */
.fertile-banner {
  background: linear-gradient(135deg, var(--sage-light), rgba(74,155,114,0.06));
  border: 1px solid rgba(74,155,114,0.3);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
}
.fb-icon { font-size: 2rem; flex-shrink: 0; }
.fb-title { font-weight: 700; font-size: 0.95rem; color: var(--sage); margin-bottom: 2px; }
.fb-sub { font-size: 0.8rem; color: var(--text-muted); }

/* ══ QUICK ACTIONS ══ */
.qa-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 28px; }
.qa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center; text-decoration: none;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
  display: block;
}
.qa-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--rose);
  background: var(--surface-2);
}
.qa-icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; margin: 0 auto 10px; transition: background var(--transition);
}
.qa-card:hover .qa-icon { background: var(--rose-glow); }
.qa-label { font-size: 0.75rem; font-weight: 600; color: var(--text-2); line-height: 1.4; }

/* ══ SECTION TITLE ══ */
.section-hd {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 14px; margin-top: 4px;
}
.section-hd h2 {
  font-family: var(--font-h); font-size: 1.25rem; font-weight: 600;
  color: var(--text-h); letter-spacing: -0.2px;
}
.section-hd a { font-size: 0.8rem; color: var(--rose); text-decoration: none; font-weight: 600; margin-left: auto; }

/* ══ HISTORY LIST ══ */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}
.history-item:hover { box-shadow: var(--shadow-sm); border-color: var(--rose-light); }
.hi-date {
  text-align: center; min-width: 44px;
  background: var(--surface-3); border-radius: 10px; padding: 6px 4px;
}
.hi-day { font-family: var(--font-h); font-size: 1.5rem; font-weight: 700; color: var(--rose); line-height: 1; }
.hi-mon { font-size: 0.65rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; letter-spacing: 0.5px; }
.hi-info { flex:1; }
.hi-title { font-weight: 600; font-size: 0.88rem; color: var(--text-h); }
.hi-meta { font-size: 0.77rem; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hi-edit {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-muted); text-decoration: none; font-size: 0.85rem;
  transition: all var(--transition);
}
.hi-edit:hover { background: var(--rose-glow); border-color: var(--rose); color: var(--rose); }

/* ══ FLOW BADGES ══ */
.flow-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.flow-spotting { background: rgba(181,68,110,0.08); color: var(--rose); }
.flow-light    { background: rgba(181,68,110,0.15); color: var(--rose); }
.flow-medium   { background: rgba(181,68,110,0.25); color: var(--rose); }
.flow-heavy    { background: var(--rose); color: white; }

/* ══ EMPTY STATE ══ */
.empty-state { text-align: center; padding: 60px 30px; }
.empty-icon { font-size: 4rem; margin-bottom: 16px; opacity: 0.7; }
.empty-state h3 { font-family: var(--font-h); font-size: 1.5rem; color: var(--text-h); margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 24px; }

/* ══ BUTTONS ══ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 24px; border-radius: 50px;
  font-family: var(--font); font-size: 0.875rem; font-weight: 700;
  cursor: pointer; text-decoration: none; border: none;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--rose), var(--rose-mid));
  color: white;
  box-shadow: 0 4px 16px var(--rose-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--rose-glow); filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; filter: none; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--rose); color: var(--rose); background: var(--rose-glow); }
.btn-danger {
  background: linear-gradient(135deg, #b03040, #e05060);
  color: white; box-shadow: 0 4px 16px rgba(200,50,70,0.25);
}
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 8px 18px; font-size: 0.82rem; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

/* ══ FORM ELEMENTS ══ */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 600; font-size: 0.83rem; color: var(--text-2); margin-bottom: 7px; letter-spacing: 0.1px; }
.form-label small { font-weight: 400; color: var(--text-muted); }
.form-input {
  width: 100%; padding: 11px 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font); font-size: 0.9rem;
  transition: all var(--transition); outline: none;
}
.form-input:focus { border-color: var(--rose); background: var(--surface); box-shadow: 0 0 0 3px var(--rose-glow); }
.form-input:disabled { opacity: 0.55; cursor: not-allowed; }
textarea.form-input { resize: vertical; min-height: 90px; }
select.form-input { cursor: pointer; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.form-msg {
  padding: 12px 16px; border-radius: var(--radius-xs);
  font-size: 0.86rem; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.form-msg.success { background: rgba(74,155,114,0.1); color: var(--sage); border: 1px solid rgba(74,155,114,0.25); }
.form-msg.error   { background: rgba(200,60,80,0.08); color: #d04060; border: 1px solid rgba(200,60,80,0.2); }

/* ══ FLOW SELECTOR ══ */
.flow-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.flow-opt input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.flow-opt-label {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1.5px solid var(--border);
  border-radius: 30px; cursor: pointer; font-size: 0.82rem; font-weight: 700;
  color: var(--text-muted); transition: all var(--transition);
}
.flow-opt input:checked + .flow-opt-label {
  background: var(--rose); border-color: var(--rose); color: white;
  box-shadow: 0 4px 12px var(--rose-glow);
}
.flow-opt-label:hover { border-color: var(--rose); color: var(--rose); }

/* ══ SYMPTOM CHECKS ══ */
.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px,1fr)); gap: 8px; }
.sym-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  cursor: pointer; font-size: 0.83rem; font-weight: 600; color: var(--text-2);
  transition: all var(--transition); background: var(--surface);
}
.sym-item:hover { border-color: var(--rose); background: var(--surface-2); }
.sym-item input { accent-color: var(--rose); width: 15px; height: 15px; flex-shrink: 0; }
.sym-item:has(input:checked) { border-color: var(--rose); background: var(--rose-glow); color: var(--text); }
.sym-section-title { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px; margin-top: 4px; }

/* ══ MOOD GRID ══ */
.mood-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px,1fr)); gap: 8px; }
.mood-opt { position: relative; }
.mood-opt input { position: absolute; opacity: 0; pointer-events: none; }
.mood-label {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  cursor: pointer; font-size: 0.83rem; font-weight: 600;
  color: var(--text-2); transition: all var(--transition);
  background: var(--surface);
}
.mood-opt input:checked + .mood-label {
  background: linear-gradient(135deg, var(--rose), var(--rose-mid));
  border-color: var(--rose); color: white;
  box-shadow: 0 4px 12px var(--rose-glow);
}
.mood-label:hover { border-color: var(--rose); background: var(--rose-glow); }

/* ══ LOG TABS ══ */
.log-tabs { display: flex; gap: 6px; margin-bottom: 22px; padding: 4px; background: var(--surface-2); border-radius: var(--radius-sm); width: fit-content; }
.log-tab {
  padding: 9px 22px; border: none; background: transparent;
  border-radius: var(--radius-xs); cursor: pointer;
  font-family: var(--font); font-weight: 700; font-size: 0.86rem;
  color: var(--text-muted); transition: all var(--transition);
}
.log-tab.active { background: var(--rose); color: white; box-shadow: 0 4px 12px var(--rose-glow); }
.log-panel { display: none; }
.log-panel.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity:0; transform: translateY(4px); } to { opacity:1; transform: none; } }

/* ══ CALENDAR ══ */
.cal-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.leg-item { display: flex; align-items: center; gap: 7px; font-size: 0.79rem; font-weight: 600; color: var(--text-2); }
.leg-dot { width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0; }

.calendar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}
.cal-nav-bar {
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.cal-nav-bar h2 { font-family: var(--font-h); font-size: 1.25rem; font-weight: 600; color: var(--text-h); }
.cal-arrow {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  cursor: pointer; color: var(--text-muted); font-size: 1rem;
  transition: all var(--transition);
}
.cal-arrow:hover { border-color: var(--rose); color: var(--rose); background: var(--rose-glow); }
.cal-body { padding: 16px 20px 20px; }
.cal-head { display: grid; grid-template-columns: repeat(7,1fr); margin-bottom: 6px; }
.cal-head div { text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; color: var(--text); position: relative;
  transition: all var(--transition);
  user-select: none;
}
.cal-cell:hover:not(.other) { background: var(--surface-3); }
.cal-cell.other { color: var(--border-strong); cursor: default; pointer-events: none; }
.cal-cell.today { outline: 2px solid var(--rose); outline-offset: -2px; color: var(--rose); font-weight: 800; }
.cal-cell.period    { background: #B5446E; color: #fff; box-shadow: 0 2px 8px rgba(181,68,110,0.45); font-weight: 700; }
.cal-cell.period:hover { background: #9b3a5e; }
.cal-cell.predicted { background: rgba(181,68,110,0.22); color: #B5446E; border: 1px dashed #B5446E; }
.cal-cell.fertile   { background: #22a06b; color: #fff; font-weight: 600; }
.cal-cell.fertile:hover { background: #1a8a5a; }
.cal-cell.ovulation { background: #e07b22; color: #fff; box-shadow: 0 2px 8px rgba(224,123,34,0.45); font-weight: 700; }
.cal-cell.ovulation:hover { background: #c86a18; }
/* Dark mode: keep same explicit colors so they stay visible */
[data-theme="dark"] .cal-cell.period    { background: #c2547a; color: #fff; }
[data-theme="dark"] .cal-cell.predicted { background: rgba(194,84,122,0.25); color: #e08aaa; border-color: #e08aaa; }
[data-theme="dark"] .cal-cell.fertile   { background: #2a9b72; color: #fff; }
[data-theme="dark"] .cal-cell.ovulation { background: #e08832; color: #fff; }

/* Day Detail Panel */
.day-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-md);
  margin-top: 16px;
  animation: fadeIn 0.2s ease;
}
.day-detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.day-detail-header h3 { font-family: var(--font-h); font-size: 1.1rem; color: var(--text-h); }
.day-detail-close {
  width: 28px; height: 28px; border: none; background: var(--surface-3);
  border-radius: 7px; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  transition: all var(--transition);
}
.day-detail-close:hover { background: var(--rose-glow); color: var(--rose); }
.day-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.day-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  font-size: 0.8rem; font-weight: 700;
}
.tag-period    { background: rgba(181,68,110,0.12); color: var(--rose); }
.tag-predicted { background: rgba(181,68,110,0.08); color: var(--rose-mid); border: 1px dashed var(--rose); }
.tag-ovulation { background: rgba(212,128,58,0.12); color: var(--amber); }
.tag-fertile   { background: rgba(74,155,114,0.12); color: var(--sage); }
.day-empty { font-size: 0.87rem; color: var(--text-muted); }

/* ══ INSIGHTS ══ */
.insights-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.ig-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px; text-align: center;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition);
}
.ig-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ig-icon { font-size: 1.8rem; margin-bottom: 10px; }
.ig-val { font-family: var(--font-h); font-size: 1.5rem; font-weight: 700; color: var(--rose); line-height: 1; }
.ig-lbl { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; font-weight: 600; line-height: 1.3; }

.chart-card { margin-bottom: 20px; }

.mood-bars { display: flex; flex-direction: column; gap: 12px; }
.mb-row { display: flex; align-items: center; gap: 12px; }
.mb-label { width: 150px; font-size: 0.82rem; font-weight: 600; color: var(--text-2); flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-track { flex:1; height: 8px; background: var(--surface-3); border-radius: 10px; overflow: hidden; }
.mb-fill { height: 100%; border-radius: 10px; transition: width 0.7s cubic-bezier(0.4,0,0.2,1); }
.mb-count { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); min-width: 24px; text-align: right; }

/* ══ PROFILE ══ */
.profile-hero {
  background: linear-gradient(135deg, #5a1e38, #a84e7a, #c97bb8);
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  display: flex; align-items: center; gap: 20px;
  color: white; margin-bottom: 24px;
  box-shadow: var(--shadow-xl); position: relative; overflow: hidden;
}
.profile-hero::before {
  content: ''; position: absolute;
  top: -50px; right: -50px; width: 200px; height: 200px;
  background: rgba(255,255,255,0.06); border-radius: 50%;
}
.profile-hero-ava {
  width: 70px; height: 70px; border-radius: 18px;
  background: rgba(255,255,255,0.2); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-h); font-size: 1.8rem; font-weight: 700;
  flex-shrink: 0; position: relative;
  border: 2px solid rgba(255,255,255,0.3);
}
.profile-hero-name { font-family: var(--font-h); font-size: 1.5rem; font-weight: 700; }
.profile-hero-email { opacity: 0.8; font-size: 0.88rem; }
.profile-hero-since { opacity: 0.6; font-size: 0.75rem; margin-top: 4px; }

/* ══ AUTH PAGE ══ */
body.auth-body { background: var(--bg); }
.auth-wrap { display: flex; min-height: 100vh; }
.auth-side {
  flex: 1; position: relative; overflow: hidden;
  background: linear-gradient(145deg, #2d0a20, #6a1a42, #9b3a6e, #c2547a);
  display: flex; align-items: center; justify-content: center; padding: 48px;
}
.auth-side-art { position: absolute; inset: 0; pointer-events: none; }
.art-orb {
  position: absolute; border-radius: 50%; opacity: 0.12;
  animation: drift 8s ease-in-out infinite;
}
.art-orb-1 { width: 400px; height: 400px; background: white; top: -100px; right: -100px; }
.art-orb-2 { width: 250px; height: 250px; background: white; bottom: 20px; left: -60px; animation-delay: -3s; animation-duration: 10s; }
.art-orb-3 { width: 150px; height: 150px; background: #ffd0e8; top: 45%; left: 35%; animation-delay: -5s; animation-duration: 7s; }
@keyframes drift { 0%,100%{transform:translateY(0) scale(1)} 50%{transform:translateY(-24px) scale(1.03)} }
.auth-side-content { position: relative; z-index: 1; color: white; max-width: 420px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; }
.auth-logo-mark {
  width: 46px; height: 46px; background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px); border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; border: 1px solid rgba(255,255,255,0.25);
}
.auth-logo-name { font-family: var(--font-h); font-size: 1.8rem; font-weight: 700; letter-spacing: -0.5px; }
.auth-headline { font-family: var(--font-h); font-size: 2.6rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.5px; margin-bottom: 14px; }
.auth-sub { opacity: 0.78; font-size: 1rem; margin-bottom: 40px; line-height: 1.6; }
.auth-feats { display: flex; flex-direction: column; gap: 12px; }
.auth-feat { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; font-weight: 500; opacity: 0.88; }
.auth-feat-dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; flex-shrink: 0;
}

.auth-form-side {
  width: 480px; flex-shrink: 0;
  background: var(--surface);
  display: flex; flex-direction: column; justify-content: center;
  padding: 56px 48px;
  overflow-y: auto;
}
.auth-tabs { display: flex; gap: 0; margin-bottom: 32px; border-bottom: 2px solid var(--border); }
.auth-tab {
  flex:1; padding: 12px 0; border: none; background: none;
  font-family: var(--font); font-size: 0.95rem; font-weight: 700;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: all var(--transition);
}
.auth-tab.active { color: var(--rose); border-bottom-color: var(--rose); }
.auth-panel { display: none; }
.auth-panel.active { display: block; animation: fadeIn 0.2s ease; }
.auth-panel h2 { font-family: var(--font-h); font-size: 1.7rem; color: var(--text-h); margin-bottom: 4px; letter-spacing: -0.3px; }
.auth-panel-sub { color: var(--text-muted); font-size: 0.87rem; margin-bottom: 26px; }

/* ══ RESPONSIVE ══ */
@media (max-width: 1200px) {
  .insights-grid { grid-template-columns: repeat(2,1fr); }
  .main-content { padding: 28px 24px; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 230px; }
  .qa-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 260px; transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 199; display: none; }
  .sidebar-overlay.show { display: block; }

  .mobile-topbar {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 0; left: 0; right: 0; height: 58px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 0 16px; z-index: 100; box-shadow: var(--shadow-sm);
  }
  /* Hamburger pinned to left, logo centered absolutely */
  #mob-menu-btn { position: absolute; left: 16px; }
  .mob-logo {
    font-family: var(--font-h); font-size: 1.3rem; font-weight: 700;
    color: var(--text-h); display: flex; align-items: center; gap: 8px;
    position: absolute; left: 50%; transform: translateX(-50%);
  }
  .mob-logo-mark { width: 28px; height: 28px; background: linear-gradient(135deg,var(--rose),var(--violet)); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
  .mob-actions { display: flex; align-items: center; gap: 8px; }
  .mob-btn {
    width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface-2); cursor: pointer; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
    transition: all var(--transition);
  }
  .mob-btn:hover { border-color: var(--rose); color: var(--rose); }
  .mob-menu-btn { font-size: 1.1rem; }

  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    z-index: 100; padding: 6px 8px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  }
  .mnav-item {
    flex:1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 4px; text-decoration: none; color: var(--text-muted);
    font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    border-radius: var(--radius-xs); transition: color var(--transition);
  }
  .mnav-item .mi-icon { font-size: 1.25rem; }
  .mnav-item.active { color: var(--rose); }
  .mnav-fab {
    flex: 0 0 56px; display: flex; align-items: center; justify-content: center;
    width: 54px; height: 54px; margin: -16px 6px 0;
    background: linear-gradient(135deg, var(--rose), var(--rose-mid));
    border-radius: 16px; text-decoration: none; color: white;
    font-size: 1.5rem; font-weight: 300;
    box-shadow: 0 6px 20px var(--rose-glow);
  }

  .main-content { margin-left: 0; padding: 80px 16px 90px; }
  .phase-card { grid-template-columns: auto 1fr; }
  .phase-ring-wrap { display: none; }
  .stats-row { grid-template-columns: repeat(3,1fr); gap: 10px; }
  .stat-pill { flex-direction: column; text-align: center; padding: 14px 10px; gap: 6px; }
  .stat-dot { margin: 0 auto; }
  .qa-grid { grid-template-columns: repeat(4,1fr); gap: 8px; }
  .qa-card { padding: 14px 8px; }
  .insights-grid { grid-template-columns: repeat(2,1fr); }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .auth-wrap { flex-direction: column; }
  .auth-side { min-height: 240px; flex: none; padding: 32px 24px; }
  .auth-headline { font-size: 1.8rem; }
  .auth-feats { display: none; }
  .auth-form-side { width: 100%; padding: 32px 24px; }
  .page-header h1 { font-size: 1.65rem; }
}

@media (max-width: 480px) {
  .qa-grid { grid-template-columns: repeat(2,1fr); }
  .sym-grid { grid-template-columns: repeat(2,1fr); }
  .mood-grid { grid-template-columns: repeat(2,1fr); }
  .log-tabs { width: 100%; }
  .log-tab { flex:1; text-align: center; }
}

/* ══ MODAL ══════════════════════════════════ */
.luna-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.luna-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.luna-modal-box {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px;
  max-height: 85vh; overflow-y: auto;
  animation: modalIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn {
  from { opacity:0; transform: scale(0.92) translateY(20px); }
  to   { opacity:1; transform: none; }
}
.lm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.lm-header h3 {
  font-family: var(--font-h); font-size: 1.1rem; color: var(--text-h);
}
.lm-close {
  width: 28px; height: 28px; border: none;
  background: var(--surface-3); border-radius: 7px;
  cursor: pointer; color: var(--text-muted); font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.lm-close:hover { background: var(--rose-glow); color: var(--rose); }
.lm-body { padding: 18px 22px; }
.lm-footer {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.lm-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.lm-row  { display: flex; align-items: flex-start; gap: 10px; font-size: 0.87rem; }
.lm-full { flex-direction: column; gap: 4px; }
.lm-key  { font-weight: 700; color: var(--text-2); min-width: 90px; flex-shrink: 0; }
.lm-val  { color: var(--text); }
.lm-notes { color: var(--text-muted); font-style: italic; }
.lm-section-title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 10px; margin-top: 4px;
}
.lm-sym-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.lm-sym-tag {
  background: var(--rose-glow); color: var(--rose);
  padding: 4px 11px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 700;
}
.lm-empty { font-size: 0.85rem; color: var(--text-muted); }

/* ══ LANG SWITCHER ══════════════════════════ */
.lang-switcher {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; margin-bottom: 8px;
  border-radius: var(--radius-xs);
  background: var(--surface-2); border: 1px solid var(--border);
}
.lang-icon { font-size: 0.9rem; color: var(--text-muted); }
.lang-btn {
  font-size: 0.76rem; font-weight: 800; color: var(--text-muted);
  text-decoration: none; letter-spacing: 0.5px; padding: 2px 6px;
  border-radius: 5px; transition: all var(--transition);
}
.lang-btn:hover { color: var(--rose); background: var(--rose-glow); }
.lang-btn.active { color: var(--rose); background: var(--rose-glow); }
.lang-sep { color: var(--border-strong); font-size: 0.8rem; }

/* ══ LAYOUT: full-width desktop fix ════════ */
.app-layout { width: 100%; }
.main-content { width: 100%; box-sizing: border-box; }

/* inner max-width for readability */
.page-inner {
  max-width: 860px;
}

/* ══ MOBILE TOPBAR adjustments ══════════════ */
@media (max-width: 768px) {
  .mob-actions { display: flex; align-items: center; gap: 6px; }
}

/* ══ MODAL mobile ════════════════════════════ */
@media (max-width: 480px) {
  .luna-modal-box { max-width: 100%; border-radius: var(--radius); }
  .lm-footer { flex-direction: column; }
  .lm-footer .btn { width: 100%; justify-content: center; }
}

/* ── MODAL ───────────────────────────────── */
.luna-modal {
  position:fixed;inset:0;z-index:1000;
  display:flex;align-items:center;justify-content:center;padding:20px;
}
.lm-backdrop {
  position:absolute;inset:0;
  background:rgba(0,0,0,0.55);backdrop-filter:blur(4px);cursor:pointer;
}
.lm-box {
  position:relative;z-index:1;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-lg);box-shadow:var(--shadow-xl);
  width:100%;max-width:480px;max-height:85vh;overflow-y:auto;
  animation:lmIn .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes lmIn{from{opacity:0;transform:scale(.92) translateY(20px)}to{opacity:1;transform:none}}
.lm-head{display:flex;align-items:center;justify-content:space-between;padding:20px 22px 16px;border-bottom:1px solid var(--border);}
.lm-head h3{font-family:var(--font-h);font-size:1.1rem;color:var(--text-h);}
.lm-close{width:28px;height:28px;border:none;background:var(--surface-3);border-radius:7px;cursor:pointer;color:var(--text-muted);font-size:.8rem;display:flex;align-items:center;justify-content:center;transition:all var(--transition);}
.lm-close:hover{background:var(--rose-glow);color:var(--rose);}
.lm-body{padding:18px 22px;}
.lm-foot{padding:14px 22px 18px;border-top:1px solid var(--border);display:flex;gap:10px;flex-wrap:wrap;}
.lm-grid{display:flex;flex-direction:column;gap:10px;margin-bottom:16px;}
.lm-row{display:flex;align-items:flex-start;gap:10px;font-size:.87rem;}
.lm-full{flex-direction:column;gap:4px;}
.lm-key{font-weight:700;color:var(--text-2);min-width:90px;flex-shrink:0;}
.lm-val{color:var(--text);}
.lm-notes{color:var(--text-muted);font-style:italic;}
.lm-section-title{font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.8px;color:var(--text-muted);margin-bottom:10px;margin-top:4px;}
.lm-sym-tags{display:flex;flex-wrap:wrap;gap:7px;}
.lm-sym-tag{background:var(--rose-glow);color:var(--rose);padding:4px 11px;border-radius:20px;font-size:.78rem;font-weight:700;}
.lm-empty{font-size:.85rem;color:var(--text-muted);}

/* ── LANG SWITCHER ───────────────────────── */
.lang-switcher{display:flex;align-items:center;gap:6px;padding:7px 12px;margin-bottom:8px;border-radius:var(--radius-xs);background:var(--surface-2);border:1px solid var(--border);}
.lang-icon{font-size:.9rem;color:var(--text-muted);}
.lang-btn{font-size:.76rem;font-weight:800;color:var(--text-muted);text-decoration:none;letter-spacing:.5px;padding:2px 6px;border-radius:5px;transition:all var(--transition);}
.lang-btn:hover,.lang-btn.active{color:var(--rose);background:var(--rose-glow);}
.lang-sep{color:var(--border-strong);font-size:.8rem;}

/* ── AUTH PAGE EXTRAS ────────────────────── */
.auth-top-controls{position:absolute;top:20px;right:20px;display:flex;gap:8px;align-items:center;}
.auth-lang-btn{font-size:.78rem;font-weight:700;color:var(--text-muted);text-decoration:none;padding:6px 10px;border:1px solid var(--border);border-radius:8px;background:var(--surface-2);transition:all var(--transition);}
.auth-lang-btn:hover{border-color:var(--rose);color:var(--rose);}
.auth-theme-btn{width:34px;height:34px;border-radius:9px;border:1px solid var(--border);background:var(--surface-2);cursor:pointer;font-size:1rem;display:flex;align-items:center;justify-content:center;transition:all var(--transition);}
.auth-theme-btn:hover{border-color:var(--rose);}
@media(max-width:768px){.auth-top-controls{display:none;}}
.auth-switch{margin-top:16px;text-align:center;font-size:.82rem;color:var(--text-muted);}
.auth-switch a{color:var(--rose);font-weight:700;text-decoration:none;}

/* ══════════════════════════════════════════════════════════
   LAYOUT — Desktop responsive, no horizontal scroll
   ══════════════════════════════════════════════════════════ */

/* Body never overflows */
html { overflow-x: hidden; }
body { overflow-x: hidden; }

/* Main content area: fills space right of sidebar exactly */
.main-content {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-width: 0;                    /* critical: allows shrinking below content width */
  box-sizing: border-box;
  padding: 36px 40px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* All direct children respect the container */
.main-content > * {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Grids use minmax(0,1fr) so cells never force overflow */
.qa-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stats-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.insights-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Phase card — ring never overflows */
.phase-card {
  min-width: 0;
  overflow: hidden;
}
.phase-ring-wrap { flex-shrink: 0; min-width: 0; }
.phase-info { min-width: 0; flex: 1; }

/* Cards */
.card { min-width: 0; overflow: hidden; word-break: break-word; }

/* History items wrap */
.history-item { flex-wrap: wrap; }
.hi-meta { flex-wrap: wrap; gap: 6px; }

/* Flow picker wraps */
.flow-picker { flex-wrap: wrap; }

/* Mood grid wraps */
.mood-grid { flex-wrap: wrap; }

/* Symptom grid — flexible columns */
.sym-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* Calendar wraps */
.calendar-wrap { min-width: 0; overflow-x: auto; }
.cal-body { min-width: 280px; }

/* Charts */
.chart-card { min-width: 0; overflow: hidden; }
.chart-card canvas { max-width: 100% !important; }

/* Profile hero */
.profile-hero { flex-wrap: wrap; gap: 16px; align-items: flex-start; min-width: 0; }

/* Responsive breakpoints — desktop */
@media (max-width: 1200px) {
  .main-content { padding: 28px 28px; }
  .qa-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .main-content { padding: 24px 20px; }
}
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-2 { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 74px 16px 90px;
  }
}
@media (max-width: 480px) {
  .qa-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── HISTORY ITEM CURSOR ─────────────── */
.history-item[data-pid] { cursor: pointer; }
.history-item[data-pid]:hover { box-shadow: var(--shadow-md); border-color: var(--rose-light); }
.hi-note { color: var(--text-muted); font-style: italic; }

/* ── AVATAR ──────────────────────────── */
.profile-avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.profile-hero-img {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--rose-light);
  display: block;
}
.avatar-edit-btn {
  position: absolute; bottom: -4px; right: -4px;
  width: 26px; height: 26px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: .75rem; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.avatar-edit-btn:hover { background: var(--rose-glow); }
.avatar-remove-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: .78rem;
  cursor: pointer; padding: 4px 0;
  text-decoration: underline; display: block;
}
.avatar-remove-btn:hover { color: var(--rose); }
.btn-link { background: none; border: none; cursor: pointer; }

/* ── MODAL mobile ────────────────────── */
@media (max-width: 480px) {
  .luna-modal { padding: 12px; }
  .lm-box { max-height: 90vh; }
}
