:root {
    /* Color Palette - Premium Modern */
    --primary-color: #6C63FF;
    /* Deep Violet */
    --secondary-color: #00D2D3;
    /* Neon Teal */
    --accent-color: #FF6B6B;
    /* Soft Red */
    --background-bg: #eef2f5;
    /* Cooler Grey */
    --surface-color: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-primary: #2D3436;
    --text-secondary: #636E72;
    --success-color: #00B894;

    /* Effects */
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --blur-strength: 12px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f7f9fc;
    color: var(--text-primary);
    overflow: hidden;
    /* Prevent body scroll completely */
    overscroll-behavior: none;
    /* Stop bounce/pull-to-refresh */
    width: 100%;
    height: 100%;
    position: fixed;
    /* Nuclear option to lock viewport */
    top: 0;
    left: 0;
}

b,
strong {
    font-family: inherit;
    font-weight: 700;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #eef2f5;
}

#app-container {
    width: 100%;
    background: var(--background-bg);
    color: var(--text-primary);
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Dynamic Viewport Height (Key fix) */
    overflow: hidden;
    display: flex;
    justify-content: center;
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.08);
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Key for containment */
    overflow: hidden;
    /* Prevent elements from escaping */
    background: #eef2f5;
    margin: 0 auto;
    /* Center in body */
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
    /* App shadow */
}

.hidden {
    display: none !important;
}

/* Header */
.app-header {
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    align-items: center;
    background: rgba(238, 242, 245, 0.95);
    /* Solid glass background */
    backdrop-filter: blur(10px);
    z-index: 50;
    /* Above content */
}

.header-content h1 {
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    font-size: 28px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background var(--transition-fast);
}

.icon-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 100px 0;
    /* Bottom padding for nav */
}

/* Sticky Category Headers */
.sticky-header {
    position: sticky;
    top: 0;
    /* Flush with container top */
    z-index: 10;
    background: rgba(238, 242, 245, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 12px 24px;
    margin-bottom: 8px;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

/* Item Cards (Premium Glass) */
.item-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    padding: 12px 16px;
    margin: 0 20px 12px 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Pill Controls */
.pill-controls {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 24px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    gap: 4px;
}

.pill-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--primary-color);
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pill-btn:active {
    background: rgba(108, 99, 255, 0.1);
}

.pill-val {
    min-width: 32px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
}

.pill-val-num {
    font-weight: 700;
    font-size: 15px;
}

.pill-val-unit {
    font-size: 9px;
    color: #888;
    margin-top: 2px;
}

/* Bottom Nav */
.bottom-nav {
    position: absolute;
    /* Changed from absolute (was actually fixed in behavior if container wasn't relative) to absolute inside container */
    bottom: 24px;
    max-width: 100%;
    /* Fill container */
    margin: 0 16px;
    /* Side margins */
    left: 0;
    right: 0;
    width: auto;
    /* Allow margins to work */
    height: 72px;
    z-index: 100;

    /* Restored Visuals */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 12px;
    z-index: 9999;
    /* Fix for sticky overlays / containment */
    pointer-events: auto;
    /* Ensure clickable */
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    font-family: 'Heebo', sans-serif;
    font-size: 10px;
    gap: 4px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

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

.nav-item .material-icons-round {
    font-size: 24px;
}

/* FAB */
/* FAB Shared Visuals */
.fab-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 8px 16px rgba(108, 99, 255, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform var(--transition-bounce);
    z-index: 90;
}

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

/* Floating FAB (Add Item) */
.fab-float {
    position: absolute;
    /* Changed from fixed to absolute */
    bottom: 110px;
    /* Above the nav */
    left: 24px;
    /* Move to side */
    transform: none;
    /* Remove centering transform */
}

/* Docked FAB (Scan Button) */
.fab-docked {
    position: relative;
    margin-top: -32px;
    /* Pop out of the bar */
    border: 4px solid #eef2f5;
    /* Match bg to create cutout effect */
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
}

/* Modals & Onboarding */
.onboarding-container {
    position: absolute;
    /* Changed from fixed for containment */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.modal-card {
    background: white;
    width: 100%;
    max-width: 320px;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.onboarding-container.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Utilities */
.card {
    background: white;
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 0 20px 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

/* Chips */
.chip-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

.chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: #f0f0f0;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

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

/* Force Hidden Override */
.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Animations */
@keyframes slideDown {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
        max-height: 200px;
        margin-bottom: 12px;
    }

    60% {
        opacity: 0.5;
        transform: translateY(20px) scale(0.95);
        max-height: 200px;
        margin-bottom: 12px;
    }

    100% {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        border: none;
    }
}

.slide-out {
    animation: slideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

/* Force Hidden Override */
.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* --- Global Micro-Animations (Premium Interactivity) --- */

/* 1. Base Transition for Interactive Elements */
button,
.btn,
.icon-btn,
.fab-btn,
.nav-item,
.chip,
.pill-btn {
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
        background-color 0.2s ease,
        filter 0.2s ease,
        box-shadow 0.2s ease;
}

/* 2. Hover Effects (Pop & Brighten) */
button:hover,
.btn:hover,
.icon-btn:hover,
.fab-btn:hover,
.nav-item:hover,
.chip:hover,
.pill-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.1);
    z-index: 10;
    /* Bring to front on hover */
}

/* 3. Active/Click Effects (Press Down) */
button:active,
.btn:active,
.icon-btn:active,
.fab-btn:active,
.nav-item:active,
.chip:active,
.pill-btn:active {
    transform: scale(0.9);
    filter: brightness(0.9);
}

/* 4. Special Handling for Cards */
.item-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    z-index: 5;
}

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

/* 5. Fix for FAB Float (Ensure it doesn't jump, though generic rule should work) */
.fab-float:hover {
    transform: scale(1.1);
}

.fab-float:active {
    transform: scale(0.9);
}