        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            height: 100vh;
            background-color: #f4f7f6;
        }
        .header {
            background-color: #2c3e50;
            color: white;
            padding: 15px;
            text-align: center;
            font-size: 1.5em;
        }
        .container {
            display: flex;
            flex-direction: column;
            flex-grow: 1;
            padding: 20px;
            max-width: 800px;
            margin: 0 auto;
            width: 100%;
        }
        .api-key-section {
            margin-bottom: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            background-color: #e8f5e9; /* Light green */
            display: flex;
            align-items: center;
        }
        .api-key-section label {
            margin-right: 10px;
            font-weight: bold;
            color: #388e3c; /* Darker green */
            white-space: nowrap;
        }
        .api-key-section input[type="text"] {
            flex-grow: 1;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 1em;
            margin-right: 10px;
            min-width: 150px; /* Ensure input doesn't shrink too much */
        }
        .api-key-section button {
            padding: 10px 15px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1em;
            white-space: nowrap;
        }
        .api-key-section button:hover {
            background-color: #45a049;
        }

        /* New styles for model selection */
        .model-selection-section {
            margin-bottom: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            background-color: #e3f2fd; /* Light blue */
            display: flex;
            align-items: center;
        }
        .model-selection-section label {
            margin-right: 10px;
            font-weight: bold;
            color: #1976d2; /* Darker blue */
            white-space: nowrap;
        }
        .model-selection-section select {
            flex-grow: 1;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 1em;
            min-width: 150px;
            appearance: none; /* Remove default dropdown arrow */
            background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007bff%22%20d%3D%22M287%20164.7c-4.6%204.6-10.7%207-16.5%207-5.9%200-11.7-2.3-16.5-7L146.2%2054.6%2042.4%20158.4c-4.8%204.6-10.9%207-16.5%207s-11.7-2.3-16.5-7c-9.1-9.3-9.1-24.1-.2-33.3L130%2010.5c9.2-9.2%2024.1-9.2%2033.3%200L287%20131.4c9.1%209.2%209.1%2024.1-.1%2033.3z%22/%3E%3Csvg%3E'); /* Custom arrow */
            background-repeat: no-repeat;
            background-position: right 10px center;
            background-size: 12px;
            padding-right: 30px; /* Make space for the arrow */
        }

        /* New styles for system instruction */
        .system-instruction-section {
            margin-bottom: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            background-color: #fff3e0; /* Light orange */
            display: flex; /* Use flexbox to align label, textarea, button */
            flex-direction: column; /* Stack items vertically */
        }
        .system-instruction-section label {
            display: block;
            margin-bottom: 10px;
            font-weight: bold;
            color: #ef6c00; /* Darker orange */
        }
        .system-instruction-section textarea {
            width: calc(100% - 22px); /* Account for padding and border */
            min-height: 80px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-family: Arial, sans-serif;
            font-size: 0.9em;
            resize: vertical;
        }
        .system-instruction-section button {
            margin-top: 10px;
            padding: 8px 15px;
            background-color: #dc3545; /* Red for clear/remove action */
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9em;
            font-weight: bold;
            align-self: flex-end; /* Align button to the right */
        }
        .system-instruction-section button:hover {
            background-color: #c82333;
        }

        /* New styles for chat action buttons */
        .chat-actions-section {
            margin-bottom: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            background-color: #e0f7fa; /* Light cyan */
            display: flex;
            flex-wrap: wrap; /* Allow buttons to wrap */
            gap: 10px;
            justify-content: center;
        }
        .chat-actions-section button {
            padding: 10px 15px;
            background-color: #00bcd4; /* Cyan */
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1em;
            font-weight: bold;
            flex-grow: 1;
            max-width: 180px; /* Adjusted for more buttons */
        }
        .chat-actions-section button:hover {
            background-color: #00838f; /* Darker cyan */
        }


        .chat-history {
            flex-grow: 1;
            overflow-y: auto;
            border: 1px solid #ccc;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 20px;
            background-color: #ffffff;
            display: flex;
            flex-direction: column;
        }
        .message-bubble {
            max-width: 80%;
            margin-bottom: 10px;
            padding: 10px 15px;
            border-radius: 18px;
            position: relative;
            word-wrap: break-word;
            min-height: 20px; /* Ensure content has some height */
        }
        .message-bubble.user-message {
            background-color: #dcf8c6;
            align-self: flex-end;
            margin-left: auto;
            border-bottom-right-radius: 2px;
        }
        .message-bubble.model-message {
            background-color: #e0e0e0;
            align-self: flex-start;
            margin-right: auto;
            border-bottom-left-radius: 2px;
        }
        /* Removed contenteditable specific styles as we're using a separate raw editor */
        .message-bubble p {
            margin: 0;
        }

        /* New styles for raw chat history section */
        .raw-chat-history-section {
            margin-top: 10px;
            margin-bottom: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            background-color: #f8f9fa; /* Light grey */
        }
        .raw-chat-history-section label {
            display: block;
            margin-bottom: 10px;
            font-weight: bold;
            color: #333;
        }
        .raw-chat-history-section textarea {
            width: calc(100% - 22px); /* Account for padding and border */
            min-height: 150px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-family: 'Courier New', Courier, monospace;
            font-size: 0.9em;
            resize: vertical; /* Allow vertical resizing */
            margin-bottom: 10px;
        }
        .raw-chat-history-section .debug-controls {
            display: flex;
            gap: 10px;
            margin-bottom: 10px;
            justify-content: flex-end; /* Align debug button to the right */
        }
        .raw-chat-history-section .debug-controls button {
            padding: 8px 12px;
            background-color: #6c757d; /* Grey for debug */
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9em;
            font-weight: normal;
        }
        .raw-chat-history-section .debug-controls button:hover {
            background-color: #5a6268;
        }
        /* Class to hide elements */
        .hidden {
            display: none;
        }

        /* New section for API Request/Response Debug */
        .api-debug-section {
            margin-bottom: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            background-color: #ffe0b2; /* Light orange for API debug */
            display: flex;
            flex-direction: column;
        }
        .api-debug-section button {
            padding: 10px 15px;
            background-color: #ff9800; /* Orange */
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1em;
            font-weight: bold;
            margin-bottom: 10px;
        }
        .api-debug-section button:hover {
            background-color: #fb8c00; /* Darker orange */
        }
        .api-debug-section h4 {
            margin-top: 15px;
            margin-bottom: 5px;
            color: #e65100; /* Darker orange */
            font-size: 1em;
        }
        .api-debug-section pre {
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 10px;
            overflow-x: auto;
            white-space: pre-wrap; /* Wrap long lines */
            word-break: break-all; /* Break words to prevent overflow */
            font-family: 'Courier New', Courier, monospace;
            font-size: 0.85em;
            max-height: 300px; /* Limit height */
            margin-bottom: 10px;
        }


        .chat-input-area {
            display: flex;
            border-top: 1px solid #eee;
            padding-top: 15px;
            align-items: flex-end; /* Align textarea and button at bottom */
        }
        .chat-input-area textarea {
            flex-grow: 1;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-right: 10px;
            resize: none;
            font-size: 1em;
            height: 50px; /* Initial height */
            box-sizing: border-box; /* Include padding and border in the element's total width and height */
        }
        .chat-input-area button {
            padding: 10px 20px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1em;
            height: 50px; /* Match textarea height for alignment */
            min-width: 80px;
        }
        .chat-input-area button:hover {
            background-color: #0056b3;
        }

        /* Status messages moved to top */
        .error-message {
            color: red;
            margin-bottom: 5px; /* Add space below error */
            text-align: center;
            min-height: 20px;
        }
        .token-stats {
            margin-top: 10px; /* Add space above it */
            margin-bottom: 20px; /* Push content below it down */
            padding: 10px;
            background-color: #f0f0f0;
            border-radius: 5px;
            text-align: center;
            font-size: 0.9em;
            color: #555;
            min-height: 20px;
            font-weight: bold;
            border: 1px solid #ddd;
        }
        .token-stats > div { /* Style for individual token lines */
            margin: 5px 0;
        }


        /* New section for "Remove Last Entry" button */
        .quick-actions-section {
            margin-top: -10px; /* Adjust to bring it closer to the input area */
            margin-bottom: 20px; /* Standard spacing for sections */
            display: flex;
            justify-content: flex-end; /* Align to the right */
            gap: 10px; /* Add gap between buttons */
        }
        .quick-actions-section button { /* General style for buttons in this section */
            padding: 8px 15px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9em;
            font-weight: bold;
        }
        .quick-actions-section button#removeLastEntryButton { /* Specific style for remove button */
            background-color: #dc3545; /* Red for remove/danger */
            color: white;
        }
        .quick-actions-section button#removeLastEntryButton:hover {
            background-color: #c82333; /* Darker red */
        }
        .quick-actions-section button#regenerateSystemReplyButton { /* Specific style for regenerate button */
            background-color: #007bff; /* Primary blue */
            color: white;
        }
        .quick-actions-section button#regenerateSystemReplyButton:hover {
            background-color: #0056b3; /* Darker blue */
        }