* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 300px;
    background: #fff;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.settings-group {
    margin-bottom: 20px;
}

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.settings-group select,
.settings-group input[type="range"],
.settings-group input[type="password"],
.settings-group input[type="number"], /* Added */
.settings-group textarea,
.settings-group input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.settings-group textarea {
    resize: vertical;
    font-family: inherit;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    margin: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column; /* Stack message content and actions vertically */
    /* align-items will be set by .user or .assistant specific rules */
}

.message.user {
    align-items: flex-end; /* User messages align to the right */
}

.message.assistant {
    align-items: flex-start; /* Assistant messages align to the left */
}

.message-content {
    max-width: 70%; /* Original max-width for message bubble */
    padding: 12px 16px;
    border-radius: 8px;
    word-wrap: break-word;
}

.message.user .message-content {
    background: #007bff;
    color: white;
}

.message.assistant .message-content {
    background: #f1f3f5;
    color: #333;
}

.message.assistant.cached .message-content {
    background: #e8f5e9;
}

.message-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content code {
    background: #e9ecef;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.input-container {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    width: 48%;
}

.btn-secondary:hover {
    background: #545b62;
}

.settings-group button {
    margin-right: 4%;
}

.settings-group button:last-child {
    margin-right: 0;
}

#uploaded-files {
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.file-item {
    background: #f8f9fa;
    padding: 5px 10px;
    margin-top: 5px;
    border-radius: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-item .remove-file {
    cursor: pointer;
    color: #dc3545;
}

#cache-status {
    padding: 5px 10px;
    background: #28a745;
    color: white;
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cache-indicator {
    font-size: 11px;
    color: #28a745;
    margin-top: 5px;
}

/* Styles for Copy/Edit buttons */
.message .actions-div {
    margin-top: 5px;
    display: flex;
    gap: 5px;
    /* align-self is not needed here as parent .message.user or .message.assistant handles alignment */
}

.message .copy-btn, .message .edit-btn, .message .rerun-btn, .message .delete-btn, .message .branch-btn {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 2px 5px;
    font-size: 0.8em;
    cursor: pointer;
    border-radius: 3px;
}
.message .copy-btn:hover, .message .edit-btn:hover, .message .rerun-btn:hover { /* Keep general hover for non-delete/non-branch */
    background-color: #e0e0e0;
}

.message .rerun-btn {
    background-color: #e0e0e0;
}
.message .rerun-btn:hover {
    background-color: #d0d0d0;
}

.message .branch-btn {
    background-color: #2196F3; /* Blue */
    color: white;
    border-color: #1976D2; /* Darker blue border */
}
.message .branch-btn:hover {
    background-color: #1976D2; /* Darker blue on hover */
}

.message .delete-btn {
    background-color: #f44336; /* Red */
    color: white;
    border-color: #d32f2f; /* Darker red border */
}
.message .delete-btn:hover {
    background-color: #d32f2f; /* Darker red on hover */
}

/* Styles for message editing UI */
.message .edit-area {
    width: 100%; /* Take full width of the message bubble area */
    box-sizing: border-box;
    min-height: 60px;
    margin-bottom: 5px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1em; /* Match message font size */
    resize: vertical; /* Allow vertical resize */
}

.message .save-edit-btn, .message .cancel-edit-btn {
    border: none;
    padding: 4px 8px; /* Slightly more padding */
    font-size: 0.8em;
    cursor: pointer;
    border-radius: 3px;
    margin-right: 5px;
    color: white;
}

.message .save-edit-btn {
    background-color: #4CAF50; /* Green */
}
.message .save-edit-btn:hover {
    background-color: #45a049;
}

.message .cancel-edit-btn {
    background-color: #f44336; /* Red */
}
.message .cancel-edit-btn:hover {
    background-color: #e53935;
}

/* Class for visually hidden elements, accessible to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Styles for Word/Token counts */
.message-stats {
    font-size: 0.8em;
    color: #777;
    margin-top: 5px;
    /* text-align will be handled by user/assistant specific rules */
}

.message.user .message-stats {
    text-align: right;
}

.message.assistant .message-stats {
    text-align: left;
}

.input-stats-display {
    /* Inline styles already set: font-size, color, text-align, padding-right, margin-top */
    /* Add any other specific styles here if needed, e.g. for consistency if inline styles are removed */
}

/* Styles for new Model Selection UI */
.model-select-toggle {
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px; /* Match other inputs */
    font-size: 14px; /* Match other inputs */
    /* Inherits .btn .btn-secondary styles, which is fine */
}

#current-model-display {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px; /* Space before the dropdown arrow */
}

.model-selection-popup {
    /* Styles already partially set inline in HTML for border, padding, margin, radius, bg, z-index */
    /* Add any other necessary styles here */
    position: relative; /* Needed if you want to position absolutely inside a relative parent */
}

#model-list-container .model-item {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.9em; /* Slightly smaller if desired */
}

#model-list-container .model-item:last-child {
    border-bottom: none;
}

#model-list-container .model-item:hover {
    background-color: #f0f0f0;
}

#model-list-container .model-item.selected {
    background-color: #e0e0e0;
    font-weight: bold;
}

/* Styles for Developer Info Section */
#developer-info-section {
    /* Inline styles from HTML: display: none; padding: 15px; margin-top: 20px; border-top: 1px solid #ccc; background-color: #f9f9f9; */
    /* Keeping most inline styles for now, but could be moved here. */
    border-radius: 5px; /* Added for consistency */
}

#dev-options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    /* margin-bottom: 15px; /* From original plan, HTML has margin-bottom:10px on it currently */
}

/* Specific styling for buttons within dev-options-container if needed, */
/* but they should inherit .btn and .btn-secondary adequately. */
/* #dev-options-container .btn { } */

#raw-api-response-display {
    /* Inline styles from HTML: width: 100%; font-family: monospace; white-space: pre; word-wrap: break-word; box-sizing: border-box; border: 1px solid #ddd; padding: 5px; */
    /* Ensuring some values here if inline were to be removed */
    width: 100%;
    font-family: monospace;
    white-space: pre;
    word-wrap: break-word;
    box-sizing: border-box;
    border: 1px solid #ccc; /* Standardized border */
    border-radius: 4px;    /* Standardized radius */
    padding: 8px;          /* Standardized padding */
    resize: vertical;
}

#copy-raw-response-btn {
    /* Inline style from HTML: margin-top: 5px; */
    /* Inherits .btn .btn-primary, which should be fine. */
}

footer {
    /* Inline styles from HTML: text-align: center; margin-top: 20px; padding: 10px 0; border-top: 1px solid #eee; */
    /* Keeping most inline styles for now. */
    font-size: 0.9em;
    color: #666;
}

/* Styles for #toggle-dev-info-btn are now handled by .btn and .btn-secondary, so specific .btn-link rules are removed. */
/*
#toggle-dev-info-btn.btn-link {
    background-color: transparent;
    border: none;
    color: #007bff;
    text-decoration: underline;
    padding: 0;
    font-size: 0.9em;
}

#toggle-dev-info-btn.btn-link:hover {
    color: #0056b3;
}
*/

/* Styles for Browser Info Subsection */
#browser-info-subsection h3 {
    margin-top: 0; /* Remove default h3 margin if it's too large */
    margin-bottom: 10px;
    font-size: 1.1em; /* Slightly smaller than main section h2 */
    color: #333;
}

.btn-sm { /* For smaller buttons like "Show My Browser Info" and "Copy Browser Info" */
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem; /* ~14px if base is 16px */
    border-radius: 0.2rem;
}