/* ============================================================
   APP PAGES — Auth, Journal, Chat, Dashboard, Settings
   V3 Luminous Stillness Design
   ============================================================ */

/* App Shell */
.app-main {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding-top: 96px;
}

.app-navbar { z-index: 100; }
.nav-link.active { color: var(--cream); }
.nav-link.active::after { width: 100%; }
.nav-user { font-size: 14px; color: var(--muted); margin-right: 12px; }
.nav-logout {
    background: none; border: 1px solid rgba(255,255,255,0.08);
    color: var(--muted); padding: 6px 16px; border-radius: 16px;
    font-size: 13px; cursor: pointer; transition: all 0.3s;
}
.nav-logout:hover { color: var(--cream); border-color: rgba(255,255,255,0.15); }

/* Page container */
.page-container { max-width: 1200px; margin: 0 auto; padding: 0 40px 80px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; flex-wrap: wrap; gap: 16px; }
.page-title { font-family: var(--font-serif); font-size: 36px; font-weight: 700; color: var(--cream); }
.page-subtitle { font-size: 15px; color: var(--muted); margin-top: 4px; }
.back-link { display: inline-block; color: var(--muted); font-size: 14px; margin-bottom: 24px; transition: color 0.3s; }
.back-link:hover { color: var(--cream); }

/* Loading & errors */
.page-loading { display: flex; justify-content: center; padding: 60px; }
.spinner { width: 32px; height: 32px; border: 2px solid rgba(255,255,255,0.08); border-top-color: var(--lavender); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { text-align: center; padding: 60px 20px; }
.error-state h2 { font-family: var(--font-serif); color: var(--cream); margin-bottom: 8px; }
.error-state p { color: var(--muted); margin-bottom: 20px; }
.empty-state { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--font-serif); color: var(--cream); margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin-bottom: 24px; max-width: 400px; margin-left: auto; margin-right: auto; }

/* ============================================================
   HOME PAGE — Bento Grid Dashboard
   ============================================================ */
.home-page { max-width: 1200px; margin: 0 auto; padding: 0 40px 80px; }

.home-hero { margin-bottom: 48px; display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 32px; }
.home-hero-content { flex: 1; min-width: 300px; }

.home-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px; border-radius: 20px; margin-bottom: 24px;
    font-size: 13px; color: var(--muted);
}
.home-badge .status-dot { width: 8px; height: 8px; background: var(--sage); border-radius: 50%; animation: pulse-glow 2s ease-in-out infinite; }

.home-greeting {
    font-family: var(--font-serif);
    font-size: clamp(36px, 5vw, 64px);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 12px;
}

.home-sub { font-size: 18px; color: var(--muted); }

.home-quick-stats { display: flex; gap: 12px; flex-shrink: 0; }
.home-stat { padding: 20px 28px; border-radius: 16px; text-align: center; min-width: 100px; }
.home-stat-value { font-family: var(--font-serif); font-size: 28px; color: var(--cream); margin-bottom: 4px; }
.home-stat-label { font-size: 12px; color: var(--dim); text-transform: capitalize; }

/* Bento grid */
.home-bento {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: auto auto;
    gap: 16px;
    margin-bottom: 48px;
}

.bento-card {
    padding: 28px;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.4s var(--ease-out);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.bento-card:hover { transform: translateY(-4px); border-color: rgba(255,255,255,0.12); }

.bento-large { grid-column: span 3; grid-row: span 2; padding: 36px; }
.bento-medium { grid-column: span 3; }
.bento-small { grid-column: span 2; }

.bento-icon { margin-bottom: 20px; }
.bento-icon-sm { font-size: 28px; margin-bottom: 10px; }

.bento-card h2 { font-family: var(--font-serif); font-size: 28px; color: var(--cream); margin-bottom: 12px; line-height: 1.2; }
.bento-card h3 { font-family: var(--font-serif); font-size: 22px; color: var(--cream); margin-bottom: 8px; }
.bento-card h4 { font-family: var(--font-serif); font-size: 16px; color: var(--cream); margin-bottom: 4px; }
.bento-card p { font-size: 14px; color: var(--muted); line-height: 1.5; flex: 1; }

.bento-cta {
    margin-top: 20px;
    font-size: 15px; font-weight: 600; color: var(--sage);
    display: flex; align-items: center; gap: 6px;
    transition: gap 0.3s;
}
.bento-card:hover .bento-cta { gap: 12px; }
.bento-cta span { transition: transform 0.3s; }
.bento-card:hover .bento-cta span { transform: translateX(4px); }

.bento-cta-sm { font-size: 13px; color: var(--lavender); margin-top: 12px; }
.bento-status { font-size: 12px; color: var(--sage); display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.bento-status .status-dot { width: 6px; height: 6px; background: var(--sage); border-radius: 50%; animation: pulse-glow 2s ease-in-out infinite; }

/* Recent entries */
.home-recent { margin-bottom: 32px; }
.home-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.home-section-header h3 { font-family: var(--font-serif); font-size: 20px; color: var(--cream); }
.home-view-all { font-size: 14px; color: var(--lavender); transition: color 0.3s; }
.home-view-all:hover { color: var(--lavender-bright); }

.home-entries-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.home-entry-card { padding: 20px; border-radius: 16px; text-decoration: none; transition: all 0.3s var(--ease-out); }
.home-entry-card:hover { transform: translateY(-2px); border-color: rgba(180,160,230,0.15); }
.home-entry-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.home-entry-date { font-size: 12px; color: var(--dim); }
.home-entry-emotion { font-size: 16px; }
.home-entry-card h4 { font-family: var(--font-serif); font-size: 15px; color: var(--cream); margin-bottom: 6px; }
.home-entry-card p { font-size: 13px; color: var(--muted); line-height: 1.4; }
.home-empty-entries { padding: 32px; border-radius: 16px; text-align: center; }
.home-empty-entries p { font-size: 14px; color: var(--muted); }
.home-empty-entries a { color: var(--lavender); font-weight: 600; }

/* Inspiration card */
.home-inspiration {
    padding: 40px;
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    text-align: center;
}
.inspiration-quote {
    font-family: var(--font-serif);
    font-size: 80px;
    color: rgba(180, 160, 230, 0.08);
    position: absolute;
    top: -10px;
    left: 20px;
    line-height: 1;
    pointer-events: none;
}
.home-inspiration blockquote p {
    font-family: var(--font-serif);
    font-size: 20px;
    font-style: italic;
    color: var(--cream);
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto 12px;
}
.home-inspiration cite {
    font-size: 14px;
    color: var(--muted);
    font-style: normal;
}

@media (max-width: 1024px) {
    .home-bento { grid-template-columns: repeat(4, 1fr); }
    .bento-large { grid-column: span 4; grid-row: span 1; }
    .bento-medium { grid-column: span 2; }
    .bento-small { grid-column: span 2; }
    .home-entries-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .home-page { padding: 0 20px 60px; }
    .home-hero { flex-direction: column; align-items: flex-start; }
    .home-quick-stats { width: 100%; }
    .home-bento { grid-template-columns: 1fr 1fr; }
    .bento-large { grid-column: span 2; }
    .bento-medium { grid-column: span 2; }
    .bento-small { grid-column: span 1; }
    .home-entries-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 70vh; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 440px; padding: 48px 40px; border-radius: 24px; }
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-header h1 { font-family: var(--font-serif); font-size: 28px; color: var(--cream); margin-bottom: 8px; }
.auth-header p { color: var(--muted); font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 20px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 14px; color: var(--muted); }
.auth-footer a { color: var(--lavender); font-weight: 500; }
.auth-footer a:hover { color: var(--lavender-bright); }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; }
.form-input {
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; padding: 14px 16px; color: var(--text); font-size: 15px;
    font-family: var(--font-sans); outline: none; transition: all 0.3s;
}
.form-input:focus { border-color: var(--lavender); box-shadow: 0 0 0 3px rgba(180,160,230,0.1); }
.form-input::placeholder { color: var(--dim); }
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }
.form-hint { font-size: 12px; color: var(--dim); }
.form-error { color: #EF4444; font-size: 14px; min-height: 20px; }
.form-select {
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px; padding: 10px 14px; color: var(--text); font-size: 14px;
    font-family: var(--font-sans); outline: none; cursor: pointer;
}
.btn-full { width: 100%; }
.btn-sm { padding: 10px 20px; font-size: 14px; }

/* ============================================================
   JOURNAL PAGES
   ============================================================ */
.journal-list { display: flex; flex-direction: column; gap: 12px; }
.journal-card-link { text-decoration: none; }
.journal-list-card { padding: 24px; border-radius: 16px; cursor: pointer; transition: all 0.3s var(--ease-out); }
.journal-list-card:hover { transform: translateY(-2px); border-color: rgba(180,160,230,0.2); }
.journal-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.journal-card-date { font-size: 13px; color: var(--dim); }
.journal-card-title { font-family: var(--font-serif); font-size: 18px; color: var(--cream); margin-bottom: 6px; }
.journal-card-preview { font-size: 14px; color: var(--muted); line-height: 1.5; }

/* Emotion badge */
.emotion-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 32px; }
.pagination-info { font-size: 14px; color: var(--muted); }

/* Theme picker */
.theme-picker { margin-bottom: 20px; }
.theme-picker-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; display: block; }
.theme-options { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-option {
    display: flex; align-items: center; gap: 6px; padding: 8px 14px;
    border-radius: 12px; border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03); cursor: pointer; transition: all 0.3s;
    font-size: 12px; color: var(--muted); font-family: var(--font-sans);
}
.theme-option:hover { border-color: rgba(255,255,255,0.15); }
.theme-option.active { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.06); color: var(--cream); }
.theme-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.theme-name { white-space: nowrap; }

/* Journal editor */
.journal-editor { padding: 32px; border-radius: 20px; transition: all 0.5s; }
.journal-title-input {
    width: 100%; background: none; border: none; font-family: var(--font-serif);
    font-size: 24px; font-weight: 700; color: var(--cream); outline: none;
    padding-bottom: 16px;
}
.journal-title-input::placeholder { color: var(--dim); }
.journal-content-input {
    width: 100%; min-height: 300px; background: none; border: none;
    font-family: var(--font-sans); font-size: 16px; color: var(--text);
    line-height: 1.8; outline: none; resize: none;
}
.journal-content-input::placeholder { color: var(--dim); }
.journal-editor-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.06); }
.word-count { font-size: 13px; color: var(--dim); }

/* Journal view */
.journal-view { padding: 40px; border-radius: 24px; margin-bottom: 24px; }
.journal-view-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.journal-view-title { font-family: var(--font-serif); font-size: 28px; color: var(--cream); }
.journal-view-date { font-size: 14px; color: var(--dim); display: block; margin-top: 4px; }
.journal-view-content { font-size: 16px; color: var(--text); line-height: 1.8; }
.journal-view-actions { margin-top: 32px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.06); }

/* Emotion result */
.emotion-result { padding: 28px; border-radius: 20px; margin-top: 24px; }
.emotion-result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.emotion-primary { display: flex; align-items: center; gap: 12px; }
.emotion-primary-emoji { font-size: 40px; }
.emotion-primary-label { font-family: var(--font-serif); font-size: 20px; color: var(--cream); text-transform: capitalize; }
.emotion-primary-conf { font-size: 14px; color: var(--muted); }
.emotion-sentiment { display: flex; align-items: center; gap: 8px; }
.sentiment-pill { padding: 4px 14px; border-radius: 12px; font-size: 13px; font-weight: 600; text-transform: capitalize; }
.sentiment-pill.positive { background: rgba(52,211,153,0.12); color: #34D399; }
.sentiment-pill.negative { background: rgba(239,68,68,0.12); color: #EF4444; }
.sentiment-pill.neutral { background: rgba(148,163,184,0.12); color: #94A3B8; }
.sentiment-score { font-size: 13px; color: var(--dim); }
.emotion-bars-container { display: flex; flex-direction: column; gap: 8px; }
.emo-bar-row { display: flex; align-items: center; gap: 12px; }
.emo-bar-label { width: 100px; font-size: 13px; color: var(--muted); text-transform: capitalize; flex-shrink: 0; }
.emo-bar-track { flex: 1; height: 8px; background: rgba(255,255,255,0.05); border-radius: 4px; overflow: hidden; }
.emo-bar-fill { height: 100%; border-radius: 4px; transition: width 1s ease-out; }
.emo-bar-pct { width: 36px; text-align: right; font-size: 12px; color: var(--dim); }
.ai-feedback { margin-top: 24px; padding: 20px; background: rgba(180,160,230,0.06); border-left: 3px solid var(--lavender); border-radius: 0 12px 12px 0; }
.ai-feedback-label { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; color: var(--lavender); margin-bottom: 8px; }
.ai-feedback p { font-size: 15px; color: var(--muted); line-height: 1.6; }

/* ============================================================
   CHAT PAGE
   ============================================================ */
/* While on the chat route, lock the page so ONLY the messages list scrolls.
   Other routes (journal, dashboard) keep their normal page scrolling. */
body.chat-active {
    overflow: hidden;
    height: 100vh;
}
body.chat-active .app-main {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}

/* ChatGPT-style containment: only the messages list scrolls. */
.chat-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: calc(100vh - 96px);
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}
.chat-sidebar { padding: 20px; border-radius: 20px; overflow-y: auto; height: 100%; }
.chat-sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.chat-sidebar-header h3 { font-family: var(--font-serif); font-size: 18px; color: var(--cream); }
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; transition: all 0.3s; display: flex; }
.btn-icon:hover { color: var(--cream); background: rgba(255,255,255,0.05); }
.chat-sessions { display: flex; flex-direction: column; gap: 4px; }
.chat-session-item { padding: 12px 14px; border-radius: 12px; cursor: pointer; transition: all 0.3s; display: flex; align-items: center; gap: 8px; }
.chat-session-item:hover { background: rgba(255,255,255,0.04); }
.chat-session-item.active { background: rgba(180,160,230,0.08); border: 1px solid rgba(180,160,230,0.12); }
.chat-session-content { flex: 1; min-width: 0; }
.chat-session-title { font-size: 14px; color: var(--text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-session-date { font-size: 12px; color: var(--dim); }
.chat-session-delete {
    background: transparent; border: 0; color: rgba(245,240,255,0.45);
    width: 26px; height: 26px; border-radius: 6px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 180ms ease, background 180ms ease, color 180ms ease;
    flex-shrink: 0;
}
.chat-session-item:hover .chat-session-delete { opacity: 1; }
.chat-session-delete:hover { background: rgba(192,75,75,0.18); color: #FF8A8A; }
.chat-session-delete:focus-visible { opacity: 1; outline: 2px solid #FF8A8A; outline-offset: 2px; }
.chat-no-sessions { font-size: 14px; color: var(--dim); padding: 20px 0; text-align: center; }

.chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.chat-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: 16px; margin-bottom: 8px; flex-shrink: 0; }
.chat-sidebar-toggle { display: none; }
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-header-info strong { color: var(--cream); font-size: 15px; display: block; }
.chat-ai-avatar { width: 36px; height: 36px; border-radius: 50%; background: rgba(180,160,230,0.15); display: flex; align-items: center; justify-content: center; color: var(--lavender); font-weight: 700; font-size: 13px; }
.chat-status { font-size: 12px; color: var(--sage); display: flex; align-items: center; gap: 4px; }
.status-dot { width: 6px; height: 6px; background: var(--sage); border-radius: 50%; animation: pulse-glow 2s ease-in-out infinite; }

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(180,160,230,0.25) transparent;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(180,160,230,0.18);
    border-radius: 999px;
    transition: background 0.2s;
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(180,160,230,0.35); }

#chat-end-anchor {
    height: 1px;
    width: 100%;
    flex-shrink: 0;
    scroll-margin-bottom: 8px;
}

.chat-welcome { text-align: center; padding: 80px 20px; }
.chat-welcome-icon { font-size: 48px; margin-bottom: 12px; }
.chat-welcome h3 { font-family: var(--font-serif); color: var(--cream); margin-bottom: 8px; }
.chat-welcome p { color: var(--muted); font-size: 15px; }

.chat-bubble { max-width: 70%; }
.chat-bubble.user { align-self: flex-end; }
.chat-bubble.ai { align-self: flex-start; }
.bubble-content { padding: 14px 18px; border-radius: 18px; font-size: 15px; line-height: 1.6; }
.chat-bubble.user .bubble-content { background: rgba(180,160,230,0.15); border: 1px solid rgba(180,160,230,0.1); color: var(--text); border-bottom-right-radius: 6px; }
.chat-bubble.ai .bubble-content { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); color: var(--text); border-bottom-left-radius: 6px; }
.bubble-meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; padding: 0 4px; }
.bubble-time { font-size: 11px; color: var(--dim); }
.bubble-emotion { font-size: 12px; }

/* Typing indicator */
.typing-dots { display: flex; gap: 4px; padding: 14px 18px; }
.typing-dots span { width: 8px; height: 8px; background: var(--muted); border-radius: 50%; animation: typingBounce 1.4s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

.chat-input-area {
    flex-shrink: 0;
    padding: 12px 0 16px;
    background: linear-gradient(to top, rgba(8, 8, 18, 0.92) 60%, rgba(8, 8, 18, 0));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: relative;
    z-index: 2;
}
.chat-disclaimer { font-size: 11px; color: var(--dim); text-align: center; margin-bottom: 8px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-input { flex: 1; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; padding: 14px 18px; color: var(--text); font-size: 15px; font-family: var(--font-sans); outline: none; resize: none; max-height: 120px; transition: border-color 0.3s; }
.chat-input:focus { border-color: var(--lavender); }
.chat-input::placeholder { color: var(--dim); }
.btn-sage-round { width: 48px; height: 48px; border-radius: 50%; background: var(--sage); border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s; color: #0a1208; flex-shrink: 0; }
.btn-sage-round:hover { background: var(--sage-bright); transform: scale(1.05); }
.btn-sage-round:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.dash-stat { padding: 24px; border-radius: 16px; text-align: center; }
.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-value { font-family: var(--font-serif); font-size: 22px; color: var(--cream); text-transform: capitalize; margin-bottom: 4px; }
.stat-desc { font-size: 13px; color: var(--dim); }

.dash-charts { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 40px; }
.dash-chart-card { padding: 28px; border-radius: 20px; }
.dash-chart-card h3 { font-family: var(--font-serif); font-size: 18px; color: var(--cream); margin-bottom: 16px; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.chart-range-tabs { display: flex; gap: 4px; }
.range-tab { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); border-radius: 8px; padding: 6px 14px; color: var(--muted); font-size: 13px; cursor: pointer; transition: all 0.3s; font-family: var(--font-sans); }
.range-tab.active { background: rgba(180,160,230,0.12); color: var(--lavender); border-color: rgba(180,160,230,0.2); }
.chart-container { position: relative; height: 260px; }

.dash-insights h3 { font-family: var(--font-serif); font-size: 22px; color: var(--cream); margin-bottom: 16px; }
.insights-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.insight-card { padding: 24px; border-radius: 16px; }
.insight-icon { font-size: 24px; margin-bottom: 8px; display: block; }
.insight-card h4 { font-family: var(--font-serif); color: var(--cream); margin-bottom: 6px; }
.insight-card p { font-size: 14px; color: var(--muted); line-height: 1.5; }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-section { padding: 28px; border-radius: 20px; margin-bottom: 20px; }
.settings-section h3 { font-family: var(--font-serif); font-size: 20px; color: var(--cream); margin-bottom: 20px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,0.04); gap: 16px; }
.setting-row:last-child { border-bottom: none; }
.setting-info strong { display: block; color: var(--cream); font-size: 15px; margin-bottom: 2px; }
.setting-info p { color: var(--muted); font-size: 13px; }
.security-badge { font-size: 13px; color: var(--sage); }
.settings-danger { border: 1px solid rgba(239,68,68,0.15); }
.settings-danger h3 { color: #EF4444; }
.btn-danger { background: rgba(239,68,68,0.12); color: #EF4444; border: 1px solid rgba(239,68,68,0.2); padding: 10px 20px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s; font-family: var(--font-sans); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

/* Toggle switch */
.toggle { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle input { display: none; }
.toggle-slider { position: absolute; inset: 0; background: rgba(255,255,255,0.08); border-radius: 26px; cursor: pointer; transition: all 0.3s; }
.toggle-slider::before { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: var(--muted); border-radius: 50%; transition: all 0.3s; }
.toggle input:checked + .toggle-slider { background: rgba(140,180,130,0.25); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); background: var(--sage); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); display: none; justify-content: center; align-items: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal { max-width: 480px; width: 100%; padding: 36px; border-radius: 24px; text-align: center; }
.modal h2 { font-family: var(--font-serif); color: var(--cream); margin-bottom: 12px; }
.modal p { color: var(--muted); font-size: 15px; margin-bottom: 16px; }
.crisis-resources { text-align: left; margin: 20px 0; display: flex; flex-direction: column; gap: 10px; }
.crisis-item { font-size: 15px; color: var(--text); }
.crisis-item a { color: var(--sage); font-weight: 600; }
.crisis-note { font-size: 13px; color: var(--dim); font-style: italic; }

/* ============================================================
   TOAST
   ============================================================ */
#toast-container { position: fixed; top: 100px; right: 20px; z-index: 1001; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 14px 20px; border-radius: 12px; font-size: 14px; backdrop-filter: blur(16px); opacity: 0; transform: translateX(100%); transition: all 0.3s var(--ease-out); pointer-events: auto; }
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: rgba(140,180,130,0.15); border: 1px solid rgba(140,180,130,0.2); color: var(--sage-bright); }
.toast-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.2); color: #FCA5A5; }
.toast-info { background: rgba(180,160,230,0.15); border: 1px solid rgba(180,160,230,0.2); color: var(--lavender-bright); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .chat-layout { grid-template-columns: 1fr; }
    .chat-sidebar { position: fixed; left: -320px; top: 90px; bottom: 0; width: 300px; z-index: 50; border-radius: 0 20px 20px 0; transition: left 0.3s var(--ease-out); }
    .chat-sidebar.open { left: 0; }
    .chat-sidebar-toggle { display: flex; }
    .dash-charts { grid-template-columns: 1fr; }
    .dash-stats { grid-template-columns: repeat(2, 1fr); }
    .insights-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .page-container { padding: 0 20px 60px; }
    .dash-stats { grid-template-columns: 1fr 1fr; }
    .chat-bubble { max-width: 85%; }
    .auth-card { padding: 32px 24px; }
    .settings-section { padding: 20px; }
    .setting-row { flex-direction: column; align-items: flex-start; }

    /* Mobile navbar is shorter, so tighten the app-main top-offset */
    .app-main { padding-top: 78px; }

    /* Mobile chat: tighter top-offset, less side padding */
    .chat-layout { height: calc(100vh - 78px); padding: 0 12px; }
    .chat-messages { padding: 16px 14px 24px; }
    .chat-header { padding: 12px 14px; }
}

/* ============================================================
   OAUTH BUTTONS + FORGOT/RESET PASSWORD
   ============================================================ */

/* HTML `hidden` attribute must win over our explicit display rules
   (.auth-form, .auth-success, etc. set display:flex which would otherwise
   override the browser's default `[hidden] { display: none }`). */
[hidden] { display: none !important; }

/* Stack of provider buttons */
.oauth-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}
.oauth-slot { min-height: 44px; display: flex; align-items: stretch; }
.oauth-slot > div,
.oauth-slot > iframe,
.oauth-slot > button { width: 100% !important; }

/* Custom OAuth button (used for Apple — Google renders its own widget) */
.btn-oauth {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 20px;
    border-radius: 28px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: var(--cream);
    text-decoration: none;
    backdrop-filter: blur(10px);
}
.btn-oauth:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.18);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.btn-oauth:disabled,
.btn-oauth-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-oauth-disabled:hover {
    transform: none;
    box-shadow: none;
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.1);
}
.btn-oauth-apple { background: #000; border-color: #000; color: #fff; }
.btn-oauth-apple:hover { background: #111; border-color: #222; }
.oauth-icon { flex-shrink: 0; }

/* Divider with text — "or sign in with email" */
.oauth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 4px 0 22px;
    font-size: 12px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.oauth-divider::before,
.oauth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
}
.oauth-divider span { white-space: nowrap; }

/* Form label row — label + "Forgot password?" link on opposite ends */
.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}
.form-label-link {
    font-size: 12px;
    color: var(--lavender);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}
.form-label-link:hover { color: var(--lavender-bright); }

/* Ghost button — used for "Back to sign in" on success screens */
.btn-ghost {
    background: rgba(255,255,255,0.03);
    color: var(--muted);
    border: 1px solid rgba(255,255,255,0.08);
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.06);
    color: var(--cream);
    border-color: rgba(255,255,255,0.15);
}

/* Success state shared by forgot/reset password */
.auth-success {
    text-align: center;
    padding: 8px 4px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: auth-success-in 0.5s var(--ease-out);
}
.auth-success-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 30%, rgba(140,180,130,0.25), rgba(180,160,230,0.18));
    color: var(--sage-bright, var(--sage));
    border: 1px solid rgba(140,180,130,0.25);
    box-shadow: 0 0 40px rgba(140,180,130,0.15);
    margin-bottom: 4px;
}
.auth-success h2 {
    font-family: var(--font-serif);
    font-size: 22px;
    color: var(--cream);
    margin: 0;
}
.auth-success p {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
    max-width: 320px;
}
.auth-success-hint {
    font-size: 12px !important;
    color: var(--dim) !important;
}
.auth-success .btn {
    margin-top: 12px;
    width: 100%;
}
@keyframes auth-success-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Mobile */
@media (max-width: 480px) {
    .oauth-divider { font-size: 11px; letter-spacing: 0.1em; }
    .btn-oauth { font-size: 14px; padding: 12px 18px; }
}
