        * {
            box-sizing: border-box;
        }

        :root {
            /* Default Dark Theme Variables */
            --body-bg: #1a1a2e;
            --chat-container-bg: transparent;
            --ai-response-area-bg: transparent;
            --ai-response-text-color: #e0e0e0;
            --user-message-display-text-color: #9090aa;
            --input-area-bg: #24243e;
            --input-field-bg: #303050;
            --input-text-color: #e0e0e0;
            --input-placeholder-color: #9090aa;
            --button-bg: #4a4a70;
            --button-text-color: #ffffff;
            --button-hover-bg: #5a5a80;
            --options-container-bg: transparent;
            --option-bubble-bg: #303050;
            --option-bubble-text: #c0c0e0;
            --option-bubble-hover-bg: #4a4a70;
            --option-bubble-border: #4a4a70;
            --border-color: #303050;
            --scrollbar-track: #24243e;
            --scrollbar-thumb: #4a4a70;
            --scrollbar-thumb-border: #24243e;
            --theme-toggle-button-bg: #4a4a70;
            --theme-toggle-button-text: #e0e0e0;
            --theme-toggle-button-hover-bg: #5a5a80;
            --box-shadow-color: rgba(0, 0, 0, 0.3);
            --cursor-color: #e0e0e0;
            --footer-text-color: #9090aa;
            --modal-bg: #1a1a2e;
            --modal-content-bg: #24243e;
            --modal-text-color: #e0e0e0;
        }

        body.light-mode {
            --body-bg: #f0f2f5;
            --ai-response-area-bg: transparent;
            --ai-response-text-color: #1c1e21;
            --user-message-display-text-color: #606770;
            --input-area-bg: #f0f2f5;
            --input-field-bg: #ffffff;
            --input-text-color: #1c1e21;
            --input-placeholder-color: #606770;
            --button-bg: #0056b3;
            --button-text-color: #ffffff;
            --button-hover-bg: #004494;
            --option-bubble-bg: #e9e9eb;
            --option-bubble-text: #333333;
            --option-bubble-hover-bg: #d0d0d9;
            --option-bubble-border: #ced0d4;
            --border-color: #ced0d4;
            --scrollbar-track: #f0f2f5;
            --scrollbar-thumb: #c1c1c1;
            --scrollbar-thumb-border: #f0f2f5;
            --theme-toggle-button-bg: #e0e0e0;
            --theme-toggle-button-text: #1c1e21;
            --theme-toggle-button-hover-bg: #d0d0d0;
            --box-shadow-color: rgba(0, 0, 0, 0.1);
            --cursor-color: #1c1e21;
            --footer-text-color: #606770;
            --modal-bg: rgba(255, 255, 255, 0.9);
            --modal-content-bg: #ffffff;
            --modal-text-color: #1c1e21;
        }

        html,
        body {
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
            /* Prevent body scroll */
        }

        body {
            font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
            background-color: var(--body-bg);
            color: var(--ai-response-text-color);
            transition: background-color 0.3s, color 0.3s;
        }

        /* Main Layout Container */
        .main-container {
            display: flex;
            flex-direction: column;
            height: 100%;
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
            position: relative;
        }

        /* Top Bar (Theme Toggle & History) */
        .theme-toggle-container {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            padding: 15px;
            gap: 10px;
            z-index: 100;
            flex-shrink: 0;
            /* Don't shrink */
        }

        #themeToggleButton,
        .icon-button {
            background-color: var(--theme-toggle-button-bg);
            color: var(--theme-toggle-button-text);
            border: 1px solid var(--border-color);
            padding: 6px 10px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 0.8rem;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .icon-button {
            padding: 6px;
            border-radius: 50%;
            width: 32px;
            height: 32px;
        }

        #themeToggleButton:hover,
        .icon-button:hover {
            background-color: var(--theme-toggle-button-hover-bg);
        }

        /* Content Wrapper (AI Response) */
        .content-wrapper {
            flex: 1;
            /* Take all remaining space */
            min-height: 0;
            /* Crucial for nested scrolling */
            display: flex;
            flex-direction: column;
            position: relative;
            overflow: hidden;
            /* Contain the scrollable area */
        }

        .ai-response-container {
            width: 100%;
            max-width: 900px;
            margin: 0 auto;
            padding: 20px;
            background-color: var(--ai-response-area-bg);
            overflow-y: auto;
            /* Enable vertical scrolling */
            height: 100%;
            /* Fill the wrapper */

            /* Custom Scrollbar */
            scrollbar-width: thin;
            scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);

            /* Fade out at the top to prevent abrupt cut-off */
            -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 100%);
            mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 100%);
        }

        .ai-response-container::-webkit-scrollbar {
            width: 8px;
        }

        .ai-response-container::-webkit-scrollbar-track {
            background: var(--scrollbar-track);
            border-radius: 10px;
            margin-top: 20px;
        }

        .ai-response-container::-webkit-scrollbar-thumb {
            background-color: var(--scrollbar-thumb);
            border-radius: 10px;
            border: 2px solid var(--scrollbar-thumb-border);
        }

        .ai-message-content {
            font-size: 2.2rem;
            line-height: 1.6;
            color: var(--ai-response-text-color);
            white-space: pre-wrap;
            word-wrap: break-word;
            transition: font-size 0.3s;
            padding-bottom: 20px;
            /* Extra padding at bottom */
        }

        .typing-cursor {
            display: inline-block;
            width: 3px;
            height: 1em;
            background-color: var(--cursor-color);
            animation: blink 1s step-end infinite;
            margin-left: 2px;
            vertical-align: text-bottom;
        }

        @keyframes blink {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0;
            }
        }

        /* Bottom Container (User Msg, Options, Input, Footer) */
        .bottom-container {
            flex-shrink: 0;
            /* Don't shrink */
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            padding-bottom: 10px;
            background: linear-gradient(to top, var(--body-bg) 80%, transparent);
            z-index: 50;
        }

        .current-user-message-container {
            width: 90%;
            max-width: 600px;
            text-align: right;
            padding: 5px 15px;
            margin-bottom: 5px;
            min-height: 25px;
            display: flex;
            justify-content: flex-end;
            align-items: center;
        }

        .current-user-message {
            font-size: 0.9rem;
            color: var(--user-message-display-text-color);
            font-style: italic;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .options-container-wrapper {
            width: 100%;
            display: flex;
            justify-content: center;
            /* Center options on desktop too for better flow */
            margin-bottom: 10px;
            padding: 0 10px;
        }

        .options-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 8px;
            max-width: 800px;
        }

        .option-bubble {
            background-color: var(--option-bubble-bg);
            color: var(--option-bubble-text);
            padding: 8px 15px;
            border-radius: 18px;
            cursor: pointer;
            font-size: 0.85rem;
            border: 1px solid var(--option-bubble-border);
            transition: all 0.2s;
        }

        .option-bubble:hover {
            background-color: var(--option-bubble-hover-bg);
            transform: translateY(-2px);
        }

        .input-area-wrapper {
            width: 90%;
            max-width: 600px;
            margin-bottom: 10px;
        }

        .input-area {
            display: flex;
            padding: 8px;
            border-radius: 25px;
            background-color: var(--input-area-bg);
            box-shadow: 0 5px 15px var(--box-shadow-color);
            border: 1px solid var(--border-color);
        }

        .input-area input[type="text"] {
            flex-grow: 1;
            padding: 12px 15px;
            border: none;
            border-radius: 20px 0 0 20px;
            background-color: var(--input-field-bg);
            color: var(--input-text-color);
            outline: none;
            font-size: 0.95rem;
        }

        .input-area button {
            padding: 12px 20px;
            background-color: var(--button-bg);
            color: var(--button-text-color);
            border: none;
            border-radius: 0 20px 20px 0;
            cursor: pointer;
            font-size: 0.95rem;
            transition: background-color 0.3s;
        }

        .input-area button:hover {
            background-color: var(--button-hover-bg);
        }

        .footer-container {
            width: 100%;
            padding: 5px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.75rem;
        }

        .footer-copyright-text,
        .footer-button {
            color: var(--footer-text-color);
            text-decoration: none;
            opacity: 0.7;
            transition: opacity 0.3s;
        }

        .footer-button:hover {
            opacity: 1;
            text-decoration: underline;
        }

        /* History Modal */
        .modal {
            display: none;
            /* Hidden by default */
            position: fixed;
            z-index: 200;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.5);
            /* Black w/ opacity */
            backdrop-filter: blur(5px);
        }

        .modal-content {
            background-color: var(--modal-content-bg);
            margin: 5% auto;
            padding: 20px;
            border: 1px solid var(--border-color);
            width: 90%;
            max-width: 600px;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            display: flex;
            flex-direction: column;
            height: 80vh;
            color: var(--modal-text-color);
            position: relative;
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 10px;
            margin-bottom: 10px;
        }

        .close-modal {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }

        .close-modal:hover,
        .close-modal:focus {
            color: var(--modal-text-color);
            text-decoration: none;
            cursor: pointer;
        }

        .modal-body {
            flex-grow: 1;
            overflow-y: auto;
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        /* Chat Bubbles in History */
        .chat-bubble {
            padding: 10px 15px;
            border-radius: 15px;
            max-width: 80%;
            word-wrap: break-word;
            line-height: 1.4;
            font-size: 0.9rem;
        }

        .chat-bubble.user {
            align-self: flex-end;
            background-color: var(--button-bg);
            color: var(--button-text-color);
            border-bottom-right-radius: 2px;
        }

        .chat-bubble.assistant {
            align-self: flex-start;
            background-color: var(--input-field-bg);
            color: var(--input-text-color);
            border: 1px solid var(--border-color);
            border-bottom-left-radius: 2px;
        }

        /* Mobile Adjustments */
        @media (max-width: 768px) {
            .ai-message-content {
                font-size: 1.4rem;
                /* Slightly larger for readability */
            }

            .content-wrapper {
                padding: 0 10px;
            }

            .ai-response-container {
                padding: 10px;
            }

            .options-container {
                gap: 6px;
            }

            .option-bubble {
                padding: 6px 12px;
                font-size: 0.75rem;
            }

            .input-area-wrapper {
                width: 95%;
            }

            .modal-content {
                width: 95%;
                margin: 10% auto;
                height: 70vh;
            }
        }

        @media (max-width: 360px) {
            .ai-message-content {
                font-size: 1.2rem;
            }
        }