html, body { height: 100%; overflow: hidden; }
body { font-family: 'Inter', sans-serif; background-color: #131314; color: #e3e3e3; }
html, body {
            height: 100%;
            overflow: hidden;
        }
        body {
            font-family: 'Inter', sans-serif;
            background-color: #131314;
            color: #e3e3e3;
        }
        
        /* Switched to CSS Grid for robust full-page layout */
        #app-container {
            height: 100%; /* Use 100% to respect parent, JS will set the body/html height */
            display: grid;
            grid-template-rows: auto 1fr auto; /* Header, Main (stretches), Footer */
        }
        
        /* Header styling */
        header {
            background-color: #131314;
            border-bottom: 1px solid #333;
        }
        #fun-fact-btn {
            background: linear-gradient(90deg, #89b3f8, #9a89f7, #d783f5);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            text-fill-color: transparent;
        }

        /* Main chat area styling */
        #chat-container {
            overflow-y: auto; /* Only this container will scroll */
            padding: 1rem 0;
            display: flex;
            flex-direction: column;
        }
        #chat-box {
            width: 100%;
            max-width: 68rem;
            margin: 0 auto;
            padding: 0 1rem;
        }
        
        /* Class to center chat box initially */
        #chat-box.initial-center {
            margin-top: auto;
            margin-bottom: auto;
        }

        /* Chat bubble styling */
        .chat-message-wrapper {
            display: flex;
            gap: 1rem;
            margin-bottom: 1.5rem;
        }
        .chat-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            flex-shrink: 0;
        }
        .avatar-user {
            background-color: #4f46e5;
            color: white;
        }
        .avatar-ai {
            background: linear-gradient(135deg, #4285f4, #9b72cb);
            color: white;
        }
        .chat-bubble {
            max-width: 90%;
            padding: 1px;
            word-wrap: break-word;
            position: relative;
        }
        .chat-bubble .content {
             padding: 12px 18px;
        }
        .chat-bubble.user .content {
            background-color: #4f46e51a;
            border-radius: 6px 20px 20px 20px;
        }
        .chat-bubble.ai .content {
            background-color: #1e1f20;
            border-radius: 6px 20px 20px 20px;
        }
        .chat-bubble.ai p { margin: 0.5em 0; }
        .chat-bubble.ai ul { margin-left: 20px; list-style-type: '👉'; padding-left: 1em; }
        .chat-bubble.ai strong { color: #89b3f8; }

        /* Clarification bubble styling */
        .chat-bubble.clarification .content {
            background-color: #2c2144;
            border: 1px solid #4f46e5;
        }
        .clarification-btn {
            background-color: #282a2d; border: 1px solid #555; padding: 6px 12px;
            border-radius: 16px; cursor: pointer; transition: all 0.2s ease;
            font-size: 0.875rem; font-weight: 500; color: #e3e3e3;
        }
        .clarification-btn:hover { background-color: #4f46e5; }
        
        /* Typing indicator animation */
        .typing-indicator span {
            height: 8px; width: 8px; margin: 0 2px;
            background-color: #9e9e9e; border-radius: 50%;
            display: inline-block; animation: bounce 1.4s infinite ease-in-out both;
        }
        .typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
        .typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
        @keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }

        /* Reply button on hover */
        .reply-btn {
            position: absolute; top: 50%; right: -40px;
            transform: translateY(-50%);
            background-color: #2c2d2f; border-radius: 50%;
            padding: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
            cursor: pointer; opacity: 0; transition: opacity 0.2s ease;
        }
        .chat-bubble:hover .reply-btn { opacity: 1; }

        /* Footer and Input area styling */
        footer {
            background-color: #131314;
            padding: 0.5rem 1rem 1rem 1rem;
        }
        .footer-content {
            max-width: 68rem;
            margin: 0 auto;
        }
        
        /* Mode selector mobile scrolling */
        #mode-selector {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 0.75rem;
            overflow-x: auto;
            white-space: nowrap;
            -ms-overflow-style: none;
            scrollbar-width: none;
        }
        #mode-selector::-webkit-scrollbar {
            display: none;
        }
        .mode-btn {
            padding: 6px 16px; border-radius: 9999px; font-weight: 500;
            background-color: #282a2d; color: #e3e3e3;
            border: 1px solid #444;
            cursor: pointer;
            flex-shrink: 0;
            transition: background-color 0.2s ease;
        }
        .mode-btn:hover { background-color: #3c3d40; }
        .mode-btn.active { background-color: #4f46e5; border-color: #4f46e5; color: white; }

        /* Reply context bar styling */
        #reply-context-bar {
            background-color: #282a2d;
            border-left-color: #89b3f8;
        }
        
        /* Input field and send button */
        .input-wrapper {
            position: relative;
        }
        #user-input {
            width: 100%;
            border-radius: 28px;
            background-color: #1e1f20;
            border: 1px solid #444;
            color: #e3e3e3;
            padding: 14px 56px 14px 20px;
            font-size: 1rem;
            transition: border-color 0.2s;
        }
        #user-input:focus {
            outline: none;
            border-color: #89b3f8;
            box-shadow: none;
            --tw-ring-shadow: none;
        }
        #send-btn {
            position: absolute;
            right: 8px;
            top: 50%;
            transform: translateY(-50%);
            background-color: #4f46e5;
        }
         #send-btn:hover {
            background-color: #6366f1;
        }
        #send-btn:disabled {
            background-color: #3c3d40;
            cursor: not-allowed;
        }

        /* Initial Loader */
        .spinner {
             animation: spin 1s linear infinite;
        }
        @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }