:root {
  color-scheme: dark light;
  --bg: #1a0f2e;
  --bg-2: #211640;
  --card: #2a1b4d;
  --card-2: #322059;
  --line: #3d2970;
  --text: #f3eaff;
  --muted: #a897c7;
  --purple: #a78bfa;
  --purple-2: #8b5cf6;
  --peach: #e89373;
  --peach-2: #f2a88c;
  --good: #6ee7b7;
  --fair: #fbbf24;
  --poor: #f87171;
  --page-bg: #000;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #FAF7FF;
    --bg-2: #F0EBFA;
    --card: #FFFFFF;
    --card-2: #F4EEFF;
    --line: #E1D4F2;
    --text: #1A0F2E;
    --muted: #6B5B8C;
    --purple: #7C4DFF;
    --purple-2: #5A2FCC;
    --peach: #D97757;
    --peach-2: #E89373;
    --good: #16A374;
    --fair: #D97706;
    --poor: #DC2626;
    --page-bg: #F0EBFA;
  }
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a0f2e; --bg-2: #211640; --card: #2a1b4d; --card-2: #322059;
  --line: #3d2970; --text: #f3eaff; --muted: #a897c7;
  --purple: #a78bfa; --purple-2: #8b5cf6;
  --peach: #e89373; --peach-2: #f2a88c;
  --good: #6ee7b7; --fair: #fbbf24; --poor: #f87171;
  --page-bg: #000;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.phone {
  width: 100%;
  max-width: 420px;
  min-height: 90vh;
  background: var(--bg);
  border-radius: 32px;
  box-shadow: 0 30px 80px rgba(123, 58, 245, 0.25), 0 0 0 1px rgba(167, 139, 250, 0.1);
  overflow: hidden;
  position: relative;
  padding-bottom: 80px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px 4px;
  font-size: 14px;
  font-weight: 600;
}
.status-bar .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--purple);
}
.settings-btn {
  background: rgba(167,139,250,0.15); color: var(--purple);
  border: 1px solid var(--line); border-radius: 50%;
  width: 28px; height: 28px; font-size: 14px; cursor: pointer;
  display: grid; place-items: center;
}
.settings-btn:hover { background: rgba(167,139,250,0.25); }

.screen {
  padding: 18px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen.hidden { display: none; }

/* Header */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.top h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.2px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }

.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #d6b8f5, #7a3cd1);
  display: grid; place-items: center;
  color: #fff; font-weight: 700;
  flex-shrink: 0;
}
.avatar-lulla {
  background: radial-gradient(circle at 30% 30%, #f9e3b9, #8b5cf6);
  font-size: 22px;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--peach), var(--peach-2));
  color: #fff;
  border: none;
  padding: 14px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(232, 147, 115, 0.28);
  transition: transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); }
.pill-btn { background: linear-gradient(135deg, var(--purple-2), var(--purple)); box-shadow: 0 6px 18px rgba(139, 92, 246, 0.3); }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}

.chip {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.link {
  background: none;
  border: none;
  color: var(--purple);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  text-align: left;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card h3 { font-size: 15px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.chev { color: var(--muted); font-size: 20px; }
.bullets { padding-left: 18px; font-size: 13px; color: var(--muted); }
.bullets li { margin: 2px 0; }

.baby-card { flex-direction: row; align-items: flex-start; gap: 12px; background: linear-gradient(135deg, #38226e, #2a1b4d); }
.baby-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f6b89e, #b46fec);
  flex-shrink: 0;
}

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.stat strong { font-size: 18px; font-weight: 700; }
.stat-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.5);
}
.score-dot { width: 36px; height: 36px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 16px rgba(167, 139, 250, 0.6); margin-bottom: 8px; }

/* Recommended box */
.rec-box { background: var(--card-2); padding: 14px; border-radius: 14px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.tag { display: inline-block; background: rgba(167, 139, 250, 0.2); color: var(--purple); font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; align-self: flex-start; letter-spacing: 0.3px; }
.rec-box h4 { font-size: 17px; font-weight: 700; }

/* Recent list */
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); padding: 12px; border-radius: 14px;
  border: 1px solid var(--line);
}
.recent-item .rdot { width: 28px; height: 28px; border-radius: 50%; background: var(--purple); flex-shrink: 0; }
.recent-item.night .rdot { background: linear-gradient(135deg, #5a3da0, #7a3cd1); }
.recent-item .label { font-weight: 600; font-size: 14px; }
.recent-item .times { color: var(--muted); font-size: 12px; }
.empty { text-align: center; padding: 12px 0; }

/* Insight */
.insight { display: flex; flex-direction: column; align-items: center; padding: 10px 0; }
.insight h2 { font-size: 40px; font-weight: 800; letter-spacing: -1px; }

/* Tips */
.tip { display: flex; gap: 12px; align-items: flex-start; background: var(--card-2); padding: 12px; border-radius: 14px; border: 1px solid var(--line); }
.tip-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--purple-2); margin-top: 4px; flex-shrink: 0; }
.tip strong { font-size: 14px; }

/* Footer note */
.footer-note { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 0 6px; }

/* Nav */
.nav {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(26, 15, 46, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 10px 4px 14px;
}
.nav-btn {
  background: none; border: none;
  color: var(--muted);
  font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer;
  padding: 4px;
  font-weight: 500;
}
.nav-btn span { font-size: 20px; }
.nav-btn.active { color: var(--text); font-weight: 700; }
.nav-btn.active span { color: var(--purple); }

/* Segmented control */
.segmented {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  display: flex;
  gap: 4px;
}
.segmented .seg {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.segmented .seg.active {
  background: var(--card-2);
  color: var(--text);
  border-color: var(--purple);
}
.pill-seg .seg { padding: 8px 10px; font-size: 12px; }

/* Forms */
.form { gap: 14px; }
.toggle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle input { display: none; }
.toggle > div {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; cursor: pointer; font-weight: 600;
}
.toggle input:checked + div { border-color: var(--purple); background: rgba(139, 92, 246, 0.1); }
.toggle .dot { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
.toggle .dot.peach { background: var(--peach); }
.toggle .dot.purple { background: var(--purple); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field input, .form textarea {
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 14px; font-family: inherit;
}
.field input::placeholder, textarea::placeholder { color: var(--muted); }

.pill-row { display: flex; gap: 8px; }
.pill input { display: none; }
.pill span {
  display: inline-block; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.pill input:checked + span { border-color: var(--purple); color: var(--purple); }
.pill:nth-child(2) input:checked + span { border-color: var(--fair); color: var(--fair); }
.pill:nth-child(3) input:checked + span { border-color: var(--poor); color: var(--poor); }

/* Education */
.edu-pane { display: flex; flex-direction: column; gap: 14px; }
.edu-pane.hidden { display: none; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--purple); }
.check input:checked + span { text-decoration: line-through; color: var(--muted); }
.kb { gap: 8px; }

/* Log panes */
.log-pane.hidden { display: none; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day { background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; font-size: 11px; }
.cal-day strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 4px; }
.cal-day.has-sleep { background: rgba(139, 92, 246, 0.15); border-color: var(--purple); }

/* Chat */
.chat-screen { position: relative; min-height: calc(100vh - 40px); }
.stars {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1.5px 1.5px at 20% 15%, #fff 100%, transparent),
    radial-gradient(1px 1px at 75% 25%, rgba(255,255,255,0.8) 100%, transparent),
    radial-gradient(1.5px 1.5px at 40% 50%, #e5d5fa 100%, transparent),
    radial-gradient(1px 1px at 85% 60%, rgba(255,255,255,0.6) 100%, transparent),
    radial-gradient(1.5px 1.5px at 15% 80%, #fff 100%, transparent),
    radial-gradient(1px 1px at 60% 85%, rgba(255,255,255,0.7) 100%, transparent);
  background-size: 100% 100%;
  opacity: 0.6;
}
.chat-screen > * { position: relative; z-index: 1; }

.chat-log { display: flex; flex-direction: column; gap: 14px; padding: 8px 0; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.bot-avatar { width: 32px; height: 32px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #f9e3b9, #8b5cf6); display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.bubble {
  background: rgba(139, 92, 246, 0.25);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 280px;
}
.msg.user .bubble { background: rgba(232, 147, 115, 0.25); border-color: rgba(232, 147, 115, 0.4); }
.msg .time { color: var(--muted); font-size: 11px; padding: 2px 8px; display: block; }

.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.suggestions::-webkit-scrollbar { display: none; }
.suggestions .chip { flex-shrink: 0; }

.chat-input {
  display: flex; gap: 8px; align-items: center;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
  margin-top: auto;
}
.chat-input input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 14px; padding: 10px 0;
}
.chat-input button {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-2), var(--purple));
  border: none; color: #fff; font-size: 15px; cursor: pointer;
}

/* Stats specific */
.score-x { width: 40px; height: 40px; border-radius: 50%; background: var(--purple); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.champion { background: linear-gradient(135deg, #4a2c89, #6a3aa8); align-items: center; text-align: center; }
.champ-orb {
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f2c2a8, #a78bfa);
  box-shadow: 0 0 40px rgba(167, 139, 250, 0.5);
  margin: 10px auto;
}

.bar-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 80px; padding-top: 8px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; background: linear-gradient(180deg, var(--purple), var(--purple-2)); border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.3s; }
.bar-col span { font-size: 10px; color: var(--muted); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: grid; place-items: center;
  padding: 20px; z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  display: flex; flex-direction: column; gap: 14px;
}
.modal-box h3 { font-size: 17px; font-weight: 700; }
.reason-block { display: flex; flex-direction: column; gap: 4px; }
.reason-block strong { color: var(--purple); font-size: 13px; }
.reason-block.trust { background: rgba(139, 92, 246, 0.1); padding: 10px; border-radius: 10px; border: 1px solid var(--line); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.modal-actions .full, .btn-primary.full, .btn-secondary.full { grid-column: 1 / -1; }

/* Legal / disclaimer modals */
.legal-modal { max-width: 420px; max-height: 85vh; }
.legal-modal .legal-emoji { font-size: 32px; text-align: center; }
.legal-modal p { font-size: 14px; line-height: 1.55; color: var(--text-2, #cfc7df); }
.legal-modal p strong { color: var(--text, #fff); }
.legal-body { overflow-y: auto; max-height: 55vh; padding-right: 6px; }
.legal-body p { margin: 0 0 10px 0; }
.legal-body p:last-child { margin-bottom: 0; }

/* Toast */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--purple-2); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.4);
  z-index: 200;
  animation: fadeUp 0.3s ease;
}
.toast.hidden { display: none; }
@keyframes fadeUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

textarea { resize: none; }

/* ============ Onboarding overlay ============ */
.onb {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #1a0f2e, #2a1b4d);
  z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  overflow-y: auto;
}
.onb.hidden { display: none; }
.onb-inner {
  width: 100%;
  max-width: 360px;
  display: flex; flex-direction: column; gap: 16px;
}
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.onb-dots div { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.onb-dots div.active { background: var(--purple); width: 20px; border-radius: 4px; }
.onb-step { display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: center; }
.onb-step.hidden { display: none; }
.onb-step h1 { font-size: 22px; font-weight: 700; }
.onb-step .field { text-align: left; }
.onb-emoji { font-size: 56px; text-align: center; padding: 12px 0; }
.onb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

/* SweetSpot predictive banner */
.sweetspot { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; margin: 12px 0; font-size: 14px; font-weight: 600; border: 1px solid; }
.sweetspot .ss-emoji { font-size: 24px; }
.sweetspot .ss-body { flex: 1; }
.sweetspot .ss-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.sweetspot .ss-sub { font-size: 12px; font-weight: 500; opacity: 0.85; }
.sweetspot.tone-good { background: rgba(110, 231, 183, 0.12); border-color: var(--good); color: var(--good); }
.sweetspot.tone-warn { background: rgba(251, 191, 36, 0.12); border-color: var(--fair); color: var(--fair); }
.sweetspot.tone-bad  { background: rgba(248, 113, 113, 0.14); border-color: var(--poor); color: var(--poor); }
.sweetspot.tone-info { background: rgba(167, 139, 250, 0.10); border-color: var(--line); color: var(--text); }
.quick-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-bottom: 14px; }
.quick-nap { font-size: 15px; }

/* Challenge picker */
.challenge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.challenge-opt { display: flex; align-items: center; justify-content: center; text-align: center; padding: 14px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; font-size: 13px; font-weight: 600; min-height: 56px; }
.challenge-opt input { display: none; }
.challenge-opt:has(input:checked) { border-color: var(--purple); background: rgba(167,139,250,0.15); color: var(--purple); }

/* Nav SVG icons */
.nav-icon { width: 22px; height: 22px; margin-bottom: 2px; color: var(--muted); transition: color 200ms, transform 200ms; }
.nav-btn.active .nav-icon { color: var(--purple); transform: translateY(-2px); filter: drop-shadow(0 0 6px rgba(167,139,250,0.4)); }
.nav-btn { transition: transform 120ms ease; }
.nav-btn:active { transform: scale(0.94); }

/* Chat bubbles */
.msg .bubble { border-radius: 18px; padding: 10px 14px; max-width: 78%; line-height: 1.45; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.msg.bot .bubble { background: linear-gradient(135deg, var(--card), var(--card-2)); border: 1px solid rgba(167,139,250,0.22); border-top-left-radius: 4px; }
.msg.user .bubble { background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: #fff; border-top-right-radius: 4px; }
.msg.user .bubble { box-shadow: 0 2px 8px rgba(139,92,246,0.35); }
.bot-avatar { box-shadow: 0 2px 6px rgba(0,0,0,0.25); }

/* Knowledge card colored chips */
.card.kb { position: relative; overflow: hidden; }
.card.kb::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--purple), var(--peach)); }
.card.kb .tag { background: linear-gradient(135deg, rgba(167,139,250,0.22), rgba(232,147,115,0.18)); color: var(--purple); border: 1px solid rgba(167,139,250,0.3); }

/* Onboarding stars */
.onb { position: relative; }
.onb::before { content: ''; position: absolute; inset: 0; background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, #F3EAFF, transparent 50%),
    radial-gradient(1px 1px at 70% 15%, #F3EAFF, transparent 50%),
    radial-gradient(1.2px 1.2px at 40% 60%, #F3EAFF, transparent 50%),
    radial-gradient(0.8px 0.8px at 85% 45%, #F3EAFF, transparent 50%),
    radial-gradient(1px 1px at 15% 80%, #F3EAFF, transparent 50%),
    radial-gradient(1.3px 1.3px at 60% 85%, #F3EAFF, transparent 50%);
  opacity: 0.4; pointer-events: none; }
.onb-inner { position: relative; z-index: 1; }

/* Micro-interactions */
.btn-primary, .btn-secondary, .btn-siwa, .btn-google, .btn-facebook, .chip, .challenge-opt { transition: transform 120ms ease, box-shadow 200ms, border-color 200ms; }
.btn-primary:active, .btn-secondary:active, .btn-siwa:active, .btn-google:active, .btn-facebook:active, .chip:active { transform: scale(0.97); }
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at center, rgba(255,255,255,0.25), transparent 60%); opacity: 0; transition: opacity 300ms; }
.btn-primary:hover::after { opacity: 1; }
.card { transition: transform 200ms ease; }
.recent-item:hover { transform: translateX(2px); }

/* Confetti container */
#confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; width: 8px; height: 14px; opacity: 0.9; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(120vh) rotate(720deg); opacity: 0; } }

/* Recent session duration bars + quality dots */
.recent-bar { height: 4px; background: rgba(167,139,250,0.12); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.recent-bar-fill { height: 100%; border-radius: 2px; transition: width 600ms ease; }
.recent-bar-fill.q-good { background: linear-gradient(90deg, var(--good), #34d399); }
.recent-bar-fill.q-fair { background: linear-gradient(90deg, var(--fair), #f59e0b); }
.recent-bar-fill.q-poor { background: linear-gradient(90deg, var(--poor), #ef4444); }
.rdot.q-good { background: var(--good); box-shadow: 0 0 8px rgba(110,231,183,0.5); }
.rdot.q-fair { background: var(--fair); box-shadow: 0 0 8px rgba(251,191,36,0.4); }
.rdot.q-poor { background: var(--poor); box-shadow: 0 0 8px rgba(248,113,113,0.4); }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px 10px; text-align: center; }
.empty-state p { margin: 0; max-width: 240px; }

/* Avatar gradient ring */
.avatar { position: relative; }
.avatar::before { content: ''; position: absolute; inset: -3px; border-radius: 50%; background: conic-gradient(from 45deg, var(--purple), var(--peach), var(--purple)); z-index: -1; }

/* Decorative sky header */
.home-header { position: relative; padding-top: 36px !important; overflow: hidden; }
.deco-sky { position: absolute; top: 0; left: -28px; right: -28px; width: calc(100% + 56px); height: 90px; z-index: 0; pointer-events: none; }
.home-header > *:not(.deco-sky) { position: relative; z-index: 1; }

/* 24-hour timeline */
.day-timeline { margin-top: 12px; }
#day-bar { width: 100%; height: 18px; border-radius: 6px; background: var(--card-2); display: block; }
.day-legend { display: flex; justify-content: space-between; margin-top: 6px; }
.day-legend .legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* Score ring */
.score-ring-wrap { position: relative; width: 140px; height: 140px; margin: 8px auto; }
.score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: var(--card-2); stroke-width: 10; }
.score-ring .ring-fg { fill: none; stroke: var(--purple); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 314.16; stroke-dashoffset: 314.16; transition: stroke-dashoffset 900ms cubic-bezier(0.4, 0, 0.2, 1); filter: drop-shadow(0 0 6px rgba(167,139,250,0.55)); }
.score-ring.good .ring-fg { stroke: var(--good); filter: drop-shadow(0 0 6px rgba(110,231,183,0.5)); }
.score-ring.fair .ring-fg { stroke: var(--fair); filter: drop-shadow(0 0 6px rgba(251,191,36,0.45)); }
.score-ring.poor .ring-fg { stroke: var(--poor); filter: drop-shadow(0 0 6px rgba(248,113,113,0.5)); }
.score-ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring-center h2 { font-size: 32px; font-weight: 800; margin: 0; background: linear-gradient(135deg, var(--purple), var(--peach)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-ring-center p { margin-top: -4px; }

/* Weekly trend sparkline */
.week-spark { width: 100%; height: 30px; margin-top: 10px; display: block; }
.week-spark path { fill: none; stroke: var(--purple); stroke-width: 1.5; }
.week-spark .baseline { stroke: var(--line); stroke-dasharray: 2 3; stroke-width: 1; }
.week-spark circle { fill: var(--purple); }
.week-spark-labels { display: flex; justify-content: space-between; margin-top: 4px; font-size: 10px; }

/* Daily focus card */
.focus-card { background: linear-gradient(135deg, rgba(167,139,250,0.18), rgba(139,92,246,0.08)); border: 1px solid var(--line); }
.focus-card .focus-label { text-transform: uppercase; font-size: 10px; letter-spacing: 1px; color: var(--purple); font-weight: 700; }
.focus-card h3 { margin: 4px 0 6px; }

/* Onboarding / auth overlay — force brand dark palette regardless of system theme */
.onb {
  background: #1A0F2E;
  color: #F3EAFF;
}
.onb .muted, .onb .small { color: #A897C7; }
.onb-step h1, .onb-step h3, .onb-step p, .onb-step label, .onb-step .field > span { color: #F3EAFF; }
.onb input[type="text"], .onb input[type="email"], .onb input[type="password"], .onb input[type="date"], .onb .date-btn, .onb select {
  background: #2A1B4D; color: #F3EAFF; border: 1px solid #3D2970;
}
.onb input::placeholder { color: #8878A8; }
.onb .btn-secondary { background: transparent; color: #F3EAFF; border: 1px solid #3D2970; }
.onb .link-btn { color: #A78BFA; }
.onb-dots div { background: #3D2970; }
.onb-dots div.active { background: #A78BFA; }

/* Auth */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--card-2); padding: 4px; border-radius: 12px; margin: 10px 0 6px; }
.auth-tab { background: transparent; color: var(--muted); border: none; padding: 10px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.auth-tab.active { background: var(--purple); color: #fff; }
.link-btn { background: transparent; border: none; color: var(--purple); text-decoration: underline; font-size: 13px; cursor: pointer; padding: 8px; }
.btn-siwa, .btn-google, .btn-facebook { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 12px; font-size: 14px; font-weight: 600; cursor: pointer; width: 100%; border: 1px solid transparent; }
.btn-siwa { background: #000; color: #fff; border-color: #000; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.btn-google .g-logo { background: linear-gradient(135deg, #4285F4 0%, #EA4335 45%, #FBBC05 70%, #34A853 100%); color: #fff; width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.btn-facebook { background: #1877F2; color: #fff; border-color: #1877F2; }
.btn-facebook > span:first-child { width: 20px; height: 20px; background: #fff; color: #1877F2; border-radius: 4px; display: grid; place-items: center; font-weight: 900; font-size: 14px; }
.btn-siwa span:first-child { font-size: 18px; }
@media (prefers-color-scheme: light) {
  .btn-siwa { background: #000; color: #fff; }
}
.checkbox-field { display: flex; flex-direction: row; align-items: center; gap: 10px; text-align: left; }
.checkbox-field input[type="checkbox"] { width: 20px; height: 20px; }

/* Select */
.select {
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; width: 100%;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path fill='%23a897c7' d='M4 6l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Slider */
.slider {
  width: 100%; height: 4px;
  appearance: none; -webkit-appearance: none;
  background: linear-gradient(90deg, var(--purple), var(--peach));
  border-radius: 999px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer;
}
.slider-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Switch row */
.switch-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 6px 0; cursor: pointer;
}
.switch {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 26px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.switch::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.switch:checked { background: rgba(167,139,250,0.3); border-color: var(--purple); }
.switch:checked::before { background: var(--purple); transform: translateX(18px); }

/* Settings danger */
.btn-secondary.danger { color: var(--poor); border-color: rgba(248,113,113,0.4); }
.btn-secondary.danger:hover { background: rgba(248,113,113,0.1); }
.muted.center { text-align: center; margin-top: 8px; }

/* AI mode badge */
.ai-badge {
  background: linear-gradient(135deg, var(--purple), var(--peach));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: auto;
  opacity: 0.5;
  letter-spacing: 0.5px;
}
.ai-badge.active { opacity: 1; box-shadow: 0 0 12px rgba(167,139,250,0.5); }

/* Citation in chat */
.bubble .cite {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(139,92,246,0.15);
  border-left: 2px solid var(--purple);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
}
.bubble .cite a { color: var(--purple); text-decoration: none; }

/* Date picker button */
.date-btn {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-btn::before { content: '📅'; font-size: 16px; }
.date-btn:hover { border-color: var(--purple); }
.date-btn.empty { color: var(--muted); }

/* Date picker modal */
.date-modal-box {
  max-width: 340px;
  gap: 10px;
}
.date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}
.date-nav {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 36px; height: 36px;
  font-size: 20px; cursor: pointer;
  font-weight: 600;
}
.date-nav:hover { border-color: var(--purple); }
.date-title {
  flex: 1;
  background: transparent;
  color: var(--text);
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}
.date-title:hover { background: rgba(167,139,250,0.1); }
.date-weekdays, .date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.date-weekdays div {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 0;
  text-transform: uppercase;
}
.date-cell {
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 10px;
  height: 38px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s;
}
.date-cell:hover { background: var(--card-2); }
.date-cell.other { color: var(--muted); opacity: 0.4; }
.date-cell.today { border: 1px solid var(--purple); font-weight: 700; }
.date-cell.selected { background: var(--purple); color: #fff; font-weight: 700; }
.date-cell.disabled { color: var(--muted); opacity: 0.3; cursor: not-allowed; }
.date-shortcuts {
  display: flex; gap: 8px; justify-content: center;
  margin-top: 4px;
}
.date-year-list {
  max-height: 240px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.date-year-list button {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 4px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.date-year-list button:hover { border-color: var(--purple); }
.date-year-list button.selected { background: var(--purple); color: #fff; font-weight: 700; }

/* RTL support */
html[dir="rtl"] .top { flex-direction: row-reverse; }
html[dir="rtl"] .msg.user { flex-direction: row; }
html[dir="rtl"] .msg.bot { flex-direction: row-reverse; }
html[dir="rtl"] .chat-input { direction: rtl; }
html[dir="rtl"] .chev { transform: scaleX(-1); }
html[dir="rtl"] .nav-btn span:first-child { }
html[dir="rtl"] .bullets { padding-left: 0; padding-right: 18px; }
html[dir="rtl"] .select { background-position: left 14px center; padding-right: 14px; padding-left: 36px; }
html[dir="rtl"] .ai-badge { margin-left: 0; margin-right: auto; }
