/* =========================================
   Gemini UI Replica - Professional
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Roboto+Mono:wght@400;500&display=swap');

:root {
    /* Gemini Palette (Light Mode approximation) */
    --gem-bg-body: #ffffff;
    --gem-bg-sidebar: #f0f4f9;
    --gem-bg-hover: #e8eaed;
    --gem-bg-active: #d3e3fd;
    --gem-text-primary: #1f1f1f;
    --gem-text-secondary: #444746;
    --gem-text-tertiary: #5e5e5e;
    --gem-accent: #0b57d0;
    
    --gem-user-bubble: #f0f4f9;
    --gem-radius-l: 24px;
    --gem-radius-m: 12px;
    --gem-radius-s: 8px;
    
    --sidebar-width: 280px;
    --header-height: 64px;
    --input-max-width: 800px;
    --content-width: 800px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--gem-bg-body);
    color: var(--gem-text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden; /* Prevent body scroll, everything uses flex */
}

/* Subscription Tier Badges */
.tier-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tier-free {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.tier-plus {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    border: 1px solid #86efac;
}
.tier-pro {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border: 1px solid #93c5fd;
}
.tier-ultra {
    background: linear-gradient(135deg, #fffbeb 0%, #fcd34d 100%);
    color: #92400e;
    border: 1px solid #fde047;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.2);
}

/* Hide Global Elements */
.navbar-island, footer {
    display: none !important;
}

/* Hide default Scrollbar but keep functionality */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 3px;
}
::-webkit-scrollbar-track {
    margin-top: 10px;
    text-align: center;
}

/* =========================================
   Layout
   ========================================= */
.chat-layout-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: var(--gem-bg-body);
}

.chat-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* =========================================
   Fixed Header
   ========================================= */
/* =========================================
   Fixed Header
   ========================================= */
.chat-custom-header {
    height: var(--header-height);
    background: var(--gem-bg-body);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0; /* Remove padding to flush with sidebar */
    margin-right: 1.5rem; /* Add margin to right side only */
    border-bottom: none;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    width: var(--sidebar-width);
    background-color: var(--gem-bg-sidebar); /* Match Sidebar BG */
    height: 100%;
    padding-left: 1.5rem;
    border-top-right-radius: 0;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--gem-text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}
.header-brand img { height: 24px; width: auto; }

.header-center {
    display: flex;
    align-items: center;
    gap: 24px;
}
.header-link {
    text-decoration: none;
    color: var(--gem-text-secondary);
    font-size: 1.2rem;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.header-link:hover { 
    color: var(--gem-text-primary);
    background: #f0f4f9;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile-header {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0b57d0, #a78bfa);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s;
}
.user-profile-header:hover { transform: scale(1.05); }

/* =========================================
   Sidebar
   ========================================= */
.chat-sidebar {
    width: var(--sidebar-width);
    background-color: var(--gem-bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 0.5rem 1rem 1rem 1rem;
    flex-shrink: 0;
    border: none;
    height: 100%;
}

/* New Chat Pill */
.sidebar-top { margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: space-between;}
.btn-new-chat {
    background: #dde3ea;
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    color: #444746;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    width: 140px;
}
.btn-new-chat:hover {
    background: #d3d7de;
    color: #1f1f1f;
}

.btn-sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--gem-text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
}
.btn-sidebar-toggle:hover { background: rgba(0,0,0,0.05); }


.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.nav-section { 
    margin-bottom: 1rem; 
    flex-shrink: 0;
}

/* History section - scrollable */
.sidebar-history-section {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    margin-bottom: 0.5rem;
}

/* New Sidebar Headers */
.nav-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #8e9092; /* Muted gray for header */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-left: 1rem; /* Align with nav items padding */
}

/* Nav Item Group (Split Layout) */
.nav-item-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 4px;
    padding-right: 8px; /* Space for action button */
    border-radius: 20px;
    transition: background 0.1s;
}
.nav-item-group:hover, .nav-item-group.active {
    background-color: #e0e5eb;
}
.nav-item-group.active {
    background-color: #d3e3fd;
}

/* Main Clickable Area */
.nav-item-main {
    flex: 1;
    background: transparent;
    border: none;
    text-align: left;
    padding: 10px 16px;
    border-radius: 20px; /* Fully rounded */
    color: #444746;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    text-decoration: none;
    margin: 0;
}
.nav-item-main:hover { background: transparent; } /* Handled by group */ 

/* Active State Styles */
.nav-item-group.active .nav-item-main {
    color: #041e49;
    font-weight: 600;
}
.nav-item-group.active .nav-item-main i { color: #041e49; }

/* Action Button (The +) */
.nav-item-action {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #444746;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    opacity: 0.6; /* Subtle default */
}
.nav-item-action:hover {
    background: rgba(0,0,0,0.1);
    color: #1f1f1f;
    opacity: 1;
}

/* Update regular nav-item (legacy/unused now but good to keep safe) */
.nav-item-legacy {
    flex: 1;
    overflow-y: auto; /* Scroll ONLY the history */
    min-height: 0;
    padding-right: 4px; /* avoid scrollbar overlap */
}

/* History List Headings - Sticky */
.history-label {
    position: sticky;
    top: 0;
    background: var(--gem-bg-sidebar); /* Match sidebar background */
    z-index: 5;
    padding: 10px 8px 8px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gem-text-tertiary);
    border-bottom: 1px solid #e0e4ea;
    margin-bottom: 4px;
}

.history-list {
    display: flex;
    flex-direction: column;
}

/* .nav-item removed/refactored above, keeping legacy class just in case */

.badge-free {
    background: #c4eed0;
    color: #0f5223;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: auto;
}

.badge-soon {
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: auto;
    border: 1px solid #e2e8f0;
}

.sidebar-footer {
    padding-top: 1rem;
    flex-shrink: 0; /* Keep upgrade card fixed at bottom */
    margin-top: auto; /* Push to bottom */
}

/* Premium Upgrade Card */
.upgrade-card-premium {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--gem-text-primary);
    padding: 12px;
    border-radius: 16px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
    border: 1px solid #e1e9f5;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.upgrade-card-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(11, 87, 208, 0.1);
    border-color: #d3e3fd;
}
.upgrade-card-premium .icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff8a00, #e52e71);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 2px 5px rgba(229, 46, 113, 0.3);
}
.upgrade-card-premium .text-content .title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f1f1f;
}
.upgrade-card-premium .text-content .subtitle {
    font-size: 0.75rem;
    color: #5e5e5e;
}

/* =========================================
   Main Content Area
   ========================================= */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: white;
    border-top-left-radius: 28px;
    border-bottom-left-radius: 28px; /* Curve bottom too */
    margin: 8px 8px 8px 0; /* Add margin to create floating effect */
    box-shadow: -2px 0 10px rgba(0,0,0,0.02);
    overflow: hidden; 
}

/* View Switching */
.view-container {
    display: none; /* Hidden by default */
    flex: 1;
    flex-direction: column;
    height: 100%; /* Full height of main */
}

.view-container.active {
    display: flex; /* Show when active */
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem 150px 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;
}

.welcome-screen {
    max-width: 800px;
    width: 100%;
    margin-top: 10vh;
    padding-left: 2rem;
}
.welcome-screen h1 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: 3.5rem;
    font-weight: 400;
    /* Updated to Indigo-Magenta Gradient */
    background: linear-gradient(120deg, #4f46e5, #9333ea, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

/* Global Gradient Text Utility */
.gradient-text {
    background: linear-gradient(120deg, #4f46e5, #9333ea, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.welcome-screen .subtitle {
    font-size: 1.5rem;
    color: #c4c7c5;
    font-weight: 500;
}

.subscription-prompt-box {
    background: #f8fafd;
    border: 1px solid #e1e3e6;
    padding: 1.5rem;
    border-radius: 16px;
    max-width: 500px;
}
.subscription-prompt-box p { font-size: 0.95rem; color: #444746; }

/* Stack Builder Premium Styles */
.guest-stack-container {
    position: relative;
    z-index: 1;
}

/* Background Ambient Glow */
.guest-stack-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.15) 0%, rgba(59, 130, 246, 0.1) 40%, transparent 70%);
    z-index: -1;
    pointer-events: none;
    filter: blur(60px);
}

.premium-icon-box {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 10px 15px -3px rgba(0, 0, 0, 0.05),
        inset 0 0 20px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    font-size: 2.5rem;
    color: #4f46e5;
    background-image: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.4));
}

.stack-title-gradient {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #1e293b 0%, #475569 100%); 
    /* Or a more colorful one if preferred: linear-gradient(135deg, #4f46e5, #ec4899); */
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.stack-description {
    font-size: 1.15rem;
    line-height: 1.6;
    color: #64748b;
    font-weight: 400;
}

/* Glassmorphic Demo Card */
.glass-demo-card {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 10px 40px -10px rgba(0, 0, 0, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    padding: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.glass-demo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.12);
}

/* Premium Chips */
.prompt-chips-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    max-width: 900px;
    width: 100%;
    padding: 0 10px;
}
.prompt-chip {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 100px;
    padding: 10px 20px;
    font-size: 0.9rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.prompt-chip:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: #cbd5e1;
    transform: translateY(-1px);
    color: #1e293b;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* Hide scroll-to-top button on chat page */
.chat-layout-wrapper ~ .scroll-to-top-btn,
.chat-layout-wrapper .scroll-to-top-btn {
    display: none !important;
}

/* === Keep existing welcome screen h1 === */
.welcome-screen h1 {
    font-size: 3.5rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #4285f4 0%, #9b72cb 50%, #d96570 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}
.welcome-screen .subtitle {
    font-size: 1.5rem;
    color: #c4c7c5; 
    font-weight: 400;
    margin-bottom: 3rem;
}

/* Messages */
.message {
    width: 100%;
    max-width: var(--content-width);
    margin-bottom: 2rem;
    display: flex;
    gap: 16px;
    animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* User Message */
.user-message { justify-content: flex-end; }
.user-message .message-content {
    background: var(--gem-user-bubble);
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 1rem;
    line-height: 1.6;
    max-width: 80%;
}

/* AI Message */
.ai-message { justify-content: flex-start; }
.ai-message .message-content {
    background: transparent;
    padding: 0;
    font-size: 1rem;
    line-height: 1.6;
    width: 100%;
}

/* Neural Pulse Animation */
.loading-content {
    background: transparent !important;
    padding: 0 !important;
    min-height: 24px;
    display: flex;
    align-items: center;
}

.neural-loader {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 20px;
}

.neural-bar {
    width: 6px;
    height: 6px;
    border-radius: 99px;
    background: linear-gradient(180deg, #6366f1, #a855f7);
    animation: neuralPulse 1.2s ease-in-out infinite;
    opacity: 0.7;
}

.neural-bar.delay-1 { animation-delay: 0.15s; background: linear-gradient(180deg, #8b5cf6, #d946ef); }
.neural-bar.delay-2 { animation-delay: 0.3s; background: linear-gradient(180deg, #ec4899, #f43f5e); }

@keyframes neuralPulse {
    0%, 100% {
        height: 6px;
        transform: translateY(0);
        opacity: 0.5;
    }
    50% {
        height: 18px;
        transform: translateY(0);
        opacity: 1;
        box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
    }
}
.input-area-wrapper {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 0 1rem 1.5rem 1rem;
    background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #ffffff 40%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
}

.chat-input-container {
    width: 100%;
    max-width: var(--input-max-width);
    background: rgba(255, 255, 255, 0.7); /* Glassmorphic base */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 32px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 64px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.02),
        0 2px 4px -1px rgba(0, 0, 0, 0.02),
        inset 0 1px 2px rgba(255, 255, 255, 0.8);
}
.chat-input-container:focus-within {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.08), 
        0 8px 10px -6px rgba(0, 0, 0, 0.05);
    border-color: #e2e8f0;
}

/* Left Tools */
.input-tools-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-input-tool {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(241, 245, 249, 0.8);
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}
.btn-input-tool:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: scale(1.05);
}

/* Right Actions */
.input-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Model Selector - Premium Dropdown (Dropup) */
.model-selector-inline { position: relative; }

.model-dropdown-menu {
    top: auto !important;
    bottom: 115% !important; /* Slide up, above the button */
    margin-bottom: 0 !important;
    transform: none !important;
    max-height: 350px;
    overflow-y: auto;
    border-radius: 16px; /* Smooth corners */
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15); /* Shadow upwards */
    border: 1px solid #e0e4ea;
    min-width: 240px;
    padding: 8px;
}

.current-model {
    font-weight: 500;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-model-trigger {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid #cbd5e1;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 20px; /* Capsule */
    white-space: nowrap;
    transition: all 0.2s;
    height: 38px;
}
.btn-model-trigger:hover { 
    background: #f1f5f9;
    border-color: #94a3b8;
}
.btn-model-trigger i { font-size: 0.75rem; }

/* Custom Dropdown Styling */
.model-dropdown-menu {
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-radius: 16px;
    padding: 8px;
    min-width: 240px;
    animation: fadeInDrop 0.2s ease-out;
}
@keyframes fadeInDrop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.dropdown-item {
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #1f1f1f;
    font-weight: 500;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}
.dropdown-item:hover { background-color: #f0f4f9; }
.dropdown-item.active {
    background-color: #e8f0fe;
    color: #0b57d0;
}
.dropdown-item .premium-badge {
    font-size: 0.65rem;
    background: linear-gradient(135deg, #fce8e6, #fff0e3);
    color: #c5221f;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
    margin-left: auto; /* Push to right */
}

.input-divider { display: none; }

#chatInput, #stackInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    max-height: 200px;
    padding: 12px 0;
    font-size: 1.05rem;
    line-height: 1.5;
    color: #1f1f1f;
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-width: 0; /* Fix flex issue */
}

/* Send Button */
.send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #9333ea); /* Indigo to Purple */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.25);
}
.send-btn:hover:not(:disabled) {
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 8px 15px rgba(79, 70, 229, 0.35);
}
.send-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}



.input-disclaimer {
    font-size: 0.75rem;
    color: var(--gem-text-tertiary);
    margin-top: 10px;
    text-align: center;
}

/* =========================================
   Modern Stack Builder Results (Timeline)
   ========================================= */
.stack-response {
    animation: fadeIn 0.4s ease-out;
}

.response-header { margin-bottom: 2rem; }
.response-header h2 { font-size: 1.8rem; font-weight: 500; margin-bottom: 0.5rem; letter-spacing: -0.02em; }
.response-summary { color: var(--gem-text-secondary); font-size: 1.05rem; line-height: 1.6; }

/* Timeline Container */
.timeline-container {
    padding-left: 20px;
    position: relative;
    border-left: 2px solid #e2e8f0;
    margin-left: 8px;
}

.timeline-step {
    position: relative;
    padding-left: 32px;
    margin-bottom: 2.5rem;
}

/* Dot on the timeline */
.timeline-marker {
    position: absolute;
    left: -29px; /* Adjust to center on line (2px line, left 20px padding) -> -20 - 9 roughly */
    top: 4px;
    width: 20px;
    height: 20px;
    background: white;
    border: 2px solid #4f46e5;
    border-radius: 50%;
    color: #4f46e5;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.step-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: #1e293b;
}

.step-description {
    color: #64748b;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.step-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

/* Modern Tool Card */
.modern-tool-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.modern-tool-card:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    border-color: #cbd5e1;
}

.tool-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.tool-info { flex: 1; min-width: 0; }

.tool-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-category {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

.tool-card-body p {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-visit-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tool-visit-icon:hover {
    background: #4f46e5;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

/* Legacy Logo Styles (Still used) */
.tool-logo {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.tool-logo-placeholder {
    width: 32px;
    height: 32px;
    background: #e0e0e0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Feedback Actions */
.response-feedback {
    display: flex;
    gap: 8px;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}
.btn-feedback {
    background: transparent;
    border: none;
    color: var(--gem-text-tertiary);
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-feedback:hover {
    background: #f0f4f9;
    color: var(--gem-text-primary);
}

/* =========================================
   Mobile & Responsive Styles
   ========================================= */

/* Sidebar Backdrop Overlay */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* Tablet and below (< 992px) */
@media (max-width: 991px) {
    :root {
        --header-height: 56px;
        --sidebar-width: 280px;
    }

    .chat-custom-header {
        height: var(--header-height);
        padding: 0 1rem;
    }

    .header-left {
        width: auto;
        padding-left: 0;
        background: transparent;
    }

    .header-brand {
        font-size: 1.1rem;
    }

    .header-brand img {
        height: 20px;
    }

    .header-center {
        display: none;
    }

    /* Welcome screen adjustments */
    .welcome-screen {
        margin-top: 5vh;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .welcome-screen h1 {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .welcome-screen .subtitle {
        font-size: 1.2rem;
    }

    /* Prompt chips - Horizontal scroll */
    .prompt-chips-container {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 10px;
        padding: 0 1rem 10px 1rem;
        margin-bottom: 15px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }

    .prompt-chips-container::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }

    .prompt-chip {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

/* Mobile phones (< 768px) */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .chat-layout-wrapper {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        position: fixed;
        overflow: hidden;
        width: 100%;
    }

    .chat-workspace {
        height: calc(100% - var(--header-height));
    }

    .chat-custom-header {
        padding: 0 0.75rem;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .header-left {
        gap: 12px;
    }

    .btn-sidebar-toggle {
        font-size: 1.4rem;
        padding: 8px;
    }

    /* Sidebar - Off-canvas with backdrop - SLIDES FROM LEFT */
    .chat-sidebar {
        position: fixed;
        left: 0 !important;
        right: auto !important;
        top: 0 !important; /* Full height starting from top */
        height: 100vh !important;
        height: 100dvh !important; 
        z-index: 2000 !important; /* Above EVERYTHING including header */
        width: var(--sidebar-width);
        box-shadow: 2px 0 20px rgba(0,0,0,0.2);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        transform: translateX(-100%) !important;
        display: flex !important;
        visibility: visible !important;
        background-color: var(--gem-bg-sidebar);
        padding-top: 1rem; /* Add some padding since header is covered */
    }

    .chat-sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 24px rgba(0,0,0,0.15) !important;
    }

    /* Adjust sidebar nav padding if needed */
    .chat-sidebar .sidebar-nav {
        margin-top: 10px;
    }

    /* Main content area */
    .chat-main {
        border-radius: 0;
        margin: 0;
        box-shadow: none;
        height: 100%;
    }

    /* Messages container */
    .messages-container {
        padding: 1rem 0.75rem 160px 0.75rem;
    }

    /* Welcome screen mobile */
    .welcome-screen {
        margin-top: 2vh;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .welcome-screen h1 {
        font-size: 2rem;
        line-height: 1.2;
        margin-bottom: 0.75rem;
    }

    .welcome-screen .subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    /* Guest welcome containers */
    .guest-welcome-container,
    .guest-stack-container {
        min-height: 40vh !important;
        padding: 1rem;
    }

    .guest-welcome-container h1,
    .guest-stack-container h1 {
        font-size: 1.75rem !important;
    }

    .guest-welcome-container .lead,
    .guest-stack-container .lead {
        font-size: 0.95rem !important;
    }

    .premium-icon-box {
        width: 60px;
        height: 60px;
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    .glass-demo-card {
        padding: 1.5rem;
    }

    /* Input area - Sticky at bottom */
    .input-area-wrapper {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 0 0.75rem 1rem 0.75rem;
        background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.98) 20%, #ffffff 100%);
        z-index: 50;
    }

    .chat-input-container {
        max-width: 100%;
        min-height: 56px;
        padding: 10px 16px;
        border-radius: 28px;
    }

    #chatInput,
    #stackInput {
        font-size: 1rem;
        padding: 8px 0;
    }

    /* Input tools - Compact on mobile */
    .input-tools-left {
        gap: 4px;
    }

    .btn-input-tool {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    /* Model selector - Compact */
    .model-selector-inline {
        display: none; /* Hide on very small screens, or make smaller */
    }

    .btn-model-trigger {
        padding: 6px 12px;
        font-size: 0.75rem;
        height: 34px;
    }

    .current-model {
        max-width: 80px;
    }

    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }

    /* Message bubbles */
    .message {
        margin-bottom: 1.5rem;
    }

    .user-message .message-content {
        max-width: 90%;
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    .ai-message .message-content {
        font-size: 0.95rem;
    }

    /* Markdown in messages */
    .markdown-body {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .markdown-body h2 {
        font-size: 1.3rem;
        margin-top: 1.5rem;
    }

    .markdown-body h3 {
        font-size: 1.1rem;
    }

    .markdown-body pre {
        margin: 1rem 0;
        border-radius: 10px;
    }

    .markdown-body pre code {
        font-size: 0.85rem;
        padding: 12px;
    }

    /* Stack Builder Results */
    .timeline-container {
        padding-left: 15px;
        margin-left: 4px;
    }

    .timeline-marker {
        width: 18px;
        height: 18px;
        left: -26px;
        font-size: 0.65rem;
    }

    .timeline-step {
        padding-left: 24px;
        margin-bottom: 2rem;
    }

    .step-title {
        font-size: 1.1rem;
    }

    .step-description {
        font-size: 0.9rem;
    }

    .step-tools-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .modern-tool-card {
        padding: 12px;
    }

    .tool-name {
        font-size: 0.9rem;
    }

    .tool-category {
        font-size: 0.7rem;
    }

    .tool-card-body p {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    /* User profile header - Show on mobile */
    .user-profile-header {
        font-size: 0.8rem;
        padding: 0 12px;
        width: auto !important;
        display: flex !important;
    }

    .tier-badge {
        font-size: 0.6rem;
        padding: 2px 8px;
    }
    
    /* FORCE HIDE scroll-to-top on chat page - Specific Selector */
    body > .scroll-to-top-btn,
    .scroll-to-top-btn {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
        z-index: -1 !important;
    }
}

/* Very small phones (< 400px) */
@media (max-width: 400px) {
    .welcome-screen h1 {
        font-size: 1.75rem;
    }

    .chat-input-container {
        padding: 8px 12px;
    }

    .btn-input-tool {
        width: 32px;
        height: 32px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }

    .model-selector-inline {
        display: none;
    }

    .prompt-chip {
        font-size: 0.85rem;
        padding: 8px 16px;
    }
}

/* Sidebar History Styles - Fixed */
.history-section-title {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
    margin: 24px 12px 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}

.history-item {
    padding: 10px 12px;
    margin: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    display: block;
}

.history-item:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.history-item.active {
    background-color: #eff6ff; /* Blue tint */
    color: #1d4ed8;
    font-weight: 500;
}

/* =========================================
   Markdown Body Styling (AI Output)
   ========================================= */
/* Message Content */
/* --- Refined Gemini-like Markdown Styling --- */
.markdown-body {
    font-size: 1.05rem;
    line-height: 1.75;
    color: #3c4043; /* Gemini's soft black */
    font-family: 'Inter', -apple-system, sans-serif !important;
}

/* Headings */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: #1f1f1f;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.3;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
}

.markdown-body h2 { font-size: 1.5rem; }
.markdown-body h3 { font-size: 1.25rem; }

/* Paragraphs and Lists */
.markdown-body p {
    margin-bottom: 1.2rem;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1.2rem;
    padding-left: 1.5rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

/* Bold and emphasis */
.markdown-body strong {
    color: #1f1f1f;
    font-weight: 600;
}

/* Inline Code */
.markdown-body code:not(pre code) {
    background: #f1f3f4;
    color: #d93025;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
}

/* Code Blocks - Gemini Style */
.markdown-body pre {
    background: #f8f9fa !important; /* Soft light gray */
    border: 1px solid #dadce0;
    border-radius: 12px;
    margin: 1.5rem 0;
    position: relative;
    overflow: hidden;
}

/* Custom Header for Code Blocks */
.markdown-body pre::before {
    content: attr(data-lang);
    display: block;
    background: #f1f3f4;
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #5f6368;
    text-transform: uppercase;
    border-bottom: 1px solid #dadce0;
}

.markdown-body pre code {
    display: block;
    padding: 16px;
    overflow-x: auto;
    font-family: 'Roboto Mono' !important;
    font-size: 0.9rem;
    color: #404142;
    background: transparent !important;
}

/* Table Styling */
.markdown-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
    border: 1px solid #dadce0;
    border-radius: 8px;
    overflow: hidden;
}

.markdown-body th {
    background: #f8f9fa;
    font-weight: 600;
    padding: 12px;
    border-bottom: 1px solid #dadce0;
}

.markdown-body td {
    padding: 12px;
    border-bottom: 1px solid #f1f3f4;
}

.markdown-body tr:last-child td {
    border-bottom: none;
}

/* Copy Button */
.code-copy-btn {
    position: absolute;
    top: 4px;
    right: 8px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    font-family: 'Plus Jakarta Sans', sans-serif;
    z-index: 10;
}

.code-copy-btn:hover {
    background: #e0e0e0;
    color: #0f172a;
}

.code-copy-btn i {
    font-size: 0.9rem;
}


/* Blockquote */
.markdown-body blockquote {
    border-left: 4px solid #8b5cf6;
    background: #f8fafc;
    padding: 12px 16px;
    margin: 1em 0;
    border-radius: 0 8px 8px 0;
    color: #475569;
}

/* Horizontal Rule */
.markdown-body hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 2em 0;
}

/* Links */
.markdown-body a {
    color: #2563eb;
    text-decoration: none;
}
.markdown-body a:hover {
    text-decoration: underline;
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.95rem;
}
.markdown-body th, 
.markdown-body td {
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    text-align: left;
}
.markdown-body th {
    background: #f8fafc;
    font-weight: 600;
}
.markdown-body tr:nth-child(even) {
    background: #fafafa;
}

/* Coming Soon Badge */
.coming-soon-badge {
    font-size: 0.65rem;
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
    margin-left: auto;
}

.dropdown-item:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

