* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --sage: #7B8F6B;
    --sage-light: #A8B89C;
    --sage-bg: #EEF2EA;
    --mint: #C8D8C0;
    --green: #5A7A4A;
    --bg: #F5F7F2;
    --card: #FFFFFF;
    --text: #1A1A1A;
    --text-secondary: #888;
    --border: #E8ECE4;
    --blue: #6B8FB0;
    --blue-light: #D0E0F0;
    --amber: #B08F5A;
    --red: #C06050;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --safe-bottom: max(20px, env(safe-area-inset-bottom));
}

body {
    font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.hidden { display: none !important; }

/* SCREENS */
.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
}

.safe-top { height: max(20px, env(safe-area-inset-top)); }

.scroll-area {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: calc(100% - 70px - var(--safe-bottom));
    padding: 0 16px 24px;
}

/* ONBOARDING */
.onboard-bg {
    height: 100%;
    background: linear-gradient(180deg, #C8D8C0 0%, #8BA87A 40%, #5A7A4A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.onboard-content {
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
}
.onboard-title {
    font-size: 42px;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
    margin-bottom: 32px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.ai-bubble {
    background: #fff;
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #333;
    box-shadow: var(--shadow);
}
.ai-badge {
    background: var(--sage);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 8px;
    flex-shrink: 0;
}
.onboard-input-wrap { margin-bottom: 16px; }
.onboard-input {
    width: 100%;
    padding: 14px 18px;
    border-radius: 14px;
    border: none;
    font-size: 15px;
    background: rgba(255,255,255,0.9);
    outline: none;
}

/* AUTH */
.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
}
.auth-switch a {
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}
.auth-error {
    color: #ffb3b3;
    font-size: 13px;
    text-align: center;
    margin-bottom: 8px;
    min-height: 18px;
}

/* BUTTONS */
.btn {
    display: block;
    width: 100%;
    padding: 15px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary { background: var(--sage); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); margin-bottom: 12px; }
.btn-accent { background: var(--sage); color: #fff; }
.btn-danger { background: var(--red); color: #fff; opacity: 0.7; }
.btn-full { width: 100%; }

/* MANTRA SCREEN */
.mantra-bg {
    height: 100%;
    background: linear-gradient(180deg, #A8B89C 0%, #7B8F6B 50%, #5A7A4A 100%);
    display: flex;
    flex-direction: column;
}
.mantra-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 60px 20px 20px;
}
.back-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
}
.mantra-title-small {
    color: rgba(255,255,255,0.8);
    font-size: 15px;
    font-weight: 500;
}
.mantra-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 32px 60px;
}
.mantra-text {
    font-size: 44px;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
    margin-bottom: 48px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

/* HOME DASHBOARD */
.mantra-card {
    background: linear-gradient(135deg, #7B8F6B, #5A7A4A);
    border-radius: 18px;
    padding: 20px;
    margin: 12px 0 16px;
    color: #fff;
}
.mantra-card-label {
    font-size: 12px;
    opacity: 0.7;
    font-weight: 500;
    margin-bottom: 8px;
}
.mantra-card-text {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}
.mantra-card-sub {
    font-size: 13px;
    opacity: 0.6;
}
.mantra-dots {
    display: flex;
    gap: 6px;
    margin-top: 12px;
}
.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
}
.dot.active { background: #fff; }

/* TRACKER CARDS */
.tracker-card {
    background: var(--card);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
}
.tracker-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.hydration-icon { background: #D0E0F0; }
.calories-icon { background: #F0E0D0; }
.exercise-icon { background: #D0F0D0; }
.sleep-icon { background: #E0D0F0; }
.streak-icon { background: #F0F0D0; }
.tracker-info { flex: 1; min-width: 0; }
.tracker-label { font-size: 13px; color: var(--text-secondary); }
.tracker-value { font-size: 16px; font-weight: 700; }
.tracker-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.tracker-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.hydration-bar { background: var(--blue); }
.calories-bar { background: var(--sage); }
.exercise-bar { background: var(--green); }
.sleep-bar { background: #8B6BB0; }
.streak-bar { background: var(--amber); }

/* CHECK-IN CARD */
.checkin-card {
    background: var(--card);
    border-radius: 14px;
    padding: 18px;
    margin-top: 6px;
    box-shadow: var(--shadow);
    text-align: center;
}
.checkin-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.checkin-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.checkin-stars { display: flex; gap: 8px; justify-content: center; }
.star {
    font-size: 32px;
    color: #ddd;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
}
.star.filled { color: var(--amber); }
.star:active { transform: scale(1.2); }

/* BOTTOM NAV */
.tab-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    display: flex;
    padding-bottom: var(--safe-bottom);
    border-top: 1px solid var(--border);
    z-index: 100;
}
.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 4px;
    background: none;
    border: none;
    color: #bbb;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}
.tab-btn.active { color: var(--sage); }
.tab-btn svg { stroke: currentColor; }

.tab-content { display: none; height: 100%; }
.tab-content.active { display: flex; flex-direction: column; }

/* LOG TAB */
.tab-title {
    font-size: 28px;
    font-weight: 800;
    margin: 8px 0 16px;
}
.log-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.log-card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px 14px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 140px;
}
.log-icon { font-size: 32px; margin-bottom: 6px; }
.log-label { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.log-action { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.log-btn {
    background: var(--sage);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}
.log-btn:active { opacity: 0.8; }
.log-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12px;
    outline: none;
    background: var(--bg);
}
.log-input.small { width: 100%; }
.log-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12px;
    background: var(--bg);
    outline: none;
}
.log-row { display: flex; gap: 6px; width: 100%; }
.log-row .log-input { flex: 1; }
.mood-row { display: flex; gap: 4px; justify-content: center; }
.mood-btn {
    font-size: 24px;
    background: none;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 4px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}
.mood-btn.selected { border-color: var(--sage); background: var(--sage-bg); }
.mood-btn:active { transform: scale(1.15); }
.supplement-list { text-align: left; width: 100%; }
.supp-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 13px;
    cursor: pointer;
}
.supp-item input { accent-color: var(--sage); width: 16px; height: 16px; }

.section-title {
    font-size: 16px;
    font-weight: 700;
    margin: 20px 0 8px;
}
.log-entry {
    background: var(--card);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 6px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.log-entry-time { color: var(--text-secondary); }

/* PROGRESS TAB */
.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 16px;
}
.calendar-card {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.cal-title { font-size: 16px; font-weight: 700; }
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--sage);
    cursor: pointer;
    width: 28px;
    height: 28px;
}
.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.cal-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}
.cal-cell.today { background: var(--sage); color: #fff; font-weight: 700; }
.cal-cell.logged { background: var(--sage-bg); color: var(--green); }
.cal-cell.empty { visibility: hidden; }

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.chart-card {
    background: var(--card);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow);
}
.chart-card canvas { width: 100%; height: auto; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.momentum-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.momentum-score {
    font-size: 56px;
    font-weight: 800;
    color: var(--sage);
}

/* PROFILE TAB */
.profile-card {
    background: var(--card);
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.profile-avatar { font-size: 48px; margin-bottom: 8px; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-goal { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.profile-section {
    background: var(--card);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}
.profile-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.profile-row:last-of-type { border-bottom: none; margin-bottom: 12px; }
.profile-input {
    width: 80px;
    text-align: right;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
}
.profile-val { color: var(--text-secondary); font-size: 13px; }

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 200;
    pointer-events: none;
}
.toast.show { opacity: 1; }
