/* ==========================================================================
   ROOT VARIABLES & THEME
   ========================================================================== */
:root {
    --bg-color: #f4f7fb; 
    --surface-color: rgba(255, 255, 255, 0.85); 
    --text-primary: #1e293b; 
    --text-secondary: #64748b;
    --accent-color: #3b82f6; 
    --accent-hover: #2563eb; 
    --danger-color: #ef4444; 
    --danger-bg: rgba(254, 242, 242, 0.9);
    --border-color: rgba(203, 213, 225, 0.6); 
    --glass-blur: blur(20px);
    
    --heatmap-0: #e2e8f0; 
    --heatmap-1: #bfdbfe; 
    --heatmap-2: #60a5fa; 
    --heatmap-3: #3b82f6; 
    --heatmap-4: #1d4ed8;
}

body.dark-mode {
    --bg-color: #0f172a; 
    --surface-color: rgba(30, 41, 59, 0.85); 
    --text-primary: #f1f5f9; 
    --text-secondary: #94a3b8;
    --accent-color: #60a5fa; 
    --accent-hover: #3b82f6; 
    --danger-color: #f87171; 
    --danger-bg: rgba(69, 26, 26, 0.9);
    --border-color: rgba(51, 65, 85, 0.6);
    
    --heatmap-0: #1e293b; 
    --heatmap-1: #1e3a8a; 
    --heatmap-2: #2563eb; 
    --heatmap-3: #3b82f6; 
    --heatmap-4: #60a5fa;
}

/* ==========================================================================
   GLOBAL STYLES & RESETS
   ========================================================================== */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    /* THIS STOPS TEXT LEAKING: */
    overflow-wrap: break-word; 
}

body { 
    background-color: var(--bg-color); 
    color: var(--text-primary); 
    transition: background-color 0.3s ease, color 0.3s ease; 
    padding-bottom: 120px; /* Space for nav */
    min-height: 100vh; 
    position: relative; 
    overflow-x: hidden; 
    line-height: 1.6;
}

/* Background Mesh Animation */
.bg-mesh { 
    position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; z-index: -1; 
    background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 40%), 
                radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.1) 0%, transparent 30%); 
    animation: rotateMesh 30s linear infinite; 
    pointer-events: none; 
}
@keyframes rotateMesh { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */
h1, h2, h3, h4 { line-height: 1.3; }
h2 { font-weight: 800; font-size: 1.6rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.15rem; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 8px; font-weight: 700; }

.small-text { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 1.2rem; }
.quote-text { font-size: 1.05rem; font-style: italic; color: var(--text-secondary); line-height: 1.5; margin-top: 0.5rem; font-weight: 500; }
.section-title { font-size: 0.9rem; font-weight: 700; color: var(--text-secondary); margin: 1.5rem 0 1rem 0; text-transform: uppercase; letter-spacing: 1px; }

/* Inline Icon sizing fix */
.icon-inline { width: 18px; height: 18px; vertical-align: -3px; display: inline-block; }

/* ==========================================================================
   LAYOUT CONTAINERS
   ========================================================================== */
header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; max-width: 700px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 0.8rem; } 
.logo-dot { width: 14px; height: 14px; background: var(--accent-color); border-radius: 50%; box-shadow: 0 0 10px var(--accent-color); }
header h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; }

.header-actions { display: flex; align-items: center; gap: 0.8rem; }
.streak-badge { display: flex; align-items: center; gap: 5px; background: rgba(245, 158, 11, 0.15); color: #d97706; padding: 6px 14px; border-radius: 20px; font-weight: 700; font-size: 0.9rem; border: 1px solid rgba(245, 158, 11, 0.3); }

#app-container { max-width: 700px; margin: 0 auto; padding: 0 1rem; position: relative; z-index: 10; }
.page-header { margin-bottom: 1.5rem; }

/* ==========================================================================
   CARDS & UI BLOCKS
   ========================================================================== */
.diagnostic-disclaimer {
	font-size: 10pt;
	color: grey;
	}

.card { 
    background: var(--surface-color); 
    backdrop-filter: var(--glass-blur); 
    -webkit-backdrop-filter: var(--glass-blur); 
    border-radius: 24px; 
    padding: 1.5rem; 
    margin-bottom: 1.5rem; 
    border: 1px solid var(--border-color); 
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03); 
    overflow: hidden; /* Stops inner elements leaking out of borders */
}
.insight-glow { border-left: 4px solid var(--accent-color); background: linear-gradient(90deg, rgba(59, 130, 246, 0.05) 0%, transparent 100%); }

.view { display: none; } 
.active-view { display: block; animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */
button, .file-upload-btn { 
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s, background 0.2s, color 0.2s !important; 
    font-family: inherit;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
button:active, .file-upload-btn:active { transform: scale(0.96) !important; }

.primary-btn { width: 100%; padding: 1.1rem; background: var(--accent-color); color: white; border: none; border-radius: 16px; font-size: 1.05rem; font-weight: 700; cursor: pointer; box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35); }
.primary-btn:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5); }

.secondary-btn { flex: 1; padding: 1rem; background: transparent; color: var(--text-primary); border: 2px solid var(--border-color); border-radius: 14px; font-weight: 700; cursor: pointer; text-align: center; }
.secondary-btn:hover { border-color: var(--accent-color); color: var(--accent-color); }

.danger-btn { width: 100%; padding: 1rem; background: var(--danger-bg); color: var(--danger-color); border: 1px solid var(--danger-color); border-radius: 14px; font-weight: 700; cursor: pointer; }

.ghost-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-weight: 700; font-size: 0.9rem; padding: 6px 10px; margin-left: -10px; border-radius: 8px; }
.ghost-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); } 
body.dark-mode .ghost-btn:hover { background: rgba(255,255,255,0.1); }

.button-row { display: flex; gap: 1rem; flex-wrap: wrap; } 
.file-upload-btn { cursor: pointer; margin: 0; }

#theme-toggle, .nav-item-top { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 8px; border-radius: 50%; } 
#theme-toggle:hover, .nav-item-top:hover { background: var(--border-color); }

/* ==========================================================================
   DASHBOARD SPECIFICS
   ========================================================================== */
.mood-emojis { 
    display: flex; 
    justify-content: space-between; 
    gap: 0.5rem; 
    margin-top: 1.5rem; 
    overflow-x: auto; /* Fixes tiny screen leaking */
    padding-bottom: 0.5rem;
}
.mood-btn { 
    background: none; border: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; 
    filter: grayscale(100%) opacity(0.4); 
    min-width: 50px;
}
.mood-btn .emoji { font-size: 2.5rem; } 
.mood-btn .mood-label { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); }
.mood-btn:hover, .mood-btn.selected { filter: grayscale(0%) opacity(1); transform: translateY(-5px) scale(1.1); } 
.mood-btn.selected .mood-label { color: var(--accent-color); }

/* Quick Relief Grid */
.quick-action-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); /* Stops text leaking! */
    gap: 1rem; 
}
.quick-action-btn { 
    background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 20px; 
    padding: 1.2rem 0.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.8rem; 
    cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.02); 
    text-align: center;
}
.quick-action-btn:hover { transform: translateY(-5px); border-color: var(--accent-color); box-shadow: 0 8px 25px rgba(59, 130, 246, 0.1); }
.quick-action-btn span { font-weight: 700; font-size: 0.85rem; color: var(--text-primary); line-height: 1.2;}

.icon-wrap { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bg-blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.bg-green { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.bg-purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

/* ==========================================================================
   CHECK-IN WIZARD & SLIDERS
   ========================================================================== */
.wizard-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; flex-wrap: wrap; gap: 10px; }
.progress-track { flex-grow: 1; min-width: 100px; height: 6px; background: var(--heatmap-0); margin: 0 1rem; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent-color); width: 33.33%; transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1); border-radius: 3px; }
.step-text { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }

.checkin-step { display: none; animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; } 
.checkin-step.active-step { display: block; }

.biometric-grid { display: grid; gap: 1rem; margin-bottom: 2rem; margin-top: 1rem; grid-template-columns: 1fr; }
.slider-group { background: rgba(0,0,0,0.02); padding: 1.2rem 1rem; border-radius: 16px; border: 1px solid rgba(0,0,0,0.04); } 
body.dark-mode .slider-group { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04); }
.slider-group label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 1.2rem; font-weight: 700; font-size: 0.95rem; } 
.slider-group label span { font-weight: 500; color: var(--text-secondary); font-size: 0.8rem; line-height: 1.2; }

/* Sleeker Sliders */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 8px; background: var(--border-color); border-radius: 4px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 20px; width: 20px; border-radius: 50%; background: var(--accent-color); margin-top: -6px; box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
input[type=range]:focus { outline: none; }

/* ==========================================================================
   AI & DATA VISUALS
   ========================================================================== */
.ai-card { border: 2px solid rgba(59, 130, 246, 0.2); box-shadow: 0 10px 40px rgba(59, 130, 246, 0.1); }
.rec-header { display: flex; align-items: center; gap: 15px; margin-bottom: 1.5rem; }
.ai-confidence { font-size: 0.8rem; font-weight: 700; color: var(--accent-color); background: rgba(59,130,246,0.1); padding: 4px 10px; border-radius: 12px; display: inline-block; margin-top: 5px; }

.ai-summary strong { display: block; font-size: 1.2rem; margin-bottom: 5px; }
.ai-insight-list { margin: 1.5rem 0; background: rgba(0,0,0,0.02); padding: 1rem; border-radius: 12px; border: 1px solid rgba(0,0,0,0.05); }
body.dark-mode .ai-insight-list { background: rgba(255,255,255,0.02); border-color: rgba(255,255,255,0.05); }
.ai-insight { margin-bottom: 0.5rem; color: var(--text-primary); }
.ai-insight:last-child { margin-bottom: 0; }
.ai-recommendation { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); }
.ai-recommendation p { font-weight: 700; font-size: 1.1rem; color: var(--accent-color); margin: 0.5rem 0; }
.diagnostic-disclaimer, 
.ai-disclaimer { 
    margin-top: 1.5rem; 
    font-size: 0.7rem;          /* Made the text smaller */
    color: var(--text-secondary); 
    opacity: 0.55;              /* Made it greyer / fade into the background */
    line-height: 1.4; 
    display: flex; 
    gap: 8px; 
    align-items: flex-start; 
}

/* Make sure the shield icon matches the new tiny text size */
.diagnostic-disclaimer i, 
.ai-disclaimer i {
    width: 14px;
    height: 14px;
    margin-top: 1px;
}

.heatmap-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-top: 1rem; } 
.heatmap-cell { aspect-ratio: 1; border-radius: 6px; background: var(--heatmap-0); transition: transform 0.2s; } 
.heatmap-cell:hover { transform: scale(1.15); }
.level-1 { background: var(--heatmap-1); } .level-2 { background: var(--heatmap-2); } .level-3 { background: var(--heatmap-3); } .level-4 { background: var(--heatmap-4); }

.chart-container { position: relative; height: 250px; width: 100%; margin-top: 1rem; }

/* ==========================================================================
   TOOLKIT & JOURNAL
   ========================================================================== */
.tool-card { display: flex; align-items: center; gap: 1.2rem; cursor: pointer; transition: 0.2s; padding: 1.2rem; }
.tool-card:hover { transform: translateY(-3px); border-color: var(--accent-color); }
.tool-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.breathe-container { display: flex; flex-direction: column; align-items: center; padding: 3rem 1rem; text-align: center; }
.audio-toggle { margin-bottom: 2rem; } 
.audio-btn { border-radius: 30px; padding: 10px 20px; font-size: 0.9rem; }
.breathing-circle { width: 160px; height: 160px; border-radius: 50%; margin: 2rem 0; box-shadow: 0 0 40px var(--accent-color); background: radial-gradient(circle, var(--accent-color) 0%, transparent 75%); opacity: 0.85; }

.timer-display { font-size: 4.5rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-primary); letter-spacing: -2px; line-height: 1; margin: 1rem 0; }

textarea { width: 100%; background: rgba(0,0,0,0.03); border: 1px solid var(--border-color); border-radius: 16px; padding: 1rem; font-size: 1rem; color: var(--text-primary); resize: vertical; outline: none; transition: 0.2s; font-family: inherit; }
body.dark-mode textarea { background: rgba(255,255,255,0.03); } 
textarea:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

.journal-entry { padding: 1.2rem; border-left: 4px solid var(--accent-color); margin-bottom: 1rem; }
.journal-date { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.5rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

/* ==========================================================================
   NAVIGATION & FOOTER
   ========================================================================== */
.bottom-nav { 
    position: fixed; bottom: 0; left: 0; width: 100%; 
    background: var(--surface-color); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); 
    display: flex; justify-content: space-around; 
    /* Safe Area padding for iPhones/Modern Androids */
    padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom)); 
    border-top: 1px solid var(--border-color); z-index: 1000; 
}
.nav-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--text-secondary); font-size: 0.75rem; gap: 0.4rem; font-weight: 600; transition: color 0.2s; }
.nav-item.active { color: var(--accent-color); transform: translateY(-2px); }

@media (min-width: 700px) { 
    .bottom-nav { max-width: 700px; left: 50%; transform: translateX(-50%); border-radius: 24px 24px 0 0; border: 1px solid var(--border-color); bottom: 10px; padding: 1.2rem 0;} 
}

.app-footer { text-align: center; padding: 2rem 1rem 4rem 1rem; margin-top: 2rem; border-top: 1px solid var(--border-color); color: var(--text-secondary); font-size: 0.9rem; opacity: 0.8; }
.footer-logo { justify-content: center; margin-bottom: 0.5rem; opacity: 0.6; }
.footer-logo h2 { font-size: 1.2rem; margin: 0; letter-spacing: -0.5px; }
.footer-heart { color: var(--danger-color); fill: var(--danger-color); width: 16px; height: 16px; margin: 0 2px; }

/* ==========================================================================
   MODALS, TOASTS & UTILS
   ========================================================================== */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: 90vw; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--surface-color); color: var(--text-primary); box-shadow: 0 10px 30px rgba(0,0,0,0.15); border-left: 4px solid var(--accent-color); animation: slideInRight 0.4s cubic-bezier(0.17, 0.88, 0.32, 1.27); display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.95rem; backdrop-filter: blur(10px); }
.toast.toast-error { border-left-color: var(--danger-color); } 
.toast.toast-out { animation: fadeOutRight 0.3s forwards; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); z-index: 2000; display: flex; justify-content: center; align-items: center; padding: 1.5rem; transition: 0.3s; }
.modal-content { background: var(--surface-color); padding: 2rem; border-radius: 24px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); border: 1px solid var(--border-color); }
.modal-icon { width: 64px; height: 64px; background: var(--accent-color); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1.5rem auto; box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4); } 
.danger-icon { background: var(--danger-color); box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4); }

.onboarding-steps { text-align: left; margin: 2rem 0; display: flex; flex-direction: column; gap: 1.5rem; } 
.step { display: flex; gap: 1rem; align-items: flex-start; } 
.step i { color: var(--accent-color); margin-top: 3px; flex-shrink: 0; } 
.step h4 { margin-bottom: 0.3rem; font-weight: 700; } 

.hidden { display: none !important; }
.mb-2 { margin-bottom: 1rem; } 
.mt-3 { margin-top: 1.5rem; } 
.w-full { width: 100%; }

/* Animations */
@keyframes spin { 100% { transform: rotate(360deg); } } 
.spin-icon { animation: spin 2s linear infinite; color: var(--accent-color); }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } 
@keyframes fadeOutRight { to { transform: translateX(120%); opacity: 0; } }
@keyframes popIn { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.slide-up { animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; } 
.fade-in { animation: fadeIn 0.4s ease forwards; } 
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* AI Loading Skeleton */
.skeleton-container { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; }
.skeleton-line { height: 14px; border-radius: 8px; background: linear-gradient(90deg, rgba(150,150,150,0.1) 25%, rgba(150,150,150,0.25) 50%, rgba(150,150,150,0.1) 75%); background-size: 400% 100%; animation: shimmer 1.5s infinite; }
.w-3-4 { width: 75%; } 
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }