/* 
         * DESIGN SYSTEM & VARIABLES 
         * Minimalist Palette, Soft Shadows, Clean Typography
         */
        :root {
            /* Core Colors */
            --bg-body: #F8F9FB;
            --bg-surface: #FFFFFF;
            --bg-sidebar: #FFFFFF;
            
            /* Text Colors */
            --text-primary: #1A1A1A;
            --text-secondary: #6B7280;
            --text-tertiary: #9CA3AF;
            
            /* Brand & Accents */
            --accent-primary: #2563EB; /* Sophisticated Royal Blue */
            --accent: #2563EB; /* Main accent color */
            --accent-hover: #1D4ED8; /* Darker accent for gradients */
            --accent-soft: #EFF6FF;
            --border: #E5E7EB;
            --border-light: #E5E7EB;

            /* Status Colors */
            --success: #22C55E; /* Green for success */
            --error: #EF4444; /* Red for error */

            /* Shadows */
            --shadow-card: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);

            /* Pastel Card Colors (Modern & Soft) */
            --pastel-pink-bg: #FFF1F2;
            --pastel-pink-text: #BE123C;
            
            --pastel-beige-bg: #FFFBEB;
            --pastel-beige-text: #B45309;
            
            --pastel-blue-bg: #EFF6FF;
            --pastel-blue-text: #1D4ED8;
            
            --pastel-purple-bg: #F3E8FF;
            --pastel-purple-text: #7E22CE;
            
            /* Alert */
            --alert-bg: #FEFCE8;
            --alert-border: #FDE047;
            --alert-text: #854D0E;

            /* Dimensions & Spacing */
            --sidebar-width: 280px;
            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 20px;
            --radius-xl: 32px;
            
            /* Shadows */
            --shadow-subtle: 0 1px 3px rgba(0,0,0,0.05);
            --shadow-float: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
            
            /* Font */
            --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        }

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

        body {
            font-family: var(--font-main);
            background-color: var(--bg-body);
            color: var(--text-primary);
            line-height: 1.6;
            height: 100vh;
            overflow: hidden; /* App-like feel */
        }

        button, input {
            font-family: inherit;
            border: none;
            outline: none;
        }

        img {
            max-width: 100%;
            height: auto;
        }

        /* LAYOUT STRUCTURE */
        .app-layout {
            display: flex;
            height: 100%;
            position: relative;
        }

        /* SIDEBAR */
        .sidebar {
            width: var(--sidebar-width);
            background-color: var(--bg-sidebar);
            border-right: 1px solid var(--border-light);
            display: flex;
            flex-direction: column;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            transform: translateX(-100%);
            transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
            z-index: 50;
            padding: 32px 24px;
        }

        .desktop-visible .sidebar {
            transform: translateX(0);
        }

        .logo-area {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 48px;
            padding-left: 8px;
        }

        .logo-icon {
            width: 32px;
            height: 32px;
            background: var(--text-primary);
            color: white;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .logo-text {
            font-size: 18px;
            font-weight: 700;
            letter-spacing: -0.5px;
            color: var(--text-primary);
        }

        .nav-header {
            font-size: 13px;
            font-weight: 600;
            text-transform: uppercase;
            color: var(--text-tertiary);
            margin-bottom: 12px;
            letter-spacing: 0.5px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
        }

        .nav-list {
            list-style: none;
            margin-bottom: 32px;
        }

        .nav-item {
            display: flex;
            align-items: center;
            gap: 12px;
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 15px;
            padding: 10px 12px;
            border-radius: var(--radius-sm);
            transition: all 0.2s ease;
            font-weight: 500;
        }

        .nav-item:hover {
            background-color: var(--bg-body);
            color: var(--text-primary);
        }
        
        .user-profile {
            margin-top: auto;
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px;
            background: var(--bg-body);
            border-radius: var(--radius-md);
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
        }
        
        .user-info div:first-child {
            font-size: 14px;
            font-weight: 600;
        }
        .user-info div:last-child {
            font-size: 12px;
            color: var(--text-tertiary);
        }

        /* MAIN CONTENT - FLEX COLUMN FOR CHAT */
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--bg-body);
            height: 100%;
            position: relative;
            transition: margin-left 0.4s ease;
        }

        /* Header Area (Mobile) */
        .mobile-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 20px;
            background-color: var(--bg-surface);
            border-bottom: 1px solid var(--border-light);
            z-index: 40;
        }

        .mobile-logo {
            font-weight: 700;
            font-size: 18px;
        }

        /* Scrollable Content Area */
        .scrollable-content {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 16px;
            display: flex;
            flex-direction: column;
            /* Smooth scrolling */
            scroll-behavior: smooth;
            width: 100%;
        }

        .container {
            max-width: 1000px;
            margin: 0 auto;
            width: 100%;
            overflow-x: hidden;
        }

        /* Breadcrumbs */
        .breadcrumbs {
            font-size: 13px;
            color: var(--text-tertiary);
            margin-bottom: 32px;
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: 500;
        }
        
        .breadcrumbs span {
            color: var(--text-secondary);
        }

        /* Cards Grid */
        .cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 32px;
        }

        .card {
            padding: 24px;
            border-radius: var(--radius-lg);
            cursor: pointer;
            transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            min-height: 140px;
            border: 1px solid transparent;
        }

        .card:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow-float);
        }

        .bg-pink { background: var(--pastel-pink-bg); color: var(--pastel-pink-text); border-color: rgba(190, 18, 60, 0.1); }
        .bg-beige { background: var(--pastel-beige-bg); color: var(--pastel-beige-text); border-color: rgba(180, 83, 9, 0.1); }
        .bg-blue { background: var(--pastel-blue-bg); color: var(--pastel-blue-text); border-color: rgba(29, 78, 216, 0.1); }
        .bg-purple { background: var(--pastel-purple-bg); color: var(--pastel-purple-text); border-color: rgba(126, 34, 206, 0.1); }

        .card-title {
            font-size: 14px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
            opacity: 0.8;
        }

        .card-text {
            font-size: 18px;
            font-weight: 600;
        }

        /* Alert Box */
        .alert-box {
            background: var(--alert-bg);
            border: 1px solid var(--alert-border);
            color: var(--alert-text);
            border-radius: var(--radius-md);
            padding: 16px;
            display: flex;
            align-items: center;
            gap: 16px;
            margin-bottom: 32px;
            font-size: 14px;
            font-weight: 500;
            max-width: 100%;
            overflow-wrap: break-word;
        }

        /* Chat Layout - Fills Remaining Space */
        .chat-section {
            display: flex;
            flex-direction: column;
            gap: 24px;
            margin-top: auto; /* Pushes to bottom of scrollable area if short */
            padding-bottom: 20px;
        }

        .chat-divider {
            text-align: center;
            position: relative;
            margin: 20px 0;
        }

        .chat-divider span {
            background: var(--bg-body);
            padding: 0 16px;
            color: var(--text-tertiary);
            font-size: 12px;
            position: relative;
            z-index: 1;
        }
        
        .chat-divider::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 1px;
            background: var(--border-light);
            z-index: 0;
        }

        .message-bubble {
            max-width: 85%;
            padding: 16px 20px;
            font-size: 15px;
            line-height: 1.5;
            position: relative;
            animation: fadeIn 0.3s ease forwards;
            box-shadow: var(--shadow-subtle);
            word-wrap: break-word;
            overflow-wrap: break-word;
            width: fit-content;
        }

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

        .bubble-left {
            align-self: flex-start;
            background: var(--bg-surface);
            color: var(--text-primary);
            border-radius: 20px 20px 20px 4px;
            border: 1px solid var(--border-light);
            display: flex;
            gap: 12px;
        }

        .bubble-right {
            align-self: flex-end;
            background: var(--accent-primary);
            color: white;
            border-radius: 20px 20px 4px 20px;
            /* Gradient for a premium feel */
            background: linear-gradient(135deg, var(--accent-primary), #1d4ed8);
        }
        
        .bot-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: var(--bg-body);
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* Sticky Footer Input */
        .input-area-sticky {
            background: var(--bg-surface);
            padding: 12px 16px;
            border-top: 1px solid var(--border-light);
            position: sticky;
            bottom: 0;
            z-index: 30;
            width: 100%;
            overflow-x: hidden;
        }

        .input-container {
            max-width: 1000px;
            margin: 0 auto;
            width: 100%;
            overflow-x: hidden;
        }

        /* AI Mode Selector */
        .ai-mode-selector {
            display: flex;
            gap: 8px;
            margin-bottom: 12px;
            padding: 4px;
            background: var(--bg-body);
            border-radius: 16px;
            width: fit-content;
            max-width: 100%;
            flex-wrap: wrap;
        }

        .mode-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 12px;
            border-radius: 12px;
            background: transparent;
            color: var(--text-secondary);
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            border: none;
            white-space: nowrap;
        }

        .mode-btn:hover {
            color: var(--text-primary);
            background: rgba(0, 0, 0, 0.03);
        }

        .mode-btn.active {
            background: var(--bg-surface);
            color: var(--text-primary);
            box-shadow: var(--shadow-subtle);
        }

        .mode-btn span {
            white-space: nowrap;
        }

        .input-wrapper {
            background: var(--bg-body);
            border-radius: 28px;
            padding: 8px 8px 8px 24px;
            display: flex;
            align-items: center;
            gap: 12px;
            transition: box-shadow 0.2s;
            border: 1px solid transparent;
        }

        .input-wrapper:focus-within {
            background: var(--bg-surface);
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
            border-color: var(--border-light);
        }

        .input-field {
            flex: 1;
            background: transparent;
            font-size: 15px;
            color: var(--text-primary);
            padding: 8px 0;
            min-height: 24px;
        }
        
        .input-field::placeholder {
            color: var(--text-tertiary);
        }

        .action-group {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .btn-icon {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s;
            background: transparent;
        }

        .btn-icon:hover {
            background: rgba(0,0,0,0.05);
            color: var(--text-primary);
        }

        .btn-send {
            background: var(--text-primary);
            color: white;
            padding: 0 24px;
            height: 40px;
            border-radius: 20px;
            font-size: 13px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            cursor: pointer;
            transition: transform 0.1s, opacity 0.2s;
        }

        .btn-send:hover {
            opacity: 0.9;
        }
        
        .btn-send:active {
            transform: scale(0.96);
        }

        /* OVERLAY & MODALS */
        .overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.3);
            backdrop-filter: blur(2px);
            z-index: 45;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
        }
        
        .overlay.active {
            opacity: 1;
            pointer-events: all;
        }

        .modal-wrapper {
            position: fixed;
            inset: 0;
            z-index: 100;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.3s;
        }

        .modal-wrapper.active {
            opacity: 1;
            pointer-events: all;
        }

        .modal-card {
            background: white;
            width: 90%;
            max-width: 480px;
            border-radius: 24px;
            padding: 32px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
            transform: scale(0.95);
            transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
            position: relative;
        }

        .modal-wrapper.active .modal-card {
            transform: scale(1);
        }

        .modal-close-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: var(--bg-body);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-secondary);
        }

        /* Toast */
        .toast {
            position: fixed;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%) translateY(20px);
            background: rgba(26, 26, 26, 0.9);
            backdrop-filter: blur(4px);
            color: white;
            padding: 12px 24px;
            border-radius: 50px;
            font-size: 14px;
            font-weight: 500;
            opacity: 0;
            transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
            z-index: 200;
            pointer-events: none;
            box-shadow: 0 10px 20px rgba(0,0,0,0.15);
        }
        
        .toast.visible {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }

        /* IMAGE SETTINGS PANEL */
        .image-settings {
            background: var(--bg-body);
            border-radius: 16px;
            padding: 16px;
            margin-bottom: 12px;
            border: 1px solid var(--border-light);
            max-width: 100%;
            overflow-x: hidden;
        }

        .settings-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
            gap: 12px;
        }

        .setting-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .setting-label {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .setting-select {
            background: var(--bg-surface);
            border: 1px solid var(--border-light);
            border-radius: 10px;
            padding: 10px 12px;
            font-size: 14px;
            color: var(--text-primary);
            cursor: pointer;
            transition: all 0.2s ease;
            font-weight: 500;
        }

        .setting-select:hover {
            border-color: var(--text-tertiary);
        }

        .setting-select:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

        /* MEDIA QUERIES */
        @media (max-width: 640px) {
            .scrollable-content { padding: 12px; }
            .input-area-sticky { padding: 8px 12px; }
            .message-bubble {
                max-width: 90%;
                padding: 12px 16px;
                font-size: 14px;
            }
            .mode-btn {
                padding: 6px 10px;
                font-size: 12px;
            }
            .mode-btn span {
                font-size: 12px;
            }
            .cards-grid {
                grid-template-columns: 1fr;
                gap: 12px;
            }
            .alert-box {
                padding: 12px;
                gap: 12px;
                font-size: 13px;
            }
            .settings-row {
                grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
                gap: 8px;
            }
            .image-settings {
                padding: 12px;
            }
            .setting-label {
                font-size: 11px;
            }
            .setting-select {
                font-size: 13px;
                padding: 8px 10px;
            }
        }

        @media (min-width: 1024px) {
            .mobile-header { display: none; }
            .sidebar {
                transform: translateX(0);
                position: relative;
                border-right: 1px solid var(--border-light);
            }
            .cards-grid { grid-template-columns: repeat(4, 1fr); }
            .input-wrapper { padding: 10px 10px 10px 32px; }
            .bubble-left, .bubble-right { max-width: 60%; }
            .scrollable-content { padding: 24px; }
            .input-area-sticky { padding: 20px 24px; }
        }