:root {
    /* Default (night) theme - overridden by JS time-of-day classes */
    --bg-color: #07101e;
    --bg-glow-a: rgba(59, 130, 246, 0.07);
    --bg-glow-b: rgba(16, 185, 129, 0.07);
    --bg-glow-c: rgba(139, 92, 246, 0.05);
    --header-grad-a: #e2e8f0;
    --header-grad-b: #64748b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(20, 30, 48, 0.5);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
}

/* === TIME-OF-DAY THEMES === */
/* Dawn  5am–8am: warm amber/rose tint */
body.theme-dawn {
    --bg-color: #100d14;
    --bg-glow-a: rgba(251, 146, 60, 0.10);
    --bg-glow-b: rgba(244, 114, 182, 0.08);
    --bg-glow-c: rgba(251, 191, 36, 0.06);
    --header-grad-a: #fde68a;
    --header-grad-b: #fb923c;
    --glass-bg: rgba(32, 18, 22, 0.5);
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
}

/* Morning  8am–12pm: crisp teal/cyan */
body.theme-morning {
    --bg-color: #05111a;
    --bg-glow-a: rgba(6, 182, 212, 0.10);
    --bg-glow-b: rgba(16, 185, 129, 0.08);
    --bg-glow-c: rgba(59, 130, 246, 0.05);
    --header-grad-a: #a5f3fc;
    --header-grad-b: #0ea5e9;
    --glass-bg: rgba(5, 20, 35, 0.5);
    --accent: #06b6d4;
    --accent-hover: #22d3ee;
}

/* Afternoon  12pm–17pm: violet/indigo */
body.theme-afternoon {
    --bg-color: #0c0d1e;
    --bg-glow-a: rgba(99, 102, 241, 0.09);
    --bg-glow-b: rgba(139, 92, 246, 0.08);
    --bg-glow-c: rgba(16, 185, 129, 0.05);
    --header-grad-a: #c4b5fd;
    --header-grad-b: #818cf8;
    --glass-bg: rgba(18, 16, 40, 0.5);
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
}

/* Evening  17pm–21pm: deep rose/orange */
body.theme-evening {
    --bg-color: #120a0e;
    --bg-glow-a: rgba(239, 68, 68, 0.08);
    --bg-glow-b: rgba(251, 146, 60, 0.08);
    --bg-glow-c: rgba(244, 114, 182, 0.05);
    --header-grad-a: #fca5a5;
    --header-grad-b: #f97316;
    --glass-bg: rgba(30, 14, 18, 0.5);
    --accent: #f97316;
    --accent-hover: #fb923c;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 20%, var(--bg-glow-a), transparent 40%),
        radial-gradient(circle at 90% 80%, var(--bg-glow-b), transparent 40%),
        radial-gradient(circle at 80% 20%, var(--bg-glow-c), transparent 30%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1.5rem 2rem;
    transition: background-color 1s ease;
}

#app {
    max-width: 1400px;
    margin: 0 auto;
}

/* Dashboard layout: main grid + sidebar */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .chore-sidebar {
        display: none;
    }
}

.dashboard-header {
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    font-weight: 800;
    font-size: 2.75rem;
    letter-spacing: -0.03em;
    background: linear-gradient(90deg, var(--header-grad-a), var(--header-grad-b));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: background 1s ease;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.25rem;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 1.25rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.action-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.85rem 1.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    width: 100%;
    margin-top: 1rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.action-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.23);
    transform: translateY(-2px);
}

/* Views */
.view {
    display: none;
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view.active {
    display: block;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.97) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Widget Grid */
.widget-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.fitness-widget, .ai-widget, .reminders-widget {
    grid-column: span 2;
}

.steps-widget, .currency-widget, .pantry-widget, .video-widget {
    grid-column: span 1;
}

/* Mobile chore widget hidden on desktop — shown only in mobile snap carousel */
.mobile-chore-widget {
    display: none;
}

@media (max-width: 1024px) {
    .widget-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .fitness-widget, .ai-widget, .reminders-widget {
        grid-column: span 2;
    }
    .steps-widget, .currency-widget, .pantry-widget, .video-widget {
        grid-column: span 1;
    }
    .mobile-chore-widget {
        display: none !important;
    }
}

/* Mobile: snap-scroll carousel of widget cards */
@media (max-width: 640px) {
    body {
        padding: 1rem;
    }
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .chore-sidebar {
        display: none !important;
    }
    /* Hide these widgets entirely on mobile */
    .video-widget,
    .currency-widget,
    .ai-widget,
    .pantry-widget {
        display: none !important;
    }
    /* Show the mobile-only chore card */
    .mobile-chore-widget {
        display: flex !important;
    }
    .widget-grid {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: scroll;
        gap: 0;
        padding: 0 1rem 1rem;
        margin: 0 -1rem;        /* bleed to screen edge */
        /* CSS scroll snap */
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .widget-grid::-webkit-scrollbar {
        display: none;
    }
    /* Every direct child is a snap point */
    .widget-grid > * {
        flex: 0 0 calc(100vw - 2rem);   /* one card = full viewport minus body padding */
        max-width: calc(100vw - 2rem);
        height: 320px;
        grid-column: unset !important;
        scroll-snap-align: start;
        scroll-snap-stop: always;
        margin-right: 1rem;             /* gap between snapped cards */
        border-radius: 1.25rem;
    }
    /* Remove right margin on last visible card */
    .widget-grid > *:last-child {
        margin-right: 0;
    }
    /* Chore card needs more room to show tasks + coming up section */
    .widget-grid > .mobile-chore-widget {
        height: 520px;
    }
    .widget {
        height: 320px;
        min-height: unset;
    }
    .dashboard-header h1 {
        font-size: 1.9rem;
    }
    .subtitle {
        font-size: 0.95rem;
    }
}

.widget {
    cursor: pointer;
    height: 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.widget:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.15);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.widget-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.metrics-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric {
    flex: 1;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.75rem;
    border-radius: 1rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.metric .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.metric .value {
    font-size: 1.5rem;
    font-weight: 800;
}

/* Benchmarks */
.benchmarks-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.benchmarks-list::-webkit-scrollbar {
    width: 4px;
}
.benchmarks-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.benchmarks-list h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.benchmark-item {
    margin-bottom: 0.75rem;
}

.benchmark-item:last-child {
    margin-bottom: 0;
}

.b-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.b-target {
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expanded Fitness View */
.back-btn {
    margin-bottom: 2rem;
}

.fitness-dashboard {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: minmax(auto, auto);
    gap: 1.5rem;
}

.span-2 {
    grid-column: span 2;
}

@media (max-width: 900px) {
    .fitness-dashboard {
        grid-template-columns: 1fr;
    }
    .span-2 {
        grid-column: 1;
    }
}

.stats-card {
    display: flex;
    flex-direction: column;
}

.stats-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.85rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.3);
}

select option {
    background: rgba(30, 41, 59, 1);
    color: var(--text-primary);
}

.history-list {
    margin-top: auto;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}
.history-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
}
.history-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-item-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Rivalry Competition */
.competition-card {
    text-align: center;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.vs-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.competitor {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s;
}

.competitor:hover {
    transform: scale(1.05);
}

.competitor .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0 auto 1rem;
    background: var(--glass-bg);
    border: 3px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.competitor.you .avatar {
    border-color: var(--accent-green);
    color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
}

.competitor.rival .avatar {
    border-color: var(--accent-red);
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
}

.competitor .score {
    font-size: 1.75rem;
    font-weight: 800;
}

.vs-divider {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-style: italic;
    background: rgba(0,0,0,0.3);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
}

.motivation-text {
    font-size: 0.9rem;
    font-weight: 600;
}

/* AI Chef Recipe Boxes */
.recipe-box {
    padding: 1rem;
    border-radius: 0.75rem;
    color: white;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    animation: fadeIn 0.4s ease forwards;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Badges */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.badge-item {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.badge-item.locked {
    opacity: 0.4;
    filter: grayscale(100%);
}

.badge-item.earned {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

.badge-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.badge-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.badge-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Fitness Belt Badges */
.belt-badge {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.03em;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Fitness Belt Borders */
.belt-none { border-color: var(--glass-border) !important; }
.belt-white { border-color: #ffffff !important; box-shadow: 0 0 15px rgba(255,255,255,0.1); }
.belt-yellow { border-color: #fbbf24 !important; box-shadow: 0 0 15px rgba(251,191,36,0.15); }
.belt-orange { border-color: #f97316 !important; box-shadow: 0 0 15px rgba(249,115,22,0.15); }
.belt-green { border-color: #22c55e !important; box-shadow: 0 0 15px rgba(34,197,94,0.15); }
.belt-blue { border-color: #3b82f6 !important; box-shadow: 0 0 15px rgba(59,130,246,0.15); }
.belt-purple { border-color: #a855f7 !important; box-shadow: 0 0 15px rgba(168,85,247,0.15); }
.belt-brown { border-color: #92400e !important; box-shadow: 0 0 15px rgba(146,64,14,0.1); }
.belt-red { border-color: #ef4444 !important; box-shadow: 0 0 15px rgba(239,68,68,0.15); }
.belt-black { border-color: #000000 !important; border-width: 2px !important; box-shadow: 0 0 20px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1); }

/* Belt Badge UI */
.belt-tag {
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    text-transform: uppercase;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.bg-white { background: #ffffff; color: #000; text-shadow: none; }
.bg-yellow { background: #fbbf24; }
.bg-orange { background: #f97316; }
.bg-green { background: #22c55e; }
.bg-blue { background: #3b82f6; }
.bg-purple { background: #a855f7; }
.bg-brown { background: #92400e; }
.bg-red { background: #ef4444; }
.bg-black { background: #000000; border: 1px solid rgba(255,255,255,0.2); }
