/* ========================================================
   CalVis V2.0 Design System - Master Stylesheet
   Crafted with Google Stitch (M3) + Apple Health (HIG) + Impeccable
   ======================================================== */

:root {
    /* Color Palette - Google Stitch & Health Wellness */
    --primary: #10b981;
    --primary-rgb: 16, 185, 129;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --primary-container: #d1fae5;
    --on-primary-container: #064e3b;
    
    --accent-blue: #0ea5e9;
    --accent-blue-rgb: 14, 165, 233;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;

    /* Light Theme (M3 Surface Tones) */
    --bg-base: #f8fafc;
    --surface-1: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-subtle: rgba(226, 232, 240, 0.8);
    --border-glass: rgba(255, 255, 255, 0.4);

    /* Apple-style Elevation & Glass Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 8px 24px -4px rgba(16, 185, 129, 0.35);

    /* Glassmorphism Blur */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-blur: blur(16px);

    /* Radius & Spacing */
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Dark Theme (OLED Black + Tonal Elevation) */
    --bg-base: #0a0f1d;
    --surface-1: #131b2e;
    --surface-2: #1e293b;
    --surface-3: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-subtle: rgba(51, 65, 85, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);

    --primary-container: rgba(16, 185, 129, 0.15);
    --on-primary-container: #34d399;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 8px 24px -4px rgba(16, 185, 129, 0.25);

    --glass-bg: rgba(19, 27, 46, 0.88);
}

/* Base Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}

/* Mobile Frame (Centered responsive canvas) */
.mobile-frame {
    width: 100%;
    max-width: 440px;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
}

/* ========================================================
   Desktop & Tablet Presentation (Studio Smartphone Showcase)
   Keeps mobile 100% untouched while making PC look stunning
   ======================================================== */
@media (min-width: 481px) {
    body {
        background: radial-gradient(circle at 50% 18%, #ecfdf5 0%, #e2e8f0 45%, #cbd5e1 100%);
        min-height: 100vh;
        overflow: hidden;
    }

    [data-theme="dark"] body {
        background: radial-gradient(circle at 50% 18%, #064e3b 0%, #0a0f1d 45%, #030712 100%);
    }

    .mobile-frame {
        height: min(94vh, 900px);
        max-width: 425px;
        border-radius: 48px;
        border: 10px solid #1e293b;
        box-shadow: 0 25px 70px -15px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15);
        position: relative;
        overflow: hidden;
    }

    [data-theme="dark"] .mobile-frame {
        border-color: #0f172a;
        box-shadow: 0 25px 70px -15px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
    }

    /* Subtle Smartphone Speaker/Sensor Pill at Top */
    .mobile-frame::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 80px;
        height: 16px;
        background: #000000;
        border-radius: 20px;
        z-index: 100;
        pointer-events: none;
    }

    .app-header {
        padding-top: 24px !important;
    }

    /* Contain Navigation Bar & Floating Action Button inside Phone Frame */
    .bottom-nav-bar {
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        transform: none !important;
        border-radius: 0 0 38px 38px !important;
    }

    .fab-depth-wrap {
        position: absolute !important;
        bottom: 30px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    /* Contain Modals, Camera & Scanner Viewfinder inside Phone Frame */
    .modal-overlay,
    .live-camera-overlay,
    .ai-scanning-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 38px !important;
        overflow: hidden !important;
    }

    .modal-sheet {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 28px 28px 0 0 !important;
    }

    /* Contain Toast Notifications & Update Banners inside Phone Frame */
    .toast-bar {
        position: absolute !important;
        top: 32px !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(-120px) !important;
    }

    .toast-bar.show {
        transform: translateX(-50%) translateY(0) !important;
    }

    .pwa-update-banner {
        position: absolute !important;
        top: 24px !important;
        left: 50% !important;
        width: calc(100% - 32px) !important;
    }

    .pull-refresh-indicator {
        position: absolute !important;
    }

    /* Sleek, Modern Minimal Scrollbar for PC Frame */
    .scroll-content {
        scrollbar-width: thin;
        scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
    }
    .scroll-content::-webkit-scrollbar {
        display: block !important;
        width: 5px;
    }
    .scroll-content::-webkit-scrollbar-track {
        background: transparent;
    }
    .scroll-content::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.35);
        border-radius: 999px;
    }
    .scroll-content::-webkit-scrollbar-thumb:hover {
        background: rgba(148, 163, 184, 0.7);
    }
    [data-theme="dark"] .scroll-content::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.2);
    }
    [data-theme="dark"] .scroll-content::-webkit-scrollbar-thumb:hover {
        background: rgba(148, 163, 184, 0.45);
    }
}

/* App Header (Sticky Glassmorphic - Compact Two-Row Layout) */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.brand-greeting-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo-lockup {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 0.9;
}

.brand-logo-text {
    font-size: 21px;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 0.9;
}

.brand-swoosh-svg {
    width: 84px;
    height: 10px;
    margin-top: -2px;
}

.header-dot-sep {
    color: var(--text-muted);
    opacity: 0.4;
    font-weight: 700;
    font-size: 15px;
}

.header-greeting-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.header-sub-row {
    width: 100%;
}

.header-encouragement-txt {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:active {
    transform: scale(0.92);
}

.user-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid var(--primary);
    background-size: cover;
    background-position: center;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
}

/* Scroll Content */
.scroll-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 18px calc(110px + env(safe-area-inset-bottom, 0px));
    scroll-behavior: smooth;
}
.scroll-content::-webkit-scrollbar {
    display: none;
}

/* Views Management */
.view {
    display: none;
    animation: fadeIn 0.3s ease-in-out forwards;
}
.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero Glanceable Card (Apple-style Activity Dashboard) */
.hero-cal-card {
    background: linear-gradient(145deg, var(--surface-1) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 14px 16px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

/* Greeting & Encouragement Banner */
.greeting-banner {
    margin-bottom: 14px;
    padding: 0 4px;
}
.greeting-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}
.greeting-subtext {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.45;
    font-weight: 400;
}

/* Share Button on Hero Card */
.btn-share-hero {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-share-hero:active {
    transform: scale(0.92);
    background: var(--primary);
    color: white;
}

/* Integrated Water Strip inside Hero Card */
.hero-water-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 10px 0 8px;
}
.hero-water-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.hero-water-info {
    flex: 1;
    min-width: 0;
}
.hero-water-label-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.hero-water-amount {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
}
.hero-water-bar-bg {
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--surface-3);
    overflow: hidden;
}
.hero-water-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, #38bdf8, var(--accent-blue));
    transition: width 0.4s ease;
}
.hero-water-chips {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.btn-water-micro {
    padding: 6px 10px;
    border-radius: var(--radius-full);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-fast);
}
.btn-water-micro:active {
    transform: scale(0.94);
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
    border-color: rgba(56, 189, 248, 0.3);
}

/* Trio Veggie Shop Shopee Banner */
.shop-banner-trio {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin: 16px 0;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.shop-banner-trio:active {
    transform: scale(0.98);
}
.shop-banner-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.shop-banner-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.shop-banner-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.2px;
    line-height: 1.2;
}
.shop-banner-subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 2px;
}
.shop-banner-badge {
    background: rgba(255, 255, 255, 0.25);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.hero-cal-card::after {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.hero-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.hero-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.metric-big {
    font-size: 34px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -1px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.metric-unit {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 4px;
}

.metric-label {
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Activity Ring (SVG Radial Progress) */
.activity-ring-box {
    position: relative;
    width: 78px;
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-ring-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.ring-bg {
    stroke: var(--surface-3);
    stroke-width: 8;
    fill: transparent;
}

.ring-progress {
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    fill: transparent;
    stroke-dasharray: 251.2;
    stroke-dashoffset: 60;
    transition: stroke-dashoffset 0.8s ease;
}

.ring-center-icon {
    position: absolute;
    font-size: 20px;
}

/* Macros Pill Grid (Carbs, Protein, Fat) */
.macros-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.macro-pill {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    transition: var(--transition);
}

.macro-pill:active {
    transform: scale(0.96);
}

.macro-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    display: inline-block;
    margin-right: 4px;
}
.dot-carb { background: var(--accent-amber); }
.dot-pro { background: var(--accent-rose); }
.dot-fat { background: var(--accent-blue); }

.macro-title {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.macro-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.macro-bar-bg {
    width: 100%;
    height: 4px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    margin-top: 8px;
    overflow: hidden;
}

.macro-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

/* Health Feature Cards (Water & IF) */
.feature-card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
    transition: var(--transition);
}

.feature-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.feature-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.badge-water {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent-blue);
}

.badge-if {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
}

.feature-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Water Tracker UI */
.water-display {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.water-amount {
    font-size: 26px;
    font-weight: 700;
    color: var(--accent-blue);
    font-variant-numeric: tabular-nums;
}

.water-target-txt {
    font-size: 12px;
    color: var(--text-muted);
}

.liquid-progress-bg {
    width: 100%;
    height: 10px;
    background: var(--surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 14px;
}

.liquid-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8 0%, #0284c7 100%);
    border-radius: var(--radius-full);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.water-quick-buttons {
    display: flex;
    gap: 8px;
}

.btn-water-chip {
    flex: 1;
    height: 42px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-water-chip:active {
    transform: scale(0.94);
    background: var(--primary-container);
    color: var(--on-primary-container);
}

/* IF Timer UI */
.if-timer-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.if-time-digits {
    font-size: 26px;
    font-weight: 700;
    color: var(--accent-purple);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

.if-sub-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-if-toggle {
    padding: 10px 18px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-if-toggle.start {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-if-toggle.stop {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-if-toggle:active {
    transform: scale(0.95);
}

/* Food List Section */
.section-headline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 22px 0 12px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.food-item-card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-xs);
    transition: var(--transition);
    cursor: pointer;
}

.food-item-card:active {
    transform: scale(0.98);
}

.food-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-2);
}

.food-info {
    flex: 1;
}

.food-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.food-macros {
    font-size: 11px;
    color: var(--text-muted);
}

.food-cal-badge {
    text-align: right;
}

.food-cal-num {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.food-cal-unit {
    font-size: 10px;
    color: var(--text-muted);
}

/* Modern Bottom Navigation (Ergonomic Thumb Bar) */
.bottom-nav-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 100% !important;
    max-width: 440px !important;
    height: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box !important;
    z-index: 50 !important;
}

.nav-tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 48px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    gap: 3px;
}

.nav-tab-item.active {
    color: var(--primary);
}

.nav-tab-icon {
    font-size: 20px;
}

.nav-tab-label {
    font-size: 10px;
    font-weight: 600;
}

/* ========================================================
   Floating Action Button (3D Depth Stack with Gesture & Mode Memory)
   Option 1A: 55% Opacity, Diagonal 45° Peek, Swipe Up-Right Support
   ======================================================== */
.fab-depth-wrap {
    position: fixed !important;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 55 !important;
    touch-action: none;
    cursor: pointer;
}

.fab-depth-card {
    position: absolute;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    padding: 0;
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 0.28s ease, 
                box-shadow 0.28s ease, 
                background 0.28s ease, 
                border-color 0.28s ease;
}

/* ACTIVE HERO BUTTON (Front, 56px, 100% Opacity) */
.fab-depth-wrap.mode-camera .card-camera,
.fab-depth-wrap.mode-gallery .card-gallery {
    width: 56px;
    height: 56px;
    z-index: 5;
    transform: scale(1) translate(0, 0);
    opacity: 1 !important;
    border: 3.5px solid var(--surface-1);
}

.fab-depth-wrap.mode-camera .card-camera {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5);
}

.fab-depth-wrap.mode-gallery .card-gallery {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5);
}

/* SECONDARY DIMMED BUTTON (Background, 36px, 55% Opacity, Option 1A: 45° offset) */
.fab-depth-wrap.mode-camera .card-gallery,
.fab-depth-wrap.mode-gallery .card-camera {
    width: 36px;
    height: 36px;
    z-index: 1;
    opacity: 0.55 !important;
    background: var(--surface-2);
    border: 1.5px solid var(--border-subtle);
    color: var(--text-muted);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* In Camera Mode: Gallery peeks top-right (26px, -14px) */
.fab-depth-wrap.mode-camera .card-gallery {
    transform: scale(0.8) translate(26px, -14px);
}

/* In Gallery Mode: Camera peeks top-left (-26px, -14px) */
.fab-depth-wrap.mode-gallery .card-camera {
    transform: scale(0.8) translate(-26px, -14px);
}

/* Active touch feedback */
.fab-depth-wrap:active .card-camera,
.fab-depth-wrap:active .card-gallery {
    transform: scale(0.94);
}
.fab-depth-wrap.mode-camera:active .card-gallery {
    transform: scale(0.78) translate(26px, -14px);
}
.fab-depth-wrap.mode-gallery:active .card-camera {
    transform: scale(0.78) translate(-26px, -14px);
}

@media (hover: hover) {
    .fab-depth-wrap.mode-camera .card-gallery:hover {
        opacity: 0.9 !important;
        transform: scale(0.88) translate(26px, -14px);
    }
    .fab-depth-wrap.mode-gallery .card-camera:hover {
        opacity: 0.9 !important;
        transform: scale(0.88) translate(-26px, -14px);
    }
}

/* Modals & Overlays */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000 !important;
    display: none;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
    box-sizing: border-box;
}

.modal-overlay.active {
    display: flex !important;
}

.modal-sheet {
    background: var(--surface-1);
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    max-height: 85dvh;
    border-radius: 28px 28px 0 0;
    padding: 24px;
    overflow-y: auto;
    border-top: 1px solid var(--border-glass);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.sheet-handle {
    width: 44px;
    height: 5px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    margin: 0 auto 16px;
    cursor: pointer;
    position: relative;
    touch-action: none;
    transition: background 0.15s, transform 0.15s;
}

.sheet-handle::before {
    content: '';
    position: absolute;
    top: -12px;
    bottom: -12px;
    left: -24px;
    right: -24px;
}

.sheet-handle:hover,
.sheet-handle:active {
    background: var(--text-muted);
    transform: scale(1.08);
}

/* Google Sign-in Splash Screen */
.auth-splash-view {
    position: absolute;
    inset: 0;
    background: var(--bg-base);
    z-index: 90;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    text-align: center;
}

.auth-splash-logo {
    width: 80px;
    height: 80px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: white;
    box-shadow: var(--shadow-glow);
    margin-bottom: 24px;
}

.auth-splash-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.auth-splash-desc {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 280px;
    margin-bottom: 32px;
    line-height: 1.5;
}

/* Primary Button */
.btn-primary-action {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: white;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-glow);
    transition: var(--transition);
}

.btn-primary-action:active {
    transform: scale(0.98);
}

/* Toast */
.toast-bar {
    position: fixed !important;
    top: calc(24px + env(safe-area-inset-top, 0px)) !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(-120px) !important;
    background: var(--text-primary);
    color: var(--bg-base);
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 8px 10px -6px rgba(0, 0, 0, 0.25);
    z-index: 2100000 !important;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90vw;
    pointer-events: none;
}

.toast-bar.show {
    transform: translateX(-50%) translateY(0) !important;
}

/* PWA Update Floating Banner */
.pwa-update-banner {
    position: fixed !important;
    top: calc(16px + env(safe-area-inset-top, 0px)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 32px) !important;
    max-width: 400px !important;
    background: var(--surface-1);
    color: var(--text-primary);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-full);
    padding: 8px 14px 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22), 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 99998 !important;
    animation: pwaBannerSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

@keyframes pwaBannerSlideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-24px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-update-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    flex-shrink: 0;
    animation: pwaPulse 1.5s infinite;
}

@keyframes pwaPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.btn-pwa-reload {
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-pwa-reload:active {
    transform: scale(0.94);
    opacity: 0.9;
}

/* ========================================================
   AI Meal Advisor Banner (Home Screen Smart Pill)
   ======================================================== */
.ai-coach-banner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(14, 165, 233, 0.12) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.ai-coach-banner:active {
    transform: scale(0.98);
}

.ai-coach-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.ai-pulse-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.ai-coach-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
}

.ai-coach-msg {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.3;
}

.ai-coach-cta {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: var(--surface-1);
    padding: 6px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
}

/* ========================================================
   Segmented Control (7 / 15 / 30 Days & Admin Tabs)
   ======================================================== */
.segmented-control {
    display: flex;
    background: var(--surface-2);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    margin-bottom: 16px;
}

.seg-btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    border-radius: calc(var(--radius-md) - 4px);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.seg-btn.active {
    background: var(--surface-1);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}

/* ========================================================
   Quick Meals Tab (Category Chips & 1-Tap Add)
   ======================================================== */
.chip-filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 14px;
}
.chip-filter-bar::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    padding: 7px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.chip-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-quick-plus {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--primary-container);
    color: var(--on-primary-container);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-quick-plus:active {
    transform: scale(0.88);
    background: var(--primary);
    color: white;
}

.btn-quick-shuffle {
    height: 42px;
    padding: 0 14px;
    background: var(--surface-1);
    color: var(--primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.btn-quick-shuffle:active {
    transform: scale(0.95);
    background: var(--primary-container);
}

/* ========================================================
   Unified Vector SVG Icon System (Theme-Adaptive Light/Dark)
   ======================================================== */
.svg-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.svg-icon-xs {
    width: 14px;
    height: 14px;
}

.svg-icon-sm {
    width: 16px;
    height: 16px;
}

.svg-icon-md {
    width: 22px;
    height: 22px;
}

.svg-icon-lg {
    width: 26px;
    height: 26px;
}

.food-vector-badge {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
}

.food-vector-badge.cat-protein {
    background: rgba(244, 63, 94, 0.12);
    color: var(--accent-rose);
}

.food-vector-badge.cat-thai {
    background: rgba(16, 185, 129, 0.12);
    color: var(--primary);
}

.food-vector-badge.cat-drink {
    background: rgba(14, 165, 233, 0.12);
    color: var(--accent-blue);
}

.nav-tab-item .svg-icon {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease, stroke-width 0.2s ease;
}

.nav-tab-item.active .svg-icon {
    stroke-width: 2.4;
    transform: translateY(-1px);
}

/* ==========================================
   BMI HERO CARD & THAI BMI CRITERIA
   ========================================== */
.bmi-hero-card {
    background: linear-gradient(145deg, var(--surface-1), var(--surface-2));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 14px;
    text-align: center;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.bmi-goal-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.bmi-goal-title b {
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
}

.bmi-pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
}

.bmi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.btn-view-bmi-info {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--accent-blue);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    background: transparent;
    border: none;
    font-family: inherit;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.btn-view-bmi-info:hover {
    background: rgba(14, 165, 233, 0.08);
}

/* Mode Segmented Control (Auto vs Custom) */
.mode-segmented-control {
    display: flex;
    background: var(--surface-2);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    border: 1px solid var(--border-subtle);
    gap: 4px;
}
.mode-seg-btn {
    flex: 1;
    padding: 9px 8px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.mode-seg-btn.active {
    background: var(--surface-1);
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Criteria rows in Modal */
.criteria-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
    background: var(--surface-2);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}
.criteria-row.highlight {
    border-color: currentColor;
    background: rgba(16, 185, 129, 0.12);
    font-weight: 700;
}

/* ==========================================
   PULL TO REFRESH (MOBILE NATIVE FEEL)
   ========================================== */
.pull-refresh-indicator {
    position: fixed;
    top: -70px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-1);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    z-index: 999;
    pointer-events: none;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, top 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
}

.pull-refresh-indicator.visible {
    opacity: 1;
}

.pull-refresh-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-container);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pull-refresh-icon {
    width: 15px;
    height: 15px;
    transition: transform 0.15s ease;
}

.pull-refresh-indicator.refreshing .pull-refresh-icon {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.pull-refresh-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.pull-refresh-indicator.refresh-done {
    border-color: rgba(16, 185, 129, 0.4);
}

.pull-refresh-indicator.refresh-done .pull-refresh-circle {
    background: var(--primary) !important;
    color: #ffffff !important;
}

.pull-refresh-indicator.refresh-done .pull-refresh-text {
    color: var(--primary);
    font-weight: 700;
}

/* Fasting Break Confirmation Modal (Top-Level Guard Dialog) */
#modal-if-break-fast {
    z-index: 2000000 !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

[data-theme="dark"] #modal-if-break-fast {
    background: rgba(0, 0, 0, 0.75) !important;
}

.if-break-fast-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

[data-theme="dark"] .if-break-fast-icon-wrap {
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;
}

.if-break-fast-food-box {
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
    text-align: left;
}

.if-break-fast-note {
    font-size: 11.5px;
    color: #b45309;
    line-height: 1.4;
    margin-top: 6px;
}

[data-theme="dark"] .if-break-fast-note {
    color: #fbbf24;
}

/* =====================================================
   LIVE IN-APP CAMERA VIEWFINDER (ZERO RAM CRASH)
   ===================================================== */
.live-camera-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: #000000 !important;
    z-index: 75 !important;
    display: none;
    align-items: center;
    justify-content: center;
}

.live-camera-overlay.active {
    display: flex !important;
}

.live-camera-frame {
    width: 100%;
    max-width: 440px;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #000000;
    overflow: hidden;
}

.live-cam-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.75) 0%, transparent 100%);
}

.live-cam-title {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.live-cam-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-cam-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.live-cam-icon-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.3);
}

.live-cam-icon-btn.active {
    background: #fbbf24;
    color: #000000;
    border-color: #f59e0b;
}

.live-cam-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
}

#live-cam-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Targeting Reticle */
.live-cam-reticle {
    position: absolute;
    width: 76%;
    aspect-ratio: 1 / 1;
    max-width: 310px;
    border: 1.5px dashed rgba(255, 255, 255, 0.35);
    border-radius: 28px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 16px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
}

.reticle-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--primary);
    border-style: solid;
}

.corner-tl {
    top: -2px;
    left: -2px;
    border-width: 3.5px 0 0 3.5px;
    border-top-left-radius: 26px;
}

.corner-tr {
    top: -2px;
    right: -2px;
    border-width: 3.5px 3.5px 0 0;
    border-top-right-radius: 26px;
}

.corner-bl {
    bottom: -2px;
    left: -2px;
    border-width: 0 0 3.5px 3.5px;
    border-bottom-left-radius: 26px;
}

.corner-br {
    bottom: -2px;
    right: -2px;
    border-width: 0 3.5px 3.5px 0;
    border-bottom-right-radius: 26px;
}

.reticle-hint {
    font-size: 12.5px;
    color: #ffffff;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 5px 14px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Camera Footer Controls */
.live-cam-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 24px calc(24px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
    z-index: 10;
}

.live-cam-side-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    padding: 6px;
    border-radius: var(--radius-md);
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.live-cam-side-btn:active {
    transform: scale(0.92);
    opacity: 0.8;
}

.live-cam-shutter-btn {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: transparent;
    border: 4px solid #ffffff;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    outline: none;
    transition: transform 0.12s ease;
}

.live-cam-shutter-btn:active {
    transform: scale(0.91);
}

.shutter-core {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.5);
    transition: transform 0.12s ease, background-color 0.15s ease;
}

.live-cam-shutter-btn:active .shutter-core {
    transform: scale(0.86);
    background: #059669;
}

/* =====================================================
   AI LASER SCANNING OVERLAY (HIGH-TECH VISION SCANNER)
   Theme-Adaptive: Crisp Frosted Light / OLED Sci-Fi Dark
   ===================================================== */
.ai-scanning-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: rgba(241, 245, 249, 0.92) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    z-index: 999999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.ai-scanning-overlay.active {
    display: flex !important;
    animation: fadeIn 0.2s ease-out forwards;
}

.ai-scanning-card {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.08), 0 0 25px rgba(16, 185, 129, 0.12);
    width: 100%;
    max-width: 340px;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.ai-scanning-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #059669;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.ai-scanning-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulseDot 1.4s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
}

.ai-viewfinder-wrap {
    position: relative;
    width: 100%;
    height: 230px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ai-viewfinder-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: brightness(0.92) contrast(1.05);
}

/* Corner HUD Brackets */
.viewfinder-hud {
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 2;
}

.hud-tl { top: 10px; left: 10px; border-top: 3px solid #10b981; border-left: 3px solid #10b981; border-top-left-radius: 4px; }
.hud-tr { top: 10px; right: 10px; border-top: 3px solid #10b981; border-right: 3px solid #10b981; border-top-right-radius: 4px; }
.hud-bl { bottom: 10px; left: 10px; border-bottom: 3px solid #10b981; border-left: 3px solid #10b981; border-bottom-left-radius: 4px; }
.hud-br { bottom: 10px; right: 10px; border-bottom: 3px solid #10b981; border-right: 3px solid #10b981; border-bottom-right-radius: 4px; }

/* Laser Scanning Beam */
.laser-beam {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, rgba(59, 130, 246, 0.8) 20%, #10b981 50%, rgba(59, 130, 246, 0.8) 80%, transparent 100%);
    box-shadow: 0 0 16px #10b981, 0 0 30px rgba(59, 130, 246, 0.6);
    z-index: 3;
    pointer-events: none;
    animation: laserScanMove 2.2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.laser-beam::after {
    content: '';
    position: absolute;
    top: -24px;
    left: 0;
    right: 0;
    height: 24px;
    background: linear-gradient(180deg, transparent 0%, rgba(16, 185, 129, 0.25) 100%);
}

@keyframes laserScanMove {
    0% { top: 2%; opacity: 0.6; }
    50% { top: 96%; opacity: 1; }
    100% { top: 2%; opacity: 0.6; }
}

.ai-scan-status-wrap {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.ai-scan-status-main {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.ai-scan-status-sub {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
    max-width: 290px;
}

.ai-scan-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 14px;
    position: relative;
}

.ai-scan-progress-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 35%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    border-radius: var(--radius-full);
    animation: progressIndeterminate 1.8s ease-in-out infinite;
}

@keyframes progressIndeterminate {
    0% { left: -35%; width: 35%; }
    50% { left: 40%; width: 50%; }
    100% { left: 100%; width: 35%; }
}

/* Smooth Transition from Scanner to Food Modal */
#modal-food-scan {
    z-index: 1000005 !important;
}

.ai-scanning-card.scan-success {
    border-color: #10b981 !important;
    box-shadow: 0 0 35px rgba(16, 185, 129, 0.35) !important;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.ai-scanning-card.scan-success .laser-beam {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ai-scan-progress-fill.completed {
    width: 100% !important;
    animation: none !important;
    background: #10b981 !important;
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Dark Theme Overrides for AI Scanning Overlay */
[data-theme="dark"] .ai-scanning-overlay {
    background: rgba(10, 15, 29, 0.94) !important;
}

[data-theme="dark"] .ai-scanning-card {
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(59, 130, 246, 0.35);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(16, 185, 129, 0.15);
}

[data-theme="dark"] .ai-scanning-badge {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

[data-theme="dark"] .ai-viewfinder-wrap {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ai-scan-status-main {
    color: #ffffff;
}

[data-theme="dark"] .ai-scan-status-sub {
    color: #94a3b8;
}

[data-theme="dark"] .ai-scan-progress-bar {
    background: rgba(255, 255, 255, 0.08);
}

/* ========================================================
   Portion Size Selector & Interactive Ingredient Chips
   ======================================================== */
#modal-food-scan .modal-sheet,
#modal-food-edit .modal-sheet {
    max-height: 88dvh;
    padding: 20px 20px 18px;
    transition: max-height 0.25s ease;
}

.portion-btn-group {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    height: 34px;
    align-items: center;
}

.portion-btn {
    flex: 1;
    height: 28px;
    padding: 0 4px;
    font-size: 11.5px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.portion-btn:hover {
    color: var(--text-primary);
}

.portion-btn.active {
    background: var(--primary);
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.ingredient-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    min-height: 32px;
    align-items: center;
}

.ingredient-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
    animation: fadeIn 0.15s ease-out;
}

.ingredient-chip .chip-del {
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 700;
    margin-left: 4px;
    padding: 2px 6px;
    border-radius: 50%;
    line-height: 1;
    font-size: 14px;
    transition: color 0.15s, background-color 0.15s;
}

.ingredient-chip .chip-del:hover,
.ingredient-chip .chip-del:active {
    color: var(--accent-rose);
    background: rgba(239, 68, 68, 0.12);
}

/* 2-Row Compact Inline Add Box (No Horizontal Overflow) */
.inline-add-box {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 8px;
    padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    animation: fadeIn 0.2s ease-out;
}

.inline-add-row-inputs {
    display: flex;
    gap: 8px;
    width: 100%;
}

.inline-add-row-inputs input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
}

.inline-add-row-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.inline-extras-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.inline-btn-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.btn-sm-primary {
    padding: 6px 14px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.btn-sm-ghost {
    padding: 6px 10px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.btn-text-action {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    padding: 2px 4px;
}

.quick-extras-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.quick-extra-pill,
.quick-edit-extra-pill {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: 1px dashed var(--primary);
    background: var(--primary-container);
    color: var(--on-primary-container);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.quick-extra-pill:hover,
.quick-edit-extra-pill:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.quick-extra-pill:active,
.quick-edit-extra-pill:active {
    transform: scale(0.96);
}

/* Food Detail Modal Elements */
.detail-hero-container {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.detail-hero-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    color: var(--text-secondary);
}

.detail-ingredient-chip {
    display: inline-flex;
    align-items: center;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

#scan-preview-img,
#detail-hero-img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    object-position: center;
}

/* ==========================================
   PAST DAYS HISTORY TIMELINE (DESIGN 1)
   ========================================== */
.day-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 10px;
    padding: 6px 0 8px;
    border-bottom: 1px dashed var(--border-subtle);
}

.day-title-badge {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.day-total-cal {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-container);
    padding: 2px 9px;
    border-radius: var(--radius-full);
}

.load-more-section {
    text-align: center;
    padding: 16px 0 10px;
}

.btn-load-more {
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
}

.btn-load-more:active {
    background: var(--surface-3);
    color: var(--text-primary);
    transform: scale(0.98);
}

/* Floating Back to Top Button */
.back-to-top-btn {
    position: absolute;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.9);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 45;
}

.back-to-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.back-to-top-btn:active {
    transform: translateY(0) scale(0.92);
}





